namespace gpr::neb¶
Overview¶
The nudged elastic band: path, GP-NEB driver, configuration and result, acquisition, IDPP start. More…
namespace neb {
// namespaces
namespace gpr::neb::oie;
// typedefs
typedef std::function<std::pair<double, Eigen::VectorXd>(const Eigen::VectorXd&positions)> NEBOracle;
typedef std::function<std::vector<std::pair<double, Eigen::VectorXd>>(const std::vector<Eigen::VectorXd>&positions)> NEBBatchOracle;
typedef std::function<ObservationVariance(const Eigen::VectorXd&positions)> ObservationVarianceEstimator;
// enums
enum AcquisitionType;
enum AdaptiveSo3EvaluationMode;
enum BandStallAction;
enum GPNEBConvergenceStatus;
enum GPNEBStopReason;
enum IndexGateAction;
enum MMFRejectKind;
enum MMFStatus;
enum MetatomicSO3Policy;
enum MmfHandoffPolicy;
enum NEBMode;
enum ObservationRetention;
enum PeriodicBandInitial;
// structs
struct ActiveGpRgsaddleUser;
struct ActiveLearningSession;
struct BandForceStall;
struct BandLayout;
struct BandMidpointCertificate;
struct CartesianOracleCenter;
struct CartesianOracleStencil;
struct CartesianStencilRefinement;
struct ClimbingImageIndexCertificate;
struct EndpointSymmetry;
struct ForceStopHandoffStencil;
struct GPNEBConfig;
struct GPNEBResult;
struct GprRgsaddleUser;
struct Image;
struct IndexEscapeResult;
struct MMFRunResult;
struct NEBOracleEvaluationContext;
struct NEBOracleOptimizationOutcome;
struct NEBOracleSessionCheckpoint;
struct OCINEBConfig;
struct OCINEBDiagnostics;
struct OCINEBOracleCallSummary;
struct OCINEBResult;
struct ObservationVariance;
struct OieBandTraceRecord;
struct OieFixedImageLease;
struct OracleSessionRestartRequested;
struct OuterIterCompositionCertificates;
struct OuterIterCompositionTraceRecord;
struct PeriodicBandDefaults;
struct PosteriorFactorizationCounts;
struct SaddleCertificateReport;
struct SaddlePolishResult;
struct SharedParameterState;
struct StagedDimerObservation;
struct VibrationalIndexClass;
struct VibrationalIndexDecision;
struct VibrationalIndexMeasurement;
// classes
class AdaptiveSo3Policy;
class AdaptiveSo3SessionPolicy;
class EonRelaxClient;
class LocalCartesianGP;
class NEBPath;
class OCINEBController;
class OCINEBOracleCallLedger;
class OracleForceProgressTracker;
class PairSplineModel;
class PosteriorFactorizationScope;
class RgMinMode;
class RgSellaMin;
class RgSellaSaddle;
class RgsaddleClient;
// global variables
int kMaxConsecutiveOracleFailures = 8;
int kCompositionTraceFormatVersion = 1;
int kPeriodicBandImages = 8;
double kPeriodicBandFmax = 0.05;
int kPeriodicBandSteps = 1000;
double kPeriodicBandMaxMove = 0.2;
// global functions
double perpendicularSigma(const Eigen::VectorXd& gradient_variance, const Eigen::VectorXd& tangent);
int selectNextImage(const std::vector<Eigen::VectorXd>& neb_forces, const std::vector<ObservationVariance>& variances, const std::vector<Eigen::VectorXd>& tangents, const std::vector<bool>& evaluated, AcquisitionType strategy, double kappa = 1.0, std::mt19937* rng = nullptr);
std::vector<int> expandToTriplet(int center, int n_total);
int bandStallWindow(int n_images, int polished_dofs);
void noteLowestCertifiedClimb(BandForceStall& stall, const NEBPath& path, int image);
BandStallAction observeMaxBandForce(BandForceStall& stall, double max_force, double force_tolerance, int window);
void restoreCertifiedClimb(NEBPath& path, const BandForceStall& stall);
OieBandTraceRecord captureOieBandTrace(const NEBPath& path, GaussianProcessRegression& gp, int outer, const std::vector<double>& acquisition_variance, bool con_geometry, bool global_snapshot = true, int oracle_calls = -1);
EndpointSymmetry endpointSymmetryFromPermutation(const std::vector<int>& permutation, const Eigen::VectorXd& reactant, const Eigen::VectorXd& product, const std::vector<int>& atomic_numbers);
EndpointSymmetry requireEndpointSymmetry(const std::vector<int>& permutation, const Eigen::VectorXd& reactant, const Eigen::VectorXd& product, const std::vector<int>& atomic_numbers, double radius);
int gprMeanSurfaceCallback(void* user, eon_relax_surface_request_t* req);
double forceComponentRmsForNorm(double component_rms, Eigen::Index degrees_of_freedom, ConvergenceNormType norm);
bool oracleContextRequestsAdaptiveSo3(const NEBOracleEvaluationContext& context);
static double bandPairCutoff(const GPNEBConfig& config);
void applyConfigToGP(const GPNEBConfig& config, gpr::GaussianProcessRegression& gp);
GPNEBResult gpNEBUngated(NEBOracle oracle, const Eigen::VectorXd& initial, const Eigen::VectorXd& final_state, int n_images, const GPNEBConfig& config, ActiveLearningSession* session);
GPNEBResult gpNEB(NEBOracle oracle, const Eigen::VectorXd& initial, const Eigen::VectorXd& final_state, int n_images, const GPNEBConfig& config = {}, ActiveLearningSession* session = nullptr);
NEBOracle makeLazyPotentialOracle(std::function<pot::PotentialWrapper()> potential_factory, std::vector<int> atomic_numbers, std::array<double, 9> box, int& oracle_call_counter, double* oracle_seconds = nullptr, double* oracle_energy_noise_rms = nullptr, const bool* oracle_variance_updates_enabled = nullptr, double* oracle_force_noise_rms = nullptr, std::shared_ptr<detail::LazyPotentialOracleState>* state_out = nullptr, std::shared_ptr<const gpr::WallClockLimit> wall_clock_limit = nullptr);
NEBBatchOracle makeLazyPotentialBatchOracle(std::shared_ptr<detail::LazyPotentialOracleState> state);
pot::PotentialWrapper makePotentialWrapperFromOracle(NEBOracle oracle);
double saddleForceMagnitude(const Eigen::VectorXd& gradient);
double testingHelpedModeCurvature();
void runOciNebOuterIteration(const std::shared_ptr<OCINEBController>& controller, NEBOracle& oracle, const GPNEBConfig& neb_config, int& total_oracle_calls, int& bursts_fired, int& dimer_saddle_image_idx, const std::shared_ptr<OciMmfHandoffTrapState>& handoff_trap_state, const GPNEBConfig::OuterIterHook& caller_hook, NEBPath& path, int ci_image_idx, int outer_iter, ActiveLearningSession& sess, bool& converged, bool trap_detected);
OCINEBResult runOCINEB(NEBOracle oracle, const Eigen::VectorXd& initial, const Eigen::VectorXd& final_state, int n_images, const GPNEBConfig& neb_config, const OCINEBConfig& oci_config, ActiveLearningSession& session);
IndexEscapeResult runIndexEscapeGpDimer(const OCINEBConfig& oci_config, const GPNEBConfig& neb_config, ActiveLearningSession& session, NEBOracle& oracle, const Eigen::VectorXd& x_seed, double e_seed, const Eigen::VectorXd& g_seed, const Eigen::VectorXd& mode_seed, double energy_ceiling);
OCINEBResult runOCINEBRefined(NEBOracle oracle, const Eigen::VectorXd& initial, const Eigen::VectorXd& final_state, int n_images, GPNEBConfig neb_config, const OCINEBConfig& oci_config, ActiveLearningSession& session);
void certifyOCINEBResult(OCINEBResult& result, NEBOracle oracle, const Eigen::VectorXd& initial, const Eigen::VectorXd& final_state, int n_images, const GPNEBConfig& neb_config, const OCINEBConfig& oci_config, ActiveLearningSession& session);
int reduceOracleProviderCalls(int local_calls);
bool ciIndexCertificateRefuted(const OCINEBResult& result);
bool ocinebReportsConverged(const OCINEBResult& result);
template <typename Oracle>
CartesianOracleStencil evaluateCartesianOracleStencil(const Eigen::VectorXd& center, double displacement, const Eigen::MatrixXd& directions, const Oracle& oracle, const NEBBatchOracle* batch_oracle = nullptr, Eigen::Index batch_chunk = 0);
template <typename Oracle>
CartesianOracleStencil evaluateCartesianOracleStencil(const Eigen::VectorXd& center, double displacement, const Eigen::MatrixXd& directions, const Oracle& oracle, const CartesianOracleCenter& measured_center, const NEBBatchOracle* batch_oracle = nullptr, Eigen::Index batch_chunk = 0);
Eigen::MatrixXd stencilDirectionalActions(const CartesianOracleStencil& stencil);
Eigen::MatrixXd stencilHessianColumns(const CartesianOracleStencil& stencil);
std::string oracleStencilDestination(const std::string& requested, const std::string& anchor);
SaddleCertificateReport saddleCertificateReport(bool otherwise_certified, bool stencil_measured, bool force_stop_certified, bool inconclusive);
const char* stencilIndexLabel(bool first_order, bool higher_order);
void writeCartesianOracleStencil(const std::string& path, const CartesianOracleStencil& stencil, const std::vector<int>& atomic_numbers, const std::array<double, 9>& cell, int oracle_calls, const CartesianStencilRefinement* refinement = nullptr);
std::string formatCompositionTrace(const std::vector<OuterIterCompositionTraceRecord>& records);
bool parseCompositionTrace(const std::string& text, std::vector<OuterIterCompositionTraceRecord>& out, std::string* error);
bool writeCompositionTraceFile(const std::string& path, const std::vector<OuterIterCompositionTraceRecord>& records);
bool readCompositionTraceFile(const std::string& path, std::vector<OuterIterCompositionTraceRecord>& out, std::string* error);
bool compositionTracesTextuallyEqual(const std::vector<OuterIterCompositionTraceRecord>& a, const std::vector<OuterIterCompositionTraceRecord>& b);
bool compositionTracesNumericallyClose(const std::vector<OuterIterCompositionTraceRecord>& got, const std::vector<OuterIterCompositionTraceRecord>& expected, double rtol, double atol, std::string* mismatch = nullptr);
GPNEBConfig periodicBandConfig();
rgsaddle_status_t activeGpRgsaddleSurface(void* user, rgsaddle_surface_request_t* req);
rgsaddle_status_t gprRgsaddleSurface(void* user, rgsaddle_surface_request_t* req);
BandMidpointCertificate certifyBandMidpoints(ActiveLearningSession& session, const NEBPath& path, double force_tol);
BandMidpointCertificate certifyBandMidpointsMeasured(ActiveLearningSession& session, const NEBPath& path, double force_tol, NEBOracle& oracle, int max_measurements, int* oracle_calls);
ClimbingImageIndexCertificate certifyClimbingImageIndex(const NEBOracle& oracle, ActiveLearningSession& session, const Eigen::VectorXd& x_ci, double e_ci, const Eigen::VectorXd& g_ci, double hessian_fd_step, double max_move, double force_tol, const NEBBatchOracle* batch_oracle = nullptr, Eigen::Index batch_chunk = 0);
SaddlePolishResult polishSaddleOnSurrogate(const NEBOracle& oracle, ActiveLearningSession& session, const Eigen::VectorXd& x0, double e0, const Eigen::VectorXd& g0, double force_tol, int max_steps, double max_move, double hessian_fd_step);
Eigen::LLT<Eigen::MatrixXd> factorSubstrate(const Eigen::MatrixXd& hessian);
Eigen::VectorXd substrateStep(const Eigen::MatrixXd& hessian, const Eigen::VectorXd& force);
int rejectUntrustedStep(NEBPath& path, const std::vector<Eigen::VectorXd>& accepted_positions, const gpr::TrustRadius& trust, double trust_threshold);
Eigen::MatrixXd oracleStencilDirections(const Eigen::VectorXd& positions, const gpr::AtomsConfiguration* atoms, gpr::optim::VibrationalStencil stencil = gpr::optim::VibrationalStencil::Full);
VibrationalIndexDecision decideVibrationalIndex(const Eigen::VectorXd& positions, const Eigen::VectorXd& gradient, const gpr::AtomsConfiguration* atoms, gpr::GaussianProcessRegression* gp, double variance, double variance_threshold, double move, double stencil_step, const NEBOracle* oracle, const NEBBatchOracle* batch = nullptr, Eigen::Index batch_chunk = 0, gpr::optim::VibrationalStencil stencil = gpr::optim::VibrationalStencil::Full);
void applyVibrationalIndexDecision(GPNEBResult& result, const VibrationalIndexDecision& decision, int outer_budget);
void resetForceStopStencilCache();
void writeForceStopHandoff(const std::string& archive_dir, const GPNEBResult& result);
std::optional<ForceStopHandoffStencil> readForceStopHandoff(const std::string& archive_dir, const Eigen::VectorXd& center);
int appendForceStopObservations(gpr::Observation& observations, const ForceStopHandoffStencil& handoff);
bool seedDimerModeFromForceStop(gpr::Coord& orient, const ForceStopHandoffStencil& handoff);
void certifyForceStoppedNeb(GPNEBResult& result, NEBOracle& oracle, const GPNEBConfig& config, const gpr::AtomsConfiguration* atoms);
int vibrationalIndexOuterBudget(const GPNEBConfig& config, int n_images);
IndexGateAction decideIndexGate(bool pass, bool cap_remains);
VibrationalIndexClass classifyVibrationalIndex(const Eigen::VectorXd& curvatures, double resolution);
VibrationalIndexMeasurement indexFromCartesianColumns(const Eigen::MatrixXd& columns, const Eigen::VectorXd& positions, const Eigen::VectorXd& masses, double move, const Eigen::VectorXd* center_gradient = nullptr, const Eigen::VectorXi* frozen = nullptr, bool anchored = false, const Eigen::MatrixXd* measured = nullptr);
template <typename Force>
VibrationalIndexMeasurement measureVibrationalIndex(const Eigen::VectorXd& positions, const Eigen::VectorXd& masses, double step, double move, const Force& force, const Eigen::VectorXd* center_gradient = nullptr, const Eigen::VectorXi* frozen = nullptr, gpr::optim::VibrationalStencil stencil = gpr::optim::VibrationalStencil::Full, bool periodic = false);
double indexGateVarianceToNoise();
double indexGateNoiseFloor();
double indexGateVarianceThreshold(double noise_variance);
} // namespace neb
Detailed Documentation¶
The nudged elastic band: path, GP-NEB driver, configuration and result, acquisition, IDPP start.
Typedefs¶
typedef std::function<std::pair<double, Eigen::VectorXd>(const Eigen::VectorXd&positions)> NEBOracle
Oracle function: positions -> (energy, gradient).
typedef std::function<std::vector<std::pair<double, Eigen::VectorXd>>(const std::vector<Eigen::VectorXd>&positions)> NEBBatchOracle
Whole-band oracle: evaluates every geometry in one call (an AOTI band package runs one graph call per chunk). Same contract per element as ~NEBOracle~; falls back internally when the potential has no batch surface.
typedef std::function<ObservationVariance(const Eigen::VectorXd&positions)> ObservationVarianceEstimator
Posterior variance estimator for one joint oracle observation.
The returned record contains the energy variance and every gradient variance. OIE acquisition projects that complete record onto the quantity resolved by each strategy.
Global Variables¶
int kMaxConsecutiveOracleFailures = 8
Consecutive band geometries at which the oracle may fail (raise, or return a non-finite energy or force) before the search stops with an error. Each failure is a rejected trial: the image keeps its last measured state, no row is recorded, and the band step shrinks.
int kCompositionTraceFormatVersion = 1
Bump when the on-disk golden format changes incompatibly.
int kPeriodicBandImages = 8
Images between the endpoints. GPLocalBand’s constructor default.
double kPeriodicBandFmax = 0.05
Force tolerance of GPLocalBand.run, eV/Angstrom.
int kPeriodicBandSteps = 1000
Outer-iteration budget of GPLocalBand.run.
double kPeriodicBandMaxMove = 0.2
Largest per-atom step of one band move, Angstrom. GPLocalBand’s constructor default, wider than the gprn L-BFGS cap.
Global Functions¶
double perpendicularSigma(const Eigen::VectorXd& gradient_variance, const Eigen::VectorXd& tangent)
Compute perpendicular GP variance (variance orthogonal to path tangent).
sigma_perp = sqrt(sum_d sigma_d^2 * (1 - tau_d^2))
Parameters:
gradient_variance |
Per-component gradient variance |
tangent |
Unit tangent vector |
Returns:
Perpendicular standard deviation
int selectNextImage(const std::vector<Eigen::VectorXd>& neb_forces, const std::vector<ObservationVariance>& variances, const std::vector<Eigen::VectorXd>& tangents, const std::vector<bool>& evaluated, AcquisitionType strategy, double kappa = 1.0, std::mt19937* rng = nullptr)
Select the next unevaluated intermediate image by a per-image score.
This helper scores each image independently. It does not run the chain-level TPE, PS-BAX, or IMSPE selectors used by the GP-OIE outer loop.
MaxVariance force-variance trace MaxForce ||F_NEB|| UCB ||F_NEB|| + kappa * sigma_perp ThompsonSampling N(||F_NEB||, sigma_perp) if rng is set ExpectedImprovement energy variance IMSPE, TPE, PSBAX, PriorityCascade joint energy+gradient variance trace
Parameters:
neb_forces |
NEB forces at each intermediate image |
variances |
Joint energy-and-gradient variance at each intermediate image |
tangents |
Unit tangent vectors at each intermediate image |
evaluated |
Which images have been evaluated this iteration |
strategy |
Acquisition strategy to use |
kappa |
UCB exploration weight. Used only for AcquisitionType::UCB. |
rng |
Random number generator (for Thompson sampling) |
Returns:
Index into the intermediate-image arrays (0-based), or -1 if every image is already evaluated
std::vector<int> expandToTriplet(int center, int n_total)
Expand a single image index to a triplet {i-1, i, i+1}.
Triplet evaluation ensures the improved tangent at the center image uses ground-truth neighbors.
Parameters:
center |
Center image index |
n_total |
Total number of images (including endpoints) |
Returns:
Vector of image indices to evaluate
int bandStallWindow(int n_images, int polished_dofs)
Outers the max force may sit still before the climb is stalled.
The window is the longer of two band sizes. Every ordered pair of images is one step, since the worst force can sit on any image and be handed to any other. A polished subspace that is longer than that waits one step per polished coordinate instead.
void noteLowestCertifiedClimb(BandForceStall& stall, const NEBPath& path, int image)
Remember image when it is the highest on the band and lower than the climb already kept. The whole band is stored so a later restore climbs that image in the geometry that certified it.
BandStallAction observeMaxBandForce(BandForceStall& stall, double max_force, double force_tolerance, int window)
max_force is the max NEB force on the band. Progress is a drop of one force tolerance. A quiet window with a certified climb restores it once; a second quiet window stops on that climb instead of wandering. Stop leaves the certified climb in place. When that climb’s force is still above the tolerance the band driver sets the session stagnation handoff so the dimer, not another capped band step, continues it.
void restoreCertifiedClimb(NEBPath& path, const BandForceStall& stall)
Put the certified climb back and make it the climbing image.
OieBandTraceRecord captureOieBandTrace(const NEBPath& path, GaussianProcessRegression& gp, int outer, const std::vector<double>& acquisition_variance, bool con_geometry, bool global_snapshot = true, int oracle_calls = -1)
Record what the outer iteration already holds (band energies, the measured mask, NEB force norms, the acquisition variance, hyperparameters, the oracle-call count). With global_snapshot the fitted global model is also queried at every image, without updating the band or refitting.
EndpointSymmetry endpointSymmetryFromPermutation(const std::vector<int>& permutation, const Eigen::VectorXd& reactant, const Eigen::VectorXd& product, const std::vector<int>& atomic_numbers)
The endpoint-exchanging symmetry with permutation permutation (slot a of the mapped geometry takes atom permutation[a]). Q and t are the orthogonal Procrustes fit of the permuted reactant onto the product, which is optimal over proper and improper rotations alike; the fit is exact for a degenerate reaction whose endpoints are symmetry images. Throws when the permutation is not a non-identity bijection of like atoms.
EndpointSymmetry requireEndpointSymmetry(const std::vector<int>& permutation, const Eigen::VectorXd& reactant, const Eigen::VectorXd& product, const std::vector<int>& atomic_numbers, double radius)
endpointSymmetryFromPermutation, refused unless the operation carries each endpoint to within radius of the other: only then do the mirrored rows of one basin sit inside the trust region of the other’s images.
int gprMeanSurfaceCallback(void* user, eon_relax_surface_request_t* req)
Surface trampoline: the frozen-or-live GP surface behind the eon_relax_surface_fn contract. user is a GprMeanPotential*. Every image is evaluated through the cached-factor force path; the request’s epoch_out carries surfaceEpoch() so eOn’s Matter cache keys on the model generation. A request whose version major is unknown is refused.
double forceComponentRmsForNorm(double component_rms, Eigen::Index degrees_of_freedom, ConvergenceNormType norm)
Convert per-Cartesian-component force RMS to the selected force norm.
void applyConfigToGP(const GPNEBConfig& config, gpr::GaussianProcessRegression& gp)
Push a GPNEBConfig onto a GP: profile first, then the explicit objective and every switch keyed on the effective objective.
GPNEBResult gpNEB(NEBOracle oracle, const Eigen::VectorXd& initial, const Eigen::VectorXd& final_state, int n_images, const GPNEBConfig& config = {}, ActiveLearningSession* session = nullptr)
Run GP-accelerated NEB.
Parameters:
oracle |
Energy/gradient evaluation function |
initial |
Initial state positions (flat) |
final_state |
Final state positions (flat) |
n_images |
Number of intermediate images |
config |
NEB configuration |
session |
Optional active-learning session used to share observations and restore session state |
Returns:
NEBOracle makeLazyPotentialOracle(std::function<pot::PotentialWrapper()> potential_factory, std::vector<int> atomic_numbers, std::array<double, 9> box, int& oracle_call_counter, double* oracle_seconds = nullptr, double* oracle_energy_noise_rms = nullptr, const bool* oracle_variance_updates_enabled = nullptr, double* oracle_force_noise_rms = nullptr, std::shared_ptr<detail::LazyPotentialOracleState>* state_out = nullptr, std::shared_ptr<const gpr::WallClockLimit> wall_clock_limit = nullptr)
The single-point oracle of a run. The potential is built on the first call; state_out receives the shared state so that the whole-batch oracle of the same run (makeLazyPotentialBatchOracle) measures through the same instance and the same accounting.
NEBBatchOracle makeLazyPotentialBatchOracle(std::shared_ptr<detail::LazyPotentialOracleState> state)
Whole-batch companion to ~makeLazyPotentialOracle~ over the same state: one potential call per batch when the wrapped source has a batch surface (a UMA band package runs one graph call per chunk), a per-point walk through the same wrapper otherwise.
pot::PotentialWrapper makePotentialWrapperFromOracle(NEBOracle oracle)
Build a ~pot::PotentialWrapper~ that calls through to a ~NEBOracle~ lambda. Drop the atomicNrs / box / variance arguments (the NEB oracle’s backing potential already owns those).
double saddleForceMagnitude(const Eigen::VectorXd& gradient)
Maximum atomic force for Cartesian systems, Euclidean norm for toy PESs.
double testingHelpedModeCurvature()
Measured min-mode curvature of the latest helped burst in this process. Quiet NaN until a burst converges to a saddle.
OCINEBResult runOCINEB(NEBOracle oracle, const Eigen::VectorXd& initial, const Eigen::VectorXd& final_state, int n_images, const GPNEBConfig& neb_config, const OCINEBConfig& oci_config, ActiveLearningSession& session)
Entry point. Builds a stateful ~OCINEBController~, installs its run-method as the NEB’s per-outer-iter hook, then calls ~gpNEB~ with the session. The hook fires after every NEB outer iter once CI is active, drives MMF bursts via the controller, and writes results back into the chain.
IndexEscapeResult runIndexEscapeGpDimer(const OCINEBConfig& oci_config, const GPNEBConfig& neb_config, ActiveLearningSession& session, NEBOracle& oracle, const Eigen::VectorXd& x_seed, double e_seed, const Eigen::VectorXd& g_seed, const Eigen::VectorXd& mode_seed, double energy_ceiling)
Run the standalone GP dimer from the measured seed ~x_seed~, ~e_seed~, ~g_seed~ in the shared session, oriented along ~mode_seed~. A finite ~energy_ceiling~ requests a downhill recovery from a verified higher-index point. A minimum escape uses infinity to allow an uphill search. The dimer checks measured forces and rotation before stopping; its caller certifies the complete Hessian index. A measured interatomic distance below ratio_at_limit times the seed’s minimum aborts the search.
OCINEBResult runOCINEBRefined(NEBOracle oracle, const Eigen::VectorXd& initial, const Eigen::VectorXd& final_state, int n_images, GPNEBConfig neb_config, const OCINEBConfig& oci_config, ActiveLearningSession& session)
runOCINEB with certificate-driven band refinement (GPNEBConfig :: band_refinement_max, band_certificate_force_scale, first_attempt_wall_seconds). The first attempt uses session; each refinement doubles the image count and runs on a fresh session rebuilt from neb_config.gp_setup, since the per-image models are indexed to the image count. With band_refinement_max == 0 this is exactly runOCINEB. Shared by the gprn CLI and the Python bindings so both get the same acceptance behaviour.
void certifyOCINEBResult(OCINEBResult& result, NEBOracle oracle, const Eigen::VectorXd& initial, const Eigen::VectorXd& final_state, int n_images, const GPNEBConfig& neb_config, const OCINEBConfig& oci_config, ActiveLearningSession& session)
Measure the returned band’s certificates and recover an invalid saddle through the shared GP and oracle. The result retains every certificate measurement and recovery call.
int reduceOracleProviderCalls(int local_calls)
Aggregates completed OCINEB attempts while the provider counter remains authoritative for calls made by aborted oracle-surface sessions.
provider_calls must be the communicator-wide count. parallelEvaluate shards the PES (point i on rank i % nprocs), so a rank-local increment is a slice of the ledger and fails the invariant below.
bool ciIndexCertificateRefuted(const OCINEBResult& result)
The opt-in climbing-image index certificate measured this point and refused it. An unevaluated or unverified certificate is not a refutation: the curvature was not established.
bool ocinebReportsConverged(const OCINEBResult& result)
Whether a finished OCINEB attempt may be called converged. A refuted index certificate is not a saddle, and neither is a vibrational-index refusal. The band or dimer flag alone does not settle the run.
template <typename Oracle>
CartesianOracleStencil evaluateCartesianOracleStencil(const Eigen::VectorXd& center, double displacement, const Eigen::MatrixXd& directions, const Oracle& oracle, const NEBBatchOracle* batch_oracle = nullptr, Eigen::Index batch_chunk = 0)
Every displacement of the stencil is one point of one oracle step: the points are shared out over the ranks and each rank’s points go through batch_oracle in one call when one is given. directions are the stencil’s orthonormal Cartesian directions, normally gpr::optim::vibrationalStencilDirections at center.
template <typename Oracle>
CartesianOracleStencil evaluateCartesianOracleStencil(const Eigen::VectorXd& center, double displacement, const Eigen::MatrixXd& directions, const Oracle& oracle, const CartesianOracleCenter& measured_center, const NEBBatchOracle* batch_oracle = nullptr, Eigen::Index batch_chunk = 0)
Reuse rank zero’s exact measured center, retaining all 2*K+1 rows and their original owners. An invalid, stale or partial root measurement falls back to measuring the full stencil. Other ranks need not supply a measurement.
Eigen::MatrixXd stencilDirectionalActions(const CartesianOracleStencil& stencil)
Central differences of the gradient along each stencil direction, one column per direction. Empty for an incomplete stencil.
Eigen::MatrixXd stencilHessianColumns(const CartesianOracleStencil& stencil)
The stencil’s Cartesian Hessian columns, column j the action along coordinate j (gpr::optim::hessianColumnsFromDirections about the measured center gradient). Empty for an incomplete stencil.
std::string oracleStencilDestination(const std::string& requested, const std::string& anchor)
Explicit oracle-stencil path, or oracle-stencil.json beside the run’s output (the HDF5 path for a band, the geometry for a dimer). The parent directory is created by the writer, so a search persists the stencil without a directory prepared ahead of time.
void writeCartesianOracleStencil(const std::string& path, const CartesianOracleStencil& stencil, const std::vector<int>& atomic_numbers, const std::array<double, 9>& cell, int oracle_calls, const CartesianStencilRefinement* refinement = nullptr)
Write measured gradients in eV/A without Hessian projection or mass weighting. Schema 1 is the central-difference stencil along the Cartesian axes. Schema 2 is that stencil plus the refinement probes and the bounds they support, so a later reader can reach the same index without another oracle call. Schema 3 adds directions, one row per stencil direction (rows 2k+1 and 2k+2 of the positions displace along row k), and may carry the schema 2 refinement block; it is written whenever the directions are not the Cartesian axes. Parent directories of path are created.
std::string formatCompositionTrace(const std::vector<OuterIterCompositionTraceRecord>& records)
Canonical text serialization used by golden files and exact-match asserts.
bool compositionTracesTextuallyEqual(const std::vector<OuterIterCompositionTraceRecord>& a, const std::vector<OuterIterCompositionTraceRecord>& b)
True when canonical serializations are identical (golden check).
bool compositionTracesNumericallyClose(const std::vector<OuterIterCompositionTraceRecord>& got, const std::vector<OuterIterCompositionTraceRecord>& expected, double rtol, double atol, std::string* mismatch = nullptr)
Golden check tolerant to last-ULP floating-point drift. The structural and decision fields (indices, counts, ci_active, every certificate flag, and the theta length) must match exactly; the continuous fields (barrier_estimate, max_oracle_force, each theta value) match within atol plus rtol times the magnitude of the expected value. Exact string equality is too strict for a trace that carries 17-significant-figure reductions whose ordering drifts (e.g. a cuSOLVER GPU/CPU-fallback path), where a decision-identical run differs only in the trailing digits. mismatch, when non-null, receives a human-readable description of the first divergence.
GPNEBConfig periodicBandConfig()
GPNEBConfig of a periodic local band before the geometry is attached.
BandMidpointCertificate certifyBandMidpoints(ActiveLearningSession& session, const NEBPath& path, double force_tol)
The chord midpoint of every segment is relaxed on the surrogate in the hyperplane perpendicular to the chord (no oracle call) until its in-plane force is below force_tol, and that valley-floor energy upper bound must not exceed the climbing image. force_tol <= 0 checks raw chord midpoints.
BandMidpointCertificate certifyBandMidpointsMeasured(ActiveLearningSession& session, const NEBPath& path, double force_tol, NEBOracle& oracle, int max_measurements, int* oracle_calls)
The surrogate certificate, with a refused midpoint measured before it is believed: a refusal rests on the surrogate at a point no row has sampled (16_h2po4_anion: chord midpoints of a proton-transfer band sit where the ZBL prior mean rises 0.13 to 0.56 eV above the climbing image, and each refusal bought a refinement pass of 100+ rows). One oracle row at the relaxed midpoint either corrects the surrogate, and the certificate is re-run, or confirms a ridge above the climbing image (true_ridge), which is the refusal the refinement is for. A hump the relaxation slid off into an unsampled valley is verified the same way (17_claisen: the chord between two images crossed 1.16 eV, the relaxed midpoint sat in a surrogate valley no row had seen, and the band kept a 0.28 eV conformational saddle for the 1.3 eV rearrangement). At most max_measurements rows; oracle_calls counts them when non-null.
ClimbingImageIndexCertificate certifyClimbingImageIndex(const NEBOracle& oracle, ActiveLearningSession& session, const Eigen::VectorXd& x_ci, double e_ci, const Eigen::VectorXd& g_ci, double hessian_fd_step, double max_move, double force_tol, const NEBBatchOracle* batch_oracle = nullptr, Eigen::Index batch_chunk = 0)
The stencil and the refinement pairs are oracle steps whose points are shared out over the ranks; a rank’s points go through batch_oracle in one call when one is given (GPNEBConfig::batch_oracle and GPNEBConfig::oracle_batch_chunk).
SaddlePolishResult polishSaddleOnSurrogate(const NEBOracle& oracle, ActiveLearningSession& session, const Eigen::VectorXd& x0, double e0, const Eigen::VectorXd& g0, double force_tol, int max_steps, double max_move, double hessian_fd_step)
Newton polish driven by measured gradients and the surrogate Hessian. Each step solves d = -H^+ g on the allowed coordinate subspace, keeping fixed atoms immobile and removing only rigid motions that are symmetries of the system. Cartesian components are capped at max_move. Acceptance and convergence use the maximum per-atom norm of the true gradient projected into the allowed step space. A rejected trial is halved once; every measured row joins the session. The result retains component infinity norms as additional diagnostics. Termination occurs at force_tol, a failed halving, or max_steps accepted steps. The returned gradient is measured at the returned positions.
Eigen::LLT<Eigen::MatrixXd> factorSubstrate(const Eigen::MatrixXd& hessian)
Cholesky factor of a substrate Hessian.
The factor is double. A float factor rounds every entry onto a boundary a one-ulp force can cross, and the quasi-Newton step then leaves the basin.
Eigen::VectorXd substrateStep(const Eigen::MatrixXd& hessian, const Eigen::VectorXd& force)
One substrate step, H^{-1} force, from that factor.
int rejectUntrustedStep(NEBPath& path, const std::vector<Eigen::VectorXd>& accepted_positions, const gpr::TrustRadius& trust, double trust_threshold)
Reject a simultaneous inner-loop NEB step outside the GP trust set.
Returns:
First offending image index, or -1 when all intermediate images remain within the trust threshold.
Eigen::MatrixXd oracleStencilDirections(const Eigen::VectorXd& positions, const gpr::AtomsConfiguration* atoms, gpr::optim::VibrationalStencil stencil = gpr::optim::VibrationalStencil::Full)
Directions of a true-oracle Hessian stencil of a band geometry in the frame of atoms (masses, frozen atoms, cell), the same frame decideVibrationalIndex and certifyForceStoppedNeb measure in. Null atoms is a free molecule with unit masses. Full is every coordinate.
VibrationalIndexDecision decideVibrationalIndex(const Eigen::VectorXd& positions, const Eigen::VectorXd& gradient, const gpr::AtomsConfiguration* atoms, gpr::GaussianProcessRegression* gp, double variance, double variance_threshold, double move, double stencil_step, const NEBOracle* oracle, const NEBBatchOracle* batch = nullptr, Eigen::Index batch_chunk = 0, gpr::optim::VibrationalStencil stencil = gpr::optim::VibrationalStencil::Full)
One index decision for a climbing image. The GP mean Hessian is read first and costs no true call. Posterior energy variance is compared with variance_threshold (indexGateVarianceThreshold of the fitted noise). A resolved index-1 surrogate accepts. The true stencil runs only when that variance is above the threshold or the surrogate reports three or more negative modes. Full, the default, is two force evaluations per Cartesian coordinate and a resolution that includes the rigid columns. Vibrational displaces only the complement; its resolution is the measured block and can call a borderline mode resolved where full leaves it unresolved. A resolved surrogate with fewer negatives than that does not spend true calls and does not refuse: the mean Hessian on the hollow adatom reports two negatives, or none, at a true index-1 saddle.
void applyVibrationalIndexDecision(GPNEBResult& result, const VibrationalIndexDecision& decision, int outer_budget)
Apply decision to a force-converged result. A refusal with outer iterations still below outer_budget steps the climbing image and asks the caller to resume. A refusal with the budget spent clears convergence and sets index_refused.
void resetForceStopStencilCache()
Drop the in-process stencil cache. Tests use this so a previous geometry cannot satisfy a later count.
void writeForceStopHandoff(const std::string& archive_dir, const GPNEBResult& result)
Write the handed stencil where a following saddle reads it: the observation archive the saddle opens as its seed archive.
int appendForceStopObservations(gpr::Observation& observations, const ForceStopHandoffStencil& handoff)
Append stencil rows the saddle has not already stored. Returns the number of rows added. An empty observation takes its width from the handoff.
bool seedDimerModeFromForceStop(gpr::Coord& orient, const ForceStopHandoffStencil& handoff)
Replace orient ‘s single row with the lowest handed mode when that mode matches the row length. Returns false when there is no mode.
void certifyForceStoppedNeb(GPNEBResult& result, NEBOracle& oracle, const GPNEBConfig& config, const gpr::AtomsConfiguration* atoms)
The force loop has already stopped. Measure one Cartesian stencil, certify a first-order saddle, and refine only along a soft mode when the stencil has more than one negative mode. Does not resume the band.
int vibrationalIndexOuterBudget(const GPNEBConfig& config, int n_images)
Outer-iteration cap, including the per-image reading.
VibrationalIndexMeasurement indexFromCartesianColumns(const Eigen::MatrixXd& columns, const Eigen::VectorXd& positions, const Eigen::VectorXd& masses, double move, const Eigen::VectorXd* center_gradient = nullptr, const Eigen::VectorXi* frozen = nullptr, bool anchored = false, const Eigen::MatrixXd* measured = nullptr)
Classify a float64 Cartesian central-difference Hessian. Column j of columns is (g(x + h e_j) - g(x - h e_j)) / (2h). With no frozen atoms the spectrum is the mass-weighted vibrational complement from analyzeStencilIndex, and the resolution is that stencil’s resolution. Frozen atoms fix the frame: the spectrum is the mass-weighted moving block, and rigid motion is not removed again. frozen is one flag per atom, nonzero when that atom is frozen. measured names the stencil directions when the other columns were rebuilt (gpr::optim::analyzeStencilIndex).
template <typename Force>
VibrationalIndexMeasurement measureVibrationalIndex(const Eigen::VectorXd& positions, const Eigen::VectorXd& masses, double step, double move, const Force& force, const Eigen::VectorXd* center_gradient = nullptr, const Eigen::VectorXi* frozen = nullptr, gpr::optim::VibrationalStencil stencil = gpr::optim::VibrationalStencil::Full, bool periodic = false)
Float64 central differences of force at positions. force maps a Cartesian geometry to its Cartesian gradient. Two evaluations per stencil direction, and one at the center when the directions are not the coordinate axes and center_gradient is not supplied: the removed rigid columns are rebuilt about it. Full measures all 3 coordinates for N=1, and measureVibrationalIndex(frozen, Full) probes all 3N. Vibrational uses gpr::optim::vibrationalStencilDirections : frozen atoms, when flagged, are not displaced. periodic keeps the rotations, which are not symmetries of a cell: a free molecule measures 3N-6 directions (3N-5 when linear) and a periodic cell measures 3N-3.
double indexGateVarianceToNoise()
Ratio of posterior energy variance to fitted noise variance above which the surrogate index of a climbing image is not trusted.
double indexGateNoiseFloor()
Noise variance a noise-free fit is credited with in that comparison.
double indexGateVarianceThreshold(double noise_variance)
Posterior energy variance above which decideVibrationalIndex measures the true stencil: an order of magnitude over the fitted noise.