amd.utils module¶
Miscellaneous utility functions.
- amd.utils.diameter(cell: numpy.ndarray) 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) numpy.ndarray ¶
Convert canonical 3D unit cell parameters a,b,c,α,β,γ into a 3x3
numpy.ndarray
representing the unit cell in orthogonal coordinates. Numba-accelerated version of function fromase.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
- amd.utils.cellpar_to_cell_2D(cellpar: numpy.ndarray) numpy.ndarray ¶
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
- amd.utils.cell_to_cellpar(cell: numpy.ndarray) numpy.ndarray ¶
Convert a 3x3
numpy.ndarray
representing a unit cell in orthogonal coordinates (as returned bycellpar_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
- amd.utils.cell_to_cellpar_2D(cell: numpy.ndarray) numpy.ndarray ¶
Convert a 2x2
numpy.ndarray
representing a unit cell in orthogonal coordinates (as returned bycellpar_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
- amd.utils.neighbours_from_distance_matrix(n: int, dm: numpy.ndarray) Tuple[numpy.ndarray, numpy.ndarray] ¶
Given a distance matrix, find the n nearest neighbours of each item.
- Parameters
n (int) – Number of nearest neighbours to find for each item.
dm (
numpy.ndarray
) – 2D distance matrix or 1D condensed distance matrix.
- Returns
(nn_dm, inds) –
nn_dm[i][j]
is the distance from item \(i\) to its \(j+1\) st nearest neighbour, andinds[i][j]
is the index of this neighbour (\(j+1\) since index 0 is the first nearest neighbour).- Return type
tuple of
numpy.ndarray
s
- amd.utils.random_cell(length_bounds: Tuple = (1.0, 2.0), angle_bounds: Tuple = (60.0, 120.0), dims: int = 3) numpy.ndarray ¶
Return a random unit cell with uniformally chosen length and angle parameters between bounds. Dimensions 2 and 3 only.