GPRidge v1.0.0
GPR-accelerated saddle point searches on potential energy surfaces
☾
Toggle main menu visibility
Loading...
Searching...
No Matches
RgSellaMin.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_SELLA_MIN_H_
6
#define GPR_NEB_RG_SELLA_MIN_H_
7
8
#include <cstdint>
9
#include <vector>
10
11
#include "
RgsaddleClient.h
"
12
13
namespace
gpr
{
14
namespace
neb
{
15
18
class
RgSellaMin
{
19
public
:
20
RgSellaMin
() =
default
;
21
~RgSellaMin
()
22
{
23
release();
24
}
25
RgSellaMin
(
const
RgSellaMin
&) =
delete
;
26
RgSellaMin
&
operator=
(
const
RgSellaMin
&) =
delete
;
27
28
bool
bind
(
RgsaddleClient
& client, int64_t n_atoms,
const
double
*
position
,
29
const
double
* masses,
double
force_tol, int32_t force_gate = 2)
30
{
31
if
(!client.
loaded
() || n_atoms < 1 ||
position
==
nullptr
||
32
masses ==
nullptr
) {
33
return
false
;
34
}
35
release();
36
if
(force_gate < RGSADDLE_FORCE_L2 ||
37
force_gate > RGSADDLE_FORCE_MAX_ATOM) {
38
return
false
;
39
}
40
rgsaddle_sella_min_config_t cfg{};
41
cfg.version.major = RGSADDLE_ABI_MAJOR;
42
cfg.version.minor = 0;
43
cfg.delta = 0.1;
44
cfg.force_tol = force_tol > 0.0 ? force_tol : 1e-3;
45
cfg.force_gate =
static_cast<
rgsaddle_force_gate_t
>
(force_gate);
46
sess_ = client.
sellaMinCreate
(&cfg, n_atoms,
position
, masses);
47
if
(sess_ ==
nullptr
)
return
false
;
48
client_ = &client;
49
n_atoms_ = n_atoms;
50
pos_.assign(
static_cast<
std::size_t
>
(3 * n_atoms), 0.0);
51
return
true
;
52
}
53
54
bool
step
(rgsaddle_surface_fn
surface
,
void
*
user
,
55
rgsaddle_report_t& report)
56
{
57
if
(client_ ==
nullptr
|| sess_ ==
nullptr
||
surface
==
nullptr
)
58
return
false
;
59
return
client_->sellaMinStep(sess_,
surface
,
user
, &report) == 0;
60
}
61
62
bool
position
(
double
*
out
)
63
{
64
if
(client_ ==
nullptr
|| sess_ ==
nullptr
||
out
==
nullptr
)
65
return
false
;
66
return
client_->sellaMinPosition(sess_,
out
) == 0;
67
}
68
69
[[nodiscard]] int64_t
nAtoms
() const noexcept
70
{
71
return
n_atoms_;
72
}
73
74
private
:
75
void
release()
76
{
77
if
(client_ !=
nullptr
&& sess_ !=
nullptr
)
78
client_->
sellaMinFree
(sess_);
79
sess_ =
nullptr
;
80
client_ =
nullptr
;
81
}
82
83
RgsaddleClient* client_ =
nullptr
;
84
RgsaddleClient::SellaMin
sess_ =
nullptr
;
85
int64_t n_atoms_ = 0;
86
std::vector<double> pos_;
87
};
88
89
}
// namespace neb
90
}
// namespace gpr
91
92
#endif
RgsaddleClient.h
gpr::neb::RgSellaMin::bind
bool bind(RgsaddleClient &client, int64_t n_atoms, const double *position, const double *masses, double force_tol, int32_t force_gate=2)
Definition
RgSellaMin.h:28
gpr::neb::RgSellaMin::operator=
RgSellaMin & operator=(const RgSellaMin &)=delete
gpr::neb::RgSellaMin::position
bool position(double *out)
Definition
RgSellaMin.h:62
gpr::neb::RgSellaMin::nAtoms
int64_t nAtoms() const noexcept
Definition
RgSellaMin.h:69
gpr::neb::RgSellaMin::RgSellaMin
RgSellaMin(const RgSellaMin &)=delete
gpr::neb::RgSellaMin::step
bool step(rgsaddle_surface_fn surface, void *user, rgsaddle_report_t &report)
Definition
RgSellaMin.h:54
gpr::neb::RgSellaMin::RgSellaMin
RgSellaMin()=default
gpr::neb::RgSellaMin::~RgSellaMin
~RgSellaMin()
Definition
RgSellaMin.h:21
gpr::neb::RgsaddleClient
Definition
RgsaddleClient.h:24
gpr::neb::RgsaddleClient::SellaMin
RgsaddleSellaMin * SellaMin
Definition
RgsaddleClient.h:39
gpr::neb::RgsaddleClient::loaded
bool loaded() const noexcept
Definition
RgsaddleClient.h:33
gpr::neb::RgsaddleClient::sellaMinCreate
SellaMin sellaMinCreate(const rgsaddle_sella_min_config_t *cfg, int64_t n_atoms, const double *position, const double *masses)
Definition
RgsaddleClient.cpp:141
gpr::neb::RgsaddleClient::sellaMinFree
void sellaMinFree(SellaMin sess)
Definition
RgsaddleClient.cpp:162
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
RgSellaMin.h
Generated by
1.17.0
Generated by
Doxygen 1.17.0
Analytics by
Antics
provided by
TurtleTech ehf