# Utilities¶

Here are a few utility functions:

crystals.symmetry_expansion(atoms, symmetry_operators)

Generate a set of unique atoms and structures from an asymmetric cell and symmetry operators.

Parameters
Yields

it (`Atom` and/or `AtomicStructure`) – Appropriately-transformed object. Original objects are left untouched.

`symmetry_reduction`

Determine the asymmetric cell that can generate a unit cell.

crystals.lattice_system(a, b, c, alpha, beta, gamma, atol=0.01)

Determine the lattice system. All cyclic permutations are checked, so that no convention on ordering of lattice parameters is assumed.

Parameters
• a, b, c (floats) – Lattice vectors lengths [Å]

• alpha, beta, gamma (floats) – Angles between lattice vectors [deg]

• atol (float, optional) – Absolute tolerance (in Angstroms)

Returns

system (LatticeSystem) – One of the seven lattice system.

crystals.distance_fractional(atm1, atm2)

Calculate the distance between two atoms in fractional coordinates.

Parameters

atm1, atm2 (`Atom`)

Returns

dist (float) – Fractional distance between atoms.

:raises RuntimeError : if atoms are not associated with the same lattice.:

crystals.distance_cartesian(atm1, atm2)

Calculate the distance between two atoms in cartesian coordinates.

Parameters

atm1, atm2 (`Atom`)

Returns

dist (float) – Cartesian distance between atoms in Angstroms..

:raises RuntimeError : if atoms are not associated with the same lattice.:

crystals.is_element(element)

Create a function that checks whether an atom is of a certain element.

Parameters

element (str, int, or Element) – Elemental symbol (e.g. “He”), atomic number, or Element instance.

Returns

func (callable) – Returns a function that can be used to check whether a crystals.Atom instance is of a certain element.

Examples

```>>> is_vanadium = is_element('V') # is_vanadium is a function
>>> atm = Atom('V', [0,0,0])