17#ifndef GPR_NEB_NEBPATH_H_
18#define GPR_NEB_NEBPATH_H_
67 NEBPath(
const Eigen::VectorXd& initial,
const Eigen::VectorXd& final_state,
68 int n_images,
double spring_constant = 0.1);
91 void initializeIDPP(
int n_atoms,
const std::vector<char>& moving_atoms,
92 bool collective =
false);
100 void initializeSIDPP(
int n_atoms,
const std::vector<char>& moving_atoms,
101 double alpha = 0.33);
112 const std::vector<char>& moving_atoms,
113 double alpha = 0.33);
215 std::vector<double> weights = {});
218 return spring_coordinates_;
222 return spring_weights_;
233 Eigen::Ref<Eigen::VectorXd> vector)
const;
237 const Eigen::VectorXd& reference,
238 const Eigen::VectorXd&
geometry)
const;
244 void pinFixedAtoms(Eigen::Ref<Eigen::VectorXd> positions)
const;
259 return neb_forces_[i];
270 convergence_force_norm_ = norm;
275 return convergence_force_norm_.value_or(
289 if (!convergence_force_norm_)
return neb_forces_[i].norm();
340 return static_cast<int>(images_.size());
375 spring_constant_ = k_max;
376 spring_constant_min_ = k_min;
392 use_geometric_spring_ = on;
396 return use_geometric_spring_;
416 energy_weighted_springs_ = on;
420 return energy_weighted_springs_;
440 return spring_rest_lengths_;
464 const std::vector<Eigen::MatrixXd>& segment_metric_factors)
const;
515 const std::vector<Eigen::MatrixXd>& segment_metric_factors);
521 const std::vector<Eigen::MatrixXd>& segment_metric_factors,
545 int n_atoms,
const std::vector<char>& moving_atoms)
const;
561 int n_atoms,
const std::vector<char>& moving_atoms);
567 int n_atoms,
const std::vector<char>& moving_atoms,
int anchor_index);
578 int n_atoms,
const std::vector<char>& moving_atoms,
579 const Eigen::VectorXd& positions,
const Eigen::VectorXd& cartesian_step,
580 const std::array<double, 9>* cell =
nullptr);
591 int n_atoms,
const std::vector<char>& moving_atoms,
592 const Eigen::VectorXd& left,
const Eigen::VectorXd& right,
double alpha,
593 const std::array<double, 9>* cell =
nullptr);
605 posterior_variance_threshold_ = threshold;
612 climbing_curvature_direction_ = std::move(direction);
617 climbing_curvature_direction_.resize(0);
622 return climbing_curvature_direction_;
628 return posterior_variance_threshold_;
632 std::optional<ConvergenceNormType> convergence_force_norm_;
633 std::vector<Image> images_;
634 std::vector<Eigen::VectorXd> neb_forces_;
637 std::vector<Eigen::VectorXd> force_variance_;
638 double posterior_variance_threshold_ =
639 std::numeric_limits<double>::infinity();
640 double spring_constant_;
641 enum class RuntimeSeed { Idpp, Collective, Sidpp, SidppInverseDistance };
643 bool seedFromRuntime(RuntimeSeed kind,
int n_atoms,
644 const std::vector<char>& moving_atoms,
double alpha);
645 std::vector<double> spring_rest_lengths_;
646 double spring_constant_min_ = -1.0;
648 bool use_geometric_spring_ =
false;
649 bool energy_weighted_springs_ =
true;
650 std::array<double, 9> cell_{};
651 bool periodic_ =
false;
652 bool molecular_rigid_motion_ =
false;
653 bool external_fixed_atoms_ =
false;
654 std::vector<Eigen::Index> spring_coordinates_;
656 std::vector<double> spring_weights_;
658 std::vector<char> moving_atoms_;
659 Eigen::VectorXd climbing_curvature_direction_;
661 [[nodiscard]] Eigen::VectorXd segmentDisplacement(
662 const Eigen::VectorXd& from,
const Eigen::VectorXd& to)
const;
663 void removeNetTranslation(Eigen::VectorXd& delta)
const;
664 [[nodiscard]]
bool allAtomsFree()
const;
665 double reparametrizeFromCumulativeArc(
const std::vector<double>& arc);
666 double reparametrizeFromCumulativeArc(
const std::vector<double>& arc,
669 void invalidateResampledImage(
int index);
674 Eigen::VectorXd tangent(
int i)
const;
678 bool rawTangent(
int i, Eigen::VectorXd& tau, Eigen::VectorXd& tau_plus,
679 double& own_weight)
const;
const Image & image(int i) const
static Eigen::VectorXd inverseDistanceGeodesicStep(int n_atoms, const std::vector< char > &moving_atoms, const Eigen::VectorXd &positions, const Eigen::VectorXd &cartesian_step, const std::array< double, 9 > *cell=nullptr)
Apply one inverse-distance internal-coordinate retraction.
std::vector< Eigen::MatrixXd > inverseDistanceSegmentMetricFactors(int n_atoms) const
Build segment metric factors for inverse-distance coordinates.
int highestEnergyImageIndex() const
Highest finite interior energy, or -1 when none exists.
double reparametrizeByArcLengthKeepingImage(int anchor_index)
Redistribute the two subchains while preserving one image.
void setForceVariance(int i, const Eigen::VectorXd &variance)
void setSpringRestLengths(std::vector< double > rest_lengths)
Per-segment spring rest lengths (numImages()-1 entries).
void setClimbingCurvatureDirection(Eigen::VectorXd direction)
double reparametrizeByArcLength()
Redistribute interior images uniformly along arc length.
int highestLocalMaximumImageIndex() const
Strict interior local maximum, else the highest finite energy.
void setFromObservation(const Observation &obs, int start_image=1)
Set energies and gradients for images from an Observation.
void setExternalFixedAtoms(bool present)
NEBPath(const Eigen::VectorXd &initial, const Eigen::VectorXd &final_state, int n_images, double spring_constant=0.1)
Initialize path with linear interpolation between endpoints.
double maxSpacingDeviation() const
Maximum relative deviation of image spacing from uniform.
void clearClimbingCurvatureDirection()
void maskFixedForce(Eigen::Ref< Eigen::VectorXd > force) const
Zero a force on fixed atoms.
void setMolecularRigidMotion(bool enabled)
void initializeIDPP(int n_atoms, bool collective=false)
Initialize from IDPP (image dependent pair potential) interpolation.
void projectPhysicalVector(const Eigen::VectorXd &reference, Eigen::Ref< Eigen::VectorXd > vector) const
double reparametrizeByMetricArcLength(const std::vector< Eigen::MatrixXd > &segment_metric_factors)
Redistribute interior images uniformly in a pullback metric.
void setEnergyWeightedSprings(bool on)
Allow the energy-weighted spring taper.
void alignMolecularFrames()
Normalize seed frames before evaluation, invalidating changed images.
void setPosteriorVarianceThreshold(double threshold)
Set the signal-scaled posterior-variance confidence threshold.
void enableClimbingImage()
Enable climbing image on the highest-energy intermediate image.
void setSpringBounds(double k_max, double k_min)
Set the spring constant bounds for the energy-weighted variable-spring force computation.
void initializeSIDPP(int n_atoms, double alpha=0.33)
Initialize via Sequential IDPP (SIDPP). rgsaddle_sidpp_alternating_path. The spring on that call is t...
bool geometricSpring() const
Eigen::VectorXd tangentAt(int i) const
Improved (energy-weighted) tangent at image i, normalised. Used by the OCINEB controller to seed the ...
bool usesPeriodicCell() const noexcept
bool hasForceVariance(int i) const
bool energyWeightedSprings() const
double posteriorVarianceThreshold() const
Current signal-scaled posterior-variance confidence threshold.
void interpolateFromEndpoints()
Rebuild interior images on the chord between the current endpoints.
void setSpringCoordinates(std::vector< Eigen::Index > coordinates, std::vector< double > weights={})
Band coordinates that carry the springs; empty means all.
bool molecularRigidMotion() const
void setMovingAtoms(std::vector< char > moving_atoms)
double tangentStiffness(int i) const
Stiffness the tangent adds to image i across the path.
void initializeSIDPPGeodesic(int n_atoms, double alpha=0.33)
Initialize via inverse-distance S-IDPP. rgsaddle_sidpp_alternating_inverse_distance_path....
const Eigen::VectorXd & climbingCurvatureDirection() const
void pinFixedAtoms(Eigen::Ref< Eigen::VectorXd > positions) const
Copy reactant coordinates onto fixed atoms.
double nebForceMagnitude(int i) const
double reparametrizeByInverseDistanceGeodesicArcLength(int n_atoms)
Redistribute the band by solving inverse-distance targets.
int numIntermediate() const
void setPeriodicCell(const std::array< double, 9 > &cell)
EigenMatrix intermediatePositions() const
Get all intermediate image positions as a matrix.
double reparametrizeByInverseDistanceGeodesicArcLengthKeepingImage(int n_atoms, const std::vector< char > &moving_atoms, int anchor_index)
Anchor-preserving inverse-distance geodesic reparameterization.
const Eigen::VectorXd & nebForce(int i) const
Get the NEB force for image i.
double reparametrizeByMetricArcLengthKeepingImage(const std::vector< Eigen::MatrixXd > &segment_metric_factors, int anchor_index)
Metric pullback variant of reparametrizeByArcLengthKeepingImage().
void setGeometricSpring(bool on)
Toggle the geometric (cubic-potential) spring on the intermediate-image NEB force....
int highestEnergyImageIndexPreferring(int preferred) const
void clearForceVariance()
void computeNEBForces()
Compute NEB forces for all intermediate images.
static Eigen::VectorXd inverseDistanceGeodesicInterpolate(int n_atoms, const std::vector< char > &moving_atoms, const Eigen::VectorXd &left, const Eigen::VectorXd &right, double alpha, const std::array< double, 9 > *cell=nullptr)
Interpolate between two geometries in inverse-distance space.
double forceMagnitude(const Eigen::VectorXd &force) const
const std::vector< Eigen::Index > & springCoordinates() const
Eigen::VectorXd alignMolecularGeometry(const Eigen::VectorXd &reference, const Eigen::VectorXd &geometry) const
Proper rigid alignment with fixed atom correspondence; no reassignment.
const std::vector< double > & springRestLengths() const
double maxMetricSpacingDeviation(const std::vector< Eigen::MatrixXd > &segment_metric_factors) const
Maximum relative spacing deviation measured in a pullback metric.
ConvergenceNormType convergenceForceNorm(Eigen::Index dof) const
Image & image(int i)
Access image i.
double saddleForce(int i) const
const std::vector< double > & springWeights() const
void setConvergenceForceNorm(std::optional< ConvergenceNormType > norm)
int highestLocalMaximumImageIndexPreferring(int preferred) const
The nudged elastic band: path, GP-NEB driver, configuration and result, acquisition,...
double saddleForceMagnitude(const Eigen::VectorXd &gradient)
Gaussian-process regression, kernels, priors, and the searches that run on the surrogate.
double forceNorm(const Eigen::MatrixBase< Derived > &force, ConvergenceNormType norm)
Eigen::Matrix< double, EigenDynamic, EigenDynamic, EigenMatrixStorage > EigenMatrix
Observation data: energy, gradient and positions.
A single image on the NEB path.
double posterior_variance
Eigen::VectorXd positions