gpridge.ase_active_gp ===================== .. py:module:: gpridge.ase_active_gp .. autoapi-nested-parse:: ASE calculator backed by the C++ learning engine. This is the surrogate as a potential: an ASE ``Calculator`` that answers from the Gaussian process where the posterior is resolved and calls the inner calculator where it is not. Because it is a calculator, it drops into anything ASE already drives -- BFGS, ``ase.mep.NEB``, the dimer -- without those knowing a surrogate is present. It differs from :class:`~gpridge._calculator.GPRCalculator` in where the policy lives. ``GPRCalculator`` reimplements the learn-on-the-fly loop in Python against an absolute variance threshold. This one delegates to ``libgpr_engine.so`` through the same C ABI eOn loads, so ASE and eOn run one policy: a two-sided gate in multiples of the model's own likelihood noise rather than an absolute number, a convergence certificate that forces a ground-truth call before a driver may claim convergence, and a split between acquiring a row and incorporating it so the surface is constant between epoch boundaries. Usage mirrors any wrapping calculator:: from ase.optimize import BFGS atoms.calc = ActiveGPCalculator(inner_calc=EMT()) BFGS(atoms).run(fmax=0.01) print(atoms.calc.oracle_calls, "true evaluations") Classes ------- .. autoapisummary:: gpridge.ase_active_gp.ActiveGPCalculator Module Contents --------------- .. py:class:: ActiveGPCalculator(inner_calc, library=None, sigma_lo_factor=None, sigma_hi_factor=None, certify_below_force=None, refit_training_revisions=None, **kwargs) Bases: :py:obj:`_CALC_BASE` Learning surrogate around an inner ASE calculator. :param inner_calc: The expensive calculator to stand in for. It is called only where the posterior is unresolved, and its result is returned verbatim when it is called. :type inner_calc: :py:class:`ase.calculators.calculator.Calculator` :param library: Path to ``libgpr_engine.so``; defaults to ``GPR_ENGINE_LIBRARY`` and then to the loader search path. :type library: :py:class:`str`, *optional* :param certify_below_force: Set this to the driver's own force convergence criterion, or a little above it. An ASE optimizer stops when the forces it is handed fall below ``fmax``, and those forces come from the model; the certificate is what turns that into a ground-truth call before the driver is allowed to stop. Left unset, an optimizer can and does converge to a minimum of the surrogate that is not a minimum of ``inner_calc``. :type certify_below_force: :py:class:`float`, *optional* :param sigma_lo_factor: Gate and cadence, forwarded to the engine unchanged. :type sigma_lo_factor: *optional* :param sigma_hi_factor: Gate and cadence, forwarded to the engine unchanged. :type sigma_hi_factor: *optional* :param refit_training_revisions: Gate and cadence, forwarded to the engine unchanged. :type refit_training_revisions: *optional* .. py:attribute:: implemented_properties :value: ['energy', 'forces'] Properties calculator can handle (energy, forces, ...) .. py:attribute:: name :value: 'ActiveGPCalculator' .. py:attribute:: inner_calc .. py:property:: oracle_calls True evaluations spent. The number the surrogate exists to reduce, so it is reported rather than inferred. .. py:property:: model_state Surface epoch; changes only when the posterior moved. .. py:method:: calculate(atoms=None, properties=None, system_changes=None) Evaluate ``atoms`` through the engine and store the result. ``results`` holds ``energy`` (eV), ``forces`` (eV/Angstrom) and ``gp_variance``, the predictive variance reported by the engine for the answer. The engine calls the inner calculator where the posterior is unresolved. .. py:method:: close() Release the engine handle. Safe to call more than once.