crystals.Crystal
- class crystals.Crystal(unitcell: Iterable[Atom | AtomicStructure], lattice_vectors: _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes], source: str | None = None, **kwargs)
The
Crystalclass is a set-like container that represent crystalline structures. In addition to constructing theCrystalobject yourself, other constructors are also available (and preferred):Crystal.from_cif(): create an instance from a CIF file;Crystal.from_pdb(): create an instance from a Protein Data Bank entry;Crystal.from_database(): create an instance from the internal database of CIF files;Crystal.from_cod(): create an instance from a Crystallography Open Database entry;Crystal.from_mp(): create an instance from the Materials Project database;Crystal.from_pwscf(): create an instance from the output of the PWSCF program;Crystal.from_ase(): create an instance from anase.Atomsinstance;Crystal.from_poscar(): create an instance from VASP POSCAR files.
- Parameters:
unitcell (iterable of
AtomorAtomicStructure) – Unit cell atoms or substructures. It is assumed that the atoms are in fractional coordinates.lattice_vectors (iterable of array_like) – Lattice vectors. If
lattice_vectorsis provided as a 3x3 array, it is assumed that each lattice vector is a row.source (str or None, optional) – Provenance, e.g. filename. Only used for bookkeeping.
- __init__(unitcell: Iterable[Atom | AtomicStructure], lattice_vectors: _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes], source: str | None = None, **kwargs)
Methods
__add__(other)Create a new structure made from the combination of two structures.
__array__(*args, **kwargs)Returns an array in which each row represents an
Atominstance.__bool__()An
AtomicStructureis False if empty, and True otherwise__contains__(item)Check containership of
Atominstances orAtomicStructuresubstructures recursively.__delattr__(name, /)Implement delattr(self, name).
__dir__()Default dir() implementation.
__eq__(other)Return self==value.
__format__(format_spec, /)Default object formatter.
__ge__(value, /)Return self>=value.
__getattribute__(name, /)Return getattr(self, name).
__gt__(value, /)Return self>value.
__hash__()Return hash(self).
__init__(unitcell, lattice_vectors[, source])__init_subclass__This method is called when a class is subclassed.
__iter__()Yields
Atominstances from the structure and substructures recursively.__le__(value, /)Return self<=value.
__len__()Number of
Atominstances present in the structure and substructures__lt__(value, /)Return self<value.
__ne__(value, /)Return self!=value.
__new__(**kwargs)__reduce__()Helper for pickle.
__reduce_ex__(protocol, /)Helper for pickle.
__repr__()Verbose string representation of this instance.
__setattr__(name, value, /)Implement setattr(self, name, value).
__sizeof__()Size of object in memory, in bytes.
__str__()String representation of this instance.
__subclasshook__Abstract classes can override this to customize issubclass().
_from_spglib_cell(lattice_vectors, ...)Build a Crystal object from the return value of many SPGLIB routines.
_spglib_cell()Returns an array in spglib's cell format.
_to_string(natoms)Generate a string representation of this Crystal.
asymmetric_cell()Calculates the asymmetric cell that generates the crystal unit cell.
bounded_reflections(bound[, min_bound])Generates reflections (hkl) with norm(G) <= bound
frac_mesh(*xi[, indexing])Coordinate arrays for fractional coordinates.
from_ase(atoms, **kwargs)Returns a Crystal object created from an ASE Atoms object.
from_cif(path, **kwargs)Returns a Crystal object created from a CIF 1.0, 1.1 or 2.0 file.
from_cod(num[, revision, download_dir, ...])Returns a Crystal object built from the Crystallography Open Database.
from_database(name, **kwargs)Returns a Crystal object create from the internal CIF database.
from_mp(query[, api_key, download_dir, ...])Returns a Crystal object built from the Materials Project.
from_parameters(a, b, c, alpha, beta, gamma)Create a Lattice instance from three lengths and angles.
from_pdb(ID[, download_dir, overwrite])Returns a Crystal object created from a Protein DataBank entry.
from_poscar(path, **kwargs)Returns a Crystal object created from a VASP's POSCAR file.
from_pwscf(path, **kwargs)Returns a Crystal object created from an output file of PWSCF.
groupby(by[, symprec, angle_tolerance])Group unit cell atoms by some measure of site symmetry, for example Wyckoff letters or crystallographic orbits.
ideal([symprec])Returns a Crystal object with an idealized unit cell.
indexed_by(lattice)Return a crystal structure, indexed by another lattice/crystal structure.
itersorted(*[, key, reverse])Yields
Atomin sorted order.mesh(*xi[, indexing])Cartesian coordinate arrays from fractional coordinate vectors.
miller_indices(scattering_vector)Miller indices from scattering vector components.
primitive([symprec])Returns a Crystal object in the primitive unit cell.
reciprocal_symmetry_operations([symprec])Get the symmetry operations that the reciprocal unit cell respects.
satisfying(predicate)Builds a new AtomicStructure from atoms satisfying a predicate.
scattering_vector(reflection)Scattering vector from Miller indices.
supercell(n1, n2, n3)Create a supercell from this crystal, i.e. an atomic structure where the crystal unit cell is duplicated along lattice vectors.
symmetry([symprec, angle_tolerance])Returns a dictionary containing space-group information.
symmetry_operations([symprec])Get the symmetry operations that the crystal unit cell respects.
to_ase(**kwargs)Convert a into an
ase.Atomsobject.to_cif(filename)Convert this
Crystalinstance to a CIF file.to_poscar(filename, **kwargs)Convert this
Crystalinstance to a POSCAR file.to_xyz(filename)Convert this
Crystalinstance to a XYZ file.transform(*operators)Return a transformed AtomicStructure based on symmetry operators.
Attributes
__annotations__builtinscenteringCentering type of this crystals.
chemical_compositionChemical composition of this structure as an ordered dictionary.
chemical_formulaEmpirical chemical formula for this structure based on the chemical symbols.
hall_numberHall number (between 1 and 531).
hall_symbolHall symbol.
hm_symbolHermann-Mauguin symbol.
international_fullInternational Tables of Crystallography space-group full symbol.
international_numberInternational Tables of Crystallography space-group number (between 1 and 230).
international_symbolInternational Tables of Crystallography space-group short symbol.
lattice_parametersLattice parameters as three lengths [Å] and three angles [degrees].
lattice_systemOne of the seven lattice system, returned in the form of the
LatticeSystemenumeration.lattice_vectorsIterable of lattice vectors
periodicityCrystal periodicity in x, y and z direction from the lattice constants.
pointgroupInternational Tables of Crystallography point-group.
reciprocalReciprocal lattice
reciprocal_vectorsReciprocal lattice vectors, defined as:
unitcellGenerator of atoms forming the crystal unit cell.
volumeLattice cell volume Angtroms cubed