gpridge.integrations.oracle =========================== .. py:module:: gpridge.integrations.oracle .. autoapi-nested-parse:: 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 ------- .. autoapisummary:: gpridge.integrations.oracle.Evaluation gpridge.integrations.oracle.Oracle gpridge.integrations.oracle.OracleCalculator Module Contents --------------- .. py:class:: Evaluation One evaluation in GPRidge units. .. py:attribute:: energy_eV :type: float .. py:attribute:: forces_eV_per_A :type: numpy.ndarray .. py:attribute:: gradient_eV_per_A :type: numpy.ndarray .. py:class:: 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. .. py:attribute:: last_failure :type: str | None :value: None .. py:property:: n_atoms :type: int .. py:property:: atomic_numbers :type: numpy.ndarray .. py:property:: reference_positions_A :type: numpy.ndarray .. py:property:: fixed :type: numpy.ndarray .. py:property:: cell_A :type: numpy.ndarray | None .. py:property:: pbc :type: numpy.ndarray .. py:property:: closed :type: bool .. py:method:: 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. .. py:method:: as_neb_oracle() Return ``positions -> (energy_eV, gradient)`` with a flat gradient. Exceptions propagate. The C buffer writers are ``write_oracle`` and ``write_force``. .. py:method:: as_calculator() -> OracleCalculator Return a calculator with ``get_potential_energy`` and ``get_forces``. .. py:method:: 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``. .. py:method:: 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. .. py:method:: close() -> None Release owned engine state. A second call does nothing. .. py:class:: OracleCalculator(oracle: Oracle) Duck-typed calculator over one :class:`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. .. py:attribute:: implemented_properties :value: ('energy', 'forces') .. py:attribute:: name :value: 'gpridge-oracle' .. py:attribute:: results :type: dict .. py:method:: calculate(atoms=None, properties=None, system_changes=None) .. py:method:: get_potential_energy(atoms=None, force_consistent=False) .. py:method:: get_forces(atoms=None)