GP surface API ============== The surface API belongs to ``gpridge.gp.GaussianProcess``. A model must be fitted before prediction, inspection of fitted parameters, or adapter creation. Position arguments accept an ASE ``Atoms`` object or an array with shape ``(N, 3)``. A flat array with ``3N`` values is also accepted and reshaped in atom order. Prediction ---------- .. table:: +-------------------------------------+---------------------------------+---------------------------------------------------------------+ | Member | Return | Meaning | +=====================================+=================================+===============================================================+ | ``energy(x)`` | ``float`` | Posterior-mean energy in eV | +-------------------------------------+---------------------------------+---------------------------------------------------------------+ | ``forces(x)`` | array ``(N, 3)`` | Posterior-mean ASE forces in eV/Å | +-------------------------------------+---------------------------------+---------------------------------------------------------------+ | ``energy_and_forces(x)`` | ``(energy, forces)`` | One mean prediction | +-------------------------------------+---------------------------------+---------------------------------------------------------------+ | ``variance(x)`` | ``float`` | Predictive energy variance in eV² | +-------------------------------------+---------------------------------+---------------------------------------------------------------+ | ``hessian_action(x, direction)`` | array shaped like ``direction`` | Posterior-mean Cartesian Hessian times ``direction`` | +-------------------------------------+---------------------------------+---------------------------------------------------------------+ | ``predict_hessian(atoms)`` | array ``(3N, 3N)`` | Full posterior-mean Cartesian Hessian | +-------------------------------------+---------------------------------+---------------------------------------------------------------+ | ``predict_with_uncertainty(atoms)`` | ``Prediction`` | Energy, forces, energy variance, and force-component variance | +-------------------------------------+---------------------------------+---------------------------------------------------------------+ ``Prediction.force_variance`` has shape ``(N, 3)``. Variances are variances, not standard deviations. ``Prediction.energy_std`` returns the energy standard deviation. Training and inspection ----------------------- .. table:: +--------------------------------------+----------------------------------------------------------------------------------------+ | Member | Return | +======================================+========================================================================================+ | ``observe(atoms)`` | Append energy and forces read from ``atoms.calc`` | +--------------------------------------+----------------------------------------------------------------------------------------+ | ``observe(atoms, energy``, forces=)= | Append values already evaluated | +--------------------------------------+----------------------------------------------------------------------------------------+ | ``fit(atoms_list=None)`` | Fit all accumulated observations | +--------------------------------------+----------------------------------------------------------------------------------------+ | ``training_set`` | ``TrainingSet(positions, energies, forces)`` with owned arrays | +--------------------------------------+----------------------------------------------------------------------------------------+ | ``hyperparameters`` | Dictionary of length scales, signal variance, likelihood variance, and jitter variance | +--------------------------------------+----------------------------------------------------------------------------------------+ | ``noise_report`` | ``NoiseReport`` | +--------------------------------------+----------------------------------------------------------------------------------------+ | ``fit_diagnostics`` | ``FitDiagnostics`` | +--------------------------------------+----------------------------------------------------------------------------------------+ ``TrainingSet.positions`` and ``TrainingSet.forces`` have shape ``(n_observations, N, 3)``. ``TrainingSet.energies`` has shape ``(n_observations,)``. Forces use the ASE sign convention. All three arrays are copies. ``NoiseReport`` fields are variance values: .. table:: +--------------------------------+---------------------------------------------+ | Field | Meaning | +================================+=============================================+ | ``configured_floor_variance`` | ``gp_sigma2`` supplied in the GP parameters | +--------------------------------+---------------------------------------------+ | ``fitted_likelihood_variance`` | Fitted Gaussian likelihood noise | +--------------------------------+---------------------------------------------+ | ``numerical_jitter_variance`` | Diagonal numerical jitter | +--------------------------------+---------------------------------------------+ | ``effective_variance`` | Likelihood variance plus jitter | +--------------------------------+---------------------------------------------+ ``FitDiagnostics`` contains ``iterations``, ``stop_reason``, and ``optimizer_failed``. ``iterations`` is rgmin's SCG steps plus the L-BFGS fallback steps that finish a stalled rgmin SCG fit. An unfitted model reports ``iterations``-1=, ``stop_reason``"unset"``, and =optimizer_failed=False``. A fitted model reports ``budget``, ``library``, ``restored scg point``, ``wall-clock limit``, ``non-finite marginal likelihood``, or ``unset``. The core does not provide model serialization. There are no ``save`` or ``load`` methods. Adapters -------- ASE ~~~ ``as_calculator()`` returns the same ``GaussianProcess`` through its ASE ``Calculator`` interface. Set ``atoms.calc = gp.as_calculator()``. ASE requests ``energy`` and ``forces``. Variance remains available from ``gp.variance(atoms)``. rgpot ~~~~~ ``as_rgpot()`` returns ``RgpotGPSurface``. The underlying C++ type is ``pot::GprMeanPotential``, derived from ``rgpot::Potential`` and therefore from ``rgpot::PotentialBase``. Its call signature is: ``surface(positions, atomic_numbers, box) -> (energy, forces, energy_variance)`` Positions and forces have shape ``(N, 3)``. Atomic numbers have shape ``(N,)``. The box has shape ``(3, 3)`` with lattice vectors as rows. The adapter reports ``ProcessSerial`` reentrancy because prediction updates model workspaces. Repeated calls return the same live adapter. A later ``gp.fit()`` retargets it to the new posterior and advances ``surface_epoch()``. The atomic identities, periodic axes, and fixed periodic cell must still match the model's template. ``ForceOut::variance`` carries energy variance. rgpot has no standard force-variance channel. The proposed generic interface is recorded in ``docs/design/usability-audit-gp-surface.md``. The C++ header is ``gpridge/GprMeanPotential.h``. Construct ``pot::GprMeanPotential`` from a trained ``GaussianProcessRegression&`` and pass it wherever an ``rgpot::PotentialBase&`` is accepted. Its ``hessianVectorImpl`` supplies rgpot's analytic Hessian-action concept from the GP posterior mean.