Loading...
Searching...
No Matches
aux::InverseDistanceCache Struct Reference

Methods to calculate distances between atoms. More...

#include <gpr/auxiliary/Distance.h>

Public Member Functions

void clear ()
bool matches (const gpr::Coord &x1, const gpr::Coord &x2, const double cell[9]) const
 Whether the cache describes exactly this pair of coordinate sets.

Public Attributes

std::vector< std::vector< double > > invr_x1
std::vector< std::vector< double > > invr_x2
std::vector< gpr::Index_t > pair_types
gpr::Coord x1_cached
gpr::Coord x2_cached
double cell_cached [9] = {0., 0., 0., 0., 0., 0., 0., 0., 0.}
Eigen::Index n1 = 0
Eigen::Index n2 = 0
Eigen::Index n_mov = 0
Eigen::Index n_fro = 0
bool valid = false

Detailed Description

Methods to calculate distances between atoms.

Cache for raw inverse interatomic distances.

During hyperparameter optimization, atomic positions are fixed while lengthscales change every iteration. This cache stores the position- dependent 1/r_ij values so that dist_at() only needs to recompute the lengthscale-weighted sum on subsequent calls.

Cache layout: invr_x1[pair_idx][n] = 1/r_ij for configuration n in x1 invr_x2[pair_idx][m] = 1/r_ij for configuration m in x2 pair_types[pair_idx] = pairtype index for this atom pair

Moving-moving pairs come first (triangular: j < i), then moving-frozen.

Definition at line 104 of file Distance.h.

Member Function Documentation

◆ clear()

void aux::InverseDistanceCache::clear ( )
inline

Definition at line 121 of file Distance.h.

122 {
123 invr_x1.clear();
124 invr_x2.clear();
125 pair_types.clear();
126 x1_cached.resize(0, 0);
127 x2_cached.resize(0, 0);
128 for (int i = 0; i < 9; ++i)
129 cell_cached[i] = 0.0;
130 n1 = n2 = n_mov = n_fro = 0;
131 valid = false;
132 }
std::vector< std::vector< double > > invr_x1
Definition Distance.h:105
std::vector< std::vector< double > > invr_x2
Definition Distance.h:106
std::vector< gpr::Index_t > pair_types
Definition Distance.h:107

◆ matches()

bool aux::InverseDistanceCache::matches ( const gpr::Coord & x1,
const gpr::Coord & x2,
const double cell[9] ) const
inlinenodiscard

Whether the cache describes exactly this pair of coordinate sets.

Definition at line 135 of file Distance.h.

137 {
138 if (!valid || x1_cached.rows() != x1.rows() ||
139 x1_cached.cols() != x1.cols() || x2_cached.rows() != x2.rows() ||
140 x2_cached.cols() != x2.cols() || x1_cached != x1 ||
141 x2_cached != x2) {
142 return false;
143 }
144 for (int i = 0; i < 9; ++i) {
145 if (cell_cached[i] != cell[i]) return false;
146 }
147 return true;
148 }

Member Data Documentation

◆ cell_cached

double aux::InverseDistanceCache::cell_cached[9] = {0., 0., 0., 0., 0., 0., 0., 0., 0.}

Definition at line 116 of file Distance.h.

116{0., 0., 0., 0., 0., 0., 0., 0., 0.};

◆ invr_x1

std::vector<std::vector<double> > aux::InverseDistanceCache::invr_x1

Definition at line 105 of file Distance.h.

◆ invr_x2

std::vector<std::vector<double> > aux::InverseDistanceCache::invr_x2

Definition at line 106 of file Distance.h.

◆ n1

Eigen::Index aux::InverseDistanceCache::n1 = 0

Definition at line 117 of file Distance.h.

◆ n2

Eigen::Index aux::InverseDistanceCache::n2 = 0

Definition at line 117 of file Distance.h.

◆ n_fro

Eigen::Index aux::InverseDistanceCache::n_fro = 0

Definition at line 118 of file Distance.h.

◆ n_mov

Eigen::Index aux::InverseDistanceCache::n_mov = 0

Definition at line 118 of file Distance.h.

◆ pair_types

std::vector<gpr::Index_t> aux::InverseDistanceCache::pair_types

Definition at line 107 of file Distance.h.

◆ valid

bool aux::InverseDistanceCache::valid = false

Definition at line 119 of file Distance.h.

◆ x1_cached

gpr::Coord aux::InverseDistanceCache::x1_cached

Definition at line 114 of file Distance.h.

◆ x2_cached

gpr::Coord aux::InverseDistanceCache::x2_cached

Definition at line 115 of file Distance.h.


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