mag4.lattice

Lattice geometry helpers (matrix construction, fractional ↔ Cartesian, PBC distances).

Functions

find_site(new_cart, cart_coords, lat_vecs, ...)

Index of the site in cart_coords closest to new_cart under PBC, or -1.

frac_to_cart(frac, lat_mat)

Convert fractional → Cartesian coordinates.

get_cartesian_coords(atoms, lat_mat)

Cartesian coordinates of a list of atoms in the legacy [label, x, y, z, …] format.

lattice_matrix(a, b, c, alpha_deg, beta_deg, ...)

Build a 3×3 lattice matrix (columns = a, b, c) from cell parameters.

pbc_distance(c1, c2, lat_vecs, inv_lat)

Minimum-image distance between two Cartesian points.

mag4.lattice.lattice_matrix(a, b, c, alpha_deg, beta_deg, gamma_deg)[source]

Build a 3×3 lattice matrix (columns = a, b, c) from cell parameters.

Parameters:
  • a (float) – Lattice parameters in Å.

  • b (float) – Lattice parameters in Å.

  • c (float) – Lattice parameters in Å.

  • alpha_deg (float) – Cell angles in degrees.

  • beta_deg (float) – Cell angles in degrees.

  • gamma_deg (float) – Cell angles in degrees.

Returns:

Lattice matrix with the three lattice vectors as columns.

Return type:

ndarray, shape (3, 3)

mag4.lattice.frac_to_cart(frac, lat_mat)[source]

Convert fractional → Cartesian coordinates.

Return type:

ndarray

Parameters:
mag4.lattice.get_cartesian_coords(atoms, lat_mat)[source]

Cartesian coordinates of a list of atoms in the legacy [label, x, y, z, …] format.

Return type:

ndarray

Parameters:
mag4.lattice.pbc_distance(c1, c2, lat_vecs, inv_lat)[source]

Minimum-image distance between two Cartesian points.

Return type:

float

Parameters:
mag4.lattice.find_site(new_cart, cart_coords, lat_vecs, inv_lat, tol=0.05)[source]

Index of the site in cart_coords closest to new_cart under PBC, or -1.

Return type:

int

Parameters: