GPRidge v1.0.0
GPR-accelerated saddle point searches on potential energy surfaces
☾
Toggle main menu visibility
Loading...
Searching...
No Matches
IRCDriver.h
Go to the documentation of this file.
1
// SPDX-License-Identifier: MIT
2
// Copyright (c) gpridge developers
3
// See LICENSE for details.
4
5
/*
6
* IRCDriver.h -- mass-weighted Intrinsic Reaction Coordinate driver.
7
*
8
* The step is rgsaddle's IRC session: rgsaddle_irc_create, rgsaddle_irc_step,
9
* rgsaddle_irc_set_direction and rgsaddle_irc_set_lengths, through
10
* gpr::neb::RgsaddleClient. Both IRCMethod values select
11
* RGSADDLE_IRC_MOROKUMA. MorokumaExtended sets RGSADDLE_IRC_ADAPTIVE so the
12
* library grows or halves the corrector length. The kick length is
13
* initial_displacement and is not the corrector length. A library without
14
* rgsaddle_irc_set_lengths throws. There is no local stepper.
15
*
16
* The saddle Hessian is read only to choose the imaginary mode passed as
17
* rgsaddle's launch direction. hessian_sketch_rank > 0 ignores that matrix
18
* and launches with rgsaddle_irc_create_from_surface (Lanczos on the
19
* gradient). The path sample stored for each step is that step's first
20
* surface evaluation. The kick sample is the geometry after the launch
21
* displacement; a small force there is still the saddle neighborhood,
22
* and the branch does not stop on it. A later step that is already
23
* inside conv_tol comes back from the library without moving, and that
24
* sample ends the branch. When the library then accepts a different
25
* geometry whose mass-weighted force is inside conv_tol, that geometry
26
* is stored too and the branch stops. A converged library status does
27
* not by itself end the branch.
28
*
29
* Coordinates: the library mass-weights Cartesian positions. Returned
30
* geometries are plain Cartesians.
31
*
32
* References:
33
* - Ishida-Morokuma-Komornicki 1977 -- predictor-corrector IRC
34
* - Page-McIver 1988 -- reaction-path Hamiltonian, MW coordinates
35
*/
36
37
#ifndef GPR_IRC_IRCDRIVER_H_
38
#define GPR_IRC_IRCDRIVER_H_
39
40
#include <Eigen/Dense>
41
#include <cstdint>
42
#include <functional>
43
#include <vector>
44
45
namespace
gpr
{
46
namespace
irc
{
47
48
enum class
IRCMethod
{
49
Morokuma
,
// rgsaddle Morokuma, fixed corrector length step_size
50
MorokumaExtended
,
// same step; rgsaddle adapts the length
51
};
52
53
enum class
IRCDirection
{
54
Forward
,
55
Reverse
,
56
Both
,
57
};
58
59
struct
IRCOptions
{
60
IRCMethod
method
=
IRCMethod::MorokumaExtended
;
61
IRCDirection
direction
=
IRCDirection::Both
;
62
// Mass-weighted Morokuma corrector length (sqrt(amu) * A).
63
double
step_size
= 0.1;
64
// Bounds for MorokumaExtended. The library clamps the next length here.
65
double
max_step
= 0.3;
66
double
min_step
= 0.01;
67
// Stop when ||M^{-1/2} g||_2 falls to this value. The same number is
68
// rgsaddle's RGSADDLE_FORCE_MW_L2 tolerance.
69
double
conv_tol
= 0.01;
70
// Hard cap on IRC steps per direction.
71
int
max_steps
= 200;
72
// Mass-weighted kick length. Independent of step_size.
73
double
initial_displacement
= 0.1;
74
// 1-indexed imaginary mode of the supplied Hessian. The Lanczos launch
75
// (hessian_sketch_rank > 0) has only the lowest mode.
76
int
mode_to_follow
= 1;
77
// Above 0, launch from rgsaddle_irc_create_from_surface instead of the
78
// supplied Hessian. The seed is a splitmix64 Box-Muller draw from
79
// sketch_seed (0 maps to 1), mass-weighted like the surface, then
80
// projected off rigid translations. A non-periodic system of three or
81
// more atoms also drops rotations. hv_eps is the library's Lanczos
82
// finite-difference step. The rank is not a mode index. A returned
83
// mode whose curvature is not negative is rejected.
84
int
hessian_sketch_rank
= 0;
85
double
hv_eps
= 1e-3;
86
uint64_t
sketch_seed
= 1;
87
// Energy and gradient of the saddle sample. Later samples always store
88
// the values rgsaddle asked the surface for.
89
bool
record_energy
=
true
;
90
};
91
92
struct
IRCStep
{
93
Eigen::VectorXd
positions
;
// plain Cartesians, length 3N
94
Eigen::VectorXd
gradient
;
// plain Cartesians, length 3N
95
double
energy
= 0.0;
96
double
g_norm
= 0.0;
// |g_mw|, mass-weighted
97
double
cumulative_arc
= 0.0;
// arc length in mass-weighted coords
98
};
99
100
struct
IRCBranch
{
101
std::vector<IRCStep>
path
;
// includes the saddle as path[0]
102
bool
converged
=
false
;
103
int
gradient_evals
= 0;
104
double
final_energy
= 0.0;
105
};
106
107
struct
IRCResult
{
108
IRCBranch
forward
;
109
IRCBranch
reverse
;
110
};
111
112
// Gradient functor: (positions) -> (energy, gradient).
113
// Both vectors are length 3N in plain Cartesian.
114
using
GradientFn
=
115
std::function<std::pair<double, Eigen::VectorXd>(
const
Eigen::VectorXd&)>;
116
117
class
IRCDriver
{
118
public
:
119
IRCDriver
(
GradientFn
gradient_fn,
120
Eigen::VectorXd masses,
// length N (amu)
121
IRCOptions
options = {});
122
123
// Trace the IRC from the saddle. The Hessian is plain Cartesians,
124
// eV/A^2, size 3N x 3N. It is used only when hessian_sketch_rank is 0.
125
IRCResult
run
(
const
Eigen::VectorXd& saddle_positions,
126
const
Eigen::MatrixXd& saddle_hessian);
127
128
private
:
129
GradientFn
gradient_fn_;
130
Eigen::VectorXd masses_;
// length N
131
Eigen::VectorXd sqrt_masses_;
// length 3N (repeated)
132
IRCOptions
options_;
133
};
134
135
}
// namespace irc
136
}
// namespace gpr
137
138
#endif
// GPR_IRC_IRCDRIVER_H_
gpr::irc::IRCDriver::IRCDriver
IRCDriver(GradientFn gradient_fn, Eigen::VectorXd masses, IRCOptions options={})
Definition
IRCDriver.cpp:281
gpr::irc::IRCDriver::run
IRCResult run(const Eigen::VectorXd &saddle_positions, const Eigen::MatrixXd &saddle_hessian)
Definition
IRCDriver.cpp:304
gpr::irc
Intrinsic reaction coordinate drivers in mass-weighted coordinates.
Definition
IRCDriver.cpp:20
gpr::irc::GradientFn
std::function< std::pair< double, Eigen::VectorXd >(const Eigen::VectorXd &)> GradientFn
Definition
IRCDriver.h:114
gpr::irc::IRCMethod
IRCMethod
Definition
IRCDriver.h:48
gpr::irc::IRCMethod::Morokuma
@ Morokuma
Definition
IRCDriver.h:49
gpr::irc::IRCMethod::MorokumaExtended
@ MorokumaExtended
Definition
IRCDriver.h:50
gpr::irc::IRCDirection
IRCDirection
Definition
IRCDriver.h:53
gpr::irc::IRCDirection::Both
@ Both
Definition
IRCDriver.h:56
gpr::irc::IRCDirection::Forward
@ Forward
Definition
IRCDriver.h:54
gpr::irc::IRCDirection::Reverse
@ Reverse
Definition
IRCDriver.h:55
gpr
Gaussian-process regression, kernels, priors, and the searches that run on the surrogate.
Definition
Macros.h:16
gpr::irc::IRCBranch
Definition
IRCDriver.h:100
gpr::irc::IRCBranch::final_energy
double final_energy
Definition
IRCDriver.h:104
gpr::irc::IRCBranch::path
std::vector< IRCStep > path
Definition
IRCDriver.h:101
gpr::irc::IRCBranch::converged
bool converged
Definition
IRCDriver.h:102
gpr::irc::IRCBranch::gradient_evals
int gradient_evals
Definition
IRCDriver.h:103
gpr::irc::IRCOptions
Definition
IRCDriver.h:59
gpr::irc::IRCOptions::conv_tol
double conv_tol
Definition
IRCDriver.h:69
gpr::irc::IRCOptions::direction
IRCDirection direction
Definition
IRCDriver.h:61
gpr::irc::IRCOptions::record_energy
bool record_energy
Definition
IRCDriver.h:89
gpr::irc::IRCOptions::method
IRCMethod method
Definition
IRCDriver.h:60
gpr::irc::IRCOptions::initial_displacement
double initial_displacement
Definition
IRCDriver.h:73
gpr::irc::IRCOptions::hv_eps
double hv_eps
Definition
IRCDriver.h:85
gpr::irc::IRCOptions::mode_to_follow
int mode_to_follow
Definition
IRCDriver.h:76
gpr::irc::IRCOptions::max_step
double max_step
Definition
IRCDriver.h:65
gpr::irc::IRCOptions::max_steps
int max_steps
Definition
IRCDriver.h:71
gpr::irc::IRCOptions::hessian_sketch_rank
int hessian_sketch_rank
Definition
IRCDriver.h:84
gpr::irc::IRCOptions::step_size
double step_size
Definition
IRCDriver.h:63
gpr::irc::IRCOptions::sketch_seed
uint64_t sketch_seed
Definition
IRCDriver.h:86
gpr::irc::IRCOptions::min_step
double min_step
Definition
IRCDriver.h:66
gpr::irc::IRCResult
Definition
IRCDriver.h:107
gpr::irc::IRCResult::forward
IRCBranch forward
Definition
IRCDriver.h:108
gpr::irc::IRCResult::reverse
IRCBranch reverse
Definition
IRCDriver.h:109
gpr::irc::IRCStep
Definition
IRCDriver.h:92
gpr::irc::IRCStep::energy
double energy
Definition
IRCDriver.h:95
gpr::irc::IRCStep::g_norm
double g_norm
Definition
IRCDriver.h:96
gpr::irc::IRCStep::gradient
Eigen::VectorXd gradient
Definition
IRCDriver.h:94
gpr::irc::IRCStep::positions
Eigen::VectorXd positions
Definition
IRCDriver.h:93
gpr::irc::IRCStep::cumulative_arc
double cumulative_arc
Definition
IRCDriver.h:97
gpr
irc
IRCDriver.h
Generated by
1.17.0
Generated by
Doxygen 1.17.0
Analytics by
Antics
provided by
TurtleTech ehf