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

Weighted angular symmetry function (type 13) More...

#include <SymFncExpAngnWeighted.h>

Inheritance diagram for nnp::SymFncExpAngnWeighted:
Collaboration diagram for nnp::SymFncExpAngnWeighted:

Public Member Functions

 SymFncExpAngnWeighted (ElementMap const &elementMap)
 Constructor, sets type = 13. More...
 
virtual bool operator== (SymFnc const &rhs) const
 Overload == operator. More...
 
virtual bool operator< (SymFnc const &rhs) const
 Overload < operator. More...
 
virtual void setParameters (std::string const &parameterString)
 Set symmetry function parameters. More...
 
virtual void changeLengthUnit (double convLength)
 Change length unit. More...
 
virtual std::string getSettingsLine () const
 Get settings file line from currently set parameters. More...
 
virtual void calculate (Atom &atom, bool const derivatives) const
 Calculate symmetry function for one atom. More...
 
virtual std::string parameterLine () const
 Give symmetry function parameters in one line. More...
 
virtual std::vector< std::string > parameterInfo () const
 Get description with parameter names and values. More...
 
bool getUseIntegerPow () const
 Get private useIntegerPow member variable. More...
 
int getZetaInt () const
 Get private zetaInt member variable. More...
 
double getEta () const
 Get private eta member variable. More...
 
double getRs () const
 Get private rs member variable. More...
 
double getLambda () const
 Get private lambda member variable. More...
 
double getZeta () const
 Get private zeta member variable. More...
 
virtual double calculateRadialPart (double distance) const
 Calculate (partial) symmetry function value for one given distance. More...
 
virtual double calculateAngularPart (double angle) const
 Calculate (partial) symmetry function value for one given angle. More...
 
virtual bool checkRelevantElement (std::size_t index) const
 Check whether symmetry function is relevant for given element. More...
 
virtual std::vector< std::string > getCacheIdentifiers () const
 Get unique cache identifiers. More...
 
- Public Member Functions inherited from nnp::SymFncBaseCutoff
virtual std::vector< std::string > parameterInfo () const
 Get description with parameter names and values. More...
 
void setCutoffFunction (CutoffFunction::CutoffType cutoffType, double cutoffAlpha)
 Set cutoff function type and parameter. More...
 
double getCutoffAlpha () const
 Get private cutoffAlpha member variable. More...
 
std::string getSubtype () const
 Get private subtype member variable. More...
 
CutoffFunction::CutoffType getCutoffType () const
 Get private cutoffType member variable. More...
 
- Public Member Functions inherited from nnp::SymFnc
virtual ~SymFnc ()
 Virtual destructor. More...
 
virtual bool operator== (SymFnc const &rhs) const =0
 Overload == operator. More...
 
virtual bool operator< (SymFnc const &rhs) const =0
 Overload < operator. More...
 
bool operator!= (SymFnc const &rhs) const
 Overload != operator. More...
 
bool operator> (SymFnc const &rhs) const
 Overload > operator. More...
 
bool operator<= (SymFnc const &rhs) const
 Overload <= operator. More...
 
bool operator>= (SymFnc const &rhs) const
 Overload >= operator. More...
 
virtual void setParameters (std::string const &parameterString)=0
 Set parameters. More...
 
virtual void changeLengthUnit (double convLength)=0
 Change length unit. More...
 
virtual std::string getSettingsLine () const =0
 Get settings file line from currently set parameters. More...
 
virtual void calculate (Atom &atom, bool const derivatives) const =0
 Calculate symmetry function for one atom. More...
 
virtual std::string parameterLine () const =0
 Give symmetry function parameters in one line. More...
 
virtual std::vector< std::string > parameterInfo () const
 Get description with parameter names and values. More...
 
void setScalingType (ScalingType scalingType, std::string statisticsLine, double Smin, double Smax)
 Set symmetry function scaling type. More...
 
double scale (double value) const
 Apply symmetry function scaling and/or centering. More...
 
double unscale (double value) const
 Undo symmetry function scaling and/or centering. More...
 
std::size_t getType () const
 Get private type member variable. More...
 
std::size_t getIndex () const
 Get private index member variable. More...
 
std::size_t getLineNumber () const
 Get private lineNumber member variable. More...
 
std::size_t getEc () const
 Get private ec member variable. More...
 
std::size_t getMinNeighbors () const
 Get private minNeighbors member variable. More...
 
double getRc () const
 Get private rc member variable. More...
 
double getGmin () const
 Get private Gmin member variable. More...
 
double getGmax () const
 Get private Gmax member variable. More...
 
double getScalingFactor () const
 Get private scalingFactor member variable. More...
 
double getConvLength () const
 Get private convLength member variable. More...
 
std::set< std::string > getParameters () const
 Get private parameters member variable. More...
 
std::vector< std::size_t > getIndexPerElement () const
 Get private indexPerElement member variable. More...
 
void setIndex (std::size_t index)
 Set private index member variable. More...
 
void setIndexPerElement (std::size_t elementIndex, std::size_t index)
 Set private indexPerElement member variable. More...
 
void setLineNumber (std::size_t lineNumber)
 Set line number. More...
 
std::string scalingLine () const
 Get string with scaling information. More...
 
virtual double calculateRadialPart (double distance) const =0
 Calculate (partial) symmetry function value for one given distance. More...
 
virtual double calculateAngularPart (double angle) const =0
 Calculate (partial) symmetry function value for one given angle. More...
 
virtual bool checkRelevantElement (std::size_t index) const =0
 Check whether symmetry function is relevant for given element. More...
 
virtual std::vector< std::string > getCacheIdentifiers () const
 Get unique cache identifiers. More...
 
void addCacheIndex (std::size_t element, std::size_t cacheIndex, std::string cacheIdentifier)
 Add one cache index for given neighbor element and check identifier. More...
 
std::vector< std::vector< std::size_t > > getCacheIndices () const
 Getter for cacheIndices. More...
 

Private Attributes

bool useIntegerPow
 Whether to use integer version of power function (faster). More...
 
int zetaInt
 Integer version of \(\zeta\). More...
 
double eta
 Width \(\eta\) of gaussian. More...
 
double rs
 Shift \(r_s\) of gaussian. More...
 
double lambda
 Cosine shift factor. More...
 
double zeta
 Exponent \(\zeta\) of cosine term. More...
 

Additional Inherited Members

- Public Types inherited from nnp::SymFnc
enum  ScalingType {
  ST_NONE , ST_SCALE , ST_CENTER , ST_SCALECENTER ,
  ST_SCALESIGMA
}
 List of available scaling types. More...
 
- Protected Types inherited from nnp::SymFnc
typedef std::map< std::string, std::pair< std::string, std::string > > PrintFormat
 
typedef std::vector< std::string > PrintOrder
 
- Protected Member Functions inherited from nnp::SymFncBaseCutoff
 SymFncBaseCutoff (std::size_t type, ElementMap const &)
 Constructor, initializes type. More...
 
- Protected Member Functions inherited from nnp::SymFnc
 SymFnc (std::size_t type, ElementMap const &)
 Constructor, initializes type. More...
 
std::string getPrintFormat () const
 Generate format string for symmetry function parameter printing. More...
 
- Static Protected Member Functions inherited from nnp::SymFnc
static PrintFormat const initializePrintFormat ()
 Initialize static print format map for all possible parameters. More...
 
static PrintOrder const initializePrintOrder ()
 Initialize static print order vector for all possible parameters. More...
 
- Protected Attributes inherited from nnp::SymFncBaseCutoff
double cutoffAlpha
 Cutoff parameter \(\alpha\). More...
 
std::string subtype
 Subtype string (specifies cutoff type). More...
 
CutoffFunction fc
 Cutoff function used by this symmetry function. More...
 
CutoffFunction::CutoffType cutoffType
 Cutoff type used by this symmetry function. More...
 
- Protected Attributes inherited from nnp::SymFnc
std::size_t type
 Symmetry function type. More...
 
ElementMap elementMap
 Copy of element map. More...
 
std::size_t index
 Symmetry function index (per element). More...
 
std::size_t lineNumber
 Line number. More...
 
std::size_t ec
 Element index of center atom. More...
 
std::size_t minNeighbors
 Minimum number of neighbors required. More...
 
double Smin
 Minimum for scaling range. More...
 
double Smax
 Maximum for scaling range. More...
 
double Gmin
 Minimum unscaled symmetry function value. More...
 
double Gmax
 Maximum unscaled symmetry function value. More...
 
double Gmean
 Mean unscaled symmetry function value. More...
 
double Gsigma
 Sigma of unscaled symmetry function values. More...
 
double rc
 Cutoff radius \(r_c\). More...
 
double scalingFactor
 Scaling factor. More...
 
double convLength
 Data set normalization length conversion factor. More...
 
ScalingType scalingType
 Symmetry function scaling type used by this symmetry function. More...
 
std::set< std::string > parameters
 Set with symmetry function parameter IDs (lookup for printing). More...
 
std::vector< std::size_t > indexPerElement
 Per-element index for derivative memory in Atom::Neighbor::dGdr arrays. More...
 
std::vector< std::vector< std::size_t > > cacheIndices
 Cache indices for each element. More...
 
- Static Protected Attributes inherited from nnp::SymFnc
static std::size_t const sfinfoWidth = 12
 Width of the SFINFO parameter description field (see parameterInfo()). More...
 
static PrintFormat const printFormat = initializePrintFormat()
 Map of parameter format strings and empty strings. More...
 
static PrintOrder const printOrder = initializePrintOrder()
 Vector of parameters in order of printing. More...
 

Detailed Description

Weighted angular symmetry function (type 13)

\[ G^{13}_i = 2^{1-\zeta} \sum_{\substack{j,k\neq i \\ j < k}} Z_j Z_k \, \left( 1 + \lambda \cos \theta_{ijk} \right)^\zeta \mathrm{e}^{-\eta \left[ (r_{ij} - r_s)^2 + (r_{ik} - r_s)^2 + (r_{jk} - r_s)^2 \right] } f_c(r_{ij}) f_c(r_{ik}) f_c(r_{jk}) \]

Parameter string:

<element-central> 13 <eta> <rshift> <lambda> <zeta> <rcutoff>
double lambda
Cosine shift factor.
double eta
Width of gaussian.
double zeta
Exponent of cosine term.

where

  • <element-central> ..... element symbol of central atom
  • <eta> ................. \(\eta\)
  • <rshift> .............. \(r_s\)
  • <lambda> .............. \(\lambda\)
  • <zeta> ................ \(\zeta\)
  • <rcutoff> ............. \(r_c\)

Definition at line 53 of file SymFncExpAngnWeighted.h.

Constructor & Destructor Documentation

◆ SymFncExpAngnWeighted()

SymFncExpAngnWeighted::SymFncExpAngnWeighted ( ElementMap const &  elementMap)

Constructor, sets type = 13.

Definition at line 30 of file SymFncExpAngnWeighted.cpp.

30 :
32 useIntegerPow(false),
33 zetaInt (0 ),
34 eta (0.0 ),
35 rs (0.0 ),
36 lambda (0.0 ),
37 zeta (0.0 )
38{
39 minNeighbors = 2;
40 parameters.insert("rs/rl");
41 parameters.insert("eta");
42 parameters.insert("zeta");
43 parameters.insert("lambda");
44}
SymFncBaseCutoff(std::size_t type, ElementMap const &)
Constructor, initializes type.
int zetaInt
Integer version of .
double rs
Shift of gaussian.
bool useIntegerPow
Whether to use integer version of power function (faster).
std::set< std::string > parameters
Set with symmetry function parameter IDs (lookup for printing).
Definition: SymFnc.h:300
ElementMap elementMap
Copy of element map.
Definition: SymFnc.h:270
std::size_t minNeighbors
Minimum number of neighbors required.
Definition: SymFnc.h:278

References nnp::SymFnc::minNeighbors, and nnp::SymFnc::parameters.

Member Function Documentation

◆ operator==()

bool SymFncExpAngnWeighted::operator== ( SymFnc const &  rhs) const
virtual

Overload == operator.

Implements nnp::SymFnc.

Definition at line 46 of file SymFncExpAngnWeighted.cpp.

47{
48 if (ec != rhs.getEc() ) return false;
49 if (type != rhs.getType()) return false;
50 SymFncExpAngnWeighted const& c =
51 dynamic_cast<SymFncExpAngnWeighted const&>(rhs);
52 if (cutoffType != c.cutoffType ) return false;
53 if (cutoffAlpha != c.cutoffAlpha) return false;
54 if (rc != c.rc ) return false;
55 if (eta != c.eta ) return false;
56 if (rs != c.rs ) return false;
57 if (zeta != c.zeta ) return false;
58 if (lambda != c.lambda ) return false;
59 return true;
60}
CutoffFunction::CutoffType cutoffType
Cutoff type used by this symmetry function.
double cutoffAlpha
Cutoff parameter .
Weighted angular symmetry function (type 13)
std::size_t type
Symmetry function type.
Definition: SymFnc.h:268
double rc
Cutoff radius .
Definition: SymFnc.h:292
std::size_t ec
Element index of center atom.
Definition: SymFnc.h:276

References nnp::SymFncBaseCutoff::cutoffAlpha, nnp::SymFncBaseCutoff::cutoffType, nnp::SymFnc::ec, eta, nnp::SymFnc::getEc(), nnp::SymFnc::getType(), lambda, nnp::SymFnc::rc, rs, nnp::SymFnc::type, and zeta.

Here is the call graph for this function:

◆ operator<()

bool SymFncExpAngnWeighted::operator< ( SymFnc const &  rhs) const
virtual

Overload < operator.

Implements nnp::SymFnc.

Definition at line 62 of file SymFncExpAngnWeighted.cpp.

63{
64 if (ec < rhs.getEc() ) return true;
65 else if (ec > rhs.getEc() ) return false;
66 if (type < rhs.getType()) return true;
67 else if (type > rhs.getType()) return false;
68 SymFncExpAngnWeighted const& c =
69 dynamic_cast<SymFncExpAngnWeighted const&>(rhs);
70 if (cutoffType < c.cutoffType ) return true;
71 else if (cutoffType > c.cutoffType ) return false;
72 if (cutoffAlpha < c.cutoffAlpha) return true;
73 else if (cutoffAlpha > c.cutoffAlpha) return false;
74 if (rc < c.rc ) return true;
75 else if (rc > c.rc ) return false;
76 if (eta < c.eta ) return true;
77 else if (eta > c.eta ) return false;
78 if (rs < c.rs ) return true;
79 else if (rs > c.rs ) return false;
80 if (zeta < c.zeta ) return true;
81 else if (zeta > c.zeta ) return false;
82 if (lambda < c.lambda ) return true;
83 else if (lambda > c.lambda ) return false;
84 return false;
85}

References nnp::SymFncBaseCutoff::cutoffAlpha, nnp::SymFncBaseCutoff::cutoffType, nnp::SymFnc::ec, eta, nnp::SymFnc::getEc(), nnp::SymFnc::getType(), lambda, nnp::SymFnc::rc, rs, nnp::SymFnc::type, and zeta.

Here is the call graph for this function:

◆ setParameters()

void SymFncExpAngnWeighted::setParameters ( std::string const &  parameterString)
virtual

Set symmetry function parameters.

Parameters
[in]parameterStringString containing weighted angular symmetry function parameters.

Implements nnp::SymFnc.

Definition at line 87 of file SymFncExpAngnWeighted.cpp.

88{
89 vector<string> splitLine = split(reduce(parameterString));
90
91 if (type != (size_t)atoi(splitLine.at(1).c_str()))
92 {
93 throw runtime_error("ERROR: Incorrect symmetry function type.\n");
94 }
95
96 ec = elementMap[splitLine.at(0)];
97 eta = atof(splitLine.at(2).c_str());
98 rs = atof(splitLine.at(3).c_str());
99 lambda = atof(splitLine.at(4).c_str());
100 zeta = atof(splitLine.at(5).c_str());
101 rc = atof(splitLine.at(6).c_str());
102
105
106 zetaInt = round(zeta);
107 if (fabs(zeta - zetaInt) <= numeric_limits<double>::min())
108 {
109 useIntegerPow = true;
110 }
111 else
112 {
113 useIntegerPow = false;
114 }
115
116 return;
117}
void setCutoffParameter(double const alpha)
Set parameter for polynomial cutoff function (CT_POLY).
void setCutoffRadius(double const cutoffRadius)
Set cutoff radius.
CutoffFunction fc
Cutoff function used by this symmetry function.
vector< string > split(string const &input, char delimiter)
Split string at each delimiter.
Definition: utility.cpp:33
string reduce(string const &line, string const &whitespace, string const &fill)
Replace multiple whitespaces with fill.
Definition: utility.cpp:60

References nnp::SymFncBaseCutoff::cutoffAlpha, nnp::SymFnc::ec, nnp::SymFnc::elementMap, eta, nnp::SymFncBaseCutoff::fc, lambda, nnp::SymFnc::rc, nnp::reduce(), rs, nnp::CutoffFunction::setCutoffParameter(), nnp::CutoffFunction::setCutoffRadius(), nnp::split(), nnp::SymFnc::type, useIntegerPow, zeta, and zetaInt.

Here is the call graph for this function:

◆ changeLengthUnit()

void SymFncExpAngnWeighted::changeLengthUnit ( double  convLength)
virtual

Change length unit.

Parameters
[in]convLengthMultiplicative length unit conversion factor.

Implements nnp::SymFnc.

Definition at line 119 of file SymFncExpAngnWeighted.cpp.

120{
121 this->convLength = convLength;
123 rs *= convLength;
124 rc *= convLength;
125
128
129 return;
130}
double convLength
Data set normalization length conversion factor.
Definition: SymFnc.h:296

References nnp::SymFnc::convLength, nnp::SymFncBaseCutoff::cutoffAlpha, eta, nnp::SymFncBaseCutoff::fc, nnp::SymFnc::rc, rs, nnp::CutoffFunction::setCutoffParameter(), and nnp::CutoffFunction::setCutoffRadius().

Here is the call graph for this function:

◆ getSettingsLine()

string SymFncExpAngnWeighted::getSettingsLine ( ) const
virtual

Get settings file line from currently set parameters.

Returns
Settings file string ("symfunction_short ...").

Implements nnp::SymFnc.

Definition at line 132 of file SymFncExpAngnWeighted.cpp.

133{
134 string s = strpr("symfunction_short %2s %2zu %16.8E %16.8E %16.8E "
135 "%16.8E %16.8E\n",
136 elementMap[ec].c_str(),
137 type,
139 rs / convLength,
140 lambda,
141 zeta,
142 rc / convLength);
143
144 return s;
145}
string strpr(const char *format,...)
String version of printf function.
Definition: utility.cpp:90

References nnp::SymFnc::convLength, nnp::SymFnc::ec, nnp::SymFnc::elementMap, eta, lambda, nnp::SymFnc::rc, rs, nnp::strpr(), nnp::SymFnc::type, and zeta.

Here is the call graph for this function:

◆ calculate()

void SymFncExpAngnWeighted::calculate ( Atom atom,
bool const  derivatives 
) const
virtual

Calculate symmetry function for one atom.

Parameters
[in,out]atomAtom for which the symmetry function is caluclated.
[in]derivativesIf also symmetry function derivatives will be calculated and saved.

Implements nnp::SymFnc.

Definition at line 147 of file SymFncExpAngnWeighted.cpp.

148{
149 double const pnorm = pow(2.0, 1.0 - zeta);
150 double const pzl = zeta * lambda;
151 double const rc2 = rc * rc;
152 double result = 0.0;
153
154 size_t numNeighbors = atom.numNeighbors;
155 // Prevent problematic condition in loop test below (j < numNeighbors - 1).
156 if (numNeighbors == 0) numNeighbors = 1;
157
158 for (size_t j = 0; j < numNeighbors - 1; j++)
159 {
160 Atom::Neighbor& nj = atom.neighbors[j];
161 size_t const nej = nj.element;
162 double const rij = nj.d;
163 if (rij < rc)
164 {
165 double const r2ij = rij * rij;
166
167 // Calculate cutoff function and derivative.
168 double pfcij;
169 double pdfcij;
170#ifndef N2P2_NO_SF_CACHE
171 if (cacheIndices[nej].size() == 0) fc.fdf(rij, pfcij, pdfcij);
172 else
173 {
174 double& cfc = nj.cache[cacheIndices[nej][0]];
175 double& cdfc = nj.cache[cacheIndices[nej][1]];
176 if (cfc < 0) fc.fdf(rij, cfc, cdfc);
177 pfcij = cfc;
178 pdfcij = cdfc;
179 }
180#else
181 fc.fdf(rij, pfcij, pdfcij);
182#endif
183 for (size_t k = j + 1; k < numNeighbors; k++)
184 {
185 Atom::Neighbor& nk = atom.neighbors[k];
186 size_t const nek = nk.element;
187 double const rik = nk.d;
188 if (rik < rc)
189 {
190 Vec3D drjk = nk.dr - nj.dr;
191 double rjk = drjk.norm2();;
192 if (rjk < rc2)
193 {
194 // Energy calculation.
195 double pfcik;
196 double pdfcik;
197#ifndef N2P2_NO_SF_CACHE
198 if (cacheIndices[nej].size() == 0)
199 {
200 fc.fdf(rik, pfcik, pdfcik);
201 }
202 else
203 {
204 double& cfc = nk.cache[cacheIndices[nek][0]];
205 double& cdfc = nk.cache[cacheIndices[nek][1]];
206 if (cfc < 0) fc.fdf(rik, cfc, cdfc);
207 pfcik = cfc;
208 pdfcik = cdfc;
209 }
210#else
211 fc.fdf(rik, pfcik, pdfcik);
212#endif
213 rjk = sqrt(rjk);
214 double pfcjk;
215 double pdfcjk;
216 fc.fdf(rjk, pfcjk, pdfcjk);
217
218 Vec3D drij = nj.dr;
219 Vec3D drik = nk.dr;
220 double costijk = drij * drik;;
221 double rinvijik = 1.0 / rij / rik;
222 costijk *= rinvijik;
223
224 double const pfc = pfcij * pfcik * pfcjk;
225 double const r2ik = rik * rik;
226 double const rijs = rij - rs;
227 double const riks = rik - rs;
228 double const rjks = rjk - rs;
229 double const pexp = elementMap.atomicNumber(nej)
231 * exp(-eta * (rijs * rijs +
232 riks * riks +
233 rjks * rjks));
234 double const plambda = 1.0 + lambda * costijk;
235 double fg = pexp;
236 if (plambda <= 0.0) fg = 0.0;
237 else
238 {
239 if (useIntegerPow)
240 {
241 fg *= pow_int(plambda, zetaInt - 1);
242 }
243 else
244 {
245 fg *= pow(plambda, zeta - 1.0);
246 }
247 }
248 result += fg * plambda * pfc;
249
250 // Force calculation.
251 if (!derivatives) continue;
252 fg *= pnorm;
253 rinvijik *= pzl;
254 costijk *= pzl;
255 double const p2etapl = 2.0 * eta * plambda;
256 double const p1 = fg * (pfc * (rinvijik - costijk
257 / r2ij - p2etapl * rijs / rij) + pfcik
258 * pfcjk * pdfcij * plambda / rij);
259 double const p2 = fg * (pfc * (rinvijik - costijk
260 / r2ik - p2etapl * riks / rik) + pfcij
261 * pfcjk * pdfcik * plambda / rik);
262 double const p3 = fg * (pfc * (rinvijik + p2etapl
263 * rjks / rjk) - pfcij * pfcik * pdfcjk
264 * plambda / rjk);
265 drij *= p1 * scalingFactor;
266 drik *= p2 * scalingFactor;
267 drjk *= p3 * scalingFactor;
268
269 // Save force contributions in Atom storage.
270 atom.dGdr[index] += drij + drik;
271#ifndef N2P2_FULL_SFD_MEMORY
272 nj.dGdr[indexPerElement[nj.element]] -= drij + drjk;
273 nk.dGdr[indexPerElement[nk.element]] -= drik - drjk;
274#else
275 nj.dGdr[index] -= drij + drjk;
276 nk.dGdr[index] -= drik - drjk;
277#endif
278 } // rjk <= rc
279 } // rik <= rc
280 } // k
281 } // rij <= rc
282 } // j
283 result *= pnorm;
284
285 atom.G[index] = scale(result);
286
287 return;
288}
void fdf(double r, double &fc, double &dfc) const
Calculate cutoff function and derivative .
std::size_t atomicNumber(std::size_t index) const
Get atomic number from element index.
Definition: ElementMap.h:145
std::size_t index
Symmetry function index (per element).
Definition: SymFnc.h:272
double scalingFactor
Scaling factor.
Definition: SymFnc.h:294
std::vector< std::vector< std::size_t > > cacheIndices
Cache indices for each element.
Definition: SymFnc.h:306
double scale(double value) const
Apply symmetry function scaling and/or centering.
Definition: SymFnc.cpp:169
std::vector< std::size_t > indexPerElement
Per-element index for derivative memory in Atom::Neighbor::dGdr arrays.
Definition: SymFnc.h:302
double pow_int(double x, int n)
Integer version of power function, "fast exponentiation algorithm".
Definition: utility.cpp:285
Struct to store information on neighbor atoms.
Definition: Atom.h:35
std::vector< double > cache
Symmetry function cache (e.g. for cutoffs, compact functions).
Definition: Atom.h:48
std::size_t element
Element index of neighbor atom.
Definition: Atom.h:41
double d
Distance to neighbor atom.
Definition: Atom.h:43
Vec3D dr
Distance vector to neighbor atom.
Definition: Atom.h:45
std::vector< Vec3D > dGdr
Derivatives of symmetry functions with respect to neighbor coordinates.
Definition: Atom.h:59
std::vector< Neighbor > neighbors
Neighbor array (maximum number defined in macros.h.
Definition: Atom.h:148
std::vector< Vec3D > dGdr
Derivative of symmetry functions with respect to this atom's coordinates.
Definition: Atom.h:146
std::vector< double > G
Symmetry function values.
Definition: Atom.h:134
std::size_t numNeighbors
Total number of neighbors.
Definition: Atom.h:106
Vector in 3 dimensional real space.
Definition: Vec3D.h:29
double norm2() const
Calculate square of norm of vector.
Definition: Vec3D.h:261

References nnp::ElementMap::atomicNumber(), nnp::Atom::Neighbor::cache, nnp::SymFnc::cacheIndices, nnp::Atom::Neighbor::d, nnp::Atom::Neighbor::dGdr, nnp::Atom::dGdr, nnp::Atom::Neighbor::dr, nnp::Atom::Neighbor::element, nnp::SymFnc::elementMap, eta, nnp::SymFncBaseCutoff::fc, nnp::CutoffFunction::fdf(), nnp::Atom::G, nnp::SymFnc::index, nnp::SymFnc::indexPerElement, lambda, nnp::Atom::neighbors, nnp::Vec3D::norm2(), nnp::Atom::numNeighbors, nnp::pow_int(), nnp::SymFnc::rc, rs, nnp::SymFnc::scale(), nnp::SymFnc::scalingFactor, useIntegerPow, zeta, and zetaInt.

Here is the call graph for this function:

◆ parameterLine()

string SymFncExpAngnWeighted::parameterLine ( ) const
virtual

Give symmetry function parameters in one line.

Returns
String containing symmetry function parameter values.

Implements nnp::SymFnc.

Definition at line 290 of file SymFncExpAngnWeighted.cpp.

291{
292 return strpr(getPrintFormat().c_str(),
293 index + 1,
294 elementMap[ec].c_str(),
295 type,
296 subtype.c_str(),
298 rs / convLength,
299 rc / convLength,
300 lambda,
301 zeta,
303 lineNumber + 1);
304}
std::string subtype
Subtype string (specifies cutoff type).
std::size_t lineNumber
Line number.
Definition: SymFnc.h:274
std::string getPrintFormat() const
Generate format string for symmetry function parameter printing.
Definition: SymFnc.cpp:285

References nnp::SymFnc::convLength, nnp::SymFncBaseCutoff::cutoffAlpha, nnp::SymFnc::ec, nnp::SymFnc::elementMap, eta, nnp::SymFnc::getPrintFormat(), nnp::SymFnc::index, lambda, nnp::SymFnc::lineNumber, nnp::SymFnc::rc, rs, nnp::strpr(), nnp::SymFncBaseCutoff::subtype, nnp::SymFnc::type, and zeta.

Here is the call graph for this function:

◆ parameterInfo()

vector< string > SymFncExpAngnWeighted::parameterInfo ( ) const
virtual

Get description with parameter names and values.

Returns
Vector of parameter description strings.

Reimplemented from nnp::SymFncBaseCutoff.

Definition at line 306 of file SymFncExpAngnWeighted.cpp.

307{
308 vector<string> v = SymFncBaseCutoff::parameterInfo();
309 string s;
310 size_t w = sfinfoWidth;
311
312 s = "eta";
313 v.push_back(strpr((pad(s, w) + "%14.8E").c_str(),
315 s = "lambda";
316 v.push_back(strpr((pad(s, w) + "%14.8E").c_str(), lambda));
317 s = "zeta";
318 v.push_back(strpr((pad(s, w) + "%14.8E").c_str(), zeta));
319 s = "rs";
320 v.push_back(strpr((pad(s, w) + "%14.8E").c_str(), rs / convLength));
321
322 return v;
323}
virtual std::vector< std::string > parameterInfo() const
Get description with parameter names and values.
static std::size_t const sfinfoWidth
Width of the SFINFO parameter description field (see parameterInfo()).
Definition: SymFnc.h:309
string pad(string const &input, size_t num, char fill, bool right)
Definition: utility.cpp:79

References nnp::SymFnc::convLength, eta, lambda, nnp::pad(), nnp::SymFncBaseCutoff::parameterInfo(), rs, nnp::SymFnc::sfinfoWidth, nnp::strpr(), and zeta.

Here is the call graph for this function:

◆ getUseIntegerPow()

bool nnp::SymFncExpAngnWeighted::getUseIntegerPow ( ) const
inline

Get private useIntegerPow member variable.

Definition at line 165 of file SymFncExpAngnWeighted.h.

166{
167 return useIntegerPow;
168}

References useIntegerPow.

◆ getZetaInt()

int nnp::SymFncExpAngnWeighted::getZetaInt ( ) const
inline

Get private zetaInt member variable.

Definition at line 170 of file SymFncExpAngnWeighted.h.

170{ return zetaInt; }

References zetaInt.

◆ getEta()

double nnp::SymFncExpAngnWeighted::getEta ( ) const
inline

Get private eta member variable.

Definition at line 171 of file SymFncExpAngnWeighted.h.

171{ return eta; }

References eta.

◆ getRs()

double nnp::SymFncExpAngnWeighted::getRs ( ) const
inline

Get private rs member variable.

Definition at line 172 of file SymFncExpAngnWeighted.h.

172{ return rs; }

References rs.

◆ getLambda()

double nnp::SymFncExpAngnWeighted::getLambda ( ) const
inline

Get private lambda member variable.

Definition at line 173 of file SymFncExpAngnWeighted.h.

173{ return lambda; }

References lambda.

◆ getZeta()

double nnp::SymFncExpAngnWeighted::getZeta ( ) const
inline

Get private zeta member variable.

Definition at line 174 of file SymFncExpAngnWeighted.h.

174{ return zeta; }

References zeta.

◆ calculateRadialPart()

double SymFncExpAngnWeighted::calculateRadialPart ( double  distance) const
virtual

Calculate (partial) symmetry function value for one given distance.

Parameters
[in]distanceDistance between two atoms.
Returns
\(\left(e^{-\eta (r - r_s)^2} f_c(r)\right)^3\)

Implements nnp::SymFnc.

Definition at line 325 of file SymFncExpAngnWeighted.cpp.

326{
327 double const& r = distance * convLength;
328 double const p = exp(-eta * (r - rs) * (r - rs)) * fc.f(r);
329
330 return p * p * p;
331}
double f(double r) const
Cutoff function .
size_t p
Definition: nnp-cutoff.cpp:33

References nnp::SymFnc::convLength, eta, nnp::CutoffFunction::f(), nnp::SymFncBaseCutoff::fc, p, and rs.

Here is the call graph for this function:

◆ calculateAngularPart()

double SymFncExpAngnWeighted::calculateAngularPart ( double  angle) const
virtual

Calculate (partial) symmetry function value for one given angle.

Parameters
[in]angleAngle between triplet of atoms (in radians).
Returns
\(1\)

Implements nnp::SymFnc.

Definition at line 333 of file SymFncExpAngnWeighted.cpp.

334{
335 return 2.0 * pow((1.0 + lambda * cos(angle)) / 2.0, zeta);
336}

References lambda, and zeta.

◆ checkRelevantElement()

bool SymFncExpAngnWeighted::checkRelevantElement ( std::size_t  index) const
virtual

Check whether symmetry function is relevant for given element.

Parameters
[in]indexIndex of given element.
Returns
True if symmetry function is sensitive to given element, false otherwise.

Implements nnp::SymFnc.

Definition at line 338 of file SymFncExpAngnWeighted.cpp.

339{
340 return true;
341}

◆ getCacheIdentifiers()

vector< string > SymFncExpAngnWeighted::getCacheIdentifiers ( ) const
virtual

Get unique cache identifiers.

Returns
Vector of string identifying the type of cache this symmetry function requires.

Reimplemented from nnp::SymFnc.

Definition at line 344 of file SymFncExpAngnWeighted.cpp.

345{
346 vector<string> v;
347 string s("");
348
349 s += subtype;
350 s += " ";
351 s += strpr("alpha = %16.8E", cutoffAlpha);
352 s += " ";
353 s += strpr("rc = %16.8E", rc / convLength);
354
355 for (size_t i = 0; i < elementMap.size(); ++i)
356 {
357 v.push_back(strpr("%zu f ", i) + s);
358 v.push_back(strpr("%zu df ", i) + s);
359 }
360
361 return v;
362}
std::size_t size() const
Get element map size.
Definition: ElementMap.h:140

References nnp::SymFnc::convLength, nnp::SymFncBaseCutoff::cutoffAlpha, nnp::SymFnc::elementMap, nnp::SymFnc::rc, nnp::ElementMap::size(), nnp::strpr(), and nnp::SymFncBaseCutoff::subtype.

Here is the call graph for this function:

Member Data Documentation

◆ useIntegerPow

bool nnp::SymFncExpAngnWeighted::useIntegerPow
private

Whether to use integer version of power function (faster).

Definition at line 148 of file SymFncExpAngnWeighted.h.

Referenced by calculate(), getUseIntegerPow(), and setParameters().

◆ zetaInt

int nnp::SymFncExpAngnWeighted::zetaInt
private

Integer version of \(\zeta\).

Definition at line 150 of file SymFncExpAngnWeighted.h.

Referenced by calculate(), getZetaInt(), and setParameters().

◆ eta

double nnp::SymFncExpAngnWeighted::eta
private

◆ rs

double nnp::SymFncExpAngnWeighted::rs
private

◆ lambda

double nnp::SymFncExpAngnWeighted::lambda
private

◆ zeta

double nnp::SymFncExpAngnWeighted::zeta
private

Exponent \(\zeta\) of cosine term.

Definition at line 158 of file SymFncExpAngnWeighted.h.

Referenced by calculate(), calculateAngularPart(), getSettingsLine(), getZeta(), operator<(), operator==(), parameterInfo(), parameterLine(), and setParameters().


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