n2p2 - A neural network potential package
nnp::EwaldTruncKolafaOptEta Class Reference

#include <EwaldTruncKolafaOptEta.h>

Inheritance diagram for nnp::EwaldTruncKolafaOptEta:
Collaboration diagram for nnp::EwaldTruncKolafaOptEta:

Public Member Functions

void calculateParameters (EwaldGlobalSettings const &settings, EwaldStructureData const &sData, EwaldParameters &params) override
 
bool publishedNewCutoffs () override
 
virtual bool isEstimateReliable (EwaldGlobalSettings const &, EwaldParameters const &) const override
 
- Public Member Functions inherited from nnp::IEwaldTrunc
virtual void calculateParameters (EwaldGlobalSettings const &settings, EwaldStructureData const &sData, EwaldParameters &params)=0
 
virtual bool publishedNewCutoffs ()=0
 
virtual bool isEstimateReliable (EwaldGlobalSettings const &settings, EwaldParameters const &params) const =0
 
virtual ~IEwaldTrunc ()=default
 

Private Member Functions

void calculateEta ()
 
double calculateRCut ()
 
double calculateKCut ()
 
void calculateS ()
 
void calculateC (double const qMax)
 

Private Attributes

bool newCutoffs = true
 
bool newCutoffsWerePublished = false
 
double C = 0.0
 
double s = 1.0
 
double eta = 1.0
 
double prec = 1.e-6
 
double volume = 0.0
 
double fourPiEps = 1.0
 
std::size_t numAtoms = 0
 

Detailed Description

Definition at line 13 of file EwaldTruncKolafaOptEta.h.

Member Function Documentation

◆ calculateParameters()

void nnp::EwaldTruncKolafaOptEta::calculateParameters ( EwaldGlobalSettings const &  settings,
EwaldStructureData const &  sData,
EwaldParameters params 
)
overridevirtual

Implements nnp::IEwaldTrunc.

Definition at line 16 of file EwaldTruncKolafaOptEta.cpp.

19 {
20 size_t N = sData.getNumAtoms();
21 double V = sData.getVolume();
22 newCutoffs = (volume != V || numAtoms != N);
23 if (!newCutoffs) return;
25
26 volume = V;
27 numAtoms = N;
28 prec = settings.precision;
29 fourPiEps = settings.fourPiEps;
30
31 calculateC(settings.maxCharge);
33
34 eta = std::max(eta,settings.maxQSigma);
35 params.eta = eta;
36 params.rCut = calculateRCut();
37 params.kCut = calculateKCut();
38 }
void calculateC(double const qMax)

References calculateC(), calculateEta(), calculateKCut(), calculateRCut(), eta, nnp::EwaldParameters::eta, fourPiEps, nnp::EwaldGlobalSettings::fourPiEps, nnp::EwaldStructureData::getNumAtoms(), nnp::EwaldStructureData::getVolume(), nnp::EwaldParameters::kCut, nnp::EwaldGlobalSettings::maxCharge, nnp::EwaldGlobalSettings::maxQSigma, newCutoffs, newCutoffsWerePublished, numAtoms, prec, nnp::EwaldGlobalSettings::precision, nnp::EwaldParameters::rCut, and volume.

Here is the call graph for this function:

◆ publishedNewCutoffs()

bool nnp::EwaldTruncKolafaOptEta::publishedNewCutoffs ( )
overridevirtual

Implements nnp::IEwaldTrunc.

Definition at line 39 of file EwaldTruncKolafaOptEta.cpp.

40 {
41 bool answer = newCutoffsWerePublished;
43 return answer;
44 }

References newCutoffsWerePublished.

◆ isEstimateReliable()

virtual bool nnp::EwaldTruncKolafaOptEta::isEstimateReliable ( EwaldGlobalSettings const &  ,
EwaldParameters const &   
) const
inlineoverridevirtual

Implements nnp::IEwaldTrunc.

Definition at line 20 of file EwaldTruncKolafaOptEta.h.

22 { return true; };

◆ calculateEta()

void nnp::EwaldTruncKolafaOptEta::calculateEta ( )
private

Definition at line 46 of file EwaldTruncKolafaOptEta.cpp.

47 {
48 double constexpr acceptError = 1.e-10;
49
50 // Initial approximation
51 double eta0 = pow(1 / TrOverTk * pow(volume, 2.0)
52 / pow(2 * M_PI, 3.0), 1.0 / 6.0);
53
54 // Selfconsistent calculation of eta
55 eta = eta0;
56 double oldEta;
57 double relError = 1.0;
58 s = 1.0;
59 while (relError > acceptError)
60 {
61 calculateS();
62 oldEta = eta;
63 eta = eta0 * pow((1 + 1 / (2 * pow(s, 2))), 1.0 / 6.0);
64 relError = abs(oldEta - eta) / eta;
65 }
66 }
double constexpr TrOverTk

References calculateS(), eta, s, nnp::TrOverTk, and volume.

Referenced by calculateParameters().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ calculateRCut()

double nnp::EwaldTruncKolafaOptEta::calculateRCut ( )
private

Definition at line 67 of file EwaldTruncKolafaOptEta.cpp.

68 {
69 return sqrt(2)*eta*s;
70 }

References eta, and s.

Referenced by calculateParameters().

Here is the caller graph for this function:

◆ calculateKCut()

double nnp::EwaldTruncKolafaOptEta::calculateKCut ( )
private

Definition at line 72 of file EwaldTruncKolafaOptEta.cpp.

73 {
74 return sqrt(2)*s / eta;
75 }

References eta, and s.

Referenced by calculateParameters().

Here is the caller graph for this function:

◆ calculateS()

void nnp::EwaldTruncKolafaOptEta::calculateS ( )
private

Definition at line 77 of file EwaldTruncKolafaOptEta.cpp.

78 {
79 double constexpr acceptError = 1.e-10;
80 double relXError = 1.0;
81 double relYError = 1.0;
82 double y = prec / C * sqrt(eta/2);
83
84 if (s <= 0.0) s = 0.5;
85
86 double step;
87 while (relXError > acceptError || relYError > acceptError)
88 {
89 step = 2*s / (4*pow(s,2.0) + 1)
90 * (1 - sqrt(s) / exp(-pow(s,2.0)) * y);
91
92 // If s would become negative, try smaller start value.
93 if (s <= -step)
94 {
95 s /= 2;
96 step = 1.0;
97 continue;
98 }
99 s += step;
100 relYError = abs((exp(-pow(s,2.0)) / sqrt(s) - y) / y);
101 relXError = abs(step/s);
102 }
103 }

References C, eta, prec, and s.

Referenced by calculateEta().

Here is the caller graph for this function:

◆ calculateC()

void nnp::EwaldTruncKolafaOptEta::calculateC ( double const  qMax)
private

Definition at line 105 of file EwaldTruncKolafaOptEta.cpp.

106 {
107 C = pow(2, 3.0/4) * pow(qMax,2.0) * sqrt(numAtoms/volume) / fourPiEps;
108 }

References C, fourPiEps, numAtoms, and volume.

Referenced by calculateParameters().

Here is the caller graph for this function:

Member Data Documentation

◆ newCutoffs

bool nnp::EwaldTruncKolafaOptEta::newCutoffs = true
private

Definition at line 24 of file EwaldTruncKolafaOptEta.h.

Referenced by calculateParameters().

◆ newCutoffsWerePublished

bool nnp::EwaldTruncKolafaOptEta::newCutoffsWerePublished = false
private

Definition at line 25 of file EwaldTruncKolafaOptEta.h.

Referenced by calculateParameters(), and publishedNewCutoffs().

◆ C

double nnp::EwaldTruncKolafaOptEta::C = 0.0
private

Definition at line 26 of file EwaldTruncKolafaOptEta.h.

Referenced by calculateC(), and calculateS().

◆ s

double nnp::EwaldTruncKolafaOptEta::s = 1.0
private

Definition at line 27 of file EwaldTruncKolafaOptEta.h.

Referenced by calculateEta(), calculateKCut(), calculateRCut(), and calculateS().

◆ eta

double nnp::EwaldTruncKolafaOptEta::eta = 1.0
private

◆ prec

double nnp::EwaldTruncKolafaOptEta::prec = 1.e-6
private

Definition at line 29 of file EwaldTruncKolafaOptEta.h.

Referenced by calculateParameters(), and calculateS().

◆ volume

double nnp::EwaldTruncKolafaOptEta::volume = 0.0
private

Definition at line 30 of file EwaldTruncKolafaOptEta.h.

Referenced by calculateC(), calculateEta(), and calculateParameters().

◆ fourPiEps

double nnp::EwaldTruncKolafaOptEta::fourPiEps = 1.0
private

Definition at line 31 of file EwaldTruncKolafaOptEta.h.

Referenced by calculateC(), and calculateParameters().

◆ numAtoms

std::size_t nnp::EwaldTruncKolafaOptEta::numAtoms = 0
private

Definition at line 32 of file EwaldTruncKolafaOptEta.h.

Referenced by calculateC(), and calculateParameters().


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