76{
77 const auto N =
static_cast<Eigen::Index
>(ring.
beads.size());
78 if (N < 4 || !(ring.
betaN > 0) || !std::isfinite(ring.
betaN) ||
79 !traceGradient)
80 throw std::invalid_argument(
81 "At least four beads, positive beta_N and a curvature derivative "
82 "required");
83 const Eigen::Index d = ring.
beads.front().size();
85 if (d == 0 || ring.
hessian.rows() != N * d ||
87 (hasReactant &&
92 throw std::invalid_argument(
93 "Ring, reactant and Hessian dimensions must match");
101 1e-10)))
102 throw std::invalid_argument(
103 "Excluded ring modes must be orthonormal columns");
107 throw std::invalid_argument(
108 "A finite log-factor gradient over all bead coordinates is "
109 "required");
110 for (
const auto& q: ring.
beads)
111 if (q.size() != d || !q.allFinite())
112 throw std::invalid_argument(
113 "Finite beads of one dimension required");
116 throw std::invalid_argument("Finite ring data required");
117 const double scale = std::max(1., ring.
hessian.cwiseAbs().maxCoeff());
118 if ((ring.
hessian - ring.
hessian.transpose()).cwiseAbs().maxCoeff() >
119 1e-10 * scale)
120 throw std::invalid_argument("Symmetric ring Hessian required");
121
123
124 Matrix Q = Matrix::Identity(N * d, N * d);
127 const Matrix full = qr.householderQ();
129 }
130 const Eigen::Index m = Q.cols();
132 Q.transpose() * (.5 * (ring.
hessian + ring.
hessian.transpose())) * Q;
133 Eigen::SelfAdjointEigenSolver<Matrix> spectrum(reduced);
134 if (spectrum.info() != Eigen::Success)
135 throw std::runtime_error("Ring Hessian spectrum failed");
136 const Vector& lambda = spectrum.eigenvalues();
137 const Matrix U = Q * spectrum.eigenvectors();
138
139
141 for (Eigen::Index j = 0; j < N; ++j)
142 tangent.segment(j * d, d) =
143 ring.
beads[(j + 1) % N] - ring.
beads[(j + N - 1) % N];
144 if (!(tangent.norm() > 0))
145 throw std::domain_error("A nonconstant orbit is required");
147 tangent -=
149 if (!(tangent.norm() > 0))
150 throw std::domain_error("The orbit tangent lies in the excluded modes");
151 tangent.normalize();
152 for (Eigen::Index k = 0; k < m; ++k) {
153 const double overlap = std::abs(U.col(k).dot(tangent));
157 }
158 }
160 throw std::domain_error("No ring mode follows the orbit tangent");
163
164
165 const Eigen::Index unstable = result.
phaseMode == 0 ? 1 : 0;
166 if (!(lambda(unstable) < 0))
167 throw std::domain_error("A ring Hessian of index one is required");
169 const double spectralScale = lambda.cwiseAbs().maxCoeff();
170 for (Eigen::Index k = unstable + 1; k < m; ++k) {
172 if (lambda(k) < 0)
173 throw std::domain_error("A ring Hessian of index one is required");
174 if (!(lambda(k) > 1e-10 * spectralScale))
175 throw std::domain_error(
176 "An unresolved zero mode must be supplied as an excluded mode");
177 }
178
180 for (Eigen::Index k = 0; k < m; ++k)
183 U.col(k) * U.col(k).transpose() / lambda(k);
184
185
186 Vector dqCoefficient = Vector::Zero(N * d);
187 for (Eigen::Index j = 0; j < N; ++j) {
189 const double length = link.norm();
190 if (!(length > 0)) throw std::domain_error("Coincident adjacent beads");
192 }
193 for (Eigen::Index j = 0; j < N; ++j) {
196 dqCoefficient.segment(j * d, d) +=
197 (previous / previous.norm() - link / link.norm()) /
200 dqCoefficient.segment(j * d, d) -=
201 .5 * traceGradient(ring.
beads[j], block);
202 }
203
206
207
208 Matrix reactantBlock = Matrix::Zero(d, d);
209 Vector reactantGradient = Vector::Zero(d);
210 if (hasReactant) {
213 if (reactantRing.info() != Eigen::Success ||
214 reactantPoint.info() != Eigen::Success)
215 throw std::domain_error(
216 "A positive reactant curvature is required");
217 const Matrix reactantInverse =
218 reactantRing.solve(Matrix::Identity(N * d, N * d));
219 for (Eigen::Index j = 0; j < N; ++j)
220 reactantBlock += reactantInverse.block(j * d, j * d, d, d);
221 reactantGradient = -.5 * reactantPoint.solve(traceGradient(
223 }
224
225 const Eigen::Index sites = hasReactant ? N + 1 : N;
226 result.
channels = Vector::Zero(sites * (d + 1));
228 if (hasReactant) result.
channels(N) = ring.
betaN *
static_cast<double>(N);
230 for (Eigen::Index k = 0; k < d; ++k) {
231 for (Eigen::Index j = 0; j < N; ++j)
233 if (hasReactant)
235 }
237 for (Eigen::Index j = 0; j < N; ++j)
240 if (hasReactant) result.
curvature.push_back(.5 * reactantBlock);
241 return result;
242}
Eigen::Index siteChannel(Eigen::Index sites, Eigen::Index site, Eigen::Index component)
std::vector< Vector > beads
double phaseTangentOverlap
double negativeEigenvalue