amd.utils module

Helpful utility functions.

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 (ndarray) – 2D distance matrix or 1D condensed distance matrix.

Returns

For item i, nn_dm[i][j] is the distance from item i to its j+1 st nearest neighbour, and inds[i][j] is the index of this neighbour (j+1 since index 0 is the first nearest neighbour).

Return type

tuple of ndarrays (nn_dm, inds)

amd.utils.diameter(cell)

Diameter of a unit cell in 3 or fewer dimensions.

amd.utils.cellpar_to_cell(a, b, c, alpha, beta, gamma)

Simplified version of function from ase.geometry. 3D unit cell parameters a,b,c,α,β,γ –> cell as 3x3 ndarray.

amd.utils.cellpar_to_cell_2D(a, b, alpha)

UD unit cell parameters a,b,α –> cell as 2x2 ndarray.

amd.utils.lattice_cubic(scale=1, dims=3)

Return a pair (motif, cell) representing a cubic lattice, passable to amd.AMD() or amd.PDD().

amd.utils.random_cell(length_bounds=(1, 2), angle_bounds=(60, 120), dims=3)

Random unit cell.

class amd.utils.ETA(to_do, update_rate=100)

Bases: object

Pass total amount to do, then call .update() on every loop. This object will estimate an ETA and print it to the terminal.

update()

Call when one item is finished.