class gpr::neb::PairSplineModel¶
Overview¶
Pair-additive energy with a cubic B-spline radial function. More…
#include <gpr/neb/PairSplineModel.h>
class PairSplineModel {
public:
// structs
struct List;
struct Pair;
// construction
PairSplineModel(Eigen::Index n_moving, Eigen::VectorXd frozen_positions, const std::array<double, 9>& cell, double r_min, double r_cut, double spacing);
// methods
Eigen::Index nMoving() const;
Eigen::Index nBasis() const;
double cutoff() const;
bool ready() const;
int observations() const;
void setNoise(double energy_sigma, double gradient_sigma);
void setPrior(double weight_sigma, double curvature_sigma);
void setTailSplit(double split, double refresh);
void staleTail(int slot);
void observe(const Eigen::VectorXd& x, double energy, const Eigen::VectorXd& gradient, int slot = 0);
bool fit();
double gradientResidual() const;
double energy(const Eigen::VectorXd& x, Eigen::VectorXd* gradient, int slot = 0) const;
double partialEnergy(const Eigen::VectorXd& x, const std::vector<char>& atom_mask, Eigen::VectorXd* gradient, int slot = 0) const;
double maskedEnergy(const Eigen::VectorXd& x, const std::vector<char>& atom_mask, Eigen::VectorXd* gradient, int slot = 0) const;
Eigen::MatrixXd hessian(const Eigen::VectorXd& x, const std::vector<Eigen::Index>& dofs, int slot = 0) const;
void radial(double r, double& phi, double& dphi, double& d2phi) const;
double minimumSeparation(const Eigen::VectorXd& x) const;
int listBuilds() const;
double listSeconds() const;
};
Detailed Documentation¶
Pair-additive energy with a cubic B-spline radial function.
E(x) = c + sum over pairs within the cutoff of phi(r), with phi a linear combination of cardinal cubic B-splines on a uniform knot grid. The weights are the posterior mean of a Bayesian linear model fitted to every measured energy and gradient, which makes the model the mean of a Gaussian process with a degenerate kernel. Pairs run over the moving atoms and between moving and frozen atoms under the minimum image convention of the cell; frozen-frozen pairs are a constant.
A Verlet list with a skin keeps the per-call cost at the listed pairs between rebuilds.
Methods¶
void setNoise(double energy_sigma, double gradient_sigma)
Noise standard deviations of the energy and gradient rows.
void setPrior(double weight_sigma, double curvature_sigma)
Prior standard deviation of the weights and of their second differences along the knot grid.
void setTailSplit(double split, double refresh)
Pairs beyond split are summed once per slot and held as a linear model until staleTail(), a list rebuild, a refit, or (when refresh is positive) an atom moving farther than refresh from that sum. A split of 0 evaluates every pair on every call.
void staleTail(int slot)
Marks the slot’s tail sum for recomputation at the next evaluation.
void observe(const Eigen::VectorXd& x, double energy, const Eigen::VectorXd& gradient, int slot = 0)
Accumulate one measurement into the normal equations.
bool fit()
Solve for the weights. Returns false without enough rows.
double gradientResidual() const
Root-mean-square gradient residual of the retained measurements after the last fit (the fit quality on the force rows).
double energy(const Eigen::VectorXd& x, Eigen::VectorXd* gradient, int slot = 0) const
Energy and, when requested, the gradient on every moving coordinate. slot names the neighbour list to reuse: callers that evaluate several geometries in turn, such as band images, keep one list each.
double partialEnergy(const Eigen::VectorXd& x, const std::vector<char>& atom_mask, Eigen::VectorXd* gradient, int slot = 0) const
Energy restricted to the pairs that involve one of atoms, with the gradient on those atoms’ coordinates written into gradient at the atoms’ flat positions. The omitted pairs are constant while the other atoms stay put.
double maskedEnergy(const Eigen::VectorXd& x, const std::vector<char>& atom_mask, Eigen::VectorXd* gradient, int slot = 0) const
The same sum over the slot’s flat arrays, from an index list of the pairs that touch a masked atom kept with the slot while the mask and the list stand; the gradient lands on every atom those pairs touch.
Eigen::MatrixXd hessian(const Eigen::VectorXd& x, const std::vector<Eigen::Index>& dofs, int slot = 0) const
Hessian block over the listed coordinates at x.
void radial(double r, double& phi, double& dphi, double& d2phi) const
Radial function and its first two derivatives at r.
double minimumSeparation(const Eigen::VectorXd& x) const
Smallest moving-moving or moving-frozen separation at x.