GPRidge v1.0.0
GPR-accelerated saddle point searches on potential energy surfaces
☾
Toggle main menu visibility
Loading...
Searching...
No Matches
RgMinMode.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
#ifndef GPR_NEB_RG_MIN_MODE_H_
6
#define GPR_NEB_RG_MIN_MODE_H_
7
8
#include <cstdint>
9
10
#include "
RgsaddleClient.h
"
11
12
namespace
gpr
{
13
namespace
neb
{
14
17
class
RgMinMode
{
18
public
:
19
enum class
Kind
{
Dimer
= 0,
Lanczos
= 1 };
20
23
static
constexpr
Kind
kOciBurstKind
=
Kind::Dimer
;
24
26
static
Kind
indexTestKind
(
const
char
* name)
27
{
28
if
(name !=
nullptr
&& name[0] ==
'd'
&& name[1] ==
'i'
&&
29
name[2] ==
'm'
&& name[3] ==
'e'
&& name[4] ==
'r'
&&
30
name[5] ==
'\0'
) {
31
return
Kind::Dimer
;
32
}
33
return
Kind::Lanczos
;
34
}
35
36
RgMinMode
() =
default
;
37
~RgMinMode
()
38
{
39
release();
40
}
41
RgMinMode
(
const
RgMinMode
&) =
delete
;
42
RgMinMode
&
operator=
(
const
RgMinMode
&) =
delete
;
43
44
bool
bind
(
RgsaddleClient
& client, int64_t n_atoms,
const
double
*
position
,
45
const
double
* mode,
double
force_tol,
Kind
kind =
Kind::Dimer
,
46
int32_t force_gate = 2, int32_t max_rotations = 16,
47
double
rotation_tol = 1e-3)
48
{
49
if
(!client.
hasMinMode
() || n_atoms < 1 ||
position
==
nullptr
||
50
mode ==
nullptr
) {
51
return
false
;
52
}
53
release();
54
if
(force_gate < RGSADDLE_FORCE_L2 ||
55
force_gate > RGSADDLE_FORCE_MAX_ATOM) {
56
return
false
;
57
}
58
rgsaddle_minmode_config_t cfg{};
59
cfg.version.major = RGSADDLE_ABI_MAJOR;
60
cfg.version.minor = 0;
61
cfg.kind = kind ==
Kind::Lanczos
? 1 : 0;
62
cfg.method = 0;
63
cfg.dr = 0.01;
64
cfg.rotation_tol = rotation_tol;
65
cfg.max_rotations = max_rotations;
66
cfg.krylov_dim = 8;
67
cfg.force_tol = force_tol > 0.0 ? force_tol : 1e-3;
68
cfg.max_move = 0.1;
69
sess_ = client.
minModeCreate
(&cfg, n_atoms,
position
, mode);
70
if
(sess_ ==
nullptr
)
return
false
;
71
if
(client.
minModeSetForceGate
(
72
sess_,
static_cast<
rgsaddle_force_gate_t
>
(force_gate)) !=
73
RGSADDLE_OK) {
74
client.
minModeFree
(sess_);
75
sess_ =
nullptr
;
76
return
false
;
77
}
78
client_ = &client;
79
n_atoms_ = n_atoms;
80
return
true
;
81
}
82
83
bool
step
(rgsaddle_surface_fn
surface
,
void
*
user
,
84
rgsaddle_report_t& report)
85
{
86
if
(client_ ==
nullptr
|| sess_ ==
nullptr
||
surface
==
nullptr
)
87
return
false
;
88
return
client_->minModeStep(sess_,
surface
,
user
, &report) == 0;
89
}
90
91
bool
position
(
double
*
out
)
92
{
93
if
(client_ ==
nullptr
|| sess_ ==
nullptr
||
out
==
nullptr
)
94
return
false
;
95
return
client_->minModePosition(sess_,
out
) == 0;
96
}
97
98
[[nodiscard]] int64_t
nAtoms
() const noexcept
99
{
100
return
n_atoms_;
101
}
102
103
private
:
104
void
release()
105
{
106
if
(client_ !=
nullptr
&& sess_ !=
nullptr
) client_->
minModeFree
(sess_);
107
sess_ =
nullptr
;
108
client_ =
nullptr
;
109
}
110
111
RgsaddleClient* client_ =
nullptr
;
112
RgsaddleClient::MinMode
sess_ =
nullptr
;
113
int64_t n_atoms_ = 0;
114
};
115
116
}
// namespace neb
117
}
// namespace gpr
118
119
#endif
RgsaddleClient.h
gpr::neb::RgMinMode::step
bool step(rgsaddle_surface_fn surface, void *user, rgsaddle_report_t &report)
Definition
RgMinMode.h:83
gpr::neb::RgMinMode::indexTestKind
static Kind indexTestKind(const char *name)
gprn --index-test token. Unrecognised names are Lanczos.
Definition
RgMinMode.h:26
gpr::neb::RgMinMode::operator=
RgMinMode & operator=(const RgMinMode &)=delete
gpr::neb::RgMinMode::Kind
Kind
Definition
RgMinMode.h:19
gpr::neb::RgMinMode::Kind::Lanczos
@ Lanczos
Definition
RgMinMode.h:19
gpr::neb::RgMinMode::Kind::Dimer
@ Dimer
Definition
RgMinMode.h:19
gpr::neb::RgMinMode::bind
bool bind(RgsaddleClient &client, int64_t n_atoms, const double *position, const double *mode, double force_tol, Kind kind=Kind::Dimer, int32_t force_gate=2, int32_t max_rotations=16, double rotation_tol=1e-3)
Definition
RgMinMode.h:44
gpr::neb::RgMinMode::RgMinMode
RgMinMode(const RgMinMode &)=delete
gpr::neb::RgMinMode::RgMinMode
RgMinMode()=default
gpr::neb::RgMinMode::nAtoms
int64_t nAtoms() const noexcept
Definition
RgMinMode.h:98
gpr::neb::RgMinMode::~RgMinMode
~RgMinMode()
Definition
RgMinMode.h:37
gpr::neb::RgMinMode::kOciBurstKind
static constexpr Kind kOciBurstKind
Definition
RgMinMode.h:23
gpr::neb::RgMinMode::position
bool position(double *out)
Definition
RgMinMode.h:91
gpr::neb::RgsaddleClient
Definition
RgsaddleClient.h:24
gpr::neb::RgsaddleClient::MinMode
RgsaddleMinMode * MinMode
Definition
RgsaddleClient.h:41
gpr::neb::RgsaddleClient::hasMinMode
bool hasMinMode() const noexcept
Definition
RgsaddleClient.h:101
gpr::neb::RgsaddleClient::minModeSetForceGate
int minModeSetForceGate(MinMode sess, rgsaddle_force_gate_t gate)
Definition
RgsaddleClient.cpp:247
gpr::neb::RgsaddleClient::minModeCreate
MinMode minModeCreate(const rgsaddle_minmode_config_t *cfg, int64_t n_atoms, const double *position, const double *mode)
Definition
RgsaddleClient.cpp:226
gpr::neb::RgsaddleClient::minModeFree
void minModeFree(MinMode sess)
Definition
RgsaddleClient.cpp:254
out
eon_relax_band_t eon_relax_surface_fn void eon_relax_outcome_t * out
Definition
eon_relax_engine.h:240
surface
eon_relax_band_t eon_relax_surface_fn surface
Definition
eon_relax_engine.h:239
user
eon_relax_band_t eon_relax_surface_fn void * user
Definition
eon_relax_engine.h:239
gpr::neb
The nudged elastic band: path, GP-NEB driver, configuration and result, acquisition,...
Definition
ChainRealign.h:29
gpr
Gaussian-process regression, kernels, priors, and the searches that run on the surrogate.
Definition
Macros.h:16
gpr
neb
RgMinMode.h
Generated by
1.17.0
Generated by
Doxygen 1.17.0
Analytics by
Antics
provided by
TurtleTech ehf