21 const Eigen::VectorXd& masses,
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();
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];
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;
39 (masses[3 * a] / copies) *
40 (r.squaredNorm() * Eigen::Matrix3d::Identity() - r * r.transpose());
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();
54 const std::vector<Eigen::VectorXd>& positions,
55 const Eigen::VectorXd& masses,
56 const std::vector<Eigen::MatrixXd>& physicalHessians,
double beta,
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 "
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);
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");
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();
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");
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");
118 const V overlaps = (eig.eigenvectors().transpose() * tangent).cwiseAbs();
119 Eigen::Index phaseIndex;
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));
134 logPartition -= std::log(betaN * hbar * std::sqrt(std::abs(value)));
137 throw std::domain_error(
138 "Molecular instanton must have exactly one nonphase negative "
142 logPartition + (rigid + 1) * std::log(
double(n)) +
143 .5 * std::log(2 * std::numbers::pi * bn * n / (beta * hbar * hbar));
192 const Eigen::VectorXd& reactantInternalCurvatures,
193 double reactantLogInertiaDeterminant,
194 double actionRelativeToReactantOverHbar, std::size_t nodes,
double beta,
195 double hbar = 1,
double symmetryFactor = 1)
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");
208 reactantInternalCurvatures, nodes, beta, hbar);
209 return std::log(symmetryFactor) -
210 std::log(2 * std::numbers::pi * beta * hbar) +
212 reactantLogInertiaDeterminant) +
214 actionRelativeToReactantOverHbar;
220 const Eigen::VectorXd& saddleInternalEigenvalues,
221 double saddleLogInertiaDeterminant,
double actionRelativeToSaddleOverHbar,
222 double beta,
double hbar = 1)
224 if (saddleInternalEigenvalues.size() < 2 ||
225 !saddleInternalEigenvalues.allFinite() ||
226 (saddleInternalEigenvalues.array() < 0).count() != 1 ||
227 !std::isfinite(saddleLogInertiaDeterminant) ||
228 !std::isfinite(actionRelativeToSaddleOverHbar) || !(beta > 0) ||
230 throw std::invalid_argument(
231 "Matched index-one molecular TST reference required");
233 saddleInternalEigenvalues, beta, hbar);
235 saddleLogInertiaDeterminant) +
237 actionRelativeToSaddleOverHbar;