Crystal

class Crystal(cell_vectors, atom_r, atom_type, atom_mass)

Stores lattice and atom information

Variables:
  • cell_vectors ((3, 3) float Quantity) – Unit cell vectors
  • n_atoms (int) – Number of atoms in the unit cell
  • atom_r ((n_atoms, 3) float ndarray) – The fractional position of each atom within the unit cell
  • atom_type ((n_atoms,) string ndarray) – The chemical symbols of each atom in the unit cell. Atoms are in the same order as in atom_r
  • atom_mass ((n_atoms,) float Quantity) – The mass of each atom in the unit cell
__init__(cell_vectors, atom_r, atom_type, atom_mass)
Parameters:
  • cell_vectors ((3, 3) float Quantity) – Cartesian unit cell vectors. cell_vectors[0] = a, cell_vectors[:, 0] = x etc.
  • atom_r ((n_atoms, 3) float ndarray) – The fractional position of each atom within the unit cell
  • atom_type ((n_atoms,) string ndarray) – The chemical symbols of each atom in the unit cell. Atoms are in the same order as in atom_r
  • atom_mass ((n_atoms,) float Quantity) – The mass of each atom in the unit cell, in the same order as atom_r
reciprocal_cell()

Calculates the reciprocal lattice vectors

Returns:recip
Return type:(3, 3) float Quantity
to_dict()

Convert to a dictionary. See Crystal.from_dict for details on keys/values

Returns:
Return type: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
classmethod from_dict(d)

Convert a dictionary to a Crystal object

Parameters:d (dict) –

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:
Return type: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
Returns:
Return type:Crystal