Loading...
Searching...
No Matches
MolecularRingRate.h
Go to the documentation of this file.
1// SPDX-License-Identifier: MIT
6#pragma once
7#include <Eigen/Eigenvalues>
8#include <limits>
9#include <numbers>
10
11#include "MolecularGeometry.h"
12namespace gpr::quantum {
20inline double molecularLogInertiaDeterminant(const Eigen::VectorXd& positions,
21 const Eigen::VectorXd& masses,
22 double copies = 1)
23{
24 if (positions.size() != masses.size() || positions.size() % 3 ||
25 !(copies > 0) || !positions.allFinite() || !masses.allFinite() ||
26 !(masses.array() > 0).all())
27 throw std::invalid_argument("Finite molecular inertia inputs required");
28 Eigen::Vector3d center = Eigen::Vector3d::Zero();
29 double total = 0;
30 for (Eigen::Index a = 0; a < positions.size() / 3; ++a) {
31 center += masses[3 * a] * positions.segment<3>(3 * a);
32 total += masses[3 * a];
33 }
34 center /= total;
35 Eigen::Matrix3d inertia = Eigen::Matrix3d::Zero();
36 for (Eigen::Index a = 0; a < positions.size() / 3; ++a) {
37 const Eigen::Vector3d r = positions.segment<3>(3 * a) - center;
38 inertia +=
39 (masses[3 * a] / copies) *
40 (r.squaredNorm() * Eigen::Matrix3d::Identity() - r * r.transpose());
41 }
42 Eigen::SelfAdjointEigenSolver<Eigen::Matrix3d> eig(inertia);
43 if (eig.info() != Eigen::Success || !(eig.eigenvalues().array() > 0).all())
44 throw std::domain_error(
45 "Nonlinear molecular rotational inertia required");
46 return eig.eigenvalues().array().log().sum();
47}
48// Uniform primitive ring-polymer fluctuations in the full Cartesian mass
49// measure. Global translations/rotations and one time-translation eigenmode
50// are removed explicitly; the single physical negative mode uses the magnitude
51// of its eigenvalue.
52// This evaluates a supplied ring, not its stationarity or a continuum limit.
54 const std::vector<Eigen::VectorXd>& positions,
55 const Eigen::VectorXd& masses,
56 const std::vector<Eigen::MatrixXd>& physicalHessians, double beta,
57 double hbar = 1)
58{
59 using V = Eigen::VectorXd;
60 using M = Eigen::MatrixXd;
61 const auto n = positions.size();
62 const Eigen::Index d = masses.size(), nd = n * d;
63 if (n < 4 || n % 2 || physicalHessians.size() != n || d < 9 || d % 3 ||
64 !(beta > 0) || !std::isfinite(beta) || !(hbar > 0) ||
65 !std::isfinite(hbar) || !masses.allFinite() ||
66 !(masses.array() > 0).all())
67 throw std::invalid_argument(
68 "Even molecular ring, physical Hessians and finite positive units "
69 "required");
70 const double betaN = beta / n, spring = 1 / std::pow(betaN * hbar, 2);
71 const V roots = masses.array().sqrt();
72 const V inverse = roots.cwiseInverse();
73 M h = M::Zero(nd, nd);
74 V stacked(nd), stackMass(nd), phase(nd);
75 double bn = 0;
76 for (std::size_t j = 0; j < n; ++j) {
77 if (positions[j].size() != d || !positions[j].allFinite() ||
78 physicalHessians[j].rows() != d ||
79 physicalHessians[j].cols() != d || !physicalHessians[j].allFinite())
80 throw std::invalid_argument(
81 "Matching finite molecular ring nodes required");
82 if ((physicalHessians[j] - physicalHessians[j].transpose()).norm() >
83 1e-8 * std::max(1., physicalHessians[j].norm()))
84 throw std::invalid_argument(
85 "Symmetric physical ring Hessians required");
86 }
87 for (std::size_t j = 0; j < n; ++j) {
88 const auto next = (j + 1) % n, previous = (j + n - 1) % n;
89 h.block(j * d, j * d, d, d) =
90 inverse.asDiagonal() * physicalHessians[j] * inverse.asDiagonal() +
91 2 * spring * M::Identity(d, d);
92 h.block(j * d, next * d, d, d) -= spring * M::Identity(d, d);
93 h.block(next * d, j * d, d, d) -= spring * M::Identity(d, d);
94 stacked.segment(j * d, d) = positions[j];
95 stackMass.segment(j * d, d) = masses;
96 phase.segment(j * d, d) =
97 roots.cwiseProduct(positions[next] - positions[previous]);
98 bn += roots.cwiseProduct(positions[next] - positions[j]).squaredNorm();
99 }
100 const M internal = molecularInternalBasis(stacked, stackMass);
101 const auto rigid = nd - internal.cols();
102 if (rigid != 6 || !(bn > 0) || !std::isfinite(bn))
103 throw std::domain_error(
104 "Noncollapsed nonlinear molecular ring required");
105 V tangent = internal.transpose() * phase;
106 if (!(tangent.norm() > 0))
107 throw std::domain_error("Resolved molecular phase tangent required");
108 tangent.normalize();
109 Eigen::SelfAdjointEigenSolver<M> eig(
110 M(internal.transpose() * h * internal));
111 if (eig.info() != Eigen::Success)
112 throw std::runtime_error(
113 "Molecular ring fluctuation eigensolve failed");
115 result.eigenvalues = eig.eigenvalues();
116 result.rigidModes = rigid;
117 result.linkMassDisplacement = bn;
118 const V overlaps = (eig.eigenvectors().transpose() * tangent).cwiseAbs();
119 Eigen::Index phaseIndex;
120 result.phaseOverlap = overlaps.maxCoeff(&phaseIndex);
121 result.phaseIndex = phaseIndex;
122 result.phaseEigenvalue = eig.eigenvalues()[phaseIndex];
123 if (result.phaseOverlap < .9)
124 throw std::domain_error("No isolated molecular time-translation mode");
125 double closest = std::numeric_limits<double>::infinity(), logPartition = 0;
126 for (Eigen::Index k = 0; k < eig.eigenvalues().size(); ++k)
127 if (k != phaseIndex) {
128 const double value = eig.eigenvalues()[k];
129 if (std::abs(value) < 1e-14)
130 throw std::domain_error(
131 "Unresolved nonphase molecular fluctuation");
132 closest = std::min(closest, std::abs(value));
133 if (value < 0) ++result.negativeModes;
134 logPartition -= std::log(betaN * hbar * std::sqrt(std::abs(value)));
135 }
136 if (result.negativeModes != 1)
137 throw std::domain_error(
138 "Molecular instanton must have exactly one nonphase negative "
139 "direction");
140 result.phaseRelativeCurvature = std::abs(result.phaseEigenvalue) / closest;
142 logPartition + (rigid + 1) * std::log(double(n)) +
143 .5 * std::log(2 * std::numbers::pi * bn * n / (beta * hbar * hbar));
145 molecularLogInertiaDeterminant(stacked, stackMass, double(n));
146 return result;
147}
149 const Eigen::VectorXd& eigenvalues, double beta, double hbar = 1)
150{
151 if (eigenvalues.size() < 2 || !eigenvalues.allFinite() ||
152 (eigenvalues.array() < 0).count() != 1 || !(beta > 0) ||
153 !std::isfinite(beta) || !(hbar > 0) || !std::isfinite(hbar))
154 throw std::invalid_argument(
155 "Index-one molecular TST eigenvalues and finite positive units "
156 "required");
157 double value = 0;
158 for (double curvature: eigenvalues)
159 if (curvature >= 0) {
160 if (!(curvature > 0))
161 throw std::domain_error("Unresolved molecular TST vibration");
162 const double x = .5 * beta * hbar * std::sqrt(curvature);
163 value -= x + std::log(-std::expm1(-2 * x));
164 }
165 return value;
166}
167// Exact finite-N product of the primitive harmonic reactant frequencies.
168// Positive curvatures exclude the global rigid modes of the molecule.
170 const Eigen::VectorXd& curvatures, std::size_t nodes, double beta,
171 double hbar = 1)
172{
173 if (nodes < 4 || curvatures.size() == 0 || !curvatures.allFinite() ||
174 !(curvatures.array() > 0).all() || !(beta > 0) ||
175 !std::isfinite(beta) || !(hbar > 0) || !std::isfinite(hbar))
176 throw std::invalid_argument(
177 "Positive molecular reactant curvature and finite ring units "
178 "required");
179 double value = 0;
180 for (double curvature: curvatures) {
181 const double x = nodes * std::asinh(beta * hbar * std::sqrt(curvature) /
182 (2 * nodes));
183 value -= x + std::log(-std::expm1(-2 * x));
184 }
185 return value;
186}
187// Matched molecular ImF rate in inverse units of beta*hbar. The supplied
188// action uses this reactant's energy zero and the same primitive ring measure.
189// The caller supplies the reaction-channel multiplicity explicitly.
191 const MolecularRingFluctuations& ring,
192 const Eigen::VectorXd& reactantInternalCurvatures,
193 double reactantLogInertiaDeterminant,
194 double actionRelativeToReactantOverHbar, std::size_t nodes, double beta,
195 double hbar = 1, double symmetryFactor = 1)
196{
197 if (nodes < 4 || ring.negativeModes != 1 || ring.rigidModes != 6 ||
198 ring.eigenvalues.size() !=
199 static_cast<Eigen::Index>(
200 nodes * (reactantInternalCurvatures.size() + 6) - 6) ||
201 !std::isfinite(reactantLogInertiaDeterminant) ||
202 !std::isfinite(actionRelativeToReactantOverHbar) ||
203 !(symmetryFactor > 0) || !std::isfinite(symmetryFactor))
204 throw std::invalid_argument(
205 "Matched nonlinear molecular ring, reactant and symmetry "
206 "convention required");
207 const double logReactant = molecularLogHarmonicRingPartition(
208 reactantInternalCurvatures, nodes, beta, hbar);
209 return std::log(symmetryFactor) -
210 std::log(2 * std::numbers::pi * beta * hbar) +
212 reactantLogInertiaDeterminant) +
213 ring.logVibrationalPartition - logReactant -
214 actionRelativeToReactantOverHbar;
215}
216// TST and instanton share the same reaction channel and symmetry convention.
217// The action is relative to this same native saddle, in units of hbar.
219 const MolecularRingFluctuations& ring,
220 const Eigen::VectorXd& saddleInternalEigenvalues,
221 double saddleLogInertiaDeterminant, double actionRelativeToSaddleOverHbar,
222 double beta, double hbar = 1)
223{
224 if (saddleInternalEigenvalues.size() < 2 ||
225 !saddleInternalEigenvalues.allFinite() ||
226 (saddleInternalEigenvalues.array() < 0).count() != 1 ||
227 !std::isfinite(saddleLogInertiaDeterminant) ||
228 !std::isfinite(actionRelativeToSaddleOverHbar) || !(beta > 0) ||
229 !(hbar > 0))
230 throw std::invalid_argument(
231 "Matched index-one molecular TST reference required");
232 const double logTst = molecularLogTstVibrationalPartition(
233 saddleInternalEigenvalues, beta, hbar);
234 return .5 * (ring.logRotationalInertiaDeterminant -
235 saddleLogInertiaDeterminant) +
236 ring.logVibrationalPartition - logTst -
237 actionRelativeToSaddleOverHbar;
238}
239} // namespace gpr::quantum
@ x
Definition Enums.h:28
Models for quantum-path (instanton) searches: arc and tail actions, amplitude continuation.
double molecularLogUnimolecularRate(const MolecularRingFluctuations &ring, const Eigen::VectorXd &reactantInternalCurvatures, double reactantLogInertiaDeterminant, double actionRelativeToReactantOverHbar, std::size_t nodes, double beta, double hbar=1, double symmetryFactor=1)
Matrix molecularInternalBasis(const Vector &x, const Vector &masses)
double molecularLogTstVibrationalPartition(const Eigen::VectorXd &eigenvalues, double beta, double hbar=1)
MolecularRingFluctuations molecularRingFluctuations(const std::vector< Eigen::VectorXd > &positions, const Eigen::VectorXd &masses, const std::vector< Eigen::MatrixXd > &physicalHessians, double beta, double hbar=1)
double molecularLogHarmonicRingPartition(const Eigen::VectorXd &curvatures, std::size_t nodes, double beta, double hbar=1)
double molecularLogInertiaDeterminant(const Eigen::VectorXd &positions, const Eigen::VectorXd &masses, double copies=1)
double molecularLogTunnelingFactor(const MolecularRingFluctuations &ring, const Eigen::VectorXd &saddleInternalEigenvalues, double saddleLogInertiaDeterminant, double actionRelativeToSaddleOverHbar, double beta, double hbar=1)