n2p2 - A neural network potential package
ErfcBuf.cpp
Go to the documentation of this file.
1//
2// Created by philipp on 5/23/22.
3//
4
5#include "ErfcBuf.h"
6
7using namespace std;
8using namespace nnp;
9
10void ErfcBuf::reset(std::vector<Atom> const& atoms, size_t const valuesPerPair)
11{
12 f.resize(atoms.size());
13 for(size_t i = 0; i < atoms.size(); ++i)
14 {
15 f[i].resize(atoms[i].numNeighbors * valuesPerPair);
16 fill(f[i].begin(), f[i].end(), -1.0);
17 }
18 numValuesPerPair = valuesPerPair;
19}
20
21double ErfcBuf::getf(const size_t atomIndex,
22 const size_t neighIndex,
23 const size_t valIndex,
24 const double x)
25{
26 size_t j = neighIndex * numValuesPerPair + valIndex;
27 if (f.at(atomIndex).at(j) == -1.0)
28 {
29 f[atomIndex][j] = erfc(x);
30 }
31 return f[atomIndex][j];
32}
Definition: Atom.h:29
std::vector< std::vector< double > > f
2d vector to store already calculated results.
Definition: ErfcBuf.h:41
size_t numValuesPerPair
Typically one needs erfc(a_i * rij), where the number of a_i's correspond to numValuesPerPair.
Definition: ErfcBuf.h:44
double getf(size_t const atomIndex, size_t const neighIndex, size_t const valIndex, double const x)
Either returns already stored value erfc(x) or calculates it if not yet stored.
Definition: ErfcBuf.cpp:21