GPRidge v1.0.0
GPR-accelerated saddle point searches on potential energy surfaces
☾
Toggle main menu visibility
Loading...
Searching...
No Matches
CovalentBondPrior.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
// Covalent-bond-distance prior on the SexpAt kernel length scale.
6
//
7
// Maps each pairtype k in [0, n_pt) to a length-scale value derived from
8
// the sum of Cordero 2008 covalent radii of the two atomic species the
9
// pairtype represents. Used to seed the GP length scale at cold start
10
// when the inverse-distance descriptor sample variance is degenerate
11
// (n_obs <= 3 typically).
12
//
13
// Cordero, Gomez, Platero-Prats, Reves, Echeverria, Cremades, Barragan,
14
// Alvarez (2008) "Covalent radii revisited", Dalton Trans. 2832-2838,
15
// DOI 10.1039/b801115j. Pyykko & Atsumi 2009 is the standard fallback
16
// for Z > 96, which the gpridge target systems (CuH2, PET-MAD AlAuYbZn4
17
// d016) do not exceed.
18
//
19
// Header-only, no dependencies beyond Eigen + the AtomsConfiguration
20
// pairtype table.
21
22
#ifndef GPR_PRIOR_COVALENT_BOND_PRIOR_H_
23
#define GPR_PRIOR_COVALENT_BOND_PRIOR_H_
24
25
#include <Eigen/Core>
26
#include <cmath>
27
#include <stdexcept>
28
#include <vector>
29
30
#include "
../../structures/Structures.h
"
31
#include "
../auxiliary/CorderoRadii.h
"
32
33
namespace
gpr
{
34
namespace
priors
{
35
36
using
geometry::kCorderoRadiusPm
;
37
39
[[nodiscard]]
inline
double
cordero_radius_angstrom
(
int
Z)
noexcept
40
{
41
if
(Z < 1 || Z >=
static_cast<
int
>
(
kCorderoRadiusPm
.size()))
return
0.0;
42
return
kCorderoRadiusPm
[
static_cast<
std::size_t
>
(Z)] * 0.01;
43
}
44
50
[[nodiscard]]
inline
double
bond_length_angstrom
(
int
Za,
int
Zb,
51
double
alpha = 1.0) noexcept
52
{
53
return
alpha * (
cordero_radius_angstrom
(Za) +
cordero_radius_angstrom
(Zb));
54
}
55
59
class
CovalentBondPrior
{
60
public
:
66
explicit
CovalentBondPrior
(
const
AtomsConfiguration
& atoms_config,
67
double
alpha = 1.0)
68
: conf_(atoms_config), alpha_(alpha)
69
{
70
}
71
74
[[nodiscard]] Eigen::VectorXd
lengthScalePerPairtype
()
const
75
{
76
const
Index_t
n_pt = conf_.n_pt;
77
Eigen::VectorXd ls =
78
Eigen::VectorXd::Constant(n_pt, default_fallback_angstrom_());
79
80
// Full atom types and atomic numbers share the input atom order.
81
// Moving-only types cannot index that sequence when frozen atoms are
82
// interleaved. Minimal molecular callers may supply only moving types.
83
const
Eigen::Index n_types = conf_.pairtype.rows();
84
std::vector<int> type_to_Z(
static_cast<
std::size_t
>
(n_types), -1);
85
const
auto
& types = conf_.type.size() == conf_.atomicNrs.size()
86
? conf_.type
87
: conf_.atoms_mov.type;
88
const
Eigen::Index count =
89
std::min(types.size(), conf_.atomicNrs.size());
90
for
(Eigen::Index atom = 0; atom < count; ++atom) {
91
const
auto
type =
static_cast<
Eigen::Index
>
(types.data()[atom]);
92
if
(type < 0 || type >= n_types)
continue
;
93
if
(type_to_Z[type] == -1)
94
type_to_Z[type] = conf_.atomicNrs.data()[atom];
95
}
96
97
// For each pairtype k, find a representative (i, j) with
98
// conf_.pairtype(type(i), type(j)) == k. With small n_pt this
99
// is O(n_pt * n_types^2); n_types is small (typically <= 4).
100
for
(
Index_t
k = 0; k < n_pt; ++k) {
101
for
(Eigen::Index ti = 0;
102
ti < n_types && ls(k) == default_fallback_angstrom_(); ++ti) {
103
for
(Eigen::Index tj = 0; tj < n_types; ++tj) {
104
if
(conf_.pairtype(ti, tj) !=
static_cast<
int
>
(k))
continue
;
105
const
int
Za = type_to_Z[
static_cast<
std::size_t
>
(ti)];
106
const
int
Zb = type_to_Z[
static_cast<
std::size_t
>
(tj)];
107
if
(Za <= 0 || Zb <= 0)
continue
;
108
ls(k) =
bond_length_angstrom
(Za, Zb, alpha_);
109
break
;
110
}
111
}
112
}
113
return
ls;
114
}
115
117
[[nodiscard]]
static
double
bondLength
(
int
Za,
int
Zb,
118
double
alpha = 1.0) noexcept
119
{
120
return
bond_length_angstrom
(Za, Zb, alpha);
121
}
122
123
private
:
124
const
AtomsConfiguration
& conf_;
125
double
alpha_;
126
132
[[nodiscard]]
static
constexpr
double
default_fallback_angstrom_() noexcept
133
{
134
return
1.5;
135
}
136
};
137
138
}
// namespace priors
139
}
// namespace gpr
140
141
#endif
// GPR_PRIOR_COVALENT_BOND_PRIOR_H_
CorderoRadii.h
Structures.h
gpr::priors::CovalentBondPrior::bondLength
static double bondLength(int Za, int Zb, double alpha=1.0) noexcept
Static convenience: bond length in Angstrom for arbitrary (Za, Zb).
Definition
CovalentBondPrior.h:117
gpr::priors::CovalentBondPrior::CovalentBondPrior
CovalentBondPrior(const AtomsConfiguration &atoms_config, double alpha=1.0)
Definition
CovalentBondPrior.h:66
gpr::priors::CovalentBondPrior::lengthScalePerPairtype
Eigen::VectorXd lengthScalePerPairtype() const
Definition
CovalentBondPrior.h:74
gpr::geometry::kCorderoRadiusPm
constexpr std::array< double, 97 > kCorderoRadiusPm
Definition
CorderoRadii.h:14
gpr::priors
Prior distributions and prior-mean functions for the GP.
Definition
CovalentBondPrior.h:34
gpr::priors::bond_length_angstrom
double bond_length_angstrom(int Za, int Zb, double alpha=1.0) noexcept
Definition
CovalentBondPrior.h:50
gpr::priors::kCorderoRadiusPm
constexpr std::array< double, 97 > kCorderoRadiusPm
Definition
CorderoRadii.h:14
gpr::priors::cordero_radius_angstrom
double cordero_radius_angstrom(int Z) noexcept
Convert one Cordero entry to Angstrom (kernel length-scale unit).
Definition
CovalentBondPrior.h:39
gpr
Gaussian-process regression, kernels, priors, and the searches that run on the surrogate.
Definition
Macros.h:16
gpr::Index_t
uint32_t Index_t
Definition
Macros.h:17
gpr::AtomsConfiguration
Stores configurations of all atoms in the system.
Definition
Structures.h:832
gpr
prior
CovalentBondPrior.h
Generated by
1.17.0
Generated by
Doxygen 1.17.0
Analytics by
Antics
provided by
TurtleTech ehf