gpridge.integrations.geometry

Cartesian layout shared by the optional oracles.

Atom i occupies coordinates 3i, 3i+1, and 3i+2 in x, y, z order. A cell is three row vectors a, b, c in Angstrom. The C force callback stores that cell as nine row-major doubles. An isolated system has no cell. A zero matrix is not a cell.

Two cells name the same box when every component differs by at most CELL_MATCH_A Angstrom. Fixed atoms are restored to the reference coordinates before an engine sees them, and their reported force is then set to zero.

Attributes

Functions

as_atomic_numbers(→ numpy.ndarray)

Return a copy of n_atoms positive atomic numbers.

as_mask(→ numpy.ndarray)

Return a boolean mask of length n_atoms.

normalize_positions(→ numpy.ndarray)

Copy positions into a contiguous (n_atoms, 3) array.

as_cell(→ numpy.ndarray | None)

Copy a (3, 3) cell in Angstrom, or return None.

as_pbc(→ numpy.ndarray)

Return three periodicity flags.

cells_match(→ bool)

True when both cells are absent or every component is within tolerance.

restore_fixed_positions(→ numpy.ndarray)

Write reference coordinates onto the fixed rows of positions.

zero_fixed_components(→ numpy.ndarray)

Set the force rows of fixed atoms to zero.

cell_to_box9(→ numpy.ndarray)

Pack a cell as nine row-major doubles.

cell_and_pbc_from_atoms(atoms)

Return (cell_A or None, pbc) from an atoms-like object.

cell_from_lammps_box(→ numpy.ndarray)

Build the LAMMPS triclinic cell, rows a, b, c, in Angstrom.

Module Contents

gpridge.integrations.geometry.CELL_MATCH_A = 1e-08
gpridge.integrations.geometry.as_atomic_numbers(values, n_atoms: int) → numpy.ndarray

Return a copy of n_atoms positive atomic numbers.

gpridge.integrations.geometry.as_mask(fixed, n_atoms: int) → numpy.ndarray

Return a boolean mask of length n_atoms.

None freezes nothing. A boolean array is a mask. An integer array is a list of atom indices.

gpridge.integrations.geometry.normalize_positions(values, n_atoms: int) → numpy.ndarray

Copy positions into a contiguous (n_atoms, 3) array.

The accepted layouts are (n_atoms, 3) and a flat (3*n_atoms,) vector in x, y, z atom order. A (3, n_atoms) array is rejected so a column-major layout is not read as coordinates.

gpridge.integrations.geometry.as_cell(cell) → numpy.ndarray | None

Copy a (3, 3) cell in Angstrom, or return None.

gpridge.integrations.geometry.as_pbc(pbc, cell: numpy.ndarray | None) → numpy.ndarray

Return three periodicity flags.

With no cell, every flag is false. With a cell and pbc is None, every flag is true.

gpridge.integrations.geometry.cells_match(left: numpy.ndarray | None, right: numpy.ndarray | None) → bool

True when both cells are absent or every component is within tolerance.

gpridge.integrations.geometry.restore_fixed_positions(positions: numpy.ndarray, reference: numpy.ndarray, mask: numpy.ndarray) → numpy.ndarray

Write reference coordinates onto the fixed rows of positions.

gpridge.integrations.geometry.zero_fixed_components(forces: numpy.ndarray, mask: numpy.ndarray) → numpy.ndarray

Set the force rows of fixed atoms to zero.

gpridge.integrations.geometry.cell_to_box9(cell: numpy.ndarray) → numpy.ndarray

Pack a cell as nine row-major doubles.

gpridge.integrations.geometry.cell_and_pbc_from_atoms(atoms)

Return (cell_A or None, pbc) from an atoms-like object.

All-false periodicity is an isolated system, including a cell array that is present and zero. A periodic object supplies a (3, 3) cell in Angstrom.

gpridge.integrations.geometry.cell_from_lammps_box(boxlo, boxhi, xy: float, yz: float, xz: float) → numpy.ndarray

Build the LAMMPS triclinic cell, rows a, b, c, in Angstrom.

LAMMPS stores the box as boxlo, boxhi, and the tilt factors xy, yz, and xz. The rows are (xhi-xlo, 0, 0), (xy, yhi-ylo, 0), and (xz, yz, zhi-zlo).