GPRidge v1.0.0
GPR-accelerated saddle point searches on potential energy surfaces
☾
Toggle main menu visibility
Loading...
Searching...
No Matches
BandStall.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_BAND_STALL_H_
6
#define GPR_NEB_BAND_STALL_H_
7
8
#include <algorithm>
9
#include <limits>
10
#include <vector>
11
12
#include "
NEBPath.h
"
13
14
namespace
gpr::neb
{
15
17
enum class
BandStallAction
{
Continue
,
Restore
,
Stop
};
18
23
struct
BandForceStall
{
24
double
best_force
= std::numeric_limits<double>::infinity();
25
int
quiet
= 0;
26
int
restores
= 0;
27
bool
have
=
false
;
28
int
image
= -1;
29
double
energy
= std::numeric_limits<double>::infinity();
30
std::vector<Image>
band
;
31
};
32
39
inline
int
bandStallWindow
(
int
n_images,
int
polished_dofs)
noexcept
40
{
41
const
int
images = n_images > 1 ? n_images : 1;
42
const
int
pairs = images * (images - 1);
43
const
int
polished = polished_dofs > 0 ? polished_dofs : 0;
44
return
std::max(pairs, std::max(polished, 1));
45
}
46
50
inline
void
noteLowestCertifiedClimb
(
BandForceStall
& stall,
const
NEBPath
& path,
51
int
image)
52
{
53
if
(image <= 0 || image >= path.
numImages
() - 1)
return
;
54
const
Image
& img = path.
image
(image);
55
const
Image
& prev = path.
image
(image - 1);
56
const
Image
& next = path.
image
(image + 1);
57
if
(!img.
evaluated
|| !prev.
evaluated
|| !next.
evaluated
)
return
;
58
if
(!std::isfinite(img.
energy
) || !std::isfinite(prev.
energy
) ||
59
!std::isfinite(next.
energy
))
60
return
;
61
// A certified climb is a measured local maximum, not a placeholder zero
62
// left on an image the oracle has not touched.
63
if
(!(img.
energy
> prev.
energy
&& img.
energy
> next.
energy
))
return
;
64
if
(stall.
have
&& !(img.
energy
< stall.
energy
))
return
;
65
stall.
have
=
true
;
66
stall.
image
= image;
67
stall.
energy
= img.
energy
;
68
stall.
band
.clear();
69
stall.
band
.reserve(
static_cast<
std::size_t
>
(path.
numImages
()));
70
for
(
int
i = 0; i < path.
numImages
(); ++i)
71
stall.
band
.push_back(path.
image
(i));
72
}
73
80
inline
BandStallAction
observeMaxBandForce
(
BandForceStall
& stall,
81
double
max_force,
82
double
force_tolerance,
int
window)
83
{
84
if
(!(force_tolerance > 0.0) || window < 1 || !std::isfinite(max_force)) {
85
return
BandStallAction::Continue
;
86
}
87
if
(max_force < stall.
best_force
- force_tolerance) {
88
stall.
best_force
= max_force;
89
stall.
quiet
= 0;
90
return
BandStallAction::Continue
;
91
}
92
if
(++stall.
quiet
< window || !stall.
have
)
return
BandStallAction::Continue
;
93
stall.
quiet
= 0;
94
if
(stall.
restores
>= 1)
return
BandStallAction::Stop
;
95
++stall.
restores
;
96
return
BandStallAction::Restore
;
97
}
98
100
inline
void
restoreCertifiedClimb
(
NEBPath
& path,
const
BandForceStall
& stall)
101
{
102
if
(!stall.
have
)
return
;
103
const
int
n =
104
std::min(path.
numImages
(),
static_cast<
int
>
(stall.
band
.size()));
105
for
(
int
i = 0; i < n; ++i)
106
path.
image
(i) = stall.
band
[
static_cast<
std::size_t
>
(i)];
107
path.
computeNEBForces
();
108
path.
enableClimbingImage
();
109
}
110
111
}
// namespace gpr::neb
112
113
#endif
// GPR_NEB_BAND_STALL_H_
NEBPath.h
NEB path management: image chain, spring forces, climbing image.
gpr::neb::NEBPath
NEB path: chain of images between two endpoints.
Definition
NEBPath.h:57
gpr::neb::NEBPath::numImages
int numImages() const
Definition
NEBPath.h:338
gpr::neb::NEBPath::enableClimbingImage
void enableClimbingImage()
Enable climbing image on the highest-energy intermediate image.
Definition
NEBPath.cpp:1121
gpr::neb::NEBPath::computeNEBForces
void computeNEBForces()
Compute NEB forces for all intermediate images.
Definition
NEBPath.cpp:880
gpr::neb::NEBPath::image
Image & image(int i)
Access image i.
Definition
NEBPath.h:329
gpr::neb
The nudged elastic band: path, GP-NEB driver, configuration and result, acquisition,...
Definition
ChainRealign.h:29
gpr::neb::restoreCertifiedClimb
void restoreCertifiedClimb(NEBPath &path, const BandForceStall &stall)
Put the certified climb back and make it the climbing image.
Definition
BandStall.h:100
gpr::neb::observeMaxBandForce
BandStallAction observeMaxBandForce(BandForceStall &stall, double max_force, double force_tolerance, int window)
Definition
BandStall.h:80
gpr::neb::BandStallAction
BandStallAction
What to do when the max band force stops falling.
Definition
BandStall.h:17
gpr::neb::BandStallAction::Stop
@ Stop
Definition
BandStall.h:17
gpr::neb::BandStallAction::Restore
@ Restore
Definition
BandStall.h:17
gpr::neb::BandStallAction::Continue
@ Continue
Definition
BandStall.h:17
gpr::neb::noteLowestCertifiedClimb
void noteLowestCertifiedClimb(BandForceStall &stall, const NEBPath &path, int image)
Definition
BandStall.h:50
gpr::neb::bandStallWindow
int bandStallWindow(int n_images, int polished_dofs) noexcept
Definition
BandStall.h:39
gpr::neb::BandForceStall
Definition
BandStall.h:23
gpr::neb::BandForceStall::image
int image
Definition
BandStall.h:28
gpr::neb::BandForceStall::best_force
double best_force
Definition
BandStall.h:24
gpr::neb::BandForceStall::restores
int restores
Definition
BandStall.h:26
gpr::neb::BandForceStall::energy
double energy
Definition
BandStall.h:29
gpr::neb::BandForceStall::band
std::vector< Image > band
Definition
BandStall.h:30
gpr::neb::BandForceStall::quiet
int quiet
Definition
BandStall.h:25
gpr::neb::BandForceStall::have
bool have
Definition
BandStall.h:27
gpr::neb::Image
A single image on the NEB path.
Definition
NEBPath.h:39
gpr::neb::Image::energy
double energy
Definition
NEBPath.h:41
gpr::neb::Image::evaluated
bool evaluated
Definition
NEBPath.h:45
gpr
neb
BandStall.h
Generated by
1.17.0
Generated by
Doxygen 1.17.0
Analytics by
Antics
provided by
TurtleTech ehf