crystal#

The Crystal class.

This module establishes the interface for the crystal structure. It’s important to note that all values are presented in ATOMIC UNITS inside, specifically hartree for energy and Bohr for length. The input positions of atoms should be in angstrom.

class jrystal.crystal.Crystal(charges: Float[Array, 'atom'] | None, positions: Float[Array, 'atom 3'] | None, cell_vectors: Float[Array, '3 3'] | None, spin: int | None = None, symbol: str | None = None)[source]#

Crystal Structure Dataclass.

This class encapsulates the essential attributes of a crystal, including atomic charges, positions, cell vectors, etc.

A Crystal object can be created via two methods:

  1. create from specifying the four core attributes: atomic numbers (charges), absolute coordinates of each atom in Bohr unit (positions), cell vectors (in Bohr unit), and the number of unpaired electrons (spin).

  2. create from a geometry file.

See Create A Crystal Structure for more details.

Examples:

from jrystal import Crystal

# Create a crystal object from a xyz file.
crystal = Crystal.create_from_file("diamond.xyz")

# Create a crystal object from crystal attributes.
crystal = Crystal(
  charges=[6, 6],
  positions=[[0, 0, 0], [1.5, 1.5, 1.5]],
  cell_vectors=[[3, 0, 0], [0, 3, 0], [0, 0, 3]],
  spin=0
)
Parameters:
  • charges (Optional[Float[Array, "atom"]]) – The atomic charges. Defaults to None.

  • positions (Optional[Float[Array, "atom 3"]]) – The absolute coordinates of each atom in Bohr unit. Defaults to None.

  • cell_vectors (Optional[Float[Array, '3 3']]) – The cell vectors in Bohr unit. Defaults to None.

  • spin (Optional[int]) – The number of unpaired electrons. Defaults to None.

  • symbol (Optional[str], optional) – The atomic symbols. Defaults to None.

Returns:

_description_

Return type:

_type_

property A#

Alias for cell_vectors.

property B#

Alias for reciprocal vectors.

static create_from_file(file_path: str, spin: int | None = None)[source]#

Create a crystal object from a xyz file.

Parameters:
  • file_path (str) – The path of the xyz file.

  • spin (int, optional) – The number of unpaired electron. Defaults to None. If not provided, spin is set to 1 if the total number of electrons is odd, otherwise 0.

Returns:

A Crystal onbject.

static create_from_symbols(symbols: str, positions: List[List] | Float[Array, 'num_atom 3'], cell_vectors: Float[Array, '3 3'])[source]#

Create a crystal object from symbols, positions, and cell vectors.

Parameters:
  • symbols (str) – The atomic symbols.

  • positions (Union[List[List], Float[Array, "num_atom 3"]) – The absolute coordinates of each atom in Bohr unit.

  • cell_vectors (Float[Array, "3 3"]) – The cell vectors in Bohr unit.

Returns:

A Crystal object.

items() a set-like object providing a view on D's items#
keys() a set-like object providing a view on D's keys#
property num_atom#

Total number of atoms.

property num_electron#

Total number of electrons.

property reciprocal_vectors#

The reciprocal cell vectors.

property scaled_positions#

The scaled coordinate of the atoms.

values() an object providing a view on D's values#
property vol#

The volume of the unit cell in Bohr^3.