GPRidge v1.0.0
GPR-accelerated saddle point searches on potential energy surfaces
☾
Toggle main menu visibility
Loading...
Searching...
No Matches
PriorPairFrame.h
Go to the documentation of this file.
1
// SPDX-License-Identifier: MIT
2
// Copyright (c) gpridge developers
3
//
4
// The atoms a pair prior mean sees. A band carries the moving atoms of its
5
// frame only, so a pair prior evaluates the moving atoms against each other
6
// and against the fixed atoms, which stay where the frame put them. Pair
7
// vectors follow the minimum image of the cell, so a bond across a periodic
8
// boundary is the bond it is and not the long way round.
9
10
#ifndef GPR_PRIOR_PRIOR_PAIR_FRAME_H_
11
#define GPR_PRIOR_PRIOR_PAIR_FRAME_H_
12
13
#include <Eigen/Core>
14
#include <cstddef>
15
#include <vector>
16
17
#include "
../../structures/Structures.h
"
18
#include "
../auxiliary/MinImage.h
"
19
20
namespace
gpr
{
21
namespace
priors
{
22
23
struct
PriorPairFrame
{
25
std::vector<int>
moving_numbers
;
27
std::vector<Eigen::Vector3d>
fixed_positions
;
28
std::vector<int>
fixed_numbers
;
29
geometry::PairBox
box
;
30
31
PriorPairFrame
() =
default
;
32
35
explicit
PriorPairFrame
(
const
AtomsConfiguration
& config) :
box
(config.cell)
36
{
37
const
Eigen::Index n = config.
atomicNrs
.size();
38
const
bool
flagged =
39
config.
is_frozen
.size() == n && config.
positions
.size() == 3 * n;
40
for (Eigen::Index i = 0; i < n; ++i) {
41
const
int
z
=
static_cast<
int
>
(*(config.
atomicNrs
.data() + i));
42
if
(!flagged || *(config.
is_frozen
.data() + i) ==
MOVING_ATOM
) {
43
moving_numbers
.push_back(
z
);
44
continue
;
45
}
46
fixed_positions
.emplace_back(
47
*(config.
positions
.data() + 3 * i),
48
*(config.
positions
.data() + 3 * i + 1),
49
*(config.
positions
.data() + 3 * i + 2));
50
fixed_numbers
.push_back(
z
);
51
}
52
}
53
54
[[nodiscard]] Eigen::Index
coordinates
() const noexcept
55
{
56
return
3 *
static_cast<
Eigen::Index
>
(
moving_numbers
.size());
57
}
58
61
[[nodiscard]]
bool
hasPair
() const noexcept
62
{
63
std::size_t known = 0;
64
for
(
int
z
:
moving_numbers
)
65
known +=
z
> 0;
66
if
(known == 0)
return
false
;
67
if
(known > 1)
return
true
;
68
for
(
int
z
:
fixed_numbers
)
69
if
(
z
> 0)
return
true
;
70
return
false
;
71
}
72
76
template
<
typename
Positions,
typename
Visit>
77
void
forEachPair
(
const
Positions& positions, Visit&& visit)
const
78
{
79
const
std::size_t n =
moving_numbers
.size();
80
for
(std::size_t i = 0; i < n; ++i) {
81
const
int
Zi =
moving_numbers
[i];
82
if
(Zi <= 0)
continue
;
83
const
Eigen::Index ix =
static_cast<
Eigen::Index
>
(3 * i);
84
const
Eigen::Vector3d xi(positions(ix), positions(ix + 1),
85
positions(ix + 2));
86
for
(std::size_t j = i + 1; j < n; ++j) {
87
const
int
Zj =
moving_numbers
[j];
88
if
(Zj <= 0)
continue
;
89
const
Eigen::Index jx =
static_cast<
Eigen::Index
>
(3 * j);
90
const
Eigen::Vector3d xj(positions(jx), positions(jx + 1),
91
positions(jx + 2));
92
visit(ix, jx, Zi, Zj,
93
Eigen::Vector3d(
box
.displacement(xj, xi)));
94
}
95
for
(std::size_t k = 0; k <
fixed_numbers
.size(); ++k) {
96
const
int
Zk =
fixed_numbers
[k];
97
if
(Zk <= 0)
continue
;
98
visit(
99
ix, Eigen::Index{-1}, Zi, Zk,
100
Eigen::Vector3d(
box
.displacement(
fixed_positions
[k], xi)));
101
}
102
}
103
}
104
};
105
106
}
// namespace priors
107
}
// namespace gpr
108
109
#endif
// GPR_PRIOR_PRIOR_PAIR_FRAME_H_
z
@ z
Definition
Enums.h:28
MOVING_ATOM
@ MOVING_ATOM
Definition
Enums.h:35
MinImage.h
Structures.h
gpr::geometry::PairBox
Definition
MinImage.h:156
gpr::priors
Prior distributions and prior-mean functions for the GP.
Definition
CovalentBondPrior.h:34
gpr
Gaussian-process regression, kernels, priors, and the searches that run on the surrogate.
Definition
Macros.h:16
gpr::AtomsConfiguration
Stores configurations of all atoms in the system.
Definition
Structures.h:832
gpr::AtomsConfiguration::atomicNrs
FieldMatrixi atomicNrs
Atomic Number of each atom.
Definition
Structures.h:836
gpr::AtomsConfiguration::is_frozen
FieldMatrixU8 is_frozen
Indicates whether atom is frozen or not.
Definition
Structures.h:834
gpr::AtomsConfiguration::positions
Coord positions
Positions of all atoms in the system.
Definition
Structures.h:833
gpr::priors::PriorPairFrame::PriorPairFrame
PriorPairFrame()=default
gpr::priors::PriorPairFrame::PriorPairFrame
PriorPairFrame(const AtomsConfiguration &config)
Definition
PriorPairFrame.h:35
gpr::priors::PriorPairFrame::box
geometry::PairBox box
Definition
PriorPairFrame.h:29
gpr::priors::PriorPairFrame::forEachPair
void forEachPair(const Positions &positions, Visit &&visit) const
Definition
PriorPairFrame.h:77
gpr::priors::PriorPairFrame::hasPair
bool hasPair() const noexcept
Definition
PriorPairFrame.h:61
gpr::priors::PriorPairFrame::coordinates
Eigen::Index coordinates() const noexcept
Definition
PriorPairFrame.h:54
gpr::priors::PriorPairFrame::moving_numbers
std::vector< int > moving_numbers
Atomic numbers of the atoms the band moves, in band order.
Definition
PriorPairFrame.h:25
gpr::priors::PriorPairFrame::fixed_numbers
std::vector< int > fixed_numbers
Definition
PriorPairFrame.h:28
gpr::priors::PriorPairFrame::fixed_positions
std::vector< Eigen::Vector3d > fixed_positions
Fixed atoms: Cartesian positions and atomic numbers.
Definition
PriorPairFrame.h:27
gpr
prior
PriorPairFrame.h
Generated by
1.17.0
Generated by
Doxygen 1.17.0
Analytics by
Antics
provided by
TurtleTech ehf