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
-
__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 cellatom_type (
ndarray) – Shape (n_atoms,) string ndarray. The chemical symbols of each atom in the unit cellatom_mass (
Quantity) – Shape (n_atoms,) float Quantity in mass units. The mass of each atom in the unit cell
-
reciprocal_cell()¶ Calculates the reciprocal lattice vectors
- Return type
Quantity- Returns
recip – Shape (3, 3) float Quantity in 1/length units, the reciprocal lattice vectors
-
cell_volume()¶ Calculates the cell volume
- Return type
Quantity- Returns
volume – Scalar float Quantity in length**3 units. The cell volume
-
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- Return type
Tuple[int,int,int]- Returns
grid_spec – The number of divisions for each reciprocal lattice vector
-
to_spglib_cell()¶ Convert to a ‘cell’ as defined by spglib
- Return type
Tuple[List[List[float]],List[List[float]],List[int]]- 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
-
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
-
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- Return type
Tuple[ndarray,ndarray,ndarray]- 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
-
to_dict()¶ Convert to a dictionary. See Crystal.from_dict for details on keys/values
- Return type
Dict[str,Any]- Returns
dict
-
to_json_file(filename)¶ Write to a JSON file. JSON fields are equivalent to Crystal.from_dict keys
- Parameters
filename (
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
- Return type
~T
- Returns
crystal
-
classmethod
from_json_file(filename)¶ Read from a JSON file. See Crystal.from_dict for required fields
- Parameters
filename (
str) – The file to read from- Return type
~T
- Returns
crystal
-
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.- Return type
~T
- Returns
crystal