struct aux::InverseDistanceCache

Overview

Methods to calculate distances between atoms. More…

#include <gpr/auxiliary/Distance.h>
 
struct InverseDistanceCache {
    // fields
 
    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;
 
    // methods
 
    void clear();
    bool matches(const gpr::Coord& x1, const gpr::Coord& x2, const double cell[9]) const;
};

Detailed Documentation

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.

Methods

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.