Utilities

Measurements

czone.util.measure.calc_rdf(coords, cutoff=20.0, px=True, py=True, pz=True)

Calculate the 3D periodic radial distribution function of array of points.

Parameters
  • coords (np.ndarray) – Nx3 numpy array representing points in 3D

  • cutoff (float) – cutoff distance for neighbor consideration

  • px (bool) – whether or not coordinates are periodic in x

  • py (bool) – whether or not coordinates are periodic in y

  • pz (bool) – whether or not coordinates are periodic in z

Returns

radial distribution function, returned in steps of 0.1

Return type

np.ndarray

czone.util.measure.get_sdist_fun(dims=None, px=False, py=False, pz=False)

Return a squared distance function in 3D space for any PBC.

Parameters
  • dims (Array[float]) – length 3 array, list, or tuple for periodic dimension sizes (x,y,z); must be passed if using periodic boundaries

  • px (bool) – whether or not periodic in x

  • py (bool) – whether or not periodic in y

  • pz (bool) – whether or not periodic in z

Returns

squared distance function obeying periodic boundaries

Return type

Callable[float]

czone.util.measure.get_voxel_grid(dim: Tuple[int], px: bool = True, py: bool = True, pz: bool = True)

Generate list of voxel neighbors for 3D voxel grid with periodic boundary conditions.

Utility function which returns a representation of a connected 3D voxel grid for arbitrary periodic boundary conditions. Voxels are ordered on a 1D list by X, then Y, then Z. For example, a 2x2x2 voxel grid will be ordered as [(0,0,0), (1,0,0), (0,1,0), (1,1,0), (0,0,1), (1,0,1), (1,1,1)]. An ordered list is returned which contains, for each voxel i, a list of all of its neighbors on the 3D grid, as ordered in the 1D indexing scheme.

For fully periodic boundary conditions, each voxel i will have 27 neighbors, including the voxel index itself.

Parameters
  • dim (Tuple[int]) – size of grid in x, y, and z

  • px (bool) – periodicity in x

  • py (bool) – periodicity in y

  • pz (bool) – periodicity in z

Returns

List[List[int]]

Miscellaneous

czone.util.misc.get_N_splits(n: int, m: int, l: int, seed: Optional[int] = None) List[int]

Get N uniform random integers in interval [M,L-M) with separation M.

Parameters
  • n (int) – number of indices

  • m (int) – minimum distance between indices and ends of list

  • l (int) – length of initial list

  • seed (int) – seed for random number generator, default None

Returns

sorted list of random indices

Return type

List[int]

czone.util.misc.round_away(x: float) float

Round to float integer away from zero–opposite of np.fix.

Parameters

x (float, ArrayLike[float]) – number(s) to round

Returns

rounded number(s)

Return type

float, ArrayLike[float]

czone.util.misc.vangle(v1: numpy.ndarray, v2: numpy.ndarray) float

Calculate angle between two vectors of same dimension in R^N.

Parameters
  • v1 (np.ndarray) – N-D vector

  • v2 (np.ndarray) – N-D vector

Returns

angle in radians

Return type

float