Utilities¶
Here are a few utility functions:
- crystals.symmetry_expansion(atoms: Iterable[Atom | AtomicStructure], symmetry_operators: Iterable[_SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]]) Iterator[Atom | AtomicStructure] ¶
Generate a set of unique atoms and structures from an asymmetric cell and symmetry operators.
- Parameters:
atoms (iterable of
Atom
and/orAtomicStructure
) – Asymmetric unit cell atoms. It is assumed that the atomic coordinates are in fractional form. Transformations work the same way forAtom
objects andAtomicStructure
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.
- Yields:
it (
Atom
and/orAtomicStructure
) – Appropriately-transformed object. Original objects are left untouched.
See also
symmetry_reduction
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.
- 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: Atom, atm2: Atom) float ¶
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: Atom, atm2: Atom) float ¶
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: str | int | Element) Callable[[Atom], bool] ¶
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]) >>> is_vanadium(atm) True