gpridge.integrations ==================== .. py:module:: gpridge.integrations .. autoapi-nested-parse:: 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 ---------- .. toctree:: :maxdepth: 1 /autoapi/gpridge/integrations/ase_oracle/index /autoapi/gpridge/integrations/errors/index /autoapi/gpridge/integrations/examples/index /autoapi/gpridge/integrations/geometry/index /autoapi/gpridge/integrations/gromacs_quantities/index /autoapi/gpridge/integrations/lammps_oracle/index /autoapi/gpridge/integrations/openmm_oracle/index /autoapi/gpridge/integrations/oracle/index /autoapi/gpridge/integrations/plumed_bias/index /autoapi/gpridge/integrations/units/index Attributes ---------- .. autoapisummary:: gpridge.integrations.CELL_MATCH_A gpridge.integrations.ANGSTROM_IN_NM gpridge.integrations.EV_IN_KJ_PER_MOL gpridge.integrations.KCAL_MOL_IN_EV gpridge.integrations.KJ_MOL_IN_EV gpridge.integrations.NM_IN_ANGSTROM Exceptions ---------- .. autoapisummary:: gpridge.integrations.EngineEvaluationError gpridge.integrations.GeometryError gpridge.integrations.IntegrationError gpridge.integrations.LifecycleError gpridge.integrations.UnsupportedUnits Classes ------- .. autoapisummary:: gpridge.integrations.ASEOracle gpridge.integrations.GromacsQuantityOracle gpridge.integrations.LammpsOracle gpridge.integrations.OpenMMOracle gpridge.integrations.Evaluation gpridge.integrations.Oracle gpridge.integrations.OracleCalculator gpridge.integrations.PlumedBias Functions --------- .. autoapisummary:: gpridge.integrations.fixed_mask_from_constraints Package Contents ---------------- .. py:class:: ASEOracle(template, calculator, **kwargs) Bases: :py:obj:`gpridge.integrations.oracle.Oracle` Evaluate an existing calculator on copies of an atoms template. .. py:method:: from_calculator(atoms, calculator) -> ASEOracle :classmethod: Bind ``calculator`` to the geometry currently stored on ``atoms``. .. py:function:: fixed_mask_from_constraints(constraints, n_atoms: int) -> numpy.ndarray Read a full-atom freeze from ``FixAtoms`` constraints. .. py:exception:: EngineEvaluationError Bases: :py:obj:`IntegrationError` The engine rejected this geometry and can be called again. .. py:exception:: GeometryError Bases: :py:obj:`IntegrationError` Positions, cell, atom order, or fixed-atom data do not match the oracle. .. py:exception:: IntegrationError Bases: :py:obj:`Exception` Base for a rejected geometry, a closed oracle, or a failed evaluation. .. py:exception:: LifecycleError Bases: :py:obj:`IntegrationError` The oracle has been closed, or a context manager was entered twice. .. py:exception:: UnsupportedUnits Bases: :py:obj:`IntegrationError` The engine unit style has no conversion into eV and Angstrom. .. py:data:: CELL_MATCH_A :value: 1e-08 .. py:class:: GromacsQuantityOracle(evaluate, **kwargs) Bases: :py:obj:`gpridge.integrations.oracle.Oracle` Convert one GROMACS-unit evaluation into the GPRidge oracle. .. py:class:: LammpsOracle(instance, *, atom_ids, units: str, container_A: numpy.ndarray, owns: bool = False, **kwargs) Bases: :py:obj:`gpridge.integrations.oracle.Oracle` One serial LAMMPS instance, evaluated with ``run 0``. .. py:property:: units :type: str .. py:property:: atom_ids :type: numpy.ndarray .. py:property:: container_A :type: numpy.ndarray LAMMPS box in Angstrom, including a non-periodic container. .. py:method:: from_instance(instance, *, atom_ids, atomic_numbers, units: str, fixed=None, reference_positions_A=None, owns: bool = False) -> LammpsOracle :classmethod: Bind a live ``lammps.lammps`` instance. The import of ``lammps`` is left to the caller, who constructed ``instance``. ``units`` is ``metal`` or ``real``. .. py:class:: OpenMMOracle(reader, **kwargs) Bases: :py:obj:`gpridge.integrations.oracle.Oracle` Single-point energy and forces from one OpenMM context. .. py:method:: from_context(context, atomic_numbers, *, fixed=None, reference_positions_A=None, unit_module=None) -> OpenMMOracle :classmethod: Bind a live ``openmm.Context``. ``unit_module`` defaults to ``openmm.unit`` and is imported only on this path. .. py:method:: from_reader(reader, atomic_numbers, *, fixed=None, reference_positions_A=None) -> OpenMMOracle :classmethod: Bind a reader that already speaks nanometres and kJ/mol. .. 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) .. py:class:: 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: :py:obj:`gpridge.integrations.oracle.Oracle` Physical oracle plus one PLUMED bias. .. py:property:: step :type: int .. py:method:: 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 :classmethod: 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. .. py:data:: ANGSTROM_IN_NM :value: 0.1 .. py:data:: EV_IN_KJ_PER_MOL :value: 96.48533212331002 .. py:data:: KCAL_MOL_IN_EV :value: 0.043364104241800934 .. py:data:: KJ_MOL_IN_EV :value: 0.010364269656262174 .. py:data:: NM_IN_ANGSTROM :value: 10.0