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

Setup data for Ewald summation. More...

#include <EwaldSetup.h>

Collaboration diagram for nnp::EwaldSetup:

Public Member Functions

 EwaldSetup ()
 Default constructor. More...
 
void setTruncMethod (EWALDTruncMethod const m)
 
EWALDTruncMethod getTruncMethod () const
 
double getMaxCharge () const
 
double getPrecision () const
 
void setMaxQSigma (double const maxWidth)
 Setter for maximum width of charges. More...
 
void readFromArgs (std::vector< std::string > const &args)
 Setup parameters from argument vector. More...
 
void toNormalizedUnits (double const convEnergy, double const convLength)
 Convert cutoff parameters to normalized units. More...
 
void calculateParameters (double const newVolume, size_t const newNumAtoms)
 Compute eta, rCut and kCut. More...
 
void logEwaldCutoffs (Log &log, double const lengthConversion) const
 Use after Ewald summation! More...
 

Public Attributes

EwaldParameters params
 

Private Member Functions

bool publishedNewCutoffs () const
 
bool isEstimateReliable () const
 

Private Attributes

EWALDTruncMethod truncMethod
 Method for determining real and k space cutoffs. More...
 
EwaldGlobalSettings GlobSett
 
std::unique_ptr< IEwaldTrunctruncImpl
 

Detailed Description

Setup data for Ewald summation.

Definition at line 37 of file EwaldSetup.h.

Constructor & Destructor Documentation

◆ EwaldSetup()

EwaldSetup::EwaldSetup ( )

Default constructor.

Definition at line 29 of file EwaldSetup.cpp.

29 : params ( ),
31 GlobSett ( ),
32 truncImpl (nullptr )
33{
34}
EwaldParameters params
Definition: EwaldSetup.h:39
EWALDTruncMethod truncMethod
Method for determining real and k space cutoffs.
Definition: EwaldSetup.h:79
std::unique_ptr< IEwaldTrunc > truncImpl
Definition: EwaldSetup.h:82
EwaldGlobalSettings GlobSett
Definition: EwaldSetup.h:80
@ JACKSON_CATLOW
Method 0: Used by RuNNer (DOI: 10.1080/08927028808080944).

References nnp::JACKSON_CATLOW.

Member Function Documentation

◆ setTruncMethod()

void nnp::EwaldSetup::setTruncMethod ( EWALDTruncMethod const  m)
inline

Definition at line 93 of file EwaldSetup.h.

94{
95 truncMethod = m;
96}

References truncMethod.

Referenced by nnp::Mode::setupElectrostatics().

Here is the caller graph for this function:

◆ getTruncMethod()

EWALDTruncMethod nnp::EwaldSetup::getTruncMethod ( ) const
inline

Definition at line 43 of file EwaldSetup.h.

43{return truncMethod;};

References truncMethod.

Referenced by nnp::Mode::setupElectrostatics().

Here is the caller graph for this function:

◆ getMaxCharge()

double nnp::EwaldSetup::getMaxCharge ( ) const
inline

Definition at line 44 of file EwaldSetup.h.

References GlobSett, and nnp::EwaldGlobalSettings::maxCharge.

Referenced by nnp::Mode::setupElectrostatics().

Here is the caller graph for this function:

◆ getPrecision()

double nnp::EwaldSetup::getPrecision ( ) const
inline

Definition at line 45 of file EwaldSetup.h.

References GlobSett, and nnp::EwaldGlobalSettings::precision.

Referenced by nnp::Mode::setupElectrostatics().

Here is the caller graph for this function:

◆ setMaxQSigma()

void nnp::EwaldSetup::setMaxQSigma ( double const  maxWidth)
inline

Setter for maximum width of charges.

Parameters
maxWidthMaximum width of gaussian charges.

Definition at line 88 of file EwaldSetup.h.

89{
90 GlobSett.maxQSigma = maxWidth;
91}

References GlobSett, and nnp::EwaldGlobalSettings::maxQSigma.

Referenced by nnp::Mode::setupElectrostatics().

Here is the caller graph for this function:

◆ readFromArgs()

void EwaldSetup::readFromArgs ( std::vector< std::string > const &  args)

Setup parameters from argument vector.

Parameters
[in]argsVector containing arguments of input file.

Definition at line 36 of file EwaldSetup.cpp.

37{
38 bool argConsistent = false;
39 if (truncMethod ==
41 argConsistent = (args.size() == 1);
42 else
43 argConsistent = (args.size() >= 1 && args.size() <= 3);
44
45 if (!argConsistent)
46 throw runtime_error("ERROR: Number of arguments for ewald_prec is "
47 "not consistent with "
48 "ewald_truncation_error_method.");
49
50 GlobSett.precision = atof(args.at(0).c_str());
51 if (GlobSett.precision <= 0.0)
52 throw runtime_error("ERROR: Ewald precision must be positive.");
53
55 {
56 truncImpl.reset(new EwaldTruncJackson{});
57 }
58 else
59 {
60 if (args.size() >= 2)
61 GlobSett.maxCharge = atof(args.at(1).c_str());
62 if (args.size() == 2)
63 {
65 }
66 if (args.size() == 3)
67 {
68 params.rCut = atof(args.at(2).c_str());
70 }
71 }
72}
double rCut
Cutoff in real space.
Definition: IEwaldTrunc.h:42

References GlobSett, nnp::JACKSON_CATLOW, nnp::EwaldGlobalSettings::maxCharge, params, nnp::EwaldGlobalSettings::precision, nnp::EwaldParameters::rCut, truncImpl, and truncMethod.

Referenced by nnp::Mode::setupElectrostatics().

Here is the caller graph for this function:

◆ toNormalizedUnits()

void EwaldSetup::toNormalizedUnits ( double const  convEnergy,
double const  convLength 
)

Convert cutoff parameters to normalized units.

Parameters
convEnergyConversion factor for energy.
convLengthConversion factor for length.

Definition at line 74 of file EwaldSetup.cpp.

76{
78 {
79 // in KOLAFA_PERRAM method precision has unit of a force.
80 GlobSett.precision *= convEnergy / convLength;
81 GlobSett.fourPiEps /= convLength * convEnergy;
82 // GlobSett.maxQSigma is already normalized
83 params = params.toNormalizedUnits(convLength);
84 // Other variables are already normalized.
85 }
86}
@ KOLAFA_PERRAM
Method 1: Optimized in n2p2 (DOI: 10.1080/08927029208049126).
double fourPiEps
Multiplicative constant .
Definition: IEwaldTrunc.h:19
EwaldParameters toNormalizedUnits(double const convLength) const
Definition: IEwaldTrunc.h:57

References nnp::EwaldGlobalSettings::fourPiEps, GlobSett, nnp::KOLAFA_PERRAM, params, nnp::EwaldGlobalSettings::precision, nnp::EwaldParameters::toNormalizedUnits(), and truncMethod.

Referenced by nnp::Mode::setupElectrostatics().

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

◆ calculateParameters()

void EwaldSetup::calculateParameters ( double const  newVolume,
size_t const  newNumAtoms 
)

Compute eta, rCut and kCut.

Parameters
[in]newVolumeVolume of the real space cell.
[in]newNumAtomsNumber of atoms in system.

Definition at line 88 of file EwaldSetup.cpp.

89{
90 if (truncImpl == nullptr)
91 throw runtime_error("ERROR: Undefined Ewald truncation method.");
92 EwaldStructureData sData{volume, numAtoms};
93 truncImpl->calculateParameters(GlobSett, sData, params);
94}

References GlobSett, params, and truncImpl.

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

Here is the caller graph for this function:

◆ logEwaldCutoffs()

void EwaldSetup::logEwaldCutoffs ( Log log,
double const  lengthConversion 
) const

Use after Ewald summation!

Returns

Definition at line 95 of file EwaldSetup.cpp.

96{
98 {
99 EwaldParameters ewaldParams = params.toPhysicalUnits(lengthConversion);
100 log << "-----------------------------------------"
101 "--------------------------------------\n";
102 log << "Ewald parameters for this structure changed:\n";
103 log << strpr("Real space cutoff: %16.8E\n",
104 ewaldParams.rCut);
105 log << strpr("Reciprocal space cutoff: %16.8E\n",
106 ewaldParams.kCut);
107 log << strpr("Ewald screening parameter: %16.8E\n",
108 ewaldParams.eta);
109 if (!isEstimateReliable())
110 log << strpr("WARNING: Ewald truncation error estimate may not be "
111 "reliable, better compare it\n"
112 " with high accuracy settings.\n");
113 }
114}
bool publishedNewCutoffs() const
Definition: EwaldSetup.cpp:115
bool isEstimateReliable() const
Definition: EwaldSetup.cpp:119
string strpr(const char *format,...)
String version of printf function.
Definition: utility.cpp:90
EwaldParameters toPhysicalUnits(double const convLength) const
Definition: IEwaldTrunc.h:51
double eta
Width of the gaussian screening charges.
Definition: IEwaldTrunc.h:40
double kCut
Cutoff in reciprocal space.
Definition: IEwaldTrunc.h:44

References nnp::EwaldParameters::eta, isEstimateReliable(), nnp::EwaldParameters::kCut, params, publishedNewCutoffs(), nnp::EwaldParameters::rCut, nnp::strpr(), and nnp::EwaldParameters::toPhysicalUnits().

Referenced by nnp::Mode::logEwaldCutoffs(), and nnp::InterfaceLammps::process().

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

◆ publishedNewCutoffs()

bool EwaldSetup::publishedNewCutoffs ( ) const
private

Definition at line 115 of file EwaldSetup.cpp.

116{
117 return truncImpl->publishedNewCutoffs();
118}

References truncImpl.

Referenced by logEwaldCutoffs().

Here is the caller graph for this function:

◆ isEstimateReliable()

bool EwaldSetup::isEstimateReliable ( ) const
private

Definition at line 119 of file EwaldSetup.cpp.

120{
121 return truncImpl->isEstimateReliable(GlobSett, params);
122}

References GlobSett, params, and truncImpl.

Referenced by logEwaldCutoffs().

Here is the caller graph for this function:

Member Data Documentation

◆ params

◆ truncMethod

EWALDTruncMethod nnp::EwaldSetup::truncMethod
private

Method for determining real and k space cutoffs.

Definition at line 79 of file EwaldSetup.h.

Referenced by getTruncMethod(), readFromArgs(), setTruncMethod(), and toNormalizedUnits().

◆ GlobSett

◆ truncImpl

std::unique_ptr<IEwaldTrunc> nnp::EwaldSetup::truncImpl
private

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