gpridge.integrations.oracle

Oracle contract for a saddle or path search.

evaluate returns energy in eV and Cartesian forces in eV/Angstrom. The gradient is the negative of the force, which is the sign the simple NEB oracle uses. The force callback writes the force itself and writes a variance of 0, the value used when the evaluation is the true surface and has no surrogate variance.

One instance is used by one thread. close is idempotent. A closed oracle rejects later evaluations. Fixed atoms are put back on the reference coordinates before the evaluator runs, and their force components are then zero. The caller’s position array is not modified.

The cell is the cell stored at construction. A caller who passes a different cell gets GeometryError from evaluate. write_oracle and write_force catch that error and write non-finite output, which is the C callback’s rejected-evaluation signal.

Classes

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.

Module Contents

class gpridge.integrations.oracle.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.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.oracle.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)