Loading...
Searching...
No Matches
gpr::quantum::ringspread Namespace Reference

Classes

struct  Spread

Typedefs

using Matrix = Eigen::MatrixXd
using Vector = Eigen::VectorXd

Functions

void checkRing (const std::vector< Vector > &q, const Vector &roots)
Matrix beadAveragedWidth (const Matrix &covariance, Eigen::Index N, const Vector &roots)
Spread orbitSpread (const std::vector< Vector > &q, const Vector &roots)
Matrix thermalCovariance (const std::vector< Vector > &q, const Matrix &H, double betaN, const Matrix &excludedModes={})
Spread instantonSpread (const std::vector< Vector > &q, const Vector &roots, const Matrix &H, double betaN, const Matrix &excludedModes={})
void addModelSpread (Spread &s, const Matrix &pseudoInverse, const Matrix &gradientCovariance, const Vector &roots)

Typedef Documentation

◆ Matrix

using gpr::quantum::ringspread::Matrix = Eigen::MatrixXd

Definition at line 26 of file RingCentroidSpread.h.

◆ Vector

using gpr::quantum::ringspread::Vector = Eigen::VectorXd

Definition at line 27 of file RingCentroidSpread.h.

Function Documentation

◆ addModelSpread()

void gpr::quantum::ringspread::addModelSpread ( Spread & s,
const Matrix & pseudoInverse,
const Matrix & gradientCovariance,
const Vector & roots )
inline

Definition at line 156 of file RingCentroidSpread.h.

159{
160 const Eigen::Index n = pseudoInverse.rows();
161 if (pseudoInverse.cols() != n || gradientCovariance.rows() != n ||
162 gradientCovariance.cols() != n || n % roots.size() != 0)
163 throw std::invalid_argument(
164 "Matching pseudoinverse and gradient covariance required");
166 pseudoInverse * gradientCovariance * pseudoInverse.transpose(),
167 n / roots.size(), roots);
168}
Matrix beadAveragedWidth(const Matrix &covariance, Eigen::Index N, const Vector &roots)

◆ beadAveragedWidth()

Matrix gpr::quantum::ringspread::beadAveragedWidth ( const Matrix & covariance,
Eigen::Index N,
const Vector & roots )
inline

Definition at line 58 of file RingCentroidSpread.h.

60{
61 const Eigen::Index d = roots.size();
62 Matrix width = Matrix::Zero(d / 3, 3);
63 for (Eigen::Index j = 0; j < N; ++j)
64 for (Eigen::Index k = 0; k < d; ++k) {
65 const double variance = covariance(j * d + k, j * d + k);
66 if (variance <
67 -1e-12 * std::max(1., covariance.cwiseAbs().maxCoeff()))
68 throw std::runtime_error("Negative bead variance");
69 width(k / 3, k % 3) +=
70 std::max(0., variance) / (roots(k) * roots(k));
71 }
72 return (width / static_cast<double>(N)).cwiseSqrt();
73}

◆ checkRing()

void gpr::quantum::ringspread::checkRing ( const std::vector< Vector > & q,
const Vector & roots )
inline

Definition at line 45 of file RingCentroidSpread.h.

46{
47 if (q.size() < 2 || roots.size() == 0 || roots.size() % 3 != 0 ||
48 !(roots.array() > 0).all() || !roots.allFinite())
49 throw std::invalid_argument(
50 "Ring beads and positive mass roots for whole atoms required");
51 for (const auto& x: q)
52 if (x.size() != roots.size() || !x.allFinite())
53 throw std::invalid_argument(
54 "Finite beads matching the mass roots required");
55}
@ x
Definition Enums.h:28

◆ instantonSpread()

Spread gpr::quantum::ringspread::instantonSpread ( const std::vector< Vector > & q,
const Vector & roots,
const Matrix & H,
double betaN,
const Matrix & excludedModes = {} )
inline

Definition at line 144 of file RingCentroidSpread.h.

146 {})
147{
148 Spread s = orbitSpread(q, roots);
149 s.thermal = beadAveragedWidth(thermalCovariance(q, H, betaN, excludedModes),
150 static_cast<Eigen::Index>(q.size()), roots);
151 return s;
152}
Matrix thermalCovariance(const std::vector< Vector > &q, const Matrix &H, double betaN, const Matrix &excludedModes={})
Spread orbitSpread(const std::vector< Vector > &q, const Vector &roots)

◆ orbitSpread()

Spread gpr::quantum::ringspread::orbitSpread ( const std::vector< Vector > & q,
const Vector & roots )
inline

Definition at line 75 of file RingCentroidSpread.h.

76{
77 checkRing(q, roots);
78 const auto N = static_cast<double>(q.size());
79 const Eigen::Index d = roots.size();
80 Vector mean = Vector::Zero(d);
81 for (const auto& x: q)
82 mean += x;
83 mean /= N;
84 Vector second = Vector::Zero(d);
85 for (const auto& x: q)
86 second += (x - mean).array().square().matrix();
87 Spread s;
88 s.centroid.resize(d / 3, 3);
89 s.orbit.resize(d / 3, 3);
90 for (Eigen::Index k = 0; k < d; ++k) {
91 s.centroid(k / 3, k % 3) = mean(k) / roots(k);
92 s.orbit(k / 3, k % 3) = std::sqrt(second(k) / N) / roots(k);
93 }
94 return s;
95}
void checkRing(const std::vector< Vector > &q, const Vector &roots)

◆ thermalCovariance()

Matrix gpr::quantum::ringspread::thermalCovariance ( const std::vector< Vector > & q,
const Matrix & H,
double betaN,
const Matrix & excludedModes = {} )
inline

Definition at line 99 of file RingCentroidSpread.h.

100 {})
101{
102 const auto N = static_cast<Eigen::Index>(q.size());
103 const Eigen::Index d = q.front().size();
104 if (H.rows() != N * d || H.cols() != N * d || !H.allFinite() ||
105 !(betaN > 0))
106 throw std::invalid_argument(
107 "A finite ring Hessian and positive beta_N required");
108 Matrix Q = Matrix::Identity(N * d, N * d);
109 if (excludedModes.size() != 0) {
110 Eigen::HouseholderQR<Matrix> qr(excludedModes);
111 const Matrix full = qr.householderQ();
112 Q = full.rightCols(N * d - excludedModes.cols());
113 }
114 Eigen::SelfAdjointEigenSolver<Matrix> s(Q.transpose() *
115 (.5 * (H + H.transpose())) * Q);
116 if (s.info() != Eigen::Success)
117 throw std::runtime_error("Ring spectrum failed");
118 const Matrix U = Q * s.eigenvectors();
119 Vector tangent(N * d);
120 for (Eigen::Index j = 0; j < N; ++j)
121 tangent.segment(j * d, d) = q[(j + 1) % N] - q[(j + N - 1) % N];
122 Eigen::Index phase = -1;
123 if (tangent.norm() > 0) {
124 tangent.normalize();
125 double best = .9;
126 for (Eigen::Index k = 0; k < U.cols(); ++k)
127 if (s.eigenvalues()(k) > 0 &&
128 std::abs(U.col(k).dot(tangent)) > best)
129 best = std::abs(U.col(k).dot(tangent)), phase = k;
130 }
131 const double scale = s.eigenvalues().cwiseAbs().maxCoeff();
132 Matrix covariance = Matrix::Zero(N * d, N * d);
133 for (Eigen::Index k = 0; k < U.cols(); ++k) {
134 if (k == phase || !(s.eigenvalues()(k) > 0)) continue;
135 if (!(s.eigenvalues()(k) > 1e-10 * scale))
136 throw std::domain_error(
137 "An unresolved zero mode must be supplied as an excluded mode");
138 covariance.noalias() +=
139 U.col(k) * U.col(k).transpose() / (betaN * s.eigenvalues()(k));
140 }
141 return covariance;
142}
Eigen::MatrixXd Matrix