24 const std::vector<Eigen::VectorXd>& path,
25 const std::vector<PotentialEvaluation>& native,
double energy,
26 Eigen::VectorXd* turningPoint =
nullptr)
28 if (path.size() < 3 || native.size() != path.size())
29 throw std::invalid_argument(
30 "Matching spatial arc nodes and energies required");
31 const auto last = path.size() - 1;
32 const double slope = native[last - 1].energy - native[last].energy;
33 if (!(slope > 0) || !(native[last - 1].energy > energy) ||
34 !std::isfinite(slope))
35 throw std::domain_error(
36 "A descending native outer turning chord is required");
39 const double fraction = (native[last - 1].energy - energy) / slope;
40 q.back() = path[last - 1] + fraction * (path[last] - path[last - 1]);
41 v.back().energy = energy;
42 if (turningPoint) *turningPoint = q.back();
52 const Eigen::MatrixXd& well,
const std::vector<Eigen::VectorXd>& path,
53 const std::vector<PotentialEvaluation>& native,
double thermalPeriod,
56 if (path.size() < 3 || native.size() != path.size() ||
57 !(thermalPeriod > 0) || !std::isfinite(thermalPeriod) || !(hbar > 0) ||
59 throw std::invalid_argument(
60 "Finite positive thermal scales and a matching spatial arc "
63 const auto& cut = path.front();
64 if (cut.size() != well.rows() || !cut.allFinite())
65 throw std::invalid_argument(
"Harmonic cut and spatial metric differ");
66 const double cutEnergy = .5 * cut.dot(well * cut);
67 double bound = cutEnergy;
68 for (std::size_t j = 0; j + 1 < native.size(); ++j) {
69 if (!(native[j].energy > 0) || !std::isfinite(native[j].energy))
70 throw std::domain_error(
71 "The measured spatial arc must enter the forbidden region");
72 bound = std::min(bound, native[j].energy);
74 if (!(bound > 0) || !std::isfinite(bound))
75 throw std::domain_error(
76 "A positive harmonic matching energy is required");
78 cut, std::log(bound) - std::log(2.), hbar);
79 const double maximumTime = .5 * thermalPeriod;
80 if (!(minimumTime < maximumTime))
81 throw std::domain_error(
82 "Thermal period is too short for this harmonic-cut branch");
83 auto evaluate = [&](
double t) {
84 const auto harmonic = tail.
evaluate(cut, t, hbar);
85 Eigen::VectorXd turning;
89 out.energy = harmonic.energy;
90 out.logEnergy = harmonic.logEnergy;
91 out.tailHalfDuration = t;
92 out.oneWayArcTime = arc.traversalTime;
93 out.period = 2 * (t + arc.traversalTime);
94 out.periodResidual =
out.period - thermalPeriod;
95 out.abbreviatedAction = 2 * arc.action + harmonic.abbreviatedAction;
97 out.abbreviatedAction + thermalPeriod * harmonic.energy;
98 out.outerContourEnergyError =
99 std::abs(native.back().energy - harmonic.energy);
100 out.matchingEnergyError = std::abs(native.front().energy - cutEnergy);
101 out.tailMomentum = harmonic.momentum;
102 out.outerTurningPoint = turning;
103 const Eigen::VectorXd tangent = (path[1] - path.front()).normalized();
104 out.cutMomentumResidual =
106 std::sqrt(2 * (native.front().energy - harmonic.energy)) * tangent)
108 out.outerTurningDisplacement = (turning - path.back()).norm();
111 double right = maximumTime, left = minimumTime;
112 (void)evaluate(right);
113 bool bracketed =
false;
114 for (
unsigned j = 1; j <= 128; ++j) {
115 const double candidate =
116 maximumTime - (maximumTime - minimumTime) * (
double(j) / 128.);
117 const auto lower = evaluate(candidate);
118 if (lower.periodResidual <= 0) {
126 throw std::domain_error(
127 "No tail-dominated thermal period bracket on this spatial arc");
128 for (
unsigned iteration = 0; iteration < 100; ++iteration) {
129 const double t = .5 * (left + right);
130 auto state = evaluate(t);
131 if (std::abs(state.periodResidual) <= 2e-13 * thermalPeriod)
133 if (state.periodResidual > 0)
138 throw std::runtime_error(
139 "Thermal spatial period matching does not converge");
ThermalJacobiPeriod matchThermalJacobiPeriod(const Eigen::MatrixXd &well, const std::vector< Eigen::VectorXd > &path, const std::vector< PotentialEvaluation > &native, double thermalPeriod, double hbar)