Loading...
Searching...
No Matches
gpr::priors::ZBLPriorMean Class Reference

#include <gpr/prior/ZBLPriorMean.h>

Public Types

using HessianPair = PriorHessianPair

Public Member Functions

 ZBLPriorMean (const AtomsConfiguration &atoms_config)
bool active () const noexcept
template<typename Derived>
double energy (const Eigen::MatrixBase< Derived > &positions) const
template<typename Derived>
ZBLPriorMeanEvaluation evaluate (const Eigen::MatrixBase< Derived > &positions) const
template<typename Derived>
std::vector< HessianPair > hessianPairs (const Eigen::MatrixBase< Derived > &positions) const
 Cartesian pair blocks retain only interactions inside the cutoff.
void subtractFromTargets (const Coord &positions, Eigen::Index energy_count, Eigen::VectorXd &targets) const
void addToObservation (Observation &observation) const

Static Public Member Functions

static double covalentRadius (int Z) noexcept
 Cordero single-bond covalent radius (Angstrom) of atomic number Z.
static double repulsionOnsetRadius (int Zi, int Zj) noexcept
template<typename Derived>
static Eigen::MatrixXd applyHessianPairs (const std::vector< HessianPair > &pairs, const Eigen::MatrixBase< Derived > &directions)
 Apply physical prior curvature without forming a dense Hessian.

Detailed Description

Definition at line 47 of file ZBLPriorMean.h.

Member Typedef Documentation

◆ HessianPair

Constructor & Destructor Documentation

◆ ZBLPriorMean()

gpr::priors::ZBLPriorMean::ZBLPriorMean ( const AtomsConfiguration & atoms_config)
inlineexplicit

Definition at line 51 of file ZBLPriorMean.h.

52 : frame_(atoms_config)
53 {
54 active_ = hasActivePair();
55 }

Member Function Documentation

◆ active()

bool gpr::priors::ZBLPriorMean::active ( ) const
inlinenodiscardnoexcept

Definition at line 57 of file ZBLPriorMean.h.

58 {
59 return active_;
60 }

◆ addToObservation()

void gpr::priors::ZBLPriorMean::addToObservation ( Observation & observation) const
inline

Definition at line 156 of file ZBLPriorMean.h.

157 {
158 if (!active_ || observation.E.rows() != observation.R.rows() ||
159 observation.G.rows() != observation.R.rows() ||
160 observation.G.cols() != observation.R.cols() ||
161 observation.E.cols() < 1 ||
162 !dimensionMatches(observation.R.cols())) {
163 return;
164 }
165
166 for (Eigen::Index row = 0; row < observation.R.rows(); ++row) {
167 visitPairs(
168 observation.R.row(row),
169 [&](double pair_energy) {
170 observation.E(row, 0) += pair_energy;
171 },
172 [&](Eigen::Index component, double value) {
173 observation.G(row, component) += value;
174 });
175 }
176 }

◆ applyHessianPairs()

template<typename Derived>
Eigen::MatrixXd gpr::priors::ZBLPriorMean::applyHessianPairs ( const std::vector< HessianPair > & pairs,
const Eigen::MatrixBase< Derived > & directions )
inlinestaticnodiscard

Apply physical prior curvature without forming a dense Hessian.

Definition at line 126 of file ZBLPriorMean.h.

129 {
130 return applyPriorHessianPairs(pairs, directions);
131 }
Eigen::MatrixXd applyPriorHessianPairs(const std::vector< PriorHessianPair > &pairs, const Eigen::MatrixBase< Derived > &directions)
Apply physical prior curvature without forming a dense Hessian.

◆ covalentRadius()

double gpr::priors::ZBLPriorMean::covalentRadius ( int Z)
inlinestaticnodiscardnoexcept

Cordero single-bond covalent radius (Angstrom) of atomic number Z.

Definition at line 63 of file ZBLPriorMean.h.

64 {
65 if (Z < 1 || Z > kLastCorderoElement) return kDefaultCovalentRadius;
66 return geometry::kCorderoRadiusPm[static_cast<std::size_t>(Z)] / 100.0;
67 }
constexpr std::array< double, 97 > kCorderoRadiusPm

◆ energy()

template<typename Derived>
double gpr::priors::ZBLPriorMean::energy ( const Eigen::MatrixBase< Derived > & positions) const
inlinenodiscard

Definition at line 82 of file ZBLPriorMean.h.

84 {
85 if (!dimensionMatches(positions.size())) return 0.0;
86 double out = 0.0;
87 visitPairs(
88 positions, [&](double pair_energy) { out += pair_energy; },
89 [](Eigen::Index, double) {});
90 return out;
91 }
eon_relax_band_t eon_relax_surface_fn void eon_relax_outcome_t * out

◆ evaluate()

template<typename Derived>
ZBLPriorMeanEvaluation gpr::priors::ZBLPriorMean::evaluate ( const Eigen::MatrixBase< Derived > & positions) const
inlinenodiscard

Definition at line 94 of file ZBLPriorMean.h.

96 {
97 ZBLPriorMeanEvaluation out;
98 out.gradient = Eigen::RowVectorXd::Zero(positions.size());
99 if (!dimensionMatches(positions.size())) return out;
100 visitPairs(
101 positions, [&](double pair_energy) { out.energy += pair_energy; },
102 [&](Eigen::Index component, double value) {
103 out.gradient(component) += value;
104 });
105 return out;
106 }

◆ hessianPairs()

template<typename Derived>
std::vector< HessianPair > gpr::priors::ZBLPriorMean::hessianPairs ( const Eigen::MatrixBase< Derived > & positions) const
inlinenodiscard

Cartesian pair blocks retain only interactions inside the cutoff.

Definition at line 110 of file ZBLPriorMean.h.

112 {
113 std::vector<HessianPair> pairs;
114 if (!dimensionMatches(positions.size())) return pairs;
115 visitPairs(
116 positions, [](double) {}, [](Eigen::Index, double) {},
117 [&](Eigen::Index first, Eigen::Index second,
118 const Eigen::Matrix3d& block) {
119 pairs.push_back({first, second, block});
120 });
121 return pairs;
122 }

◆ repulsionOnsetRadius()

double gpr::priors::ZBLPriorMean::repulsionOnsetRadius ( int Zi,
int Zj )
inlinestaticnodiscardnoexcept

Pair distance below which the switched repulsion is nonzero: the outer edge of the quintic switch, 0.75 of the covalent-radii sum. Above it the prior mean is exactly inert, so the residual process carries the whole surface; below it the delta-learning premise ends and every measured row becomes a Pauli-wall target. The band and the dimer use it as the per-element-pair contact floor of their domain.

Definition at line 75 of file ZBLPriorMean.h.

76 {
77 if (Zi <= 0 || Zj <= 0) return 0.0;
78 return kSwitchOffFactor * (covalentRadius(Zi) + covalentRadius(Zj));
79 }
static double covalentRadius(int Z) noexcept
Cordero single-bond covalent radius (Angstrom) of atomic number Z.

◆ subtractFromTargets()

void gpr::priors::ZBLPriorMean::subtractFromTargets ( const Coord & positions,
Eigen::Index energy_count,
Eigen::VectorXd & targets ) const
inline

Definition at line 133 of file ZBLPriorMean.h.

135 {
136 if (!active_ || positions.rows() != energy_count ||
137 !dimensionMatches(positions.cols())) {
138 return;
139 }
140 const Eigen::Index required =
141 energy_count + positions.rows() * positions.cols();
142 if (targets.size() < required) return;
143
144 for (Eigen::Index row = 0; row < positions.rows(); ++row) {
145 visitPairs(
146 positions.row(row),
147 [&](double pair_energy) { targets(row) -= pair_energy; },
148 [&](Eigen::Index component, double value) {
149 const Eigen::Index target_index =
150 energy_count + row + component * positions.rows();
151 targets(target_index) -= value;
152 });
153 }
154 }

The documentation for this class was generated from the following file: