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

A screening functions for use with electrostatics. More...

#include <ScreeningFunction.h>

Collaboration diagram for nnp::ScreeningFunction:

Public Member Functions

 ScreeningFunction ()
 Constructor, initializes to #CoreFunction::Type::POLY2. More...
 
void setCoreFunction (CoreFunction::Type const type)
 Set functional form of transition region. More...
 
void setCoreFunction (std::string const type)
 Set functional form of transition region. More...
 
void setInnerOuter (double inner, double outer)
 Set inner and outer limit of transition region. More...
 
CoreFunction::Type getCoreFunctionType () const
 Getter for #type. More...
 
double getInner () const
 Getter for inner. More...
 
double getOuter () const
 Getter for outer. More...
 
void changeLengthUnits (double const conv)
 Change length units of screening function. More...
 
double f (double r) const
 Screening function \(f_\text{screen}\). More...
 
double df (double r) const
 Derivative of screening function \(\frac{d f_\text{screen}}{d r}\). More...
 
void fdf (double r, double &fr, double &dfr) const
 Calculate screening function and derivative at once. More...
 
std::vector< std::string > info () const
 Get string with information of screening function. More...
 

Private Attributes

double inner
 Inner radius where transition region starts. More...
 
double outer
 Outer radius where transition region ends. More...
 
double scale
 Inverse width. More...
 
CoreFunction core
 Core function to be used in the transition region. More...
 

Detailed Description

A screening functions for use with electrostatics.

Definition at line 26 of file ScreeningFunction.h.

Constructor & Destructor Documentation

◆ ScreeningFunction()

ScreeningFunction::ScreeningFunction ( )

Constructor, initializes to #CoreFunction::Type::POLY2.

Definition at line 24 of file ScreeningFunction.cpp.

24 : inner(0.0),
25 outer(0.0),
26 scale(0.0)
27{
29}
void setType(Type const type)
Set function type.
double scale
Inverse width.
double inner
Inner radius where transition region starts.
CoreFunction core
Core function to be used in the transition region.
double outer
Outer radius where transition region ends.

References core, nnp::CoreFunction::POLY2, and nnp::CoreFunction::setType().

Here is the call graph for this function:

Member Function Documentation

◆ setCoreFunction() [1/2]

void nnp::ScreeningFunction::setCoreFunction ( CoreFunction::Type const  type)
inline

Set functional form of transition region.

Parameters
[in]typeType of core function to use.

Definition at line 113 of file ScreeningFunction.h.

114{
115 core.setType(type);
116
117 return;
118}

References core, and nnp::CoreFunction::setType().

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

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

◆ setCoreFunction() [2/2]

void nnp::ScreeningFunction::setCoreFunction ( std::string const  type)
inline

Set functional form of transition region.

Parameters
[in]typeStringType (string version) of core function to use.

Definition at line 120 of file ScreeningFunction.h.

121{
122 core.setType(typeString);
123
124 return;
125}

References core, and nnp::CoreFunction::setType().

Here is the call graph for this function:

◆ setInnerOuter()

void ScreeningFunction::setInnerOuter ( double  inner,
double  outer 
)

Set inner and outer limit of transition region.

Parameters
[in]innerInner radius where transition region begins.
[in]outerOuter radius where transition region ends.

Definition at line 31 of file ScreeningFunction.cpp.

32{
33 if (inner >= outer)
34 {
35 throw invalid_argument("ERROR: Inner radius of transition region >= "
36 "outer radius.\n");
37 }
38
39 this->inner = inner;
40 this->outer = outer;
41 this->scale = 1.0 / (outer - inner);
42
43 return;
44}

References inner, outer, and scale.

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

Here is the caller graph for this function:

◆ getCoreFunctionType()

CoreFunction::Type nnp::ScreeningFunction::getCoreFunctionType ( ) const
inline

Getter for #type.

Returns
Type used.

Definition at line 127 of file ScreeningFunction.h.

128{
129 return core.getType();
130}
Type getType() const
Getter for type.
Definition: CoreFunction.h:158

References core, and nnp::CoreFunction::getType().

Here is the call graph for this function:

◆ getInner()

double nnp::ScreeningFunction::getInner ( ) const
inline

Getter for inner.

Returns
Inner radius where transition region starts.

Definition at line 132 of file ScreeningFunction.h.

132{ return inner; }

References inner.

◆ getOuter()

double nnp::ScreeningFunction::getOuter ( ) const
inline

◆ changeLengthUnits()

void ScreeningFunction::changeLengthUnits ( double const  conv)

Change length units of screening function.

Parameters
convMultiplicative conversion factor.

Definition at line 46 of file ScreeningFunction.cpp.

47{
48 inner *= conv;
49 outer *= conv;
50 scale /= conv;
51}

References inner, outer, and scale.

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

Here is the caller graph for this function:

◆ f()

double nnp::ScreeningFunction::f ( double  r) const
inline

Screening function \(f_\text{screen}\).

Parameters
[in]rRadius argument.
Returns
Function value.

Definition at line 135 of file ScreeningFunction.h.

136{
137 if (r >= outer) return 1.0;
138 else if (r <= inner) return 0.0;
139 else return 1.0 - core.f((r - inner) * scale);
140}
double f(double x) const
Calculate function value .
Definition: CoreFunction.h:171

References core, nnp::CoreFunction::f(), inner, outer, and scale.

Referenced by nnp::Structure::calculateElectrostaticEnergyDerivatives(), and nnp::Structure::calculateScreeningEnergy().

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

◆ df()

double nnp::ScreeningFunction::df ( double  r) const
inline

Derivative of screening function \(\frac{d f_\text{screen}}{d r}\).

Parameters
[in]rRadius argument.
Returns
Value of function derivative.

Definition at line 142 of file ScreeningFunction.h.

143{
144 if (r >= outer || r <= inner) return 0.0;
145 else return -scale * core.df((r - inner) * scale);
146}
double df(double x) const
Calculate derivative of function at argument .
Definition: CoreFunction.h:179

References core, nnp::CoreFunction::df(), inner, outer, and scale.

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

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

◆ fdf()

void nnp::ScreeningFunction::fdf ( double  r,
double &  fr,
double &  dfr 
) const
inline

Calculate screening function and derivative at once.

Parameters
[in]rRadius argument.
[out]frScreening function value.
[out]dfrValue of screening function derivative.

Definition at line 148 of file ScreeningFunction.h.

149{
150 if (r >= outer)
151 {
152 fr = 1.0;
153 dfr = 0.0;
154 }
155 else if (r <= inner)
156 {
157 fr = 0.0;
158 dfr = 0.0;
159 }
160 else
161 {
162 core.fdf((r - inner) * scale, fr, dfr);
163 fr = 1.0 - fr;
164 dfr = -scale * dfr;
165 }
166
167 return;
168}
void fdf(double x, double &fx, double &dfx) const
Calculate function and derivative at once.
Definition: CoreFunction.h:189

References core, nnp::CoreFunction::fdf(), inner, outer, and scale.

Here is the call graph for this function:

◆ info()

vector< string > ScreeningFunction::info ( ) const

Get string with information of screening function.

Returns
Information string.

Definition at line 52 of file ScreeningFunction.cpp.

53{
54 vector<string> v;
55
56 v.push_back("Screening function information:\n");
57 v.push_back(strpr("Inner radius : %16.8E\n", inner));
58 v.push_back(strpr("Outer radius : %16.8E\n", outer));
59 v.push_back("Transition region functional form:\n");
60 v.push_back("x := (r - inner) / (outer - inner)\n");
61 v.push_back("fs(x) := 1 - f(x)\n");
62 vector<string> ci = core.info();
63 v.insert(v.end(), ci.begin(), ci.end());
64
65 return v;
66}
std::vector< std::string > info() const
Get string with formula of compact function.
string strpr(const char *format,...)
String version of printf function.
Definition: utility.cpp:90

References core, nnp::CoreFunction::info(), inner, outer, and nnp::strpr().

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

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

Member Data Documentation

◆ inner

double nnp::ScreeningFunction::inner
private

Inner radius where transition region starts.

Definition at line 99 of file ScreeningFunction.h.

Referenced by changeLengthUnits(), df(), f(), fdf(), getInner(), info(), and setInnerOuter().

◆ outer

double nnp::ScreeningFunction::outer
private

Outer radius where transition region ends.

Definition at line 101 of file ScreeningFunction.h.

Referenced by changeLengthUnits(), df(), f(), fdf(), getOuter(), info(), and setInnerOuter().

◆ scale

double nnp::ScreeningFunction::scale
private

Inverse width.

Definition at line 103 of file ScreeningFunction.h.

Referenced by changeLengthUnits(), df(), f(), fdf(), and setInnerOuter().

◆ core

CoreFunction nnp::ScreeningFunction::core
private

Core function to be used in the transition region.

Definition at line 105 of file ScreeningFunction.h.

Referenced by df(), f(), fdf(), getCoreFunctionType(), info(), ScreeningFunction(), and setCoreFunction().


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