Loading...
Searching...
No Matches
gpr::quantum::ArcTailAction Class Reference

#include <gpr/quantum/ArcTailAction.h>

Inheritance diagram for gpr::quantum::ArcTailAction:

Public Member Functions

 ArcTailAction (M positiveWell, double period, double hbar, std::vector< double > arcWeights)
double period () const
const M & wellCurvature () const
const std::vector< double > & arcWeights () const
ArcTailEvaluation evaluate (const std::vector< V > &q, const std::vector< gpr::quantum::PotentialEvaluation > &native, double arcDuration, const std::vector< M > &nativeHessians={}) const

Detailed Description

Definition at line 24 of file ArcTailAction.h.

Constructor & Destructor Documentation

◆ ArcTailAction()

gpr::quantum::ArcTailAction::ArcTailAction ( M positiveWell,
double period,
double hbar,
std::vector< double > arcWeights )
inline

Definition at line 36 of file ArcTailAction.h.

38 : well_(std::move(positiveWell)),
39 period_(period),
40 hbar_(hbar),
41 weights_(std::move(arcWeights))
42 {
43 require(period_ > 0 && std::isfinite(period_) && hbar_ > 0 &&
44 std::isfinite(hbar_),
45 "Finite positive arc-tail scales required");
46 require(!weights_.empty(), "An anharmonic arc needs at least one link");
47 double sum = 0;
48 for (double weight: weights_) {
49 require(weight > 0 && std::isfinite(weight),
50 "Positive finite arc time weights required");
51 sum += weight;
52 }
53 require(std::abs(sum - 1) <= 1e-12, "Arc time weights must sum to one");
54 require(well_.rows() > 0 && well_.rows() == well_.cols() &&
55 well_.allFinite() &&
56 (well_ - well_.transpose()).norm() <=
57 1e-12 * std::max(1., well_.norm()),
58 "Finite symmetric well curvature required");
59 Eigen::SelfAdjointEigenSolver<M> eig(well_);
60 require(eig.info() == Eigen::Success &&
61 (eig.eigenvalues().array() > 0).all(),
62 "Positive well curvature required");
63 }
const std::vector< double > & arcWeights() const

Member Function Documentation

◆ arcWeights()

const std::vector< double > & gpr::quantum::ArcTailAction::arcWeights ( ) const
inline

Definition at line 72 of file ArcTailAction.h.

73 {
74 return weights_;
75 }

◆ evaluate()

ArcTailEvaluation gpr::quantum::ArcTailAction::evaluate ( const std::vector< V > & q,
const std::vector< gpr::quantum::PotentialEvaluation > & native,
double arcDuration,
const std::vector< M > & nativeHessians = {} ) const
inline

Definition at line 80 of file ArcTailAction.h.

83 {}) const
84 {
85 const auto n = weights_.size() + 1;
86 const auto d = well_.rows();
87 require(q.size() == n && native.size() == n &&
88 (nativeHessians.empty() || nativeHessians.size() == n),
89 "Arc-tail node counts differ");
90 require(arcDuration > 0 && arcDuration < period_ &&
91 std::isfinite(arcDuration),
92 "Arc duration must lie inside the thermal period");
93 for (std::size_t j = 0; j < n; ++j)
94 require(q[j].size() == d && q[j].allFinite() &&
95 native[j].gradient.size() == d &&
96 native[j].gradient.allFinite() &&
97 std::isfinite(native[j].energy),
98 "Invalid native arc point");
99 ArcTailEvaluation out;
100 out.gradient.assign(n, V::Zero(d));
101 out.durationCrossGradient.assign(n, V::Zero(d));
102 out.fluctuationHessianPhysical = !nativeHessians.empty();
103 const double logScale = std::log(2 * std::acos(-1.) * hbar_);
104 auto add = [&](std::size_t a, std::size_t b, double duration,
105 double durationSlope, bool tail) {
106 const gpr::quantum::HarmonicReference reference(well_, duration);
107 const auto& kernel = reference.kernel();
108 const auto left =
109 tail ? gpr::quantum::PotentialEvaluation{.5 * q[a].dot(well_ *
110 q[a]),
111 V(well_ * q[a])}
112 : native[a];
113 const auto right =
114 tail ? gpr::quantum::PotentialEvaluation{.5 * q[b].dot(well_ *
115 q[b]),
116 V(well_ * q[b])}
117 : native[b];
118 const auto link = reference.evaluate(q[a], q[b], left, right);
119 out.action += link.action;
120 out.gradient[a] += link.leftGradient;
121 out.gradient[b] += link.rightGradient;
122 out.logKernelNormalization += .5 * (kernel.logDetL - d * logScale);
123 const M adot = -kernel.L * kernel.L, ldot = -kernel.A * kernel.L;
124 const M addot = 2 * kernel.A * kernel.L * kernel.L;
125 const M lddot =
126 (kernel.L * kernel.L + kernel.A * kernel.A) * kernel.L;
127 const double residual =
128 tail ? 0
129 : .5 * (left.energy - .5 * q[a].dot(well_ * q[a]) +
130 right.energy - .5 * q[b].dot(well_ * q[b]));
131 const double energy = .5 * q[a].dot(adot * q[a]) +
132 .5 * q[b].dot(adot * q[b]) -
133 q[a].dot(ldot * q[b]) + residual;
134 out.durationGradient += durationSlope * energy;
135 out.durationHessian +=
136 durationSlope * durationSlope *
137 (.5 * q[a].dot(addot * q[a]) + .5 * q[b].dot(addot * q[b]) -
138 q[a].dot(lddot * q[b]));
139 out.durationCrossGradient[a] +=
140 durationSlope *
141 (adot * q[a] - ldot * q[b] +
142 (tail ? V::Zero(d).eval()
143 : V(.5 * (left.gradient - well_ * q[a]))));
144 out.durationCrossGradient[b] +=
145 durationSlope *
146 (adot * q[b] - ldot * q[a] +
147 (tail ? V::Zero(d).eval()
148 : V(.5 * (right.gradient - well_ * q[b]))));
149 if (!nativeHessians.empty())
150 out.fluctuationSegments.push_back(
151 tail ? kernel
152 : reference.quadratic(nativeHessians[a],
153 nativeHessians[b]));
154 };
155 for (std::size_t j = 0; j + 1 < n; ++j)
156 add(j, j + 1, weights_[j] * arcDuration, weights_[j], false);
157 add(n - 1, 0, period_ - arcDuration, -1, true);
158 require(std::isfinite(out.action) &&
159 std::isfinite(out.durationGradient) &&
160 std::isfinite(out.durationHessian) &&
161 std::isfinite(out.logKernelNormalization),
162 "Nonfinite arc-tail action");
163 for (std::size_t j = 0; j < n; ++j)
164 require(out.gradient[j].allFinite() &&
165 out.durationCrossGradient[j].allFinite(),
166 "Nonfinite arc-tail derivative");
167 return out;
168 }
eon_relax_band_t eon_relax_surface_fn void eon_relax_outcome_t * out

◆ period()

double gpr::quantum::ArcTailAction::period ( ) const
inline

Definition at line 64 of file ArcTailAction.h.

65 {
66 return period_;
67 }

◆ wellCurvature()

const M & gpr::quantum::ArcTailAction::wellCurvature ( ) const
inline

Definition at line 68 of file ArcTailAction.h.

69 {
70 return well_;
71 }

The documentation for this class was generated from the following file: