gpridge.integrations

Optional oracles for saddle and path searches.

Importing this package does not import ASE, LAMMPS, OpenMM, PLUMED, or GROMACS. Those libraries are used only when a caller constructs the matching oracle and, for OpenMM and PLUMED, only inside that constructor.

Submodules

Attributes

Exceptions

EngineEvaluationError

The engine rejected this geometry and can be called again.

GeometryError

Positions, cell, atom order, or fixed-atom data do not match the oracle.

IntegrationError

Base for a rejected geometry, a closed oracle, or a failed evaluation.

LifecycleError

The oracle has been closed, or a context manager was entered twice.

UnsupportedUnits

The engine unit style has no conversion into eV and Angstrom.

Classes

ASEOracle

Evaluate an existing calculator on copies of an atoms template.

GromacsQuantityOracle

Convert one GROMACS-unit evaluation into the GPRidge oracle.

LammpsOracle

One serial LAMMPS instance, evaluated with run 0.

OpenMMOracle

Single-point energy and forces from one OpenMM context.

Evaluation

One evaluation in GPRidge units.

Oracle

A Cartesian energy and force evaluation with a fixed geometry contract.

OracleCalculator

Duck-typed calculator over one Oracle.

PlumedBias

Physical oracle plus one PLUMED bias.

Functions

fixed_mask_from_constraints(→ numpy.ndarray)

Read a full-atom freeze from FixAtoms constraints.

Package Contents

class gpridge.integrations.ASEOracle(template, calculator, **kwargs)

Bases: gpridge.integrations.oracle.Oracle

Evaluate an existing calculator on copies of an atoms template.

classmethod from_calculator(atoms, calculator) → ASEOracle

Bind calculator to the geometry currently stored on atoms.

gpridge.integrations.fixed_mask_from_constraints(constraints, n_atoms: int) → numpy.ndarray

Read a full-atom freeze from FixAtoms constraints.

exception gpridge.integrations.EngineEvaluationError

Bases: IntegrationError

The engine rejected this geometry and can be called again.

exception gpridge.integrations.GeometryError

Bases: IntegrationError

Positions, cell, atom order, or fixed-atom data do not match the oracle.

exception gpridge.integrations.IntegrationError

Bases: Exception

Base for a rejected geometry, a closed oracle, or a failed evaluation.

exception gpridge.integrations.LifecycleError

Bases: IntegrationError

The oracle has been closed, or a context manager was entered twice.

exception gpridge.integrations.UnsupportedUnits

Bases: IntegrationError

The engine unit style has no conversion into eV and Angstrom.

gpridge.integrations.CELL_MATCH_A = 1e-08
class gpridge.integrations.GromacsQuantityOracle(evaluate, **kwargs)

Bases: gpridge.integrations.oracle.Oracle

Convert one GROMACS-unit evaluation into the GPRidge oracle.

class gpridge.integrations.LammpsOracle(instance, *, atom_ids, units: str, container_A: numpy.ndarray, owns: bool = False, **kwargs)

Bases: gpridge.integrations.oracle.Oracle

One serial LAMMPS instance, evaluated with run 0.

property units: str
property atom_ids: numpy.ndarray
property container_A: numpy.ndarray

LAMMPS box in Angstrom, including a non-periodic container.

classmethod from_instance(instance, *, atom_ids, atomic_numbers, units: str, fixed=None, reference_positions_A=None, owns: bool = False) → LammpsOracle

Bind a live lammps.lammps instance.

The import of lammps is left to the caller, who constructed instance. units is metal or real.

class gpridge.integrations.OpenMMOracle(reader, **kwargs)

Bases: gpridge.integrations.oracle.Oracle

Single-point energy and forces from one OpenMM context.

classmethod from_context(context, atomic_numbers, *, fixed=None, reference_positions_A=None, unit_module=None) → OpenMMOracle

Bind a live openmm.Context.

unit_module defaults to openmm.unit and is imported only on this path.

classmethod from_reader(reader, atomic_numbers, *, fixed=None, reference_positions_A=None) → OpenMMOracle

Bind a reader that already speaks nanometres and kJ/mol.

class gpridge.integrations.Evaluation

One evaluation in GPRidge units.

energy_eV: float
forces_eV_per_A: numpy.ndarray
gradient_eV_per_A: numpy.ndarray
class gpridge.integrations.Oracle(evaluator=None, *, atomic_numbers, reference_positions_A, fixed=None, cell_A=None, pbc=None)

A Cartesian energy and force evaluation with a fixed geometry contract.

last_failure: str | None = None
property n_atoms: int
property atomic_numbers: numpy.ndarray
property reference_positions_A: numpy.ndarray
property fixed: numpy.ndarray
property cell_A: numpy.ndarray | None
property pbc: numpy.ndarray
property closed: bool
evaluate(positions, *, cell=_UNSET, atomic_numbers=None) → Evaluation

Energy, force, and gradient at positions.

cell defaults to the stored cell and is not a request to drop periodicity. Pass a cell only to assert that it matches.

as_neb_oracle()

Return positions -> (energy_eV, gradient) with a flat gradient.

Exceptions propagate. The C buffer writers are write_oracle and write_force.

as_calculator() → OracleCalculator

Return a calculator with get_potential_energy and get_forces.

write_oracle(n_coords: int, positions, energy, gradient) → None

Fill the simple C oracle buffers.

energy[0] is eV. gradient is dE/dR in eV/Angstrom, length n_coords, in x, y, z atom order. A rejected evaluation writes non-finite values and records last_failure.

write_force(n_atoms: int, positions, atomic_numbers, forces, energy, variance=None, box=None) → None

Fill the C force-callback buffers.

forces receives -dE/dR. On success variance[0] is 0 when variance is present. box, when present, is nine row-major cell components and must match the stored cell. With no box buffer, the callback uses the stored cell directly. A rejected evaluation writes non-finite energy, forces, and variance, and leaves box unchanged.

close() → None

Release owned engine state. A second call does nothing.

class gpridge.integrations.OracleCalculator(oracle: Oracle)

Duck-typed calculator over one Oracle.

get_potential_energy and get_forces share one evaluation for a given positions, atomic-number, and cell key. The next distinct geometry evaluates again. force_consistent selects the same energy: this calculator has one energy per geometry.

implemented_properties = ('energy', 'forces')
name = 'gpridge-oracle'
results: dict
calculate(atoms=None, properties=None, system_changes=None)
get_potential_energy(atoms=None, force_consistent=False)
get_forces(atoms=None)
class gpridge.integrations.PlumedBias(inner: gpridge.integrations.oracle.Oracle, kernel, *, masses_amu, advance_step: bool = False, owns_kernel: bool = False, owns_inner: bool = False, step: int = 0)

Bases: gpridge.integrations.oracle.Oracle

Physical oracle plus one PLUMED bias.

property step: int
classmethod from_input(inner: gpridge.integrations.oracle.Oracle, lines, *, masses_amu, timestep_ps: float, kT_eV: float, charges=None, logfile: str | None = None, restart: bool = False, advance_step: bool = False, plumed_module=None, input_units: str = 'plumed') → PlumedBias

Create a PLUMED kernel and add it to inner.

lines is the PLUMED action text, one action per string. plumed_module defaults to the plumed package and is imported only on this path. The kernel is finalized when the bias is closed. inner is left open.

gpridge.integrations.ANGSTROM_IN_NM = 0.1
gpridge.integrations.EV_IN_KJ_PER_MOL = 96.48533212331002
gpridge.integrations.KCAL_MOL_IN_EV = 0.043364104241800934
gpridge.integrations.KJ_MOL_IN_EV = 0.010364269656262174
gpridge.integrations.NM_IN_ANGSTROM = 10.0