GPRidge v1.0.0
GPR-accelerated saddle point searches on potential energy surfaces
☾
Toggle main menu visibility
Loading...
Searching...
No Matches
MidpointTaylorAction.cpp
Go to the documentation of this file.
1
// SPDX-License-Identifier: MIT
2
#include "
MidpointTaylorAction.h
"
3
4
#include <Eigen/Eigenvalues>
5
#include <cmath>
6
#include <stdexcept>
7
8
namespace
gpr::quantum::gaussian
{
9
double
midpointTaylorAction
(
const
Matrix
&hessian,
const
Vector
&gradient,
10
const
Vector
&displacement,
double
potential,
11
double
duration)
12
{
13
// The segment validation includes symmetry, finite inputs and caustics.
14
exactSegment
(hessian, duration);
15
if
(gradient.size() != hessian.rows() ||
16
displacement.size() != hessian.rows() || !gradient.allFinite() ||
17
!displacement.allFinite() || !std::isfinite(potential))
18
throw
std::invalid_argument(
"Invalid midpoint Taylor action data"
);
19
Eigen::SelfAdjointEigenSolver<Matrix> eig(.5 * hessian +
20
.5 * hessian.transpose());
21
if
(eig.info() != Eigen::Success)
22
throw
std::runtime_error(
"Midpoint action eigendecomposition failed"
);
23
const
Vector
g = eig.eigenvectors().transpose() * gradient;
24
const
Vector
d = eig.eigenvectors().transpose() * displacement;
25
long
double
action = duration * potential;
26
for
(Eigen::Index i = 0; i < g.size(); ++i) {
27
const
double
lambda = eig.eigenvalues()[i];
28
const
double
x
= duration * std::sqrt(std::abs(lambda));
29
double
kinetic, affine;
30
if
(
x
< 1e-2) {
31
const
double
z
= std::copysign(
x
*
x
, lambda);
32
kinetic =
33
(1 +
z
/ 12 -
z
*
z
/ 720 +
z
*
z
*
z
/ 30240) / (2 * duration);
34
affine = duration * duration * duration *
35
(-1. / 24 +
z
/ 240 - 17 *
z
*
z
/ 40320 +
36
31 *
z
*
z
*
z
/ 725760);
37
}
else
{
38
const
double
t = lambda > 0 ? std::tanh(
x
/ 2) : std::tan(
x
/ 2);
39
kinetic = std::sqrt(std::abs(lambda)) / (4 * t);
40
affine = duration * (2 * t /
x
- 1) / (2 * lambda);
41
}
42
action +=
static_cast<
long
double
>
(kinetic) * d[i] * d[i] +
43
static_cast<
long
double
>
(affine) * g[i] * g[i];
44
}
45
const
double
result =
static_cast<
double
>
(action);
46
if
(!std::isfinite(result))
47
throw
std::overflow_error(
"Nonfinite midpoint Taylor action"
);
48
return
result;
49
}
50
}
// namespace gpr::quantum::gaussian
z
@ z
Definition
Enums.h:28
x
@ x
Definition
Enums.h:28
MidpointTaylorAction.h
gpr::quantum::gaussian
Definition
GaussianSegments.cpp:11
gpr::quantum::gaussian::Matrix
Eigen::MatrixXd Matrix
Definition
GaussianSegments.h:14
gpr::quantum::gaussian::Vector
Eigen::VectorXd Vector
Definition
GaussianSegments.h:15
gpr::quantum::gaussian::exactSegment
Segment exactSegment(const Matrix &hessian, double duration)
Definition
GaussianSegments.cpp:34
gpr::quantum::gaussian::midpointTaylorAction
double midpointTaylorAction(const Matrix &hessian, const Vector &gradient, const Vector &displacement, double potential, double duration)
Definition
MidpointTaylorAction.cpp:9
gpr
quantum
MidpointTaylorAction.cpp
Generated by
1.17.0
Generated by
Doxygen 1.17.0
Analytics by
Antics
provided by
TurtleTech ehf