class dimer::Dimer¶
Overview¶
#include <gpr/dimer/Dimer.h>
class Dimer {
public:
// typedefs
typedef std::function<bool(gpr::Observation&)> Image1Evaluator;
typedef std::function<bool(const Eigen::VectorXd&, Eigen::VectorXd&)> HessianVectorEvaluator;
// enums
enum RotationStepResult;
// construction
Dimer(double separation, bool is_subsystem = false);
virtual ~Dimer();
// methods
void translate(const gpr::Coord& R, const gpr::Coord& orient, const gpr::Coord& F, const double curv, const gpr::TransitionParameters& param_trans, gpr::LBFGSInfo& transinfo, gpr::Coord& R_new);
void translateWithForce(const gpr::Coord& R, const gpr::Coord& force, const gpr::TransitionParameters& parameters, gpr::LBFGSInfo& history, gpr::Coord& output);
void rotate(const gpr::Coord& R, const gpr::Coord& orient, const gpr::Coord& G01, const uint8_t potential, const double T_anglerot, const bool estim_Curv, const gpr::Observation& all_obs, gpr::GaussianProcessRegression* gpr_model, gpr::LBFGSInfo& rotinfo, gpr::Coord& orient_new, double& Curv, gpr::Observation& image1);
RotationStepResult rotateWithImage1Evaluator(const gpr::Coord& R, const gpr::Coord& orient, const gpr::Coord& G01, const double T_anglerot, const bool estim_Curv, const Image1Evaluator& image1_evaluator, gpr::LBFGSInfo& rotinfo, gpr::Coord& orient_new, double& Curv, gpr::Observation& image1);
RotationStepResult rotateWithHessian(const gpr::Coord& R, const gpr::Coord& orient, const gpr::Coord& G01, const bool estim_Curv, const Image1Evaluator& image1_evaluator, gpr::Coord& orient_new, double& Curv, gpr::Observation& image1, const HessianVectorEvaluator& hessian_evaluator);
RotationStepResult rotateWithRgminDimer(const gpr::Coord& R, const gpr::Coord& orient, const gpr::Coord& G01, const bool estim_Curv, const Image1Evaluator& image1_evaluator, gpr::Coord& orient_new, double& Curv, gpr::Observation& image1);
RotationStepResult rotateWithRgminDimer(const gpr::Coord& R, const gpr::Coord& orient, const gpr::Coord& G01, const bool estim_Curv, const Image1Evaluator& image1_evaluator, gpr::Coord& orient_new, double& Curv, gpr::Observation& image1, const HessianVectorEvaluator& hessian_evaluator);
void rotateForce(const gpr::Coord& G01, const gpr::Coord& orient, gpr::Coord& F_rot);
void setForceVariance(const Eigen::VectorXd& variance);
void clearForceVariance();
bool hasForceVariance() const;
void translateForce(const gpr::Coord& F, const gpr::Coord& orient, gpr::Coord& F_trans);
double estimateRotationalAngle(const gpr::Coord& orient, const gpr::Coord& G01, const gpr::Coord& F_rot_oriented);
void setProjectRotations(bool enabled);
void setRotationBasis(Eigen::MatrixXd basis);
void setRotationObservation(const gpr::Observation* endpoint);
void bindRgminTranslation(gpr::optim::RgminStep* session);
double calculateCurvature(const gpr::Coord& G01, const gpr::Coord& orient);
void calculatePotential(const uint8_t potential, gpr::GaussianProcessRegression* gpr_model, gpr::Observation& image1);
};
Detailed Documentation¶
Dimer method.
Construction¶
Dimer(double separation, bool is_subsystem = false)
Default constructor.
Parameters:
separation |
Dimer separation |
is_subsystem |
True when the dimer coordinates are a subset of a larger system. Skips rigid rotation/translation removal, which is not robust on partial coordinates. |
Methods¶
void translate(const gpr::Coord& R, const gpr::Coord& orient, const gpr::Coord& F, const double curv, const gpr::TransitionParameters& param_trans, gpr::LBFGSInfo& transinfo, gpr::Coord& R_new)
Translate dimer.
The dimer is translated one step towards saddle point by the bound rgmin L-BFGS session (bindRgminTranslation), or by rgmin’s empty-memory step when no session is bound.
Parameters:
R |
Coordinates of the middle point of the dimer. |
orient |
Unit vector along the direction of the dimer. |
F |
Force at the middle point of the dimer. |
curv |
Curvature of energy along the direction of the dimer. |
param_trans |
Predefined step length for convex regions, maximum step length. |
transinfo |
Unused; the curvature pairs live in the rgmin session. |
R_new |
Coordinates of the new middle point of the dimer. |
void translateWithForce(const gpr::Coord& R, const gpr::Coord& force, const gpr::TransitionParameters& parameters, gpr::LBFGSInfo& history, gpr::Coord& output)
Apply a caller-assembled dimer force through the same rgmin translation step.
void rotate(const gpr::Coord& R, const gpr::Coord& orient, const gpr::Coord& G01, const uint8_t potential, const double T_anglerot, const bool estim_Curv, const gpr::Observation& all_obs, gpr::GaussianProcessRegression* gpr_model, gpr::LBFGSInfo& rotinfo, gpr::Coord& orient_new, double& Curv, gpr::Observation& image1)
Rotate dimer.
The dimer is rotated one step towards its minimum energy orientation. The first call seeds the mode with rgmin’s measured Rayleigh-Ritz plane solve; later calls with the same rotinfo continue a persistent sphere L-BFGS refinement of the curvature.
Parameters:
R |
Coordinates of the middle point of the dimer. |
orient |
Unit vector along the direction of the dimer. |
G01 |
Gradient at the middle point and image 1 of the dimer. |
potential |
Potential and gradient function. |
T_anglerot |
Unused; the caller owns rotation convergence. |
estim_Curv |
If true, an estimate for the curvature along the direction of the dimer after the rotation is calculated. |
all_obs |
Object of all observed points. |
gpr_model |
Pointer to the GPR model. |
rotinfo |
Structure with information on previous external iterations. |
orient_new |
Unit vector along the direction of the dimer after optimal rotation. |
Curv |
Estimate for the curvature along the direction of the dimer after the rotation (0 if estim_Curv = 0 or no rotation). |
image1 |
Observation of the new observed location. |
RotationStepResult rotateWithHessian(const gpr::Coord& R, const gpr::Coord& orient, const gpr::Coord& G01, const bool estim_Curv, const Image1Evaluator& image1_evaluator, gpr::Coord& orient_new, double& Curv, gpr::Observation& image1, const HessianVectorEvaluator& hessian_evaluator)
Minimize the analytic curvature in the seed and Hessian-residual plane, then query the resulting endpoint on the supplied potential.
RotationStepResult rotateWithRgminDimer(const gpr::Coord& R, const gpr::Coord& orient, const gpr::Coord& G01, const bool estim_Curv, const Image1Evaluator& image1_evaluator, gpr::Coord& orient_new, double& Curv, gpr::Observation& image1)
Rotate through rgmin’s dimer plane solve and query the resulting endpoint. The Hessian action overload uses a fixed linear operator at R; the image-only overload uses finite dimer differences.
void rotateForce(const gpr::Coord& G01, const gpr::Coord& orient, gpr::Coord& F_rot)
Calculate rotational force acting on image 1 of the dimer.
Parameters:
G01 |
Gradient vectors at the middle point and image 1 of the dimer. |
orient |
Unit vector along the direction of the dimer. |
F_rot |
Rotational force acting on image 1 of the dimer. |
void setForceVariance(const Eigen::VectorXd& variance)
UA-Dimer: per-degree-of-freedom force variance from the surrogate. When set and sized to the configuration, rotateForce removes the axial component in that Sigma^{-1} metric rather than the Euclidean one (Yu and Wang, DOI 10.48550/arxiv.2605.24401), so the rotation follows curvature the model resolves instead of the largest raw force difference. Unset leaves the classical arithmetic untouched.
void translateForce(const gpr::Coord& F, const gpr::Coord& orient, gpr::Coord& F_trans)
Calculate translational force acting on image 1 of the dimer.
Parameters:
F |
Force at the middle point of the dimer. |
orient |
Unit vector along the direction of the dimer. |
F_trans |
Translational force acting on image 1 of the dimer. |
double estimateRotationalAngle(const gpr::Coord& orient, const gpr::Coord& G01, const gpr::Coord& F_rot_oriented)
Calculate a rough estimate of the optimal Rotation angle.
Parameters:
orient |
Unit vector along the direction of the dimer (before rotation). |
G01 |
Gradient at the middle point and image 1 of the dimer (before rotation). Each point occupies one row in the field. |
F_rot_oriented |
Oriented rotational force acting on image 1 of the dimer. |
Returns:
Rough estimate of the optimal Rotation angle.
void setProjectRotations(bool enabled)
A fixed periodic cell admits translations but not rigid rotations.
void setRotationBasis(Eigen::MatrixXd basis)
Orthonormal columns span the allowed Cartesian rotation directions.
void setRotationObservation(const gpr::Observation* endpoint)
The observed endpoint supplies the sphere objective’s energy origin.
void bindRgminTranslation(gpr::optim::RgminStep* session)
The owner supplies a session that outlives each Dimer call so accepted L-BFGS pairs persist across outer iterations.
double calculateCurvature(const gpr::Coord& G01, const gpr::Coord& orient)
Calculate curvature of the energy along the dimer.
Two-point estimate from the gradients at the midpoint and at image 1; also the index-1 witness a force-converged start must pass.
Parameters:
G01 |
Gradient at the middle point and image 1 of the dimer. |
orient |
Unit vector along the direction of the dimer. |
Returns:
Curvature.
void calculatePotential(const uint8_t potential, gpr::GaussianProcessRegression* gpr_model, gpr::Observation& image1)
Calculate potential.
Parameters:
potential |
Potential type. |
gpr_model |
Pointer to the GPR model (or nullptr). |
image1 |
Observation to populate with the selected potential’s energy and gradient. |