Loading...
Searching...
No Matches
gpr::uasaddle Namespace Reference

Functions

Eigen::MatrixXd obliqueNormalProjector (const Eigen::VectorXd &tangent, const Eigen::MatrixXd &force_covariance)
Eigen::VectorXd projectPerpendicular (const Eigen::VectorXd &force, const Eigen::VectorXd &tangent, const Eigen::MatrixXd &force_covariance)
Eigen::VectorXd projectPerpendicularDiagonal (const Eigen::VectorXd &force, const Eigen::VectorXd &tangent, const Eigen::VectorXd &force_variance)
Eigen::VectorXd projectPerpendicularIsotropic (const Eigen::VectorXd &force, const Eigen::VectorXd &tangent)
Eigen::VectorXd covarianceWeightedRotationForce (const Eigen::VectorXd &force_one, const Eigen::VectorXd &force_two, const Eigen::VectorXd &axis, const Eigen::MatrixXd &force_covariance)
double directionalUncertainty (const Eigen::VectorXd &direction, const Eigen::MatrixXd &force_covariance)

Function Documentation

◆ covarianceWeightedRotationForce()

Eigen::VectorXd gpr::uasaddle::covarianceWeightedRotationForce ( const Eigen::VectorXd & force_one,
const Eigen::VectorXd & force_two,
const Eigen::VectorXd & axis,
const Eigen::MatrixXd & force_covariance )
nodiscard

UA-Dimer rotational force. The classical form is

Theta = -2 [ (F1 - F2) - ((F1 - F2) . n_hat) n_hat ]

with n_hat the dimer axis; the uncertainty-aware form removes the axial component in the Sigma^{-1} metric instead, so the rotation is driven by curvature the model actually resolves rather than by the direction of largest raw force difference.

Definition at line 143 of file UncertaintyAwareSaddle.cpp.

146{
147 checkShapes(axis, force_covariance);
148 if (force_one.size() != axis.size() || force_two.size() != axis.size()) {
149 throw std::invalid_argument(
150 "uncertainty-aware saddle: dimer forces do not match the axis");
151 }
152 const Eigen::VectorXd difference = force_one - force_two;
153 return -2.0 * projectPerpendicular(difference, axis, force_covariance);
154}
Eigen::VectorXd projectPerpendicular(const Eigen::VectorXd &force, const Eigen::VectorXd &tangent, const Eigen::MatrixXd &force_covariance)

◆ directionalUncertainty()

double gpr::uasaddle::directionalUncertainty ( const Eigen::VectorXd & direction,
const Eigen::MatrixXd & force_covariance )
nodiscard

Effective uncertainty seen along a direction, sqrt(d^T Sigma d) / ||d||. Reported so a caller can say which directions the anisotropy is acting on.

Definition at line 156 of file UncertaintyAwareSaddle.cpp.

158{
159 checkShapes(direction, force_covariance);
160 const double nrm = direction.norm();
161 if (!(nrm > 0.0)) return 0.0;
162 const double q = direction.dot(force_covariance * direction);
163 return std::sqrt(std::max(0.0, q)) / nrm;
164}

◆ obliqueNormalProjector()

Eigen::MatrixXd gpr::uasaddle::obliqueNormalProjector ( const Eigen::VectorXd & tangent,
const Eigen::MatrixXd & force_covariance )
nodiscard

The oblique projector that removes the tangent direction in the metric induced by the inverse force covariance.

force_covariance must be symmetric positive definite; it is used through a solve, never inverted explicitly. tangent need not be normalized – the projector is invariant to its scale. Throws std::invalid_argument on a shape mismatch, a non-finite input, or a tangent with no Sigma^{-1} norm.

Definition at line 46 of file UncertaintyAwareSaddle.cpp.

48{
49 checkShapes(tangent, force_covariance);
50 const Eigen::VectorXd w = solveCovariance(force_covariance, tangent);
51 const double denom = tangent.dot(w);
52 if (!(denom > 0.0) || !std::isfinite(denom)) {
53 throw std::invalid_argument(
54 "uncertainty-aware saddle: tangent has no Sigma^{-1} norm");
55 }
56 const Eigen::Index n = tangent.size();
57 return Eigen::MatrixXd::Identity(n, n) - (tangent * w.transpose()) / denom;
58}

◆ projectPerpendicular()

Eigen::VectorXd gpr::uasaddle::projectPerpendicular ( const Eigen::VectorXd & force,
const Eigen::VectorXd & tangent,
const Eigen::MatrixXd & force_covariance )
nodiscard

P F, without forming P. This is the UA-NEB replacement for F - (F . tau) tau.

Definition at line 60 of file UncertaintyAwareSaddle.cpp.

63{
64 checkShapes(tangent, force_covariance);
65 if (force.size() != tangent.size() || !force.allFinite()) {
66 throw std::invalid_argument(
67 "uncertainty-aware saddle: force does not match the tangent");
68 }
69 const Eigen::VectorXd w = solveCovariance(force_covariance, tangent);
70 const double denom = tangent.dot(w);
71 if (!(denom > 0.0) || !std::isfinite(denom)) {
72 throw std::invalid_argument(
73 "uncertainty-aware saddle: tangent has no Sigma^{-1} norm");
74 }
75 // P F = F - tau (w . F) / (tau . w), with w = Sigma^{-1} tau.
76 return force - tangent * (w.dot(force) / denom);
77}

◆ projectPerpendicularDiagonal()

Eigen::VectorXd gpr::uasaddle::projectPerpendicularDiagonal ( const Eigen::VectorXd & force,
const Eigen::VectorXd & tangent,
const Eigen::VectorXd & force_variance )
nodiscard

The diagonal case, which is the one a GP actually hands over: a per-degree of-freedom force variance rather than a dense covariance. Sigma^{-1} tau is then elementwise, so the projection costs O(D) and needs no factorization, while still being anisotropic. Entries that are not positive fall back to the mean of the positive ones, so a single unresolved component cannot dominate the metric.

Definition at line 79 of file UncertaintyAwareSaddle.cpp.

82{
83 const Eigen::Index n = tangent.size();
84 if (n == 0 || force.size() != n || force_variance.size() != n) {
85 throw std::invalid_argument(
86 "uncertainty-aware saddle: diagonal covariance shape mismatch");
87 }
88 if (!force.allFinite() || !tangent.allFinite() ||
89 !force_variance.allFinite()) {
90 throw std::invalid_argument(
91 "uncertainty-aware saddle: non-finite input");
92 }
93 // A component with no usable variance would otherwise divide by zero and
94 // take over the metric; give it the mean of the components that do.
95 double sum = 0.0;
96 Eigen::Index count = 0;
97 for (Eigen::Index i = 0; i < n; ++i) {
98 if (force_variance(i) > 0.0) {
99 sum += force_variance(i);
100 ++count;
101 }
102 }
103 if (count == 0) return projectPerpendicularIsotropic(force, tangent);
104 const double fill = sum / static_cast<double>(count);
105
106 double denom = 0.0;
107 double numer = 0.0;
108 for (Eigen::Index i = 0; i < n; ++i) {
109 const double v = (force_variance(i) > 0.0) ? force_variance(i) : fill;
110 const double w = tangent(i) / v; // (Sigma^{-1} tau)_i
111 denom += tangent(i) * w;
112 numer += w * force(i);
113 }
114 if (!(denom > 0.0) || !std::isfinite(denom) || !std::isfinite(numer)) {
115 return projectPerpendicularIsotropic(force, tangent);
116 }
117 const double scale = numer / denom;
118 if (!std::isfinite(scale)) {
119 return projectPerpendicularIsotropic(force, tangent);
120 }
121 Eigen::VectorXd out(n);
122 for (Eigen::Index i = 0; i < n; ++i)
123 out(i) = force(i) - tangent(i) * scale;
124 // The weights are tau/sigma^2, so a variance many orders below the others
125 // is meant to dominate -- that anisotropy is the method, and clamping it
126 // away would defeat the purpose. Only a result that has actually left the
127 // representable range is rejected, and then the isotropic projection is
128 // the honest fallback rather than a NaN force.
129 if (!out.allFinite()) {
130 return projectPerpendicularIsotropic(force, tangent);
131 }
132 return out;
133}
eon_relax_band_t eon_relax_surface_fn void eon_relax_outcome_t * out
Eigen::VectorXd projectPerpendicularIsotropic(const Eigen::VectorXd &force, const Eigen::VectorXd &tangent)

◆ projectPerpendicularIsotropic()

Eigen::VectorXd gpr::uasaddle::projectPerpendicularIsotropic ( const Eigen::VectorXd & force,
const Eigen::VectorXd & tangent )
nodiscard

The isotropic projection, kept alongside so callers and tests can state the comparison directly: F - (F . tau_hat) tau_hat.

Definition at line 135 of file UncertaintyAwareSaddle.cpp.

137{
138 const double nrm2 = tangent.squaredNorm();
139 if (!(nrm2 > 0.0)) return force;
140 return force - tangent * (tangent.dot(force) / nrm2);
141}