Here are a few utility functions:

crystals.symmetry_expansion(atoms: Iterable[Union[Atom, AtomicStructure]], symmetry_operators: Iterable[Union[Sequence[Sequence[Sequence[Sequence[Sequence[Any]]]]], _SupportsArray[dtype], Sequence[_SupportsArray[dtype]], Sequence[Sequence[_SupportsArray[dtype]]], Sequence[Sequence[Sequence[_SupportsArray[dtype]]]], Sequence[Sequence[Sequence[Sequence[_SupportsArray[dtype]]]]], bool, int, float, complex, str, bytes, Sequence[Union[bool, int, float, complex, str, bytes]], Sequence[Sequence[Union[bool, int, float, complex, str, bytes]]], Sequence[Sequence[Sequence[Union[bool, int, float, complex, str, bytes]]]], Sequence[Sequence[Sequence[Sequence[Union[bool, int, float, complex, str, bytes]]]]]]]) Iterator[Union[Atom, AtomicStructure]]

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

  • atoms (iterable of Atom and/or AtomicStructure) – Asymmetric unit cell atoms. It is assumed that the atomic coordinates are in fractional form. Transformations work the same way for Atom objects and AtomicStructure objects: a copy is made and moved to the symmetric location.

  • symmetry_operators (iterable of array_like) – Symmetry operators that generate the full unit cell.


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

See also


Determine the asymmetric cell that can generate a unit cell.

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

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

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

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

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


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

crystals.distance_fractional(atm1: Atom, atm2: Atom) float

Calculate the distance between two atoms in fractional coordinates.


atm1, atm2 (Atom)


dist (float) – Fractional distance between atoms.

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

crystals.distance_cartesian(atm1: Atom, atm2: Atom) float

Calculate the distance between two atoms in cartesian coordinates.


atm1, atm2 (Atom)


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

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

crystals.is_element(element: Union[str, int, Element]) Callable[[Atom], bool]

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


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


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


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