amd.utils module

Miscellaneous utility functions.

amd.utils.diameter(cell: numpy.ndarray[Any, numpy.dtype[numpy.floating]]) float

Return the diameter of a unit cell (given as a square matrix in orthogonal coordinates) in 3 or fewer dimensions. The diameter is the maxiumum distance between any two points in the unit cell.

Parameters

cell (numpy.ndarray) – Unit cell represented as a square matrix (in orthogonal coordinates).

Returns

diameter – Diameter of the unit cell.

Return type

float

amd.utils.cellpar_to_cell(cellpar: numpy.ndarray[Any, numpy.dtype[numpy.floating]]) numpy.ndarray[Any, numpy.dtype[numpy.floating]]

Convert conventional unit cell parameters a,b,c,α,β,γ into a 3x3 numpy.ndarray representing the unit cell in orthogonal coordinates. Numba-accelerated version of function from ase.geometry of the same name.

Parameters

cellpar (numpy.ndarray) – Vector of six unit cell parameters in the canonical order a,b,c,α,β,γ.

Returns

cell – Unit cell represented as a 3x3 matrix in orthogonal coordinates.

Return type

numpy.ndarray

amd.utils.cellpar_to_cell_2D(cellpar: numpy.ndarray[Any, numpy.dtype[numpy.floating]]) numpy.ndarray[Any, numpy.dtype[numpy.floating]]

Convert 3 parameters defining a 2D unit cell a,b,α into a 2x2 numpy.ndarray representing the unit cell in orthogonal coordinates.

Parameters

cellpar (numpy.ndarray) – Vector of three unit cell parameters a,b,α, where a and b are lengths of sides of the unit cell and α is the angle between the sides.

Returns

cell – Unit cell represented as a 2x2 matrix in orthogonal coordinates.

Return type

numpy.ndarray

amd.utils.cell_to_cellpar(cell: numpy.ndarray[Any, numpy.dtype[numpy.floating]]) numpy.ndarray[Any, numpy.dtype[numpy.floating]]

Convert a 3x3 numpy.ndarray representing a unit cell in orthogonal coordinates (as returned by cellpar_to_cell()) into a list of 3 lengths and 3 angles representing the unit cell.

Parameters

cell (numpy.ndarray) – Unit cell as a 3x3 matrix in orthogonal coordinates.

Returns

cellpar – Vector of 6 unit cell parameters in the canonical order a,b,c,α,β,γ.

Return type

numpy.ndarray

amd.utils.cell_to_cellpar_2D(cell: numpy.ndarray[Any, numpy.dtype[numpy.floating]]) numpy.ndarray[Any, numpy.dtype[numpy.floating]]

Convert a 2x2 numpy.ndarray representing a unit cell in orthogonal coordinates (as returned by cellpar_to_cell_2D()) into a list of 2 lengths and 1 angle representing the unit cell.

Parameters

cell (numpy.ndarray) – Unit cell as a 2x2 matrix in orthogonal coordinates.

Returns

cellpar – Vector with 3 elements, containing 3 unit cell parameters.

Return type

numpy.ndarray

amd.utils.random_cell(length_bounds: Tuple = (1.0, 2.0), angle_bounds: Tuple = (60.0, 120.0), dims: int = 3) numpy.ndarray[Any, numpy.dtype[numpy.floating]]

Return a random unit cell with uniformally chosen length and angle parameters between bounds. Dimensions 2 and 3 only.