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

#include <gpr/prior/CovalentBondPrior.h>

Public Member Functions

 CovalentBondPrior (const AtomsConfiguration &atoms_config, double alpha=1.0)
Eigen::VectorXd lengthScalePerPairtype () const

Static Public Member Functions

static double bondLength (int Za, int Zb, double alpha=1.0) noexcept
 Static convenience: bond length in Angstrom for arbitrary (Za, Zb).

Detailed Description

Length-scale prior on SexpAt keyed off the AtomsConfiguration's pairtype table. Returns one length scale per pairtype in the same indexing the SexpAt kernel uses (matches Distance.cpp:395-525).

Definition at line 59 of file CovalentBondPrior.h.

Constructor & Destructor Documentation

◆ CovalentBondPrior()

gpr::priors::CovalentBondPrior::CovalentBondPrior ( const AtomsConfiguration & atoms_config,
double alpha = 1.0 )
inlineexplicit
Parameters
atoms_configAtomsConfiguration with n_pt active pairtypes and pairtype(i, j) indexed by atoms_mov.type etc.
alphaoptional scaling factor applied to the bond-length sum (default 1.0). Tighter alpha (~0.5) makes the GP more local; looser (~2.0) makes it more global.

Definition at line 66 of file CovalentBondPrior.h.

68 : conf_(atoms_config), alpha_(alpha)
69 {
70 }

Member Function Documentation

◆ bondLength()

double gpr::priors::CovalentBondPrior::bondLength ( int Za,
int Zb,
double alpha = 1.0 )
inlinestaticnodiscardnoexcept

Static convenience: bond length in Angstrom for arbitrary (Za, Zb).

Definition at line 117 of file CovalentBondPrior.h.

119 {
120 return bond_length_angstrom(Za, Zb, alpha);
121 }
double bond_length_angstrom(int Za, int Zb, double alpha=1.0) noexcept

◆ lengthScalePerPairtype()

Eigen::VectorXd gpr::priors::CovalentBondPrior::lengthScalePerPairtype ( ) const
inlinenodiscard

Per-pairtype length scale in Angstrom. Length = conf.n_pt; element [k] is the prior length scale for pairtype k.

Definition at line 74 of file CovalentBondPrior.h.

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 }
uint32_t Index_t
Definition Macros.h:17

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