Crystal
- class Crystal(cell_vectors, atom_r, atom_type, atom_mass)
Stores lattice and atom information
- Variables:
cell_vectors – Shape (3, 3) float Quantity in length units. Cartesian unit cell vectors. cell_vectors[0] = a, cell_vectors[:, 0] = x etc.
n_atoms – Number of atoms in the unit cell
atom_r – Shape (n_atoms, 3) float ndarray. The fractional position of each atom within the unit cell
atom_type – Shape (n_atoms,) string ndarray. The chemical symbols of each atom in the unit cell
atom_mass – Shape (n_atoms,) float Quantity in mass units. The mass of each atom in the unit cell
- Parameters:
cell_vectors (Quantity)
atom_r (ndarray)
atom_type (ndarray)
atom_mass (Quantity)
- __init__(cell_vectors, atom_r, atom_type, atom_mass)
- Parameters:
cell_vectors (Quantity) – Shape (3, 3) float Quantity in length units. Cartesian unit cell vectors. cell_vectors[0] = a, cell_vectors[:, 0] = x etc.
atom_r (ndarray) – Shape (n_atoms, 3) float ndarray. The fractional position of each atom within the unit cell
atom_type (ndarray) – Shape (n_atoms,) string ndarray. The chemical symbols of each atom in the unit cell
atom_mass (Quantity) – Shape (n_atoms,) float Quantity in mass units. The mass of each atom in the unit cell
- Return type:
None
- reciprocal_cell()
Calculates the reciprocal lattice vectors
- Returns:
recip – Shape (3, 3) float Quantity in 1/length units, the reciprocal lattice vectors
- Return type:
Quantity
- cell_volume()
Calculates the cell volume
- Returns:
volume – Scalar float Quantity in length**3 units. The cell volume
- Return type:
Quantity
- get_mp_grid_spec(spacing=<Quantity(0.1, '1 / angstrom')>)
Get suggested divisions for Monkhorst-Pack grid
Determine a mesh for even Monkhorst-Pack sampling of the reciprocal cell
- Parameters:
spacing (Quantity) – Scalar float quantity in 1/length units. Maximum reciprocal-space distance between q-point samples
- Returns:
grid_spec – The number of divisions for each reciprocal lattice vector
- Return type:
tuple[int, int, int]
- to_spglib_cell()
Convert to a ‘cell’ as defined by spglib
- Returns:
cell – cell = (lattice, positions, numbers), where lattice is the lattice vectors, positions are the fractional atomic positions, and numbers are integers distinguishing the atomic species
- Return type:
tuple[list[list[float]], list[list[float]], list[int]]
- get_species_idx()
Returns a dictionary of each species and their indices
- Returns:
species_idx – An ordered dictionary containing each unique species symbol as the keys, and their indices as the values, in the same order as they appear in atom_type
- Return type:
OrderedDict[str, ndarray]
- get_symmetry_equivalent_atoms(tol=<Quantity(1e-05, 'angstrom')>)
Returns the rotational and translational symmetry operations as obtained by spglib.get_symmetry, and also the equivalent atoms that each atom gets mapped onto for each symmetry operation
- Parameters:
tol (Quantity) – Scalar float Quantity in length units. The distance tolerance, if the distance between atoms is less than this, they are considered to be equivalent. This is also passed to spglib.get_symmetry as symprec
- Returns:
rotations – Shape (n_symmetry_ops, 3, 3) integer np.ndarray. The rotational symmetry matrices as returned by spglib.get_symmetry
translations – Shape (n_symmetry_ops, 3) float np.ndarray. The rotational symmetry matrices as returned by spglib.get_symmetry
equivalent_atoms – Shape (n_symmetry_ops, n_atoms) integer np.ndarray. The equivalent atoms for each symmetry operation. e.g. equivalent_atoms[s, i] = j means symmetry operation s maps atom i to atom j
- Return type:
tuple[ndarray, ndarray, ndarray]
- to_dict()
Convert to a dictionary. See Crystal.from_dict for details on keys/values
- Returns:
dict
- Return type:
dict[str, Any]
- to_json_file(filename)
Write to a JSON file. JSON fields are equivalent to Crystal.from_dict keys
- Parameters:
filename (Path | str) – Name of the JSON file to write to
- Return type:
None
- classmethod from_dict(d)
Convert a dictionary to a Crystal object
- Parameters:
d (dict[str, Any]) –
A dictionary with the following keys/values:
’cell_vectors’: (3, 3) float ndarray
’cell_vectors_unit’: str
’atom_r’: (n_atoms, 3) float ndarray
’atom_type’: (n_atoms,) str ndarray
’atom_mass’: (n_atoms,) float np.ndaaray
’atom_mass_unit’: str
- Returns:
crystal
- Return type:
Self
- classmethod from_json_file(filename)
Read from a JSON file. See Crystal.from_dict for required fields
- Parameters:
filename (Path | str) – The file to read from
- Returns:
crystal
- Return type:
Self
- classmethod from_cell_vectors(cell_vectors)
Create a Crystal object from just cell vectors, containing no detailed structure information (atomic positions, species, masses)
- Parameters:
cell_vectors (Quantity) – Shape (3, 3) float Quantity in length units. Cartesian unit cell vectors. cell_vectors[0] = a, cell_vectors[:, 0] = x etc.
- Returns:
crystal
- Return type:
Self