Loading...
Searching...
No Matches
JacobiAction.h
Go to the documentation of this file.
1// SPDX-License-Identifier: MIT
6#pragma once
7#include <algorithm>
8#include <cmath>
9#include <stdexcept>
10#include <vector>
11
12#include "HarmonicReference.h"
13
14namespace gpr::quantum {
20
21// Mass coordinates make the line element Euclidean. The potential is linear
22// on each spatial link; its square root is integrated exactly, including a
23// single zero-momentum endpoint. Both endpoint potentials use one energy
24// origin.
25inline JacobiSegment jacobiSegment(const Eigen::VectorXd& left,
26 const Eigen::VectorXd& right,
27 const PotentialEvaluation& vl,
28 const PotentialEvaluation& vr, double energy)
29{
30 const auto d = left.size();
31 if (d < 1 || right.size() != d || vl.gradient.size() != d ||
32 vr.gradient.size() != d || !left.allFinite() || !right.allFinite() ||
33 !vl.gradient.allFinite() || !vr.gradient.allFinite() ||
34 !std::isfinite(vl.energy) || !std::isfinite(vr.energy) ||
35 !std::isfinite(energy))
36 throw std::invalid_argument(
37 "Finite matching mass-coordinate Jacobi endpoints required");
38 const double a = vl.energy - energy, b = vr.energy - energy;
39 if (a < 0 || b < 0 || !std::isfinite(a) || !std::isfinite(b))
40 throw std::invalid_argument(
41 "Jacobi endpoints must lie in the classically forbidden region");
42 const Eigen::VectorXd delta = right - left;
43 const double length = delta.norm(), p = std::sqrt(a), q = std::sqrt(b),
44 scale = std::max(p, q);
45 if (!(length > 0) || !std::isfinite(length) || !(scale > 0))
46 throw std::invalid_argument(
47 "Nonzero Jacobi link and at least one positive endpoint potential "
48 "required");
49 const double x = p / scale, y = q / scale, sum = x + y,
50 c = std::sqrt(2.) / 3.;
51 const double integral = 2 * c * scale * (x * x + x * y + y * y) / sum;
52 const double da = c * (x + 2 * y) / (scale * sum * sum),
53 db = c * (2 * x + y) / (scale * sum * sum);
55 out.action = length * integral;
56 out.leftPotentialDerivative = length * da;
57 out.rightPotentialDerivative = length * db;
58 out.traversalTime = length * std::sqrt(2.) / (scale * sum);
59 out.leftGradient = -integral * (delta / length) +
60 out.leftPotentialDerivative * vl.gradient;
61 out.rightGradient = integral * (delta / length) +
62 out.rightPotentialDerivative * vr.gradient;
63 if (!std::isfinite(out.action) || !std::isfinite(out.traversalTime) ||
64 !out.leftGradient.allFinite() || !out.rightGradient.allFinite())
65 throw std::runtime_error(
66 "Nonfinite Jacobi action or endpoint derivative");
67 return out;
68}
69
71 double action{}, traversalTime{};
72 std::vector<Eigen::VectorXd> gradient;
73};
75 const std::vector<Eigen::VectorXd>& points,
76 const std::vector<PotentialEvaluation>& native, double energy)
77{
78 if (points.size() < 2 || native.size() != points.size())
79 throw std::invalid_argument(
80 "Matching Jacobi path nodes and native values required");
82 out.gradient.assign(points.size(),
83 Eigen::VectorXd::Zero(points.front().size()));
84 for (std::size_t j = 0; j + 1 < points.size(); ++j) {
85 const auto link = jacobiSegment(points[j], points[j + 1], native[j],
86 native[j + 1], energy);
87 out.action += link.action;
88 out.traversalTime += link.traversalTime;
89 out.gradient[j] += link.leftGradient;
90 out.gradient[j + 1] += link.rightGradient;
91 }
92 return out;
93}
94} // namespace gpr::quantum
@ x
Definition Enums.h:28
@ y
Definition Enums.h:28
eon_relax_band_t eon_relax_surface_fn void eon_relax_outcome_t * out
Models for quantum-path (instanton) searches: arc and tail actions, amplitude continuation.
JacobiPathEvaluation evaluateJacobiPath(const std::vector< Eigen::VectorXd > &points, const std::vector< PotentialEvaluation > &native, double energy)
JacobiSegment jacobiSegment(const Eigen::VectorXd &left, const Eigen::VectorXd &right, const PotentialEvaluation &vl, const PotentialEvaluation &vr, double energy)
std::vector< Eigen::VectorXd > gradient
Eigen::VectorXd leftGradient
Eigen::VectorXd rightGradient