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

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

#include <SymGrpExpAngnWeighted.h>

Inheritance diagram for nnp::SymGrpExpAngnWeighted:
Collaboration diagram for nnp::SymGrpExpAngnWeighted:

Public Member Functions

 SymGrpExpAngnWeighted (ElementMap const &elementMap)
 Constructor, sets type = 13. More...
 
virtual bool operator== (SymGrp const &rhs) const
 Overload == operator. More...
 
virtual bool operator< (SymGrp const &rhs) const
 Overload < operator. More...
 
virtual bool addMember (SymFnc const *const symmetryFunction)
 Potentially add a member to group. More...
 
virtual void sortMembers ()
 Sort member symmetry functions. More...
 
virtual void setScalingFactors ()
 Fill scalingFactors with values from member symmetry functions. More...
 
virtual void calculate (Atom &atom, bool const derivatives) const
 Calculate all symmetry functions of this group for one atom. More...
 
virtual std::vector< std::string > parameterLines () const
 Give symmetry function group parameters on multiple lines. More...
 
- Public Member Functions inherited from nnp::SymGrpBaseCutoff
double getRc () const
 Get private rc member variable. More...
 
- Public Member Functions inherited from nnp::SymGrp
virtual ~SymGrp ()
 Virtual destructor. More...
 
virtual bool operator== (SymGrp const &rhs) const =0
 Overload == operator. More...
 
virtual bool operator< (SymGrp const &rhs) const =0
 Overload < operator. More...
 
bool operator!= (SymGrp const &rhs) const
 Overload != operator. More...
 
bool operator> (SymGrp const &rhs) const
 Overload > operator. More...
 
bool operator<= (SymGrp const &rhs) const
 Overload <= operator. More...
 
bool operator>= (SymGrp const &rhs) const
 Overload >= operator. More...
 
virtual bool addMember (SymFnc const *const symmetryFunction)=0
 Potentially add a member to group. More...
 
virtual void sortMembers ()=0
 Sort member symmetry functions. More...
 
virtual void setScalingFactors ()=0
 Fill scalingFactors with values from member symmetry functions. More...
 
virtual void calculate (Atom &atom, bool const derivatives) const =0
 Calculate all symmetry functions of this group for one atom. More...
 
virtual std::vector< std::string > parameterLines () const =0
 Give symmetry function group parameters on multiple lines. More...
 
void setIndex (std::size_t index)
 Set private index member variable. More...
 
std::size_t getIndex () const
 Get private index member variable. More...
 
std::size_t getType () const
 Get private type member variable. More...
 
std::size_t getEc () const
 Get private ec member variable. More...
 

Private Attributes

std::vector< SymFncExpAngnWeighted const * > members
 Vector of all group member pointers. More...
 
std::vector< bool > calculateExp
 Vector indicating whether exponential term needs to be calculated. More...
 
std::vector< double > factorNorm
 Vector containing precalculated normalizing factor for each zeta. More...
 
std::vector< double > factorDeriv
 Vector containing precalculated normalizing factor for derivatives. More...
 
std::vector< bool > useIntegerPow
 Vector containing values of all member symmetry functions. More...
 
std::vector< int > zetaInt
 Vector containing values of all member symmetry functions. More...
 
std::vector< double > eta
 Vector containing values of all member symmetry functions. More...
 
std::vector< double > rs
 Vector containing values of all member symmetry functions. More...
 
std::vector< double > lambda
 Vector containing values of all member symmetry functions. More...
 
std::vector< double > zeta
 Vector containing values of all member symmetry functions. More...
 
std::vector< double > zetaLambda
 Vector containing values of all member symmetry functions. More...
 

Additional Inherited Members

- Protected Types inherited from nnp::SymGrp
typedef std::map< std::string, std::pair< std::string, std::string > > PrintFormat
 
typedef std::vector< std::string > PrintOrder
 
- Protected Member Functions inherited from nnp::SymGrpBaseCutoff
 SymGrpBaseCutoff (std::size_t type, ElementMap const &elementMap)
 Constructor, sets type. More...
 
- Protected Member Functions inherited from nnp::SymGrp
 SymGrp (std::size_t type, ElementMap const &elementMap)
 Constructor, sets type. More...
 
std::string getPrintFormatCommon () const
 Get common parameter line format string. More...
 
std::string getPrintFormatMember () const
 Get member parameter line format string. More...
 
- Static Protected Member Functions inherited from nnp::SymGrp
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::SymGrpBaseCutoff
double rc
 Cutoff radius \(r_c\) (common feature). More...
 
double cutoffAlpha
 Cutoff function parameter \(\alpha\) (common feature). More...
 
std::string subtype
 Subtype string (specifies cutoff type) (common feature). More...
 
CutoffFunction fc
 Cutoff function used by this symmetry function group. More...
 
CutoffFunction::CutoffType cutoffType
 Cutoff type used by this symmetry function group (common feature). More...
 
- Protected Attributes inherited from nnp::SymGrp
std::size_t type
 Symmetry function type. More...
 
ElementMap elementMap
 Copy of element map. More...
 
std::size_t index
 Symmetry function group index. More...
 
std::size_t ec
 Element index of center atom (common feature). More...
 
double convLength
 Data set normalization length conversion factor. More...
 
std::vector< size_t > memberIndex
 Vector containing indices of all member symmetry functions. More...
 
std::vector< double > scalingFactors
 Scaling factors of all member symmetry functions. More...
 
std::set< std::string > parametersCommon
 Set of common parameters IDs. More...
 
std::set< std::string > parametersMember
 Set of common parameters IDs. More...
 
std::vector< std::vector< std::size_t > > memberIndexPerElement
 Vector containing per-element indices of all member symmetry functions. More...
 
- Static Protected Attributes inherited from nnp::SymGrp
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 group (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}) \]

Common features:

  • element of central atom
  • cutoff type
  • \(r_c\)
  • \(\alpha\)

Definition at line 49 of file SymGrpExpAngnWeighted.h.

Constructor & Destructor Documentation

◆ SymGrpExpAngnWeighted()

SymGrpExpAngnWeighted::SymGrpExpAngnWeighted ( ElementMap const &  elementMap)

Constructor, sets type = 13.

Definition at line 30 of file SymGrpExpAngnWeighted.cpp.

30 :
32{
33 parametersMember.insert("eta");
34 parametersMember.insert("rs/rl");
35 parametersMember.insert("lambda");
36 parametersMember.insert("zeta");
37 parametersMember.insert("mindex");
38 parametersMember.insert("sfindex");
39 parametersMember.insert("calcexp");
40}
SymGrpBaseCutoff(std::size_t type, ElementMap const &elementMap)
Constructor, sets type.
ElementMap elementMap
Copy of element map.
Definition: SymGrp.h:108
std::set< std::string > parametersMember
Set of common parameters IDs.
Definition: SymGrp.h:122

References nnp::SymGrp::parametersMember.

Member Function Documentation

◆ operator==()

bool SymGrpExpAngnWeighted::operator== ( SymGrp const &  rhs) const
virtual

Overload == operator.

Implements nnp::SymGrp.

Definition at line 42 of file SymGrpExpAngnWeighted.cpp.

43{
44 if (ec != rhs.getEc() ) return false;
45 if (type != rhs.getType()) return false;
46 SymGrpExpAngnWeighted const& c =
47 dynamic_cast<SymGrpExpAngnWeighted const&>(rhs);
48 if (cutoffType != c.cutoffType ) return false;
49 if (cutoffAlpha != c.cutoffAlpha) return false;
50 if (rc != c.rc ) return false;
51 return true;
52}
double cutoffAlpha
Cutoff function parameter (common feature).
double rc
Cutoff radius (common feature).
CutoffFunction::CutoffType cutoffType
Cutoff type used by this symmetry function group (common feature).
Weighted angular symmetry function group (type 13)
std::size_t type
Symmetry function type.
Definition: SymGrp.h:106
std::size_t ec
Element index of center atom (common feature).
Definition: SymGrp.h:112

References nnp::SymGrpBaseCutoff::cutoffAlpha, nnp::SymGrpBaseCutoff::cutoffType, nnp::SymGrp::ec, nnp::SymGrp::getEc(), nnp::SymGrp::getType(), nnp::SymGrpBaseCutoff::rc, and nnp::SymGrp::type.

Here is the call graph for this function:

◆ operator<()

bool SymGrpExpAngnWeighted::operator< ( SymGrp const &  rhs) const
virtual

Overload < operator.

Implements nnp::SymGrp.

Definition at line 54 of file SymGrpExpAngnWeighted.cpp.

55{
56 if (ec < rhs.getEc() ) return true;
57 else if (ec > rhs.getEc() ) return false;
58 if (type < rhs.getType()) return true;
59 else if (type > rhs.getType()) return false;
60 SymGrpExpAngnWeighted const& c =
61 dynamic_cast<SymGrpExpAngnWeighted const&>(rhs);
62 if (cutoffType < c.cutoffType ) return true;
63 else if (cutoffType > c.cutoffType ) return false;
64 if (cutoffAlpha < c.cutoffAlpha) return true;
65 else if (cutoffAlpha > c.cutoffAlpha) return false;
66 if (rc < c.rc ) return true;
67 else if (rc > c.rc ) return false;
68 return false;
69}

References nnp::SymGrpBaseCutoff::cutoffAlpha, nnp::SymGrpBaseCutoff::cutoffType, nnp::SymGrp::ec, nnp::SymGrp::getEc(), nnp::SymGrp::getType(), nnp::SymGrpBaseCutoff::rc, and nnp::SymGrp::type.

Here is the call graph for this function:

◆ addMember()

bool SymGrpExpAngnWeighted::addMember ( SymFnc const *const  symmetryFunction)
virtual

Potentially add a member to group.

Parameters
[in]symmetryFunctionCandidate symmetry function.
Returns
If addition was successful.

If symmetry function is compatible with common feature list its pointer will be added to members.

Implements nnp::SymGrp.

Definition at line 71 of file SymGrpExpAngnWeighted.cpp.

72{
73 if (symmetryFunction->getType() != type) return false;
74
75 SymFncExpAngnWeighted const* sf =
76 dynamic_cast<SymFncExpAngnWeighted const*>(symmetryFunction);
77
78 if (members.empty())
79 {
81 subtype = sf->getSubtype();
83 ec = sf->getEc();
84 rc = sf->getRc();
86
90 }
91
92 if (sf->getCutoffType() != cutoffType ) return false;
93 if (sf->getCutoffAlpha() != cutoffAlpha) return false;
94 if (sf->getEc() != ec ) return false;
95 if (sf->getRc() != rc ) return false;
96 if (sf->getConvLength() != convLength )
97 {
98 throw runtime_error("ERROR: Unable to add symmetry function members "
99 "with different conversion factors.\n");
100 }
101
102 members.push_back(sf);
103
104 return true;
105}
void setCutoffParameter(double const alpha)
Set parameter for polynomial cutoff function (CT_POLY).
void setCutoffType(CutoffType const cutoffType)
Set cutoff type.
void setCutoffRadius(double const cutoffRadius)
Set cutoff radius.
std::string getSubtype() const
Get private subtype member variable.
double getCutoffAlpha() const
Get private cutoffAlpha member variable.
CutoffFunction::CutoffType getCutoffType() const
Get private cutoffType member variable.
Weighted angular symmetry function (type 13)
double getConvLength() const
Get private convLength member variable.
Definition: SymFnc.h:364
double getRc() const
Get private rc member variable.
Definition: SymFnc.h:360
std::size_t getEc() const
Get private ec member variable.
Definition: SymFnc.h:356
std::string subtype
Subtype string (specifies cutoff type) (common feature).
CutoffFunction fc
Cutoff function used by this symmetry function group.
std::vector< SymFncExpAngnWeighted const * > members
Vector of all group member pointers.
double convLength
Data set normalization length conversion factor.
Definition: SymGrp.h:114

References nnp::SymGrp::convLength, nnp::SymGrpBaseCutoff::cutoffAlpha, nnp::SymGrpBaseCutoff::cutoffType, nnp::SymGrp::ec, nnp::SymGrpBaseCutoff::fc, nnp::SymFnc::getConvLength(), nnp::SymFncBaseCutoff::getCutoffAlpha(), nnp::SymFncBaseCutoff::getCutoffType(), nnp::SymFnc::getEc(), nnp::SymFnc::getRc(), nnp::SymFncBaseCutoff::getSubtype(), nnp::SymFnc::getType(), members, nnp::SymGrpBaseCutoff::rc, nnp::CutoffFunction::setCutoffParameter(), nnp::CutoffFunction::setCutoffRadius(), nnp::CutoffFunction::setCutoffType(), nnp::SymGrpBaseCutoff::subtype, and nnp::SymGrp::type.

Here is the call graph for this function:

◆ sortMembers()

void SymGrpExpAngnWeighted::sortMembers ( )
virtual

Sort member symmetry functions.

Also allocate and precalculate additional stuff.

Implements nnp::SymGrp.

Definition at line 107 of file SymGrpExpAngnWeighted.cpp.

108{
109 sort(members.begin(),
110 members.end(),
111 comparePointerTargets<SymFncExpAngnWeighted const>);
112
113 // Members are now sorted with eta changing the slowest.
114 for (size_t i = 0; i < members.size(); i++)
115 {
116 factorNorm.push_back(pow(2.0, 1.0 - members[i]->getZeta()));
117 factorDeriv.push_back(2.0 * members[i]->getEta() /
118 members[i]->getZeta() / members[i]->getLambda());
119 if (i == 0)
120 {
121 calculateExp.push_back(true);
122 }
123 else
124 {
125 if ( members[i - 1]->getEta() != members[i]->getEta() ||
126 members[i - 1]->getRs() != members[i]->getRs() )
127 {
128 calculateExp.push_back(true);
129 }
130 else
131 {
132 calculateExp.push_back(false);
133 }
134 }
135 useIntegerPow.push_back(members[i]->getUseIntegerPow());
136 memberIndex.push_back(members[i]->getIndex());
137 zetaInt.push_back(members[i]->getZetaInt());
138 eta.push_back(members[i]->getEta());
139 rs.push_back(members[i]->getRs());
140 lambda.push_back(members[i]->getLambda());
141 zeta.push_back(members[i]->getZeta());
142 zetaLambda.push_back(members[i]->getZeta() * members[i]->getLambda());
143 memberIndexPerElement.push_back(members[i]->getIndexPerElement());
144 }
145
146 return;
147}
std::vector< double > zetaLambda
Vector containing values of all member symmetry functions.
std::vector< double > eta
Vector containing values of all member symmetry functions.
std::vector< bool > useIntegerPow
Vector containing values of all member symmetry functions.
std::vector< double > zeta
Vector containing values of all member symmetry functions.
std::vector< double > lambda
Vector containing values of all member symmetry functions.
std::vector< double > rs
Vector containing values of all member symmetry functions.
std::vector< int > zetaInt
Vector containing values of all member symmetry functions.
std::vector< bool > calculateExp
Vector indicating whether exponential term needs to be calculated.
std::vector< double > factorDeriv
Vector containing precalculated normalizing factor for derivatives.
std::vector< double > factorNorm
Vector containing precalculated normalizing factor for each zeta.
std::vector< size_t > memberIndex
Vector containing indices of all member symmetry functions.
Definition: SymGrp.h:116
std::vector< std::vector< std::size_t > > memberIndexPerElement
Vector containing per-element indices of all member symmetry functions.
Definition: SymGrp.h:124
std::size_t getIndex() const
Get private index member variable.
Definition: SymGrp.h:184

References calculateExp, eta, factorDeriv, factorNorm, nnp::SymGrp::getIndex(), lambda, nnp::SymGrp::memberIndex, nnp::SymGrp::memberIndexPerElement, members, rs, useIntegerPow, zeta, zetaInt, and zetaLambda.

Here is the call graph for this function:

◆ setScalingFactors()

void SymGrpExpAngnWeighted::setScalingFactors ( )
virtual

Fill scalingFactors with values from member symmetry functions.

Implements nnp::SymGrp.

Definition at line 149 of file SymGrpExpAngnWeighted.cpp.

150{
151 scalingFactors.resize(members.size(), 0.0);
152 for (size_t i = 0; i < members.size(); i++)
153 {
154 scalingFactors.at(i) = members[i]->getScalingFactor();
155 factorNorm.at(i) *= scalingFactors.at(i);
156 }
157
158 return;
159}
std::vector< double > scalingFactors
Scaling factors of all member symmetry functions.
Definition: SymGrp.h:118

References factorNorm, members, and nnp::SymGrp::scalingFactors.

◆ calculate()

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

Calculate all symmetry functions of this group for one atom.

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

Implements nnp::SymGrp.

Definition at line 167 of file SymGrpExpAngnWeighted.cpp.

168{
169#ifndef N2P2_NO_SF_CACHE
170 // Can use cache indices of any member because this group is defined via
171 // identical symmetry function type and cutoff functions.
172 auto cacheIndices = members.at(0)->getCacheIndices();
173#endif
174 double* result = new double[members.size()];
175 for (size_t l = 0; l < members.size(); ++l)
176 {
177 result[l] = 0.0;
178 }
179
180 double const rc2 = rc * rc;
181 size_t numNeighbors = atom.numNeighbors;
182 // Prevent problematic condition in loop test below (j < numNeighbors - 1).
183 if (numNeighbors == 0) numNeighbors = 1;
184
185 for (size_t j = 0; j < numNeighbors - 1; j++)
186 {
187 Atom::Neighbor& nj = atom.neighbors[j];
188 size_t const nej = nj.element;
189 double const rij = nj.d;
190 if (rij < rc)
191 {
192 double const r2ij = rij * rij;
193
194 // Calculate cutoff function and derivative.
195 double pfcij;
196 double pdfcij;
197#ifndef N2P2_NO_SF_CACHE
198 if (cacheIndices[nej].size() == 0) fc.fdf(rij, pfcij, pdfcij);
199 else
200 {
201 double& cfc = nj.cache[cacheIndices[nej][0]];
202 double& cdfc = nj.cache[cacheIndices[nej][1]];
203 if (cfc < 0) fc.fdf(rij, cfc, cdfc);
204 pfcij = cfc;
205 pdfcij = cdfc;
206 }
207#else
208 fc.fdf(rij, pfcij, pdfcij);
209#endif
210 // SIMPLE EXPRESSIONS:
211 //Vec3D const drij(atom.neighbors[j].dr);
212 //double const* const dr1 = drij.r;
213 double const* const dr1 = nj.dr.r;
214
215 for (size_t k = j + 1; k < numNeighbors; k++)
216 {
217 Atom::Neighbor& nk = atom.neighbors[k];
218 size_t const nek = nk.element;
219 double const rik = nk.d;
220 if (rik < rc)
221 {
222 // SIMPLE EXPRESSIONS:
223 //Vec3D const drjk(atom.neighbors[k].dr
224 // - atom.neighbors[j].dr);
225 //double rjk = drjk.norm2();
226 double const* const dr2 = nk.dr.r;
227 double dr3[3];
228 dr3[0] = dr2[0] - dr1[0];
229 dr3[1] = dr2[1] - dr1[1];
230 dr3[2] = dr2[2] - dr1[2];
231 double rjk = dr3[0] * dr3[0]
232 + dr3[1] * dr3[1]
233 + dr3[2] * dr3[2];
234 if (rjk < rc2)
235 {
236 // Energy calculation.
237 double pfcik;
238 double pdfcik;
239#ifndef N2P2_NO_SF_CACHE
240 if (cacheIndices[nej].size() == 0)
241 {
242 fc.fdf(rik, pfcik, pdfcik);
243 }
244 else
245 {
246 double& cfc = nk.cache[cacheIndices[nek][0]];
247 double& cdfc = nk.cache[cacheIndices[nek][1]];
248 if (cfc < 0) fc.fdf(rik, cfc, cdfc);
249 pfcik = cfc;
250 pdfcik = cdfc;
251 }
252#else
253 fc.fdf(rik, pfcik, pdfcik);
254#endif
255 rjk = sqrt(rjk);
256
257 double pfcjk;
258 double pdfcjk;
259 fc.fdf(rjk, pfcjk, pdfcjk);
260
261 // SIMPLE EXPRESSIONS:
262 //Vec3D const drik(atom.neighbors[k].dr);
263 //double const* const dr2 = drik.r;
264 //double const* const dr3 = drjk.r;
265 double const rinvijik = 1.0 / rij / rik;
266 // SIMPLE EXPRESSIONS:
267 //double const costijk = (drij * drik) * rinvijik;
268 double const costijk = (dr1[0] * dr2[0] +
269 dr1[1] * dr2[1] +
270 dr1[2] * dr2[2]) * rinvijik;
271 double const z = elementMap.atomicNumber(nej)
273 double const pfc = z * pfcij * pfcik * pfcjk;
274 double const r2ik = rik * rik;
275 double const pr1 = z * pfcik * pfcjk * pdfcij / rij;
276 double const pr2 = z * pfcij * pfcjk * pdfcik / rik;
277 double const pr3 = z * pfcij * pfcik * pdfcjk / rjk;
278 double vexp = 0.0;
279 double rijs = 0.0;
280 double riks = 0.0;
281 double rjks = 0.0;
282
283 for (size_t l = 0; l < members.size(); ++l)
284 {
285 if (calculateExp[l])
286 {
287 rijs = rij - rs[l];
288 riks = rik - rs[l];
289 rjks = rjk - rs[l];
290 double const r2sum = rijs * rijs
291 + riks * riks
292 + rjks * rjks;
293 vexp = exp(-eta[l] * r2sum);
294 }
295 double const plambda = 1.0
296 + lambda[l] * costijk;
297 double fg = vexp;
298 if (plambda <= 0.0) fg = 0.0;
299 else
300 {
301 if (useIntegerPow[l])
302 {
303 fg *= pow_int(plambda, zetaInt[l] - 1);
304 }
305 else
306 {
307 fg *= pow(plambda, zeta[l] - 1.0);
308 }
309 }
310 result[l] += fg * plambda * pfc;
311
312 // Force calculation.
313 if (!derivatives) continue;
314 fg *= factorNorm[l];
315 double const pfczl = pfc * zetaLambda[l];
316 double const p2etapl = plambda * factorDeriv[l];
317 double const p1 = fg * (pfczl * (rinvijik - costijk
318 / r2ij - p2etapl * rijs / rij)
319 + pr1 * plambda);
320 double const p2 = fg * (pfczl * (rinvijik - costijk
321 / r2ik - p2etapl * riks / rik)
322 + pr2 * plambda);
323 double const p3 = fg * (pfczl * (rinvijik + p2etapl
324 * rjks / rjk) - pr3 * plambda);
325
326 // Save force contributions in Atom storage.
327 //
328 // SIMPLE EXPRESSIONS:
329 //size_t const li = members[l]->getIndex();
330 //atom.dGdr[li] += p1 * drij + p2 * drik;
331 //atom.neighbors[j].dGdr[li] -= p1 * drij
332 // + p3 * drjk;
333 //atom.neighbors[k].dGdr[li] -= p2 * drik
334 // - p3 * drjk;
335
336 double const p1drijx = p1 * dr1[0];
337 double const p1drijy = p1 * dr1[1];
338 double const p1drijz = p1 * dr1[2];
339
340 double const p2drikx = p2 * dr2[0];
341 double const p2driky = p2 * dr2[1];
342 double const p2drikz = p2 * dr2[2];
343
344 double const p3drjkx = p3 * dr3[0];
345 double const p3drjky = p3 * dr3[1];
346 double const p3drjkz = p3 * dr3[2];
347
348#ifndef N2P2_FULL_SFD_MEMORY
349 size_t li = memberIndex[l];
350#else
351 size_t const li = memberIndex[l];
352#endif
353 double* dGdr = atom.dGdr[li].r;
354 dGdr[0] += p1drijx + p2drikx;
355 dGdr[1] += p1drijy + p2driky;
356 dGdr[2] += p1drijz + p2drikz;
357
358#ifndef N2P2_FULL_SFD_MEMORY
359 li = memberIndexPerElement[l][nej];
360#endif
361 dGdr = nj.dGdr[li].r;
362 dGdr[0] -= p1drijx + p3drjkx;
363 dGdr[1] -= p1drijy + p3drjky;
364 dGdr[2] -= p1drijz + p3drjkz;
365
366#ifndef N2P2_FULL_SFD_MEMORY
367 li = memberIndexPerElement[l][nek];
368#endif
369 dGdr = nk.dGdr[li].r;
370 dGdr[0] -= p2drikx - p3drjkx;
371 dGdr[1] -= p2driky - p3drjky;
372 dGdr[2] -= p2drikz - p3drjkz;
373 } // l
374 } // rjk <= rc
375 } // rik <= rc
376 } // k
377 } // rij <= rc
378 } // j
379
380 for (size_t l = 0; l < members.size(); ++l)
381 {
382 result[l] *= factorNorm[l] / scalingFactors[l];
383 atom.G[memberIndex[l]] = members[l]->scale(result[l]);
384 }
385
386 delete[] result;
387
388 return;
389}
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
double pow_int(double x, int n)
Integer version of power function, "fast exponentiation algorithm".
Definition: utility.cpp:292
Struct to store information on neighbor atoms.
Definition: Atom.h:36
std::vector< double > cache
Symmetry function cache (e.g. for cutoffs, compact functions).
Definition: Atom.h:49
std::size_t element
Element index of neighbor atom.
Definition: Atom.h:42
double d
Distance to neighbor atom.
Definition: Atom.h:44
Vec3D dr
Distance vector to neighbor atom.
Definition: Atom.h:46
std::vector< Vec3D > dGdr
Derivatives of symmetry functions with respect to neighbor coordinates.
Definition: Atom.h:60
std::vector< Neighbor > neighbors
Neighbor array (maximum number defined in macros.h.
Definition: Atom.h:170
std::vector< Vec3D > dGdr
Derivative of symmetry functions with respect to this atom's coordinates.
Definition: Atom.h:161
std::vector< double > G
Symmetry function values.
Definition: Atom.h:146
std::size_t numNeighbors
Total number of neighbors.
Definition: Atom.h:109
double r[3]
cartesian coordinates.
Definition: Vec3D.h:32

References nnp::ElementMap::atomicNumber(), nnp::Atom::Neighbor::cache, calculateExp, nnp::Atom::Neighbor::d, nnp::Atom::Neighbor::dGdr, nnp::Atom::dGdr, nnp::Atom::Neighbor::dr, nnp::Atom::Neighbor::element, nnp::SymGrp::elementMap, eta, factorDeriv, factorNorm, nnp::SymGrpBaseCutoff::fc, nnp::CutoffFunction::fdf(), nnp::Atom::G, lambda, nnp::SymGrp::memberIndex, nnp::SymGrp::memberIndexPerElement, members, nnp::Atom::neighbors, nnp::Atom::numNeighbors, nnp::pow_int(), nnp::Vec3D::r, nnp::SymGrpBaseCutoff::rc, rs, nnp::SymGrp::scalingFactors, useIntegerPow, zeta, zetaInt, and zetaLambda.

Here is the call graph for this function:

◆ parameterLines()

vector< string > SymGrpExpAngnWeighted::parameterLines ( ) const
virtual

Give symmetry function group parameters on multiple lines.

Returns
Vector of string containing symmetry function parameters lines.

Implements nnp::SymGrp.

Definition at line 391 of file SymGrpExpAngnWeighted.cpp.

392{
393 vector<string> v;
394
395 v.push_back(strpr(getPrintFormatCommon().c_str(),
396 index + 1,
397 elementMap[ec].c_str(),
398 type,
399 subtype.c_str(),
400 rc / convLength,
401 cutoffAlpha));
402
403 for (size_t i = 0; i < members.size(); ++i)
404 {
405 v.push_back(strpr(getPrintFormatMember().c_str(),
406 members[i]->getEta() * convLength * convLength,
407 members[i]->getRs() / convLength,
408 members[i]->getLambda(),
409 members[i]->getZeta(),
410 members[i]->getLineNumber() + 1,
411 i + 1,
412 members[i]->getIndex() + 1,
413 (int)calculateExp[i]));
414 }
415
416 return v;
417}
std::size_t index
Symmetry function group index.
Definition: SymGrp.h:110
std::string getPrintFormatCommon() const
Get common parameter line format string.
Definition: SymGrp.cpp:97
std::string getPrintFormatMember() const
Get member parameter line format string.
Definition: SymGrp.cpp:130
string strpr(const char *format,...)
String version of printf function.
Definition: utility.cpp:90

References calculateExp, nnp::SymGrp::convLength, nnp::SymGrpBaseCutoff::cutoffAlpha, nnp::SymGrp::ec, nnp::SymGrp::elementMap, nnp::SymGrp::getIndex(), nnp::SymGrp::getPrintFormatCommon(), nnp::SymGrp::getPrintFormatMember(), nnp::SymGrp::index, members, nnp::SymGrpBaseCutoff::rc, nnp::strpr(), nnp::SymGrpBaseCutoff::subtype, and nnp::SymGrp::type.

Here is the call graph for this function:

Member Data Documentation

◆ members

std::vector<SymFncExpAngnWeighted const*> nnp::SymGrpExpAngnWeighted::members
private

Vector of all group member pointers.

Definition at line 94 of file SymGrpExpAngnWeighted.h.

Referenced by addMember(), calculate(), parameterLines(), setScalingFactors(), and sortMembers().

◆ calculateExp

std::vector<bool> nnp::SymGrpExpAngnWeighted::calculateExp
private

Vector indicating whether exponential term needs to be calculated.

Definition at line 96 of file SymGrpExpAngnWeighted.h.

Referenced by calculate(), parameterLines(), and sortMembers().

◆ factorNorm

std::vector<double> nnp::SymGrpExpAngnWeighted::factorNorm
private

Vector containing precalculated normalizing factor for each zeta.

Definition at line 98 of file SymGrpExpAngnWeighted.h.

Referenced by calculate(), setScalingFactors(), and sortMembers().

◆ factorDeriv

std::vector<double> nnp::SymGrpExpAngnWeighted::factorDeriv
private

Vector containing precalculated normalizing factor for derivatives.

Definition at line 100 of file SymGrpExpAngnWeighted.h.

Referenced by calculate(), and sortMembers().

◆ useIntegerPow

std::vector<bool> nnp::SymGrpExpAngnWeighted::useIntegerPow
private

Vector containing values of all member symmetry functions.

Definition at line 102 of file SymGrpExpAngnWeighted.h.

Referenced by calculate(), and sortMembers().

◆ zetaInt

std::vector<int> nnp::SymGrpExpAngnWeighted::zetaInt
private

Vector containing values of all member symmetry functions.

Definition at line 104 of file SymGrpExpAngnWeighted.h.

Referenced by calculate(), and sortMembers().

◆ eta

std::vector<double> nnp::SymGrpExpAngnWeighted::eta
private

Vector containing values of all member symmetry functions.

Definition at line 106 of file SymGrpExpAngnWeighted.h.

Referenced by calculate(), and sortMembers().

◆ rs

std::vector<double> nnp::SymGrpExpAngnWeighted::rs
private

Vector containing values of all member symmetry functions.

Definition at line 108 of file SymGrpExpAngnWeighted.h.

Referenced by calculate(), and sortMembers().

◆ lambda

std::vector<double> nnp::SymGrpExpAngnWeighted::lambda
private

Vector containing values of all member symmetry functions.

Definition at line 110 of file SymGrpExpAngnWeighted.h.

Referenced by calculate(), and sortMembers().

◆ zeta

std::vector<double> nnp::SymGrpExpAngnWeighted::zeta
private

Vector containing values of all member symmetry functions.

Definition at line 112 of file SymGrpExpAngnWeighted.h.

Referenced by calculate(), and sortMembers().

◆ zetaLambda

std::vector<double> nnp::SymGrpExpAngnWeighted::zetaLambda
private

Vector containing values of all member symmetry functions.

Definition at line 114 of file SymGrpExpAngnWeighted.h.

Referenced by calculate(), and sortMembers().


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