GPRidge v1.0.0
GPR-accelerated saddle point searches on potential energy surfaces
☾
Toggle main menu visibility
Loading...
Searching...
No Matches
FarField.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_AUXILIARY_FARFIELD_H_
6
#define GPR_AUXILIARY_FARFIELD_H_
7
8
#include "
../../structures/Structures.h
"
9
#include "
MinImage.h
"
10
11
namespace
aux
{
12
13
// The expansion is part of the model, shared by every covariance block.
14
// Query rows must never select the centre or the near/far partition.
15
inline
const
double
*
farFieldCentre
(
const
gpr::AtomsConfiguration
& conf,
16
Eigen::Index atom)
17
{
18
const
auto
& reference = conf.
atoms_mov
.
positions
;
19
if
(reference.rows() != 1 ||
20
reference.cols() != 3 * conf.
atoms_mov
.
type
.size() || atom < 0 ||
21
atom >= conf.
atoms_mov
.
type
.size())
22
throw
std::invalid_argument(
23
"far-field kernel requires fixed reference positions for every "
24
"moving atom"
);
25
const
double
* centre = reference.data() + 3 * atom;
26
for
(
int
d = 0; d < 3; ++d)
27
if
(!std::isfinite(centre[d]))
28
throw
std::invalid_argument(
"far-field reference must be finite"
);
29
return
centre;
30
}
31
32
// Each query has one feature coordinate in the reference atom's MIC chart.
33
// Subtracting those coordinates defines a common feature map, including when
34
// queries occupy different periodic images. Pairwise wrapping of left-right
35
// instead would not in general give a squared Euclidean feature distance.
36
inline
void
farFieldDifference
(
const
gpr::geometry::PairBox
& box,
37
const
double
centre[3],
const
double
left[3],
38
const
double
right[3],
double
delta[3])
39
{
40
double
a[3], b[3];
41
box.
displacement
(centre, left, a);
42
box.
displacement
(centre, right, b);
43
for
(
int
d = 0; d < 3; ++d)
44
delta[d] = a[d] - b[d];
45
}
46
47
// Dipole tensor of one frozen source. r is the minimum-image vector from the
48
// frozen atom to the expansion centre. weight is 2/l^2 for that pair type.
49
inline
void
addFarSource
(
double
tensor[3][3],
const
double
r[3],
double
weight)
50
{
51
const
double
r2 = r[0] * r[0] + r[1] * r[1] + r[2] * r[2];
52
if
(!(r2 > 0.0))
return
;
53
const
double
scale = weight / (r2 * r2 * r2);
54
for
(
int
a = 0; a < 3; ++a) {
55
for
(
int
b = 0; b < 3; ++b)
56
tensor[a][b] += scale * r[a] * r[b];
57
}
58
}
59
60
inline
double
farQuadratic
(
const
double
tensor[3][3],
const
double
delta[3])
61
{
62
double
contracted[3] = {0.0, 0.0, 0.0};
63
for
(
int
a = 0; a < 3; ++a) {
64
contracted[a] = tensor[a][0] * delta[0] + tensor[a][1] * delta[1] +
65
tensor[a][2] * delta[2];
66
}
67
return
delta[0] * contracted[0] + delta[1] * contracted[1] +
68
delta[2] * contracted[2];
69
}
70
71
inline
void
farContract
(
const
double
tensor[3][3],
const
double
delta[3],
72
double
out
[3])
73
{
74
for
(
int
a = 0; a < 3; ++a) {
75
out
[a] = tensor[a][0] * delta[0] + tensor[a][1] * delta[1] +
76
tensor[a][2] * delta[2];
77
}
78
}
79
80
// True when the frozen atom lies at or beyond radius from centre.
81
inline
bool
farFromCentre
(
const
gpr::geometry::PairBox
& box,
82
const
double
centre[3],
const
double
frozen[3],
83
double
radius)
84
{
85
double
r[3];
86
box.
displacement
(frozen, centre, r);
87
const
double
r2 = r[0] * r[0] + r[1] * r[1] + r[2] * r[2];
88
return
r2 >= radius * radius;
89
}
90
91
}
// namespace aux
92
93
#endif
MinImage.h
Structures.h
gpr::geometry::PairBox
Definition
MinImage.h:156
gpr::geometry::PairBox::displacement
void displacement(const double p[3], const double q[3], double dr[3]) const
Displacement from p to q. Cartesian q - p when the cell is zero.
Definition
MinImage.h:210
out
eon_relax_band_t eon_relax_surface_fn void eon_relax_outcome_t * out
Definition
eon_relax_engine.h:240
aux
Definition
AdditionalFunctionality.h:18
aux::farFromCentre
bool farFromCentre(const gpr::geometry::PairBox &box, const double centre[3], const double frozen[3], double radius)
Definition
FarField.h:81
aux::farQuadratic
double farQuadratic(const double tensor[3][3], const double delta[3])
Definition
FarField.h:60
aux::farFieldDifference
void farFieldDifference(const gpr::geometry::PairBox &box, const double centre[3], const double left[3], const double right[3], double delta[3])
Definition
FarField.h:36
aux::addFarSource
void addFarSource(double tensor[3][3], const double r[3], double weight)
Definition
FarField.h:49
aux::farContract
void farContract(const double tensor[3][3], const double delta[3], double out[3])
Definition
FarField.h:71
aux::farFieldCentre
const double * farFieldCentre(const gpr::AtomsConfiguration &conf, Eigen::Index atom)
Definition
FarField.h:15
gpr::AtomsConfiguration
Stores configurations of all atoms in the system.
Definition
Structures.h:832
gpr::AtomsConfiguration::atoms_mov
AtomsPositionAndType atoms_mov
Info on moving atoms.
Definition
Structures.h:844
gpr::AtomsPositionAndType::positions
Coord positions
Definition
Structures.h:811
gpr::AtomsPositionAndType::type
FieldMatrixIdx type
Definition
Structures.h:812
gpr
auxiliary
FarField.h
Generated by
1.17.0
Generated by
Doxygen 1.17.0
Analytics by
Antics
provided by
TurtleTech ehf