GPRidge GPRidge GPRidge
  • Python API
  • C++ API
    • SciMap Research software and its dependencies
    • eOn Saddle point finding on potential energy surfaces
    • rgpot Universal RPC potential interface
/

Getting started

  • Install GPRidge
  • Quickstart: a band on a Lennard-Jones pentamer

Tutorials

  • Python API: a first dimer search
  • First NEB band: Berry pseudorotation of a Lennard-Jones pentamer
  • A periodic Pt(111) Morse band
  • UMA HCN band
  • UMA HCN dimer
  • Python API: the functional dimer interface
  • Use a trained GP as a potential
  • Tutorial: Fortran interop
  • C API: from a GP model to a saddle point
  • C++: a GP-NEB band on a Lennard-Jones cluster
  • OCI-NEB: a climbing image with dimer bursts
  • Compare the GPRidge binding examples

How-to: build and install

  • Native packages and downstream bindings
  • Native EasyBuild installation
  • Build against EESSI with the pixi overlay
  • Build the Kokkos backend for CPU, CUDA or HIP
  • Spack installation
  • Run the fuzz targets

How-to: run searches

  • Run a GP-NEB band
  • Restart or warm-start a search
  • Run a GP-NEB band from C++
  • Minimise with a GP surrogate
  • Run a Baker-24 cell with an external potential
  • Choose GP settings
  • Control what goes into the GP
  • Get an IRC certificate for a saddle
  • Compute a harmonic rate prefactor
  • Python usage
  • Use the Student-t process model
  • Fit a free-energy surface on collective variables and estimate a rate
  • Run GPRidge on a GPU

How-to: scale and reproduce

  • Run a search across MPI ranks
  • Run on an HPC cluster
  • Check run-to-run determinism
  • Reproduce the paper’s results
  • Build SBOM and reproducible builds
  • Find where a search spends its time

How-to: choose and tune the solver

  • Choose a solver or approximation by problem size
  • Use the covariance operator layer and the Krylov solvers
  • Choose the random-feature count automatically
  • Use the variational atomic inducing posterior
  • Use the HS-SVD stable-basis solver
  • Set the noise floor and keep the variance stable
  • Use the derivative providers

How-to: use with other programs

  • Use GPRidge from ASE and eOn
  • Use GPRidge with the SciMap tools
  • Use an rgpot engine plugin
  • Engine oracles for saddle and path searches
  • How to use the searches from Fortran
  • Run a GP model through its C lifecycle
  • Load Cap’n Proto parameters and wrap potentials

How-to: extend

  • How to add an uncertainty arm

Explanation

  • How GPRidge finds a saddle
  • The surrogate loop and derivative observations
  • The scalar surrogate for a noisy oracle
  • Saddle-point certificates
  • Mathematics
    • The joint energy-force Gaussian process
    • The soft geodesic heat-kernel prior
    • Tangent projection and physical constraints
    • The switched ZBL residual prior mean
    • Conditional chart gradients
    • Objective precision in GP hyperparameter fits
    • Molecular instanton reference calculation
    • Gaussian-process helpers for spectral instantons
    • Verification notes
      • Formal Verification of gpridge Mathematical Foundations
      • Energy and derivative observation scaling
      • Conditional means with a selected covariance background
      • Exact contractions for tied pair lengths
      • Supplied-factor CHOLMOD and precision contracts
      • Exact SCG Curvature for Distributed GP Training
      • TLA+ Model for SCG Curvature-Mode Policy
      • TLA+ Model for GP-OIE NEB Control
      • Scope of variance fitting and dimer convergence claims
      • Measuring curvature outside the sampled subspace
      • Selecting an additional negative-curvature probe
      • Far-field list
  • The local pair-baseline band (gp_local)
  • How gprd checks the saddle index
  • GP-assisted fixed-energy tunneling paths
  • Potential-independent quantum paths and Gaussian fluctuations
  • Gaussian-reference force-gradient correction
  • Methods and design decisions
    • Methods: the linear solve
    • Methods: approximate models
    • Methods: numerics, noise and uncertainty
  • Where the time goes
  • History

Reference

  • Command-line reference
    • gprn command-line reference
    • gprd command-line reference
    • Variational atomic environments
    • Environment types of the pair kernel
    • Scheme II training products
    • Configuration files
  • Training policy
  • TOML configuration keys
  • Build options
  • Bindings and external interfaces
    • C API
    • C API function reference
    • Fortran module
    • Python bindings
    • Rust binding
    • R and Julia bindings
    • Cap’n Proto configuration schema
    • Native ABIs, Rust crates and data formats
  • Native library ABI checks
  • IRC certificate walk: the old and the current protocol
  • GP surface API
  • C++ API
  • API Reference
    • gpridge
      • gpridge._adapters
      • gpridge._api
      • gpridge._calculator
      • gpridge._core
      • gpridge._observers
      • gpridge.ase_active_gp
      • gpridge.ase_bridge
      • gpridge.baker_board
      • gpridge.build_info
      • gpridge.dimer
      • gpridge.engine
      • gpridge.errors
      • gpridge.fes
      • gpridge.gp
      • gpridge.instanton
        • gpridge.instanton.circle_hess
        • gpridge.instanton.cokriging
        • gpridge.instanton.gate
        • gpridge.instanton.manifold_ef
      • gpridge.integrations
        • gpridge.integrations.ase_oracle
        • gpridge.integrations.errors
        • gpridge.integrations.examples
        • gpridge.integrations.geometry
        • gpridge.integrations.gromacs_quantities
        • gpridge.integrations.lammps_oracle
        • gpridge.integrations.openmm_oracle
        • gpridge.integrations.oracle
        • gpridge.integrations.plumed_bias
        • gpridge.integrations.units
      • gpridge.neb
      • gpridge.policy
      • gpridge.provenance
      • gpridge.pyeon_bridge
      • gpridge.session
      • gpridge.surrogate
      • gpridge.wheel_smoke
  • Fortran API
  • C++ API Reference
    • C API
      • Analytical potentials (Tier 3)
        • struct gpr_lj_params_t
      • Configuration structs
        • struct gpr_atoms_config_t
        • struct gpr_bq_config_t
        • struct gpr_bq_fit_report_t
        • struct gpr_bq_integral_report_t
        • struct gpr_bq_loo_report_t
        • struct gpr_bq_uncertainty_t
        • struct gpr_calibration_report_t
        • struct gpr_dimer_config_t
        • struct gpr_local_band_config_t
        • struct gpr_marginal_likelihood_report_t
        • struct gpr_minimize_config_t
        • struct gpr_model_config_t
        • struct gpr_neb_config_t
        • struct gpr_periodic_band_config_t
      • Dimer search (Tier 1)
        • struct gpr_dimer_report_t
      • Free-energy surrogate (ABI 1.23)
        • struct gpr_fes_config_t
        • struct gpr_fes_rate_config_t
        • struct gpr_fes_rate_report_t
      • GP-accelerated NEB and OCINEB (Tier 1)
        • struct gpr_neb_report_t
        • struct gpr_ocineb_config_t
      • GP/TP model (Tier 2)
        • struct gpr_noise_floor_report
      • Harmonic rate prefactors (ABI 1.20)
        • struct gpr_htst_half
        • struct gpr_htst_options
      • Hyperparameter access (Tier 2)
        • struct gpr_rff_selection
      • Posterior-mean derivatives (ABI 1.20)
        • struct gpr_derivative_options
        • struct gpr_derivative_report
      • Scalar GP and Bayesian quadrature (ABI 1.17)
      • Scalar surrogate and parameter search (ABI 1.26)
    • Global Namespace
      • namespace Eigen
        • template struct Eigen::NumTraits<gpr::derivatives::CountedReal>
        • template struct Eigen::NumTraits<gpr::extended::DoubleDouble>
      • namespace Kokkos
      • namespace atmd
        • enum atmd::DimerOracleProgressAction
        • enum atmd::DimerProposalGlobalizationAction
        • enum atmd::DimerRelaxationCycleKind
        • enum atmd::DimerRelaxationTerminationReason
        • enum atmd::DimerResidualGlobalizationAction
        • enum atmd::DimerSurrogateActionTermination
        • enum atmd::HssvdModeSelectionPolicy
        • struct atmd::DimerRelaxationBacktrackResult
        • struct atmd::DimerRelaxationCycleCertificate
        • struct atmd::DimerSaddleMeritBacktrackResult
        • struct atmd::DimerSurrogateActionCertificate
        • class atmd::AtomicDimer
        • class atmd::OracleBudgetExhausted
      • namespace aux
        • namespace aux::distance
        • struct aux::AtomSignature
        • struct aux::ChainRealignStats
        • struct aux::EndpointAlignResult
        • struct aux::InverseDistanceCache
        • struct aux::LebedevNode
        • struct aux::OracleOrientation
        • class aux::AuxiliaryFunctionality
        • class aux::Distance
        • class aux::Gradient
        • class aux::ProblemSetUp
      • namespace ceres
      • namespace dimer
        • class dimer::Dimer
        • class dimer::SphereRotation
      • namespace featomic
      • namespace funcmin
        • struct funcmin::MapObjectiveConfig
        • template struct funcmin::RgminNlmlCtx
        • struct funcmin::RgminTensorDeleter
        • class funcmin::ADAM
        • class funcmin::Ceres
        • template class funcmin::GprCostFunction
        • class funcmin::RgminCallbackFailure
        • class funcmin::RgminLbfgs
        • class funcmin::RgminOpt
        • class funcmin::RgminScg
      • namespace gaussianinfluence
        • struct gaussianinfluence::Result
      • namespace gpr
        • namespace gpr::abi
        • namespace gpr::bo
        • namespace gpr::capi
        • namespace gpr::cli
        • namespace gpr::coord
        • namespace gpr::derivatives
        • namespace gpr::extended
        • namespace gpr::field
        • namespace gpr::geometry
        • namespace gpr::htst
        • namespace gpr::io
        • namespace gpr::irc
        • namespace gpr::itergp
        • namespace gpr::kokkos_environment
        • namespace gpr::laplace
        • namespace gpr::linalg
        • namespace gpr::memory
        • namespace gpr::neb
        • namespace gpr::numerics
        • namespace gpr::optim
        • namespace gpr::optim_abi
        • namespace gpr::pairlocal
        • namespace gpr::policy
        • namespace gpr::posterior
        • namespace gpr::potentials
        • namespace gpr::priors
        • namespace gpr::quantum
        • namespace gpr::readcon_abi
        • namespace gpr::readcon_db_abi
        • namespace gpr::rgmin_abi
        • namespace gpr::rgpot_abi
        • namespace gpr::runtime
        • namespace gpr::sfc
        • namespace gpr::ski
        • namespace gpr::startup
        • namespace gpr::track
        • namespace gpr::uasaddle
        • namespace gpr::vecchia
        • enum gpr::BorderedSchurSign
        • enum gpr::ChartScalarKernel
        • enum gpr::GPModelProfile
        • enum gpr::HyperparameterObjectiveMode
        • enum gpr::HyperparameterOptimizationMode
        • enum gpr::MapPriorWeightMode
        • enum gpr::PriorMeanStatistic
        • enum gpr::ScgCurvatureMode
        • enum gpr::UncertaintyMode
        • struct gpr::ARDSearchResult
        • struct gpr::AdamOptimizationSettings
        • struct gpr::AtomicEnvironments
        • struct gpr::AtomsConfiguration
        • struct gpr::AtomsPositionAndType
        • struct gpr::BMAPrediction
        • struct gpr::BorderedNoiseReport
        • struct gpr::BorderedVarianceInterval
        • struct gpr::CanonicalDimerDefaultOptions
        • struct gpr::CeresOptimizationSettings
        • struct gpr::CutoffPairFeature
        • template struct gpr::Derivatives
        • struct gpr::DeviceResidency
        • struct gpr::EnergyAndGradient
        • struct gpr::EnergySurfaceOutputInfo
        • struct gpr::FactoredTrainingGeometry
        • struct gpr::GPRSetup
        • struct gpr::INLAPrediction
        • struct gpr::Indices2D
        • struct gpr::InputParameters
        • struct gpr::IterationsLimits
        • struct gpr::JointObservationVarianceReduction
        • template struct gpr::KeyValuePair
        • struct gpr::LBFGSInfo
        • struct gpr::LazyFactoredTrainingGeometry
        • struct gpr::NoiseSearchResult
        • struct gpr::Observation
        • struct gpr::OptimizerCommonSettings
        • template struct gpr::Pair
        • struct gpr::PhaseTimers
        • struct gpr::PhaseTotals
        • struct gpr::PublicLayoutBytes
        • struct gpr::RFFFeatureSelection
        • struct gpr::RFFValidationPlan
        • struct gpr::RadialPairFeature
        • struct gpr::RigidDeflationDiagnostic
        • struct gpr::SaddleCertificate
        • struct gpr::ScaleFreeTrustConfig
        • struct gpr::ScgOptimizationSettings
        • struct gpr::SexpatLocalOracleScope
        • struct gpr::StableBasisPosteriorWeights
        • struct gpr::StopCriteriaForDimer
        • struct gpr::StructuredPermutation
        • struct gpr::SupportedAtomicEnvironments
        • struct gpr::TrainingKernelGeometry
        • struct gpr::TrainingKernelGeometryBlock
        • struct gpr::TrainingKernelGeometrySubset
        • struct gpr::TransitionParameters
        • template struct gpr::Triplet
        • class gpr::ARDGridSearch
        • class gpr::AdditivePairKernel
        • class gpr::AtomicInducingPosterior
        • class gpr::BayesianModelAveraging
        • class gpr::ConditionalKernelProjection
        • class gpr::ConditionalPosterior
        • class gpr::ConditionedKernel
        • class gpr::ConstantCF
        • class gpr::ConstrainedChartCovariance
        • class gpr::FactorizedLikelihood
        • class gpr::FeatomicEnvironmentDescriptor
        • class gpr::GaussianProcessRegression
        • class gpr::GeodesicCovarianceEvidence
        • class gpr::GeodesicHeat
        • class gpr::GeodesicHeatEnergyForceKernel
        • class gpr::InverseDistanceDescriptor
        • class gpr::KernelOperator
        • class gpr::Kronecker
        • class gpr::LaplaceINLA
        • class gpr::LikGaussian
        • class gpr::LowRankCholesky
        • class gpr::ManifoldEnergyForceKernel
        • class gpr::Matern52
        • class gpr::ModeRefitPolicy
        • class gpr::MpiLifetime
        • class gpr::NoiseGridSearch
        • class gpr::ObservationLikelihood
        • class gpr::PairCutoff
        • class gpr::PriorBase
        • class gpr::PriorGaussian
        • class gpr::PriorLogNormal
        • class gpr::PriorLogUnif
        • class gpr::PriorSqrtt
        • class gpr::PriorT
        • class gpr::PriorUnif
        • class gpr::Project
        • class gpr::Pullback
        • class gpr::RFFFeatureSelectionError
        • class gpr::RFFModel
        • class gpr::RandomFourierFeatures
        • class gpr::ScaleFreeTrustRegion
        • class gpr::ScopedPhaseTimer
        • class gpr::ScopedPredictTimer
        • class gpr::ScopedVarianceTimer
        • class gpr::Sexpat
        • class gpr::SexpatCF
        • class gpr::SpeciesEnvironmentKernel
        • class gpr::StableBasis1D
        • class gpr::StableBasisND
        • template class gpr::StationaryChartKernel
        • class gpr::StudentTProcessRegression
        • class gpr::Sum
        • class gpr::TrustRadius
        • class gpr::WallClockLimit
        • class gpr::WallClockLimitReached
      • namespace math
        • class math::DistributionFunctions
        • class math::MatrixProperties
      • namespace pot
        • enum pot::OracleBatchStatus
        • struct pot::ActiveGPConfig
        • struct pot::AotiPackageTarget
        • struct pot::EngineAbiStamp
        • struct pot::EngineBinding
        • struct pot::EngineCaps
        • struct pot::EngineDerivativeReport
        • struct pot::EngineReport
        • struct pot::EngineRequest
        • struct pot::HostIsa
        • struct pot::OracleBatchLayout
        • struct pot::OracleBatchOutcome
        • struct pot::OracleEvaluationScope
        • struct pot::OraclePathChoice
        • struct pot::RgpotBackend
        • struct pot::RgpotRequest
        • class pot::ActiveGP
        • class pot::ActiveGPPotential
        • class pot::EngineError
        • class pot::EnginePotential
        • class pot::GprMeanPotential
        • class pot::NestedEngineOracle
        • class pot::PotentialWrapper
      • namespace quantumbridge
        • namespace quantumbridge::quadrature
        • namespace quantumbridge::secondcumulantdetail
        • struct quantumbridge::BridgeResidualOptions
        • struct quantumbridge::BridgeResidualResult
        • struct quantumbridge::GroundStateMomentCorrection
        • struct quantumbridge::PolynomialTerm
        • struct quantumbridge::SecondCumulantResult
      • namespace readcon_db
        • class readcon_db::Corpus
      • namespace rgpot
      • namespace std
        • template struct std::numeric_limits<gpr::extended::DoubleDouble>
      • enum ConvergenceNormType
      • enum DebugLevels
      • enum DimerAlgorithm
      • enum Directions
      • enum DistanceMetricType
      • enum FrozenAndMovingAtoms
      • enum OptimizationAlgorithms
      • enum OptionsForGradCalculation
      • enum Potentials
      • enum eon_relax_kind_t
      • enum eon_relax_neb_status_t
      • enum eon_relax_rc_t
      • enum rgpot_engine_gpr_hill_policy
      • enum rgpot_engine_gpr_hint_kind
      • enum rgpot_engine_gpr_phase
      • struct Compensated
      • struct RgpotEngineGprHint
      • struct RgpotEngineGprResidualPrior
      • struct RgpotEngineGprStats
      • struct RgpotEnginePot
      • struct eon_relax_band_t
      • struct eon_relax_outcome_t
      • struct eon_relax_surface_request_t
      • struct eon_relax_version_t
      • struct gpr_scheme2_cuda_operand_v1
      • struct gpr_scheme2_cuda_table_v1
      • struct gpr_scheme2_cuda_task_v1

Project

  • Citing GPRidge
  • Changelog

Development

  • Development
    • Contributing
    • Version and releases
    • Version and source
    • Installed packages
    • Reproduction archive
    • Release order
    • Correctness checks
    • Performance development guidelines
  • Documentation build and style
  • GP module layout
  • GP execution and component ownership
  • GP optimizer boundary contracts
  • GP-NEB to GP-Dimer state transfer
  • GP-OIE controller invariants and design record
  • TPE acquisition for GP-OIE oracle targeting
  • CUTLASS backend for RFF and KernelInverse
  • Unified InputParameters schema
  • SLATE as a linear-algebra backend

On this page

  • What you need
  • Step 1: a potential for the search to call
  • Step 2: run the search
  • Step 3: read the energy
  • Step 4: a surface hop with a frozen slab
  • Step 5: check the saddle with a GP-NEB band
  • Step 6: record each oracle call
  • Step 7: change the oracle
  • Where to go next
Edit this page
gpridge 0 0
  1. GPRidge /
  2. Python API: a first dimer search
View Source Open in ChatGPT Open in Claude

Python API: a first dimer search¶

A first-order saddle point is the top of the lowest barrier between two minima. Finding one takes many energy and force evaluations of the true potential. GPDimer needs fewer of them because it fits a Gaussian-process (GP) surrogate to the evaluations it has already made and searches on the surrogate between evaluations. This tutorial runs GPDimer on a two-atom potential defined in the script, then on a gold adatom hopping on an Al(100) slab with ASE’s effective medium theory (EMT) calculator. It then checks the saddle against a GP-NEB band between the same two minima and records every evaluation of the true potential in a log and a trajectory file. Nothing here needs an input file, a model download or a GPU.

What you need¶

  • The Python bindings of gpridge and ASE 3.23 or newer. Build or install them as described in Installation.

  • The readcon Python package for the trajectory step. It is the only optional piece, and that step is skipped when it is missing.

Check the build:

python -m gpridge.wheel_smoke

The command prints one line that starts with gpridge and the library version. If it fails with an ImportError, the extension module has not been built for this Python; see Installation.

Step 1: a potential for the search to call¶

The dimer search asks a calculator (the oracle) for the energy and forces of a geometry. Any ASE calculator can be the oracle. Here the oracle is a double-well along the distance \(r\) between two atoms,

\[V(r) = a\,(r - r_1)^2 (r - r_2)^2, \qquad a = 4\ \mathrm{eV/\AA^4},\quad r_1 = 1\ \mathrm{\AA},\quad r_2 = 2\ \mathrm{\AA}.\]

It has a minimum with \(V = 0\) at each of \(r_1\) and \(r_2\) and a barrier top at \(r = 1.5\ \mathrm{\AA}\) with \(V = 0.25\ \mathrm{eV}\). A correct search ends there.

import numpy as np
from ase import Atoms
from ase.calculators.calculator import Calculator, all_changes


class DoubleWell(Calculator):
    """V(r) = a (r - r1)^2 (r - r2)^2 in eV, forces in eV/Angstrom."""

    implemented_properties = ["energy", "forces"]

    def __init__(self, a=4.0, r1=1.0, r2=2.0, **kwargs):
        super().__init__(**kwargs)
        self.a, self.r1, self.r2 = a, r1, r2

    def calculate(self, atoms=None, properties=("energy",),
                  system_changes=all_changes):
        super().calculate(atoms, properties, system_changes)
        d = atoms.positions[1] - atoms.positions[0]
        r = np.linalg.norm(d)
        u = (self.r1 - r) * (self.r2 - r)
        dV_dr = 2.0 * self.a * u * (2.0 * r - self.r1 - self.r2)
        force_on_second = -dV_dr * d / r
        self.results["energy"] = self.a * u * u
        self.results["forces"] = np.array([-force_on_second, force_on_second])


oracle = DoubleWell()
atoms = Atoms("H2", positions=[[0.0, 0.0, 0.0], [1.35, 0.0, 0.0]],
              cell=[10.0, 10.0, 10.0], pbc=False)

ASE forces point downhill, so the force is the negative gradient. The code expects forces in eV/Å and energies in eV. The start geometry has the atoms 1.35 Å apart, on the slope between the \(r_1\) minimum and the barrier top.

Step 2: run the search¶

from gpridge import GaussianProcess
from gpridge.dimer import GPDimer

gp = GaussianProcess(uncertainty="map")
dimer = GPDimer(atoms, oracle=oracle, gp=gp, verbose=False)
converged = dimer.run(fmax=0.05, steps=100)

separation = np.linalg.norm(dimer.atoms.positions[1] - dimer.atoms.positions[0])
print(converged, dimer.termination_reason, dimer.oracle_calls)
print(f"bond length at the saddle: {separation:.3f} A")

assert converged and dimer.termination_reason == "force_converged"
assert abs(separation - 1.5) < 0.01
assert gp.n_observations == dimer.oracle_calls

The call counts and the bond length below are from one run. The counts can differ by a few with another build or BLAS library.

True force_converged <n>
bond length at the saddle: 1.495 A

The pieces of that call:

  • GaussianProcess(uncertainty”map”)= is the surrogate. map is the plain choice; Tune the Gaussian-process surrogate lists the other uncertainty modes and the remaining options.

  • GPDimer(atoms, oracle…, gp=…)= takes a copy of atoms, so the start geometry is not modified. verbose=False silences the progress log that the C++ search writes to standard error (about ninety lines for this system with the default verbose=True).

  • run(fmax=0.05, steps=100) stops when the L2 norm of the force on the dimer midpoint is below fmax (eV/Å). steps limits the outer iterations, that is the alternations between the surrogate and the oracle. At that stop it measures the Cartesian index stencil of the midpoint, one true gradient on each side of each coordinate. It returns True only when the force criterion was reached and the stencil found exactly one negative mode.

  • dimer.termination_reason says why the search stopped. The strings are listed in Python bindings. A value other than force_converged means the search did not reach a saddle. "uncertified_force_stop" is a force stop that the stencil refused, at a minimum or on a flat region.

  • dimer.oracle_calls counts evaluations of the true potential, the stencil included: 12 of the 24 here. vibrational_stencil”vibrational”= measures only the bond stretch, 2 of 8 calls, and can call a borderline mode resolved where the full stencil leaves it unresolved. The surrogate is not counted. gp.n_observations is the same number here because each call adds one observation.

Step 3: read the energy¶

dimer.atoms holds the saddle geometry, without a calculator attached. Energies inside the dimer search are measured from the energy at the first oracle call, which is the start geometry. dimer.energy_eV is therefore the saddle energy minus the start energy, not the absolute energy. Add the start energy to get the absolute value.

saddle_energy = oracle.get_potential_energy(dimer.atoms)
start_energy = oracle.get_potential_energy(atoms)
print(f"saddle {saddle_energy:.4f} eV, start {start_energy:.4f} eV, "
      f"relative {dimer.energy_eV:.4f} eV")

assert abs(saddle_energy - 0.25) < 1e-3
assert abs(start_energy + dimer.energy_eV - saddle_energy) < 1e-3
saddle 0.2500 eV, start 0.2070 eV, relative 0.0430 eV

Step 4: a surface hop with a frozen slab¶

The same driver handles periodic cells and fixed atoms. The system is one Au adatom on a 2 x 2 x 2 Al(100) slab, evaluated with ASE’s EMT. Everything but the adatom is frozen with FixAtoms. GPDimer supports FixAtoms and rejects any other constraint with a ValueError.

The adatom starts in a four-fold hollow site. The dimer starts 0.6 hollow-to-hollow spacings along \(x\), which is 0.1 spacings past the bridge site between two hollows.

from ase.build import add_adsorbate, fcc100
from ase.calculators.emt import EMT
from ase.constraints import FixAtoms

slab = fcc100("Al", size=(2, 2, 2), vacuum=6.0)
add_adsorbate(slab, "Au", 1.9, "hollow")
slab.pbc = [True, True, False]
slab.set_constraint(FixAtoms(indices=range(len(slab) - 1)))
spacing = slab.cell[0, 0] / 2        # hollow-to-hollow distance along x

start = slab.copy()
start.positions[-1, 0] += 0.6 * spacing

hop = GPDimer(start, oracle=EMT(), gp=GaussianProcess(uncertainty="map"),
              verbose=False)
converged = hop.run(fmax=0.05, steps=60)

shift = hop.atoms.positions[-1, 0] - slab.positions[-1, 0]
print(converged, hop.termination_reason, hop.oracle_calls)
print(f"adatom {shift:.2f} A from the hollow; the bridge site is {spacing / 2:.2f} A")

assert converged
assert abs(shift - spacing / 2) < 0.05
assert np.array_equal(hop.atoms.positions[:-1], start.positions[:-1])
True force_converged 16
adatom 1.43 A from the hollow; the bridge site is 1.43 A

The saddle is at the bridge site, half a spacing from the hollow. The last assertion checks that the frozen atoms come back with the coordinates they went in with.

Step 5: check the saddle with a GP-NEB band¶

GPNEB searches between two minima instead of from one geometry. It takes a list of ASE Atoms (reactant, intermediate images, product) and the same oracle and gp arguments. The intermediate images are only placeholders until interpolate fills them. The band below runs from the starting hollow to the next one along \(x\), through seven images in total.

from gpridge.neb import GPNEB

product = slab.copy()
product.positions[-1, 0] += spacing
images = [slab.copy() for _ in range(7)]
images[-1] = product

band = GPNEB(images, oracle=EMT(), gp=GaussianProcess(uncertainty="map"),
             use_idpp=True, verbose=False)
band.interpolate("idpp")
ok = band.run(fmax=0.05, steps=100)

saddle = hop.atoms.copy()
saddle.calc = EMT()
hollow = slab.copy()
hollow.calc = EMT()
dimer_barrier = saddle.get_potential_energy() - hollow.get_potential_energy()
print(ok, band.max_energy_image)
print(f"band barrier {band.barrier_eV:.3f} eV, dimer barrier {dimer_barrier:.3f} eV")

assert ok
assert band.max_energy_image == 3
assert abs(band.barrier_eV - dimer_barrier) < 0.01
True 3
band barrier 0.344 eV, dimer barrier 0.344 eV

The highest image is the middle one (index 3 of 0 to 6), and the barrier height from the band agrees with the dimer saddle to within 0.01 eV. Each driver counts its own oracle calls, so band.oracle_calls and hop.oracle_calls are separate numbers for separate searches. See Python usage for the options of GPNEB and for reading the band energies and images.

Step 6: record each oracle call¶

GPDimer can write a log and a trajectory of the geometries at which the true potential was evaluated. logfile takes a file name, "-" for standard output, or an open text file. trajectory takes a file name, which is written in the readcon .con format and needs the readcon package. Without it, the driver raises an ImportError that names the package.

ASE does not read .con files on its own unless the readcon-con ASE plugin is installed, so the block below reads the file with readcon. Each frame carries the energy and forces of that oracle call. The attach observer runs after every oracle call.

import readcon

energies = []
with GPDimer(atoms, oracle=oracle, gp=GaussianProcess(uncertainty="map"),
             verbose=False, logfile="dimer.log", trajectory="dimer.con") as logged:
    logged.attach(lambda: energies.append(logged.last_atoms.get_potential_energy()))
    logged.run(fmax=0.05, steps=100)

frames = [frame.to_ase()
          for frame in readcon.ConTrajectory("dimer.con", write_index=False)]
with open("dimer.log") as log:
    last_row = log.read().splitlines()[-1].split()
print(len(frames), logged.nsteps, len(energies))
print("last log row:", last_row[0], last_row[1], last_row[3], last_row[4])

assert len(frames) == len(energies) == logged.nsteps == logged.oracle_calls
assert abs(frames[-1].get_potential_energy() - energies[-1]) < 1e-6
saddle_frame = min(frames, key=lambda frame:
                   np.linalg.norm(frame.positions - logged.atoms.positions))
assert np.max(np.abs(saddle_frame.positions - logged.atoms.positions)) < 1e-8
assert abs(saddle_frame.get_potential_energy()
           - (frames[0].get_potential_energy() + logged.energy_eV)) < 1e-6
<n> <n> <n>
last log row: GPDimer: <n> <s> <s>

The log has a header and one row per oracle call: the call number, the wall-clock time, the absolute energy in eV and fmax, the largest force magnitude on any single atom in eV/Å. The last 12 rows are the index stencil around the saddle, 0.01 Å from it. With vibrational_stencil”vibrational”= those are the last 2 rows. The trajectory frames are the same geometries in the same order, and the energy stored in each frame matches the observer’s value. The last recorded frame can belong to the validation stencil. The final assertion selects the frame at the returned saddle geometry and checks its absolute energy against the starting energy plus energy_eV.

Step 7: change the oracle¶

The oracle is an argument, so a different potential needs no other change. The block below uses the PET-MAD machine-learned potential through the metatomic ASE calculator. It does not run in the documentation build: it needs the metatomic-torch Python package and a model file.

  • Install metatomic-torch. It is not part of the python pixi environment. The scalapack and gpu-cuda environments in pixi.toml list it, and a plain environment can use pip install "metatomic-torch>=0.1.2,<0.2" (the version range that pixi.toml pins).

  • Fetch the model file. In the petmad-assets pixi environment, pixi run -e petmad-assets prepare-petmad-model writes bench_data/petmad/pet-mad-s-v1.5.0.pt (see scripts/prepare_petmad_assets.py).

from metatomic.torch.ase_calculator import MetatomicCalculator

# start is an ase.Atoms for your own system, with its cell and constraints.
oracle = MetatomicCalculator("bench_data/petmad/pet-mad-s-v1.5.0.pt",
                             device="cpu")
gp = GaussianProcess(uncertainty="map")    # a new surrogate for a new system
dimer = GPDimer(start, oracle=oracle, gp=gp, verbose=False)
dimer.run(fmax=0.05, steps=100)

Use a new GaussianProcess for each system and each oracle. A surrogate that has already seen observations from another potential would start from the wrong energies. Engine integrations shows how to connect other engines (for example LAMMPS or a Python callback) as oracles.

Where to go next¶

  • Python usage: recipes for the drivers, observers and warm starts.

  • Tune the Gaussian-process surrogate: the options of GaussianProcess.

  • Python API: the functional dimer interface: the same search through gpridge.run_dimer.

  • A periodic Pt(111) Morse band: a band on a periodic slab, run through GPLocalBand.

  • Python bindings: the full public surface, error classes and termination reasons.

  • The surrogate loop and derivative observations and How GPRidge finds a saddle: why the surrogate works as it does.

Previous
Quickstart: a band on a Lennard-Jones pentamer
Next
First NEB band: Berry pseudorotation of a Lennard-Jones pentamer

Copyright (c) gpridge developers

Made with Sphinx and Shibuya theme.

Analytics · Antics by TurtleTech ehf