Loading...
Searching...
No Matches
Dimer.cpp
Go to the documentation of this file.
1// SPDX-License-Identifier: MIT
2// Copyright (c) gpridge developers
3// See LICENSE for details.
4
5/*
6 * Dimer.cpp
7 *
8 * Created on: 30 Oct 2020
9 * Author: Maxim Masterov
10 * Company: SURFSara
11 */
12
13#include "Dimer.h"
14
15#include <cmath>
16#include <cstdint>
17#include <limits>
18#include <memory>
19#include <vector>
20
23#include "../ml/PhaseTimers.h"
24#include "SphereRotation.h"
26
27namespace dimer {
28using gpr::Index_t;
29
30Eigen::MatrixXd rigid_motion_basis(const gpr::Coord& R, bool rotations)
31{
32 const gpr::Index_t num_atoms = R.cols() / 3;
33 const gpr::Index_t dof = num_atoms * 3;
34
35 if (num_atoms == 0 || R.rows() != 1 || R.cols() % 3 != 0) {
36 return Eigen::MatrixXd(R.cols(), 0);
37 }
38
39 // 1. Calculate the Center of Mass (COM)
40 gpr::vector3_reg com(0.0, 0.0, 0.0);
41 for (Index_t i = 0; i < num_atoms; ++i) {
42 com += gpr::coord::at(R, 0, i);
43 }
44 com /= static_cast<double>(num_atoms);
45
46 // 2. Construct the 6 basis vectors for translation and rotation
47 std::vector<Eigen::VectorXd> basis;
48 basis.reserve(6);
49
50 // Translational basis vectors
51 for (int i = 0; i < 3; ++i) {
52 Eigen::VectorXd t = Eigen::VectorXd::Zero(dof);
53 for (Index_t j = 0; j < num_atoms; ++j) {
54 t(3 * j + i) = 1.0;
55 }
56 basis.push_back(t);
57 }
58
59 // Rotational basis vectors (using coordinates relative to COM)
60 Eigen::VectorXd r_x = Eigen::VectorXd::Zero(dof);
61 Eigen::VectorXd r_y = Eigen::VectorXd::Zero(dof);
62 Eigen::VectorXd r_z = Eigen::VectorXd::Zero(dof);
63
64 for (Index_t i = 0; i < num_atoms; ++i) {
65 gpr::vector3_reg pos = gpr::coord::at(R, 0, i) - com;
66 // Rotation around x-axis: dR = a * (i x R) = a * (0, -z, y)
67 r_x(3 * i + 1) = -pos(2);
68 r_x(3 * i + 2) = pos(1);
69 // Rotation around y-axis: dR = a * (j x R) = a * (z, 0, -x)
70 r_y(3 * i + 0) = pos(2);
71 r_y(3 * i + 2) = -pos(0);
72 // Rotation around z-axis: dR = a * (k x R) = a * (-y, x, 0)
73 r_z(3 * i + 0) = -pos(1);
74 r_z(3 * i + 1) = pos(0);
75 }
76 if (rotations) {
77 basis.push_back(r_x);
78 basis.push_back(r_y);
79 basis.push_back(r_z);
80 }
81
82 // 3. Orthonormalize the basis using Gram-Schmidt. The quotient of
83 // configuration space by rigid motions is singular on the linear
84 // stratum: rotation about the molecular axis fixes the geometry, its
85 // generator vanishes and the rigid subspace drops to rank five. The
86 // rank is read from the generators themselves: a generator below the
87 // roundoff of the cross products that built it (machine epsilon times
88 // the extent of the geometry about its centre) is the zero generator.
89 double extent = 0.0;
90 for (Index_t i = 0; i < num_atoms; ++i)
91 extent += (gpr::coord::at(R, 0, i) - com).squaredNorm();
92 const double resolution = std::numeric_limits<double>::epsilon() *
93 static_cast<double>(dof) *
94 std::max(std::sqrt(extent), 1.0);
95 std::vector<Eigen::VectorXd> ortho_basis;
96 ortho_basis.reserve(6);
97
98 for (auto& v: basis) {
99 Eigen::VectorXd u = v;
100 for (int pass = 0; pass < 2; ++pass)
101 for (const auto& ou: ortho_basis) {
102 u -= u.dot(ou) * ou;
103 }
104 if (u.norm() > resolution) {
105 u.normalize();
106 ortho_basis.push_back(u);
107 }
108 }
109
110 Eigen::MatrixXd result(dof, static_cast<Eigen::Index>(ortho_basis.size()));
111 for (Eigen::Index i = 0; i < result.cols(); ++i)
112 result.col(i) = ortho_basis[static_cast<std::size_t>(i)];
113 return result;
114}
115
117 Eigen::VectorXd& step)
118{
119 const Eigen::MatrixXd basis = rigid_motion_basis(R);
120 if (basis.rows() != step.size())
121 throw std::invalid_argument(
122 "rigid projection position/step dimensions");
123 const Eigen::VectorXd removed = basis * (basis.transpose() * step);
124 step -= removed;
125 return removed.norm();
126}
127
128void Dimer::translate(const gpr::Coord& R, const gpr::Coord& orient,
129 const gpr::Coord& F, const double curv,
130 const gpr::TransitionParameters& param_trans,
131 gpr::LBFGSInfo& transinfo, gpr::Coord& R_new)
132{
133 R_new.resize(0, 0);
134 R_new = R;
135
136 if (curv < 0.) {
137 translateDimerForNegCurv(orient, F, param_trans, transinfo, R_new);
138 } else {
139 translateDimerForPosCurv(orient, F, param_trans, transinfo, R_new);
140 }
141}
142
143void Dimer::translateDimerForNegCurv(
144 const gpr::Coord& orient, const gpr::Coord& F,
145 const gpr::TransitionParameters& param_trans, gpr::LBFGSInfo& transinfo,
146 gpr::Coord& R)
147{
148 gpr::Coord F_trans;
149 translateForce(F, orient, F_trans);
150 translateWithForce(R, F_trans, param_trans, transinfo, R);
151}
152
154 const gpr::Coord& F_trans,
155 const gpr::TransitionParameters& param_trans,
156 [[maybe_unused]] gpr::LBFGSInfo& transinfo,
157 gpr::Coord& R)
158{
159 R = positions;
160 // The owner's persistent session keeps the curvature pairs across outer
161 // iterations, one gradient per outer. Without one the step is rgmin's
162 // empty-memory step. empty_scale 0.01 bounds that first step: a full -g
163 // overshoots max_step_length every outer and the search cycles for
164 // hundreds of phases.
165 gpr::optim::RgminStep transient;
166 gpr::optim::RgminStep& session =
167 rgmin_trans_ != nullptr ? *rgmin_trans_ : transient;
168 const Eigen::Index n = F_trans.size();
169 Eigen::VectorXd x = Eigen::Map<const Eigen::VectorXd>(R.data(), n);
170 const Eigen::VectorXd x_before = x;
171 const Eigen::VectorXd g =
172 -Eigen::Map<const Eigen::VectorXd>(F_trans.data(), n);
173 // A refusal after a pushed pair forgets the whole session, so the
174 // retry is the empty-memory step from the same point. A second refusal
175 // is a zero or unusable force, and the dimer stays where it is.
176 if (!session.step(x, g, param_trans.max_step_length, 0.01) &&
177 !session.step(x, g, param_trans.max_step_length, 0.01))
178 return;
179 Eigen::VectorXd r_final = x_before - x;
180
181 if (!this->is_subsystem) {
182 // Rigid rotation/translation comes off the step: a torqued step
183 // feeds the session's next curvature pair with rigid motion.
184 const Eigen::MatrixXd basis = rigid_motion_basis(R, project_rotations_);
185 r_final -= basis * (basis.transpose() * r_final);
186 }
187 Eigen::Map<Eigen::VectorXd>(R.data(), R.size()) -= r_final;
188}
189
190void Dimer::translateDimerForPosCurv(
191 const gpr::Coord& orient, const gpr::Coord& F,
192 const gpr::TransitionParameters& param_trans,
193 [[maybe_unused]] gpr::LBFGSInfo& transinfo, gpr::Coord& R)
194{
195 gpr::Coord F_trans;
196 gpr::Coord orient_search;
197
198 F_trans.resize(1, R.cols());
199 F_trans.setZero();
200
201 F_trans = orient * gpr::field::flatDot(F, orient);
202 F_trans *= -1.;
203 const double f_norm = F_trans.norm();
204 if (rgmin_trans_ != nullptr) rgmin_trans_->forget();
205 if (!(f_norm > 0.0) || !std::isfinite(f_norm)) return;
206 orient_search = F_trans / f_norm;
207 R = R + orient_search * param_trans.step_length;
208}
209
210void Dimer::rotate(const gpr::Coord& R, const gpr::Coord& orient,
211 const gpr::Coord& G01, const uint8_t potential,
212 const double T_anglerot, const bool estim_Curv,
213 [[maybe_unused]] const gpr::Observation& all_obs,
215 gpr::LBFGSInfo& rotinfo, gpr::Coord& orient_new,
216 double& Curv, gpr::Observation& image1)
217{
218 auto image1_evaluator = [&](gpr::Observation& candidate) {
219 calculatePotential(potential, gpr_model, candidate);
220 return candidate.G.rows() == 1 && candidate.G.cols() == G01.cols() &&
221 candidate.G.allFinite() && candidate.E.rows() >= 1 &&
222 candidate.E.cols() >= 1 && candidate.E.allFinite();
223 };
224 (void)rotateWithImage1Evaluator(R, orient, G01, T_anglerot, estim_Curv,
225 image1_evaluator, rotinfo, orient_new, Curv,
226 image1);
227}
228
230 const gpr::Coord& R, const gpr::Coord& orient, const gpr::Coord& G01,
231 const bool estim_Curv, const Image1Evaluator& image1_evaluator,
232 gpr::Coord& orient_new, double& Curv, gpr::Observation& image1,
233 const HessianVectorEvaluator& hessian_evaluator)
234{
235 return rotateWithRgminDimer(R, orient, G01, estim_Curv, image1_evaluator,
236 orient_new, Curv, image1, hessian_evaluator);
237}
238
240 const gpr::Coord& R, const gpr::Coord& orient, const gpr::Coord& G01,
241 const bool estim_Curv, const Image1Evaluator& image1_evaluator,
242 gpr::Coord& orient_new, double& Curv, gpr::Observation& image1)
243{
244 return rotateWithRgminDimer(R, orient, G01, estim_Curv, image1_evaluator,
245 orient_new, Curv, image1, {});
246}
247
249 const gpr::Coord& R, const gpr::Coord& orient, const gpr::Coord& G01,
250 const bool estim_Curv, const Image1Evaluator& image1_evaluator,
251 gpr::Coord& orient_new, double& Curv, gpr::Observation& image1,
252 const HessianVectorEvaluator& hessian_evaluator)
253{
254 if (R.rows() != 1 || R.cols() == 0 || orient.rows() != 1 ||
255 G01.rows() < 2 || G01.cols() != R.cols() || orient.cols() != R.cols() ||
256 !R.allFinite() || !(dimer_sep > 0.0) || !std::isfinite(dimer_sep)) {
258 }
259 const Eigen::Index n = R.cols();
260 Eigen::VectorXd seed = orient.row(0).transpose();
261 if (rotation_basis_.rows() > 0) {
262 if (rotation_basis_.rows() != n || !rotation_basis_.allFinite())
264 seed = rotation_basis_ * (rotation_basis_.transpose() * seed);
265 }
266 const double seed_norm = seed.norm();
267 if (!(seed_norm > 0.0) || !std::isfinite(seed_norm)) {
269 }
270 seed /= seed_norm;
271 const Eigen::VectorXd g0 = G01.row(0).transpose();
272 if (!g0.allFinite()) return RotationStepResult::EvaluationFailed;
273
274 struct Context {
275 const gpr::Coord& center;
276 const Eigen::VectorXd& gradient;
277 const Image1Evaluator& evaluate;
278 const HessianVectorEvaluator& hessian;
279 const Eigen::MatrixXd& physical;
280 double separation;
281 bool failed = false;
282 } context{
283 R, g0, image1_evaluator, hessian_evaluator, rotation_basis_, dimer_sep};
284 const auto action = [](void* user, const DLManagedTensorVersioned*,
285 const DLManagedTensorVersioned* direction,
286 DLManagedTensorVersioned* output) noexcept {
287 auto& ctx = *static_cast<Context*>(user);
288 if (ctx.failed) return RGMIN_INTERNAL_ERROR;
289 try {
290 const Eigen::Index size = ctx.center.cols();
291 const auto* vp = reinterpret_cast<const double*>(
292 static_cast<const uint8_t*>(direction->dl_tensor.data) +
293 direction->dl_tensor.byte_offset);
294 auto* hp = reinterpret_cast<double*>(
295 static_cast<uint8_t*>(output->dl_tensor.data) +
296 output->dl_tensor.byte_offset);
297 const Eigen::Map<const Eigen::VectorXd> v(vp, size);
298 Eigen::Map<Eigen::VectorXd> hv(hp, size);
299 if (ctx.hessian) {
300 Eigen::VectorXd value;
301 if (!ctx.hessian(v, value) || value.size() != size ||
302 !value.allFinite()) {
303 ctx.failed = true;
304 return RGMIN_INTERNAL_ERROR;
305 }
306 hv = value;
307 } else {
308 gpr::Observation trial;
309 trial.R = ctx.center;
310 trial.R.row(0) += ctx.separation * v.transpose();
311 if (!ctx.evaluate(trial) || trial.G.rows() != 1 ||
312 trial.G.cols() != size || !trial.G.allFinite()) {
313 ctx.failed = true;
314 return RGMIN_INTERNAL_ERROR;
315 }
316 hv = (trial.G.row(0).transpose() - ctx.gradient) /
317 ctx.separation;
318 }
319 if (ctx.physical.rows() > 0)
320 hv = (ctx.physical * (ctx.physical.transpose() * hv)).eval();
321 if (!hv.allFinite()) {
322 ctx.failed = true;
323 return RGMIN_INTERNAL_ERROR;
324 }
325 return RGMIN_SUCCESS;
326 } catch (...) {
327 ctx.failed = true;
328 return RGMIN_INTERNAL_ERROR;
329 }
330 };
331 Eigen::VectorXd center = R.row(0).transpose();
332 Eigen::VectorXd mode(n);
333 using Tensor =
334 std::unique_ptr<DLManagedTensorVersioned, decltype(&rgmin_tensor_free)>;
336 Tensor xt(rgmin_tensor_borrow_cpu_f64(center.data(), n), rgmin_tensor_free);
337 Tensor st(rgmin_tensor_borrow_cpu_f64(seed.data(), n), rgmin_tensor_free);
338 Tensor mt(rgmin_tensor_borrow_cpu_f64(mode.data(), n), rgmin_tensor_free);
339 if (!xt || !st || !mt) return RotationStepResult::EvaluationFailed;
340
341 // The caller owns rotation convergence; rgmin owns each plane solve.
342 const rgmin_eigen_params_t params{RGMIN_EIGEN_DIMER, 1, 2, 1, 1e-8};
343 rgmin_lowest_mode_t result{};
344 const auto status = rgmin_lowest_eigenpair(
345 action, &context, xt.get(), st.get(), mt.get(), &params, &result);
346 if (status != RGMIN_SUCCESS || context.failed || !mode.allFinite() ||
347 !(mode.norm() > 0.0)) {
349 }
350 mode.normalize();
351 if (mode.dot(seed) < 0.0) mode *= -1.0;
352
353 // Finite dimer differences are not a linear operator on a nonquadratic
354 // surface. Endpoint measurements must come from the endpoint query.
355 gpr::Observation endpoint;
356 endpoint.R = R;
357 endpoint.R.row(0) += dimer_sep * mode.transpose();
358 if (!image1_evaluator(endpoint) || endpoint.G.rows() != 1 ||
359 endpoint.G.cols() != n || !endpoint.G.allFinite() ||
360 endpoint.E.rows() != 1 || endpoint.E.cols() != 1 ||
361 !endpoint.E.allFinite()) {
363 }
364 const double curvature =
365 hessian_evaluator
366 ? result.value
367 : (endpoint.G.row(0).transpose() - g0).dot(mode) / dimer_sep;
368 if (!std::isfinite(curvature)) return RotationStepResult::EvaluationFailed;
369 orient_new.resize(1, n);
370 orient_new.row(0) = mode.transpose();
371 Curv = estim_Curv ? curvature : 0.0;
372 image1 = std::move(endpoint);
374}
375
377 const gpr::Coord& R, const gpr::Coord& orient, const gpr::Coord& G01,
378 [[maybe_unused]] const double T_anglerot, const bool estim_Curv,
379 const Image1Evaluator& image1_evaluator, gpr::LBFGSInfo& rotinfo,
380 gpr::Coord& orient_new, double& Curv, gpr::Observation& image1)
381{
382 if (R.cols() > 2) {
383 if (R.rows() != 1 || orient.rows() != 1 || orient.cols() != R.cols() ||
384 G01.rows() < 2 || G01.cols() != R.cols() || !R.allFinite() ||
385 !G01.allFinite() || !(dimer_sep > 0.0) || !std::isfinite(dimer_sep))
387 Eigen::MatrixXd physical = rotation_basis_;
388 if (physical.rows() == 0)
389 physical = Eigen::MatrixXd::Identity(R.cols(), R.cols());
390 if (!rotinfo.sphere_rotation || !rotinfo.sphere_rotation.unique()) {
391 // The measured Rayleigh-Ritz initializer resolves a two-mode
392 // quadratic directly. The sphere session retains curvature
393 // across all subsequent tangent directions.
394 gpr::Observation seed_endpoint;
395 const auto initialize = [&](gpr::Observation& endpoint) {
396 if (!image1_evaluator(endpoint)) return false;
397 if (seed_endpoint.R.size() == 0) seed_endpoint = endpoint;
398 return true;
399 };
400 const auto result =
401 rotateWithRgminDimer(R, orient, G01, estim_Curv, initialize,
402 orient_new, Curv, image1);
403 if (result == RotationStepResult::EvaluationFailed) return result;
404 rotinfo.sphere_rotation = std::make_shared<SphereRotation>();
405 if (!rotinfo.sphere_rotation->start(
406 R, G01.row(0).transpose(), dimer_sep, physical,
407 std::max<gpr::Index_t>(rotinfo.num_lbfgs_iter, 1), image1,
408 &seed_endpoint))
410 return result;
411 }
412 if (!rotinfo.sphere_rotation->step(
413 R, orient, G01.row(0).transpose(), dimer_sep, physical,
414 std::max<gpr::Index_t>(rotinfo.num_lbfgs_iter, 1),
415 image1_evaluator, rotation_observation_, orient_new, image1))
417 Curv = estim_Curv
418 ? (image1.G.row(0) - G01.row(0)).dot(orient_new.row(0)) /
419 dimer_sep
420 : 0.0;
422 }
423 // A two-coordinate problem has only one tangent direction.
424 return rotateWithRgminDimer(R, orient, G01, estim_Curv, image1_evaluator,
425 orient_new, Curv, image1);
426}
427
428void Dimer::rotateForce(const gpr::Coord& G01, const gpr::Coord& orient,
429 gpr::Coord& F_rot)
430{
431 gpr::Index_t D = G01.cols();
432 gpr::FieldMatrixd F1(1, D);
433 gpr::FieldMatrixd F2(1, D);
434 gpr::FieldMatrixd F1_rot(1, D);
435 gpr::FieldMatrixd F2_rot(1, D);
436
437 F_rot.resize(1, G01.cols());
438
439 F1 = G01.row(1);
440 F1 *= -1.;
441
442 F2 = G01.row(0);
443 F2 *= -2.;
444 F2 += G01.row(1);
445
446 // UA-Dimer: with a surrogate force variance the axial component comes off
447 // in the Sigma^{-1} metric. The classical branch keeps its exact
448 // expression: it assumes a unit orient and does not divide by the norm, so
449 // routing it through the general projection would shift every existing
450 // rotation in its last bits.
451 if (hasForceVariance() &&
452 force_variance_.size() == static_cast<Eigen::Index>(D)) {
453 const Eigen::VectorXd axis = orient.row(0).transpose();
455 F1.row(0).transpose(), axis, force_variance_)
456 .transpose();
458 F2.row(0).transpose(), axis, force_variance_)
459 .transpose();
460 } else {
461 F1_rot = F1 - orient * gpr::field::flatDot(F1, orient);
462 F2_rot = F2 - orient * gpr::field::flatDot(F2, orient);
463 }
464
465 F_rot = (F1_rot - F2_rot) / dimer_sep;
466 if (rotation_basis_.rows() > 0) {
467 if (rotation_basis_.rows() != D || !rotation_basis_.allFinite())
468 throw std::invalid_argument("invalid dimer rotation basis");
469 // The rotation plane belongs to the same physical subspace as the
470 // measured mode; rigid-force noise cannot supply a tangent direction.
471 F_rot = (rotation_basis_ *
472 (rotation_basis_.transpose() * F_rot.row(0).transpose()))
473 .transpose()
474 .eval();
475 }
476}
477
478void Dimer::translateForce(const gpr::Coord& F, const gpr::Coord& orient,
479 gpr::Coord& F_trans)
480{
481 F_trans = F - orient * (gpr::field::flatDot(F, orient)) * 2.;
482}
483
485 const gpr::Coord& orient)
486{
487 if (G01.rows() < 2 || G01.cols() != orient.cols() || !(dimer_sep > 0.0) ||
488 !std::isfinite(dimer_sep)) {
489 return std::numeric_limits<double>::quiet_NaN();
490 }
491
492 double C = 0.;
493
494 for (gpr::Index_t n = 0; n < G01.cols(); ++n) {
495 C += (G01(1, n) - G01(0, n)) * orient(0, n);
496 }
497 C /= dimer_sep;
498
499 return C;
500}
501
502void Dimer::calculatePotential(const uint8_t potential,
504 gpr::Observation& image1)
505{
507
508 switch (potential) {
509 case POTENTIAL_GP:
510 gpr::assertMsg(gpr_model != nullptr,
511 "Error! NULL pointer is passed!");
512 // Dispatched predict: the inner calculatePotential returns the
513 // standardized residual E~ = (E - y_mean_)/y_scale_; only the
514 // dispatched wrapper restores physical units and the prior
515 // mean. The dimer's energies meet raw oracle energies in the
516 // saddle certificates, so they must be physical.
517 {
518 gpr::ScopedPredictTimer predict_timer;
519 gpr_model->calculatePotentialDispatched(image1);
520 }
521 break;
522
523 // This case is used in unit tests
524 case POTENTIAL_TEST1:
525 image1.E.resize(1, 1);
526 image1.G.resize(1, 2 * 3);
527
528 image1.E(0, 0) = 140.981934401792e-006;
529
530 image1.G(0, 0) = 22.0169292639464e-003;
531 image1.G(0, 1) = -25.3799869163130e-003;
532 image1.G(0, 2) = 20.4383773983493e-003;
533 image1.G(0, 3) = -17.5501833843735e-003;
534 image1.G(0, 4) = 21.9491835909580e-003;
535 image1.G(0, 5) = -28.6553826196841e-003;
536
537 break;
538
539 // This case is used in unit tests
540 case POTENTIAL_TEST2:
541 image1.E.resize(1, 1);
542 image1.G.resize(1, 2 * 3);
543
544 image1.E(0, 0) = 268.422097239501e-006;
545
546 image1.G(0, 0) = 21.4263025463240e-003;
547 image1.G(0, 1) = -30.4813824740716e-003;
548 image1.G(0, 2) = 26.0833530773849e-003;
549 image1.G(0, 3) = -16.2806875633080e-003;
550 image1.G(0, 4) = 21.0852193621926e-003;
551 image1.G(0, 5) = -35.3650094447835e-003;
552
553 break;
554
555 default:
556 err << "Error! The type of the potential is unknown!";
557
558 break;
559 }
560}
561
563 const gpr::Coord& G01,
564 const gpr::Coord& F_rot_oriented)
565{
566 double F_0 = F_rot_oriented.norm();
567 double C_0 = calculateCurvature(G01, orient);
568
569 return 0.5 * atan(0.5 * F_0 / fabs(C_0));
570}
571
572} /* namespace dimer */
@ x
Definition Enums.h:28
@ POTENTIAL_TEST1
Definition Enums.h:16
@ POTENTIAL_TEST2
Definition Enums.h:16
@ POTENTIAL_GP
Definition Enums.h:16
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)
Definition Dimer.cpp:229
bool hasForceVariance() const
Definition Dimer.h:195
void rotateForce(const gpr::Coord &G01, const gpr::Coord &orient, gpr::Coord &F_rot)
Calculate rotational force acting on image 1 of the dimer.
Definition Dimer.cpp:428
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.
Definition Dimer.cpp:128
void translateWithForce(const gpr::Coord &R, const gpr::Coord &force, const gpr::TransitionParameters &parameters, gpr::LBFGSInfo &history, gpr::Coord &output)
Definition Dimer.cpp:153
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)
Definition Dimer.cpp:376
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)
Definition Dimer.cpp:239
std::function< bool(gpr::Observation &)> Image1Evaluator
Definition Dimer.h:61
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.
Definition Dimer.cpp:210
void calculatePotential(const uint8_t potential, gpr::GaussianProcessRegression *gpr_model, gpr::Observation &image1)
Calculate potential.
Definition Dimer.cpp:502
RotationStepResult
Definition Dimer.h:65
void translateForce(const gpr::Coord &F, const gpr::Coord &orient, gpr::Coord &F_trans)
Calculate translational force acting on image 1 of the dimer.
Definition Dimer.cpp:478
double calculateCurvature(const gpr::Coord &G01, const gpr::Coord &orient)
Calculate curvature of the energy along the dimer.
Definition Dimer.cpp:484
std::function< bool(const Eigen::VectorXd &, Eigen::VectorXd &)> HessianVectorEvaluator
Definition Dimer.h:62
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.
Definition Dimer.cpp:562
bool step(const gpr::Coord &center, const gpr::Coord &orientation, const Eigen::VectorXd &gradient, double separation, const Eigen::MatrixXd &physical, std::size_t memory, const Evaluator &evaluate, const gpr::Observation *initial_endpoint, gpr::Coord &rotated, gpr::Observation &endpoint)
bool start(const gpr::Coord &center, const Eigen::VectorXd &gradient, double separation, const Eigen::MatrixXd &physical, std::size_t memory, const gpr::Observation &endpoint, const gpr::Observation *previous=nullptr)
void calculatePotentialDispatched(Observation &image1)
Definition Predict.cpp:982
Responsible for errors handling.
bool step(Eigen::VectorXd &x, const Eigen::VectorXd &gradient, double max_move, double empty_scale, Objective objective=Objective::Unspecified)
Definition RgminStep.h:122
int status
eon_relax_band_t eon_relax_surface_fn void * user
Eigen::MatrixXd rigid_motion_basis(const gpr::Coord &R, bool rotations)
Build an orthonormal basis for rigid-body translations and rotations.
Definition Dimer.cpp:30
double project_out_rot_trans_with_feedback(const gpr::Coord &R, Eigen::VectorXd &step)
Project rigid-body motion out of a Cartesian optimization step.
Definition Dimer.cpp:116
Eigen::Vector3d at(const FieldMatrixd &mat, Index_t i)
double flatDot(const Eigen::MatrixBase< DerivedA > &a, const Eigen::MatrixBase< DerivedB > &b)
void requireCompatibleLibrary()
Definition RgminAbi.h:90
Eigen::VectorXd projectPerpendicularDiagonal(const Eigen::VectorXd &force, const Eigen::VectorXd &tangent, const Eigen::VectorXd &force_variance)
Eigen::Vector3d vector3_reg
Definition Macros.h:36
FieldMatrixd Coord
Definition Macros.h:35
uint32_t Index_t
Definition Macros.h:17
Eigen::Matrix< double, EigenDynamic, EigenDynamic, FieldMatrixStorage > FieldMatrixd
Definition Macros.h:25
Structure with information for the LBFGS method.
Definition Structures.h:977
Index_t num_lbfgs_iter
Definition Structures.h:984
std::shared_ptr< dimer::SphereRotation > sphere_rotation
A copied history starts an independent sphere solve when written.
Definition Structures.h:979
Observation data: energy, gradient and positions.
FieldMatrixd E
Structure of translation parameters.