n2p2 - A neural network potential package
nnp::ErfcBuf Struct Reference

Helper class to store previously calculated values of erfc() that are needed during the charge equilibration. More...

#include <ErfcBuf.h>

Collaboration diagram for nnp::ErfcBuf:

Public Member Functions

void reset (std::vector< Atom > const &atoms, size_t const valuesPerPair)
 Resizes and resets the storage array to fit the current structure. More...
 
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. More...
 

Public Attributes

std::vector< std::vector< double > > f
 2d vector to store already calculated results. More...
 
size_t numValuesPerPair = 1
 Typically one needs erfc(a_i * rij), where the number of a_i's correspond to numValuesPerPair. More...
 

Detailed Description

Helper class to store previously calculated values of erfc() that are needed during the charge equilibration.

Definition at line 16 of file ErfcBuf.h.

Member Function Documentation

◆ reset()

void ErfcBuf::reset ( std::vector< Atom > const &  atoms,
size_t const  valuesPerPair 
)

Resizes and resets the storage array to fit the current structure.

Parameters
[in]atomsVector of atoms of the structure.
[in]valuesPerPairNumber of values that are stored for each neighbor pair (intended use is for erfc(rij...)).

Definition at line 10 of file ErfcBuf.cpp.

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}
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

References f, and numValuesPerPair.

Referenced by nnp::Structure::calculateElectrostaticEnergy().

Here is the caller graph for this function:

◆ getf()

double ErfcBuf::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.

Parameters
[in]atomIndexIndex of atom.
[in]neighIndexIndex of neighbor of this atom.
[in]valIndexIndex corresponds to the value that is requested, see numValuesPerPair.
[in]xCorresponds to erfc(x). Only used when result is not stored yet.

Definition at line 21 of file ErfcBuf.cpp.

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}

References f, and numValuesPerPair.

Referenced by nnp::Structure::calculateDAdrQ(), and nnp::Structure::calculateElectrostaticEnergy().

Here is the caller graph for this function:

Member Data Documentation

◆ f

std::vector<std::vector<double> > nnp::ErfcBuf::f

2d vector to store already calculated results.

Elements set to -1 indicate that this value has not been calculated yet.

Definition at line 41 of file ErfcBuf.h.

Referenced by getf(), and reset().

◆ numValuesPerPair

size_t nnp::ErfcBuf::numValuesPerPair = 1

Typically one needs erfc(a_i * rij), where the number of a_i's correspond to numValuesPerPair.

Definition at line 44 of file ErfcBuf.h.

Referenced by getf(), and reset().


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