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

Angular symmetry function group (type 3) More...

#include <SymGrpExpAngw.h>

Inheritance diagram for nnp::SymGrpExpAngw:
Collaboration diagram for nnp::SymGrpExpAngw:

Public Member Functions

 SymGrpExpAngw (ElementMap const &elementMap)
 Constructor, sets type = 3. 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 calculate (Atom &atom, bool const derivatives) const
 Calculate all symmetry functions of this group for one atom. More...
 
- Public Member Functions inherited from nnp::SymGrpBaseExpAng
virtual void setScalingFactors ()
 Fill scalingFactors with values from member symmetry functions. 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 Member Functions

virtual std::vector< SymFncBaseExpAng const * > getMembers () const
 Get symmetry function members. More...
 

Private Attributes

std::vector< SymFncExpAngw const * > members
 Vector of all group member pointers. 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::SymGrpBaseExpAng
 SymGrpBaseExpAng (std::size_t type, ElementMap const &elementMap)
 Constructor, sets type. More...
 
virtual std::vector< SymFncBaseExpAng const * > getMembers () const =0
 Get symmetry function members. More...
 
- 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::SymGrpBaseExpAng
std::size_t e1
 Element index of neighbor atom 1 (common feature). More...
 
std::size_t e2
 Element index of neighbor atom 2 (common feature). 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 > zeta
 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 > zetaLambda
 Vector containing values of all member symmetry functions. More...
 
std::vector< double > rs
 Vector containing values of all member symmetry functions. 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

Angular symmetry function group (type 3)

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

Common features:

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

Definition at line 49 of file SymGrpExpAngw.h.

Constructor & Destructor Documentation

◆ SymGrpExpAngw()

SymGrpExpAngw::SymGrpExpAngw ( ElementMap const &  elementMap)

Constructor, sets type = 3.

Definition at line 30 of file SymGrpExpAngw.cpp.

30 :
32{
33}
SymGrpBaseExpAng(std::size_t type, ElementMap const &elementMap)
Constructor, sets type.
ElementMap elementMap
Copy of element map.
Definition: SymGrp.h:108

Member Function Documentation

◆ operator==()

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

Overload == operator.

Implements nnp::SymGrp.

Definition at line 35 of file SymGrpExpAngw.cpp.

36{
37 if (ec != rhs.getEc() ) return false;
38 if (type != rhs.getType()) return false;
39 SymGrpExpAngw const& c = dynamic_cast<SymGrpExpAngw const&>(rhs);
40 if (cutoffType != c.cutoffType ) return false;
41 if (cutoffAlpha != c.cutoffAlpha) return false;
42 if (rc != c.rc ) return false;
43 if (e1 != c.e1 ) return false;
44 if (e2 != c.e2 ) return false;
45 return true;
46}
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).
std::size_t e2
Element index of neighbor atom 2 (common feature).
std::size_t e1
Element index of neighbor atom 1 (common feature).
Angular symmetry function group (type 3)
Definition: SymGrpExpAngw.h:50
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::SymGrpBaseExpAng::e1, nnp::SymGrpBaseExpAng::e2, 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 SymGrpExpAngw::operator< ( SymGrp const &  rhs) const
virtual

Overload < operator.

Implements nnp::SymGrp.

Definition at line 48 of file SymGrpExpAngw.cpp.

49{
50 if (ec < rhs.getEc() ) return true;
51 else if (ec > rhs.getEc() ) return false;
52 if (type < rhs.getType()) return true;
53 else if (type > rhs.getType()) return false;
54 SymGrpExpAngw const& c = dynamic_cast<SymGrpExpAngw const&>(rhs);
55 if (cutoffType < c.cutoffType ) return true;
56 else if (cutoffType > c.cutoffType ) return false;
57 if (cutoffAlpha < c.cutoffAlpha) return true;
58 else if (cutoffAlpha > c.cutoffAlpha) return false;
59 if (rc < c.rc ) return true;
60 else if (rc > c.rc ) return false;
61 if (e1 < c.e1 ) return true;
62 else if (e1 > c.e1 ) return false;
63 if (e2 < c.e2 ) return true;
64 else if (e2 > c.e2 ) return false;
65 return false;
66}

References nnp::SymGrpBaseCutoff::cutoffAlpha, nnp::SymGrpBaseCutoff::cutoffType, nnp::SymGrpBaseExpAng::e1, nnp::SymGrpBaseExpAng::e2, 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 SymGrpExpAngw::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 68 of file SymGrpExpAngw.cpp.

69{
70 if (symmetryFunction->getType() != type) return false;
71
72 SymFncExpAngw const* sf =
73 dynamic_cast<SymFncExpAngw const*>(symmetryFunction);
74
75 if (members.empty())
76 {
78 subtype = sf->getSubtype();
80 ec = sf->getEc();
81 rc = sf->getRc();
82 e1 = sf->getE1();
83 e2 = sf->getE2();
85
89 }
90
91 if (sf->getCutoffType() != cutoffType ) return false;
92 if (sf->getCutoffAlpha() != cutoffAlpha) return false;
93 if (sf->getEc() != ec ) return false;
94 if (sf->getRc() != rc ) return false;
95 if (sf->getE1() != e1 ) return false;
96 if (sf->getE2() != e2 ) return false;
97 if (sf->getConvLength() != convLength )
98 {
99 throw runtime_error("ERROR: Unable to add symmetry function members "
100 "with different conversion factors.\n");
101 }
102
103 members.push_back(sf);
104
105 return true;
106}
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.
std::size_t getE1() const
Get private e1 member variable.
std::size_t getE2() const
Get private e2 member variable.
Angular symmetry function (type 9)
Definition: SymFncExpAngw.h:54
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< SymFncExpAngw const * > members
Vector of all group member pointers.
Definition: SymGrpExpAngw.h:91
double convLength
Data set normalization length conversion factor.
Definition: SymGrp.h:114

References nnp::SymGrp::convLength, nnp::SymGrpBaseCutoff::cutoffAlpha, nnp::SymGrpBaseCutoff::cutoffType, nnp::SymGrpBaseExpAng::e1, nnp::SymGrpBaseExpAng::e2, nnp::SymGrp::ec, nnp::SymGrpBaseCutoff::fc, nnp::SymFnc::getConvLength(), nnp::SymFncBaseCutoff::getCutoffAlpha(), nnp::SymFncBaseCutoff::getCutoffType(), nnp::SymFncBaseExpAng::getE1(), nnp::SymFncBaseExpAng::getE2(), 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 SymGrpExpAngw::sortMembers ( )
virtual

Sort member symmetry functions.

Also allocate and precalculate additional stuff.

Implements nnp::SymGrp.

Definition at line 108 of file SymGrpExpAngw.cpp.

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

Here is the call graph for this function:

◆ calculate()

void SymGrpExpAngw::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 156 of file SymGrpExpAngw.cpp.

157{
158#ifndef N2P2_NO_SF_CACHE
159 // Can use cache indices of any member because this group is defined via
160 // identical symmetry function type, neighbors and cutoff functions.
161 auto cacheIndices = members.at(0)->getCacheIndices();
162#endif
163 double* result = new double[members.size()];
164 for (size_t l = 0; l < members.size(); ++l)
165 {
166 result[l] = 0.0;
167 }
168
169 size_t numNeighbors = atom.numNeighbors;
170 // Prevent problematic condition in loop test below (j < numNeighbors - 1).
171 if (numNeighbors == 0) numNeighbors = 1;
172
173 for (size_t j = 0; j < numNeighbors - 1; j++)
174 {
175 Atom::Neighbor& nj = atom.neighbors[j];
176 size_t const nej = nj.element;
177 double const rij = nj.d;
178 if ((e1 == nej || e2 == nej) && rij < rc)
179 {
180 double const r2ij = rij * rij;
181
182 // Calculate cutoff function and derivative.
183 double pfcij;
184 double pdfcij;
185#ifndef N2P2_NO_SF_CACHE
186 if (cacheIndices[nej].size() == 0) fc.fdf(rij, pfcij, pdfcij);
187 else
188 {
189 double& cfc = nj.cache[cacheIndices[nej][0]];
190 double& cdfc = nj.cache[cacheIndices[nej][1]];
191 if (cfc < 0) fc.fdf(rij, cfc, cdfc);
192 pfcij = cfc;
193 pdfcij = cdfc;
194 }
195#else
196 fc.fdf(rij, pfcij, pdfcij);
197#endif
198 // SIMPLE EXPRESSIONS:
199 //Vec3D drij(atom.neighbors[j].dr);
200 double const* const dr1 = nj.dr.r;
201
202 for (size_t k = j + 1; k < numNeighbors; k++)
203 {
204 Atom::Neighbor& nk = atom.neighbors[k];
205 size_t const nek = nk.element;
206 if ((e1 == nej && e2 == nek) ||
207 (e2 == nej && e1 == nek))
208 {
209 double const rik = nk.d;
210 if (rik < rc)
211 {
212 // SIMPLE EXPRESSIONS:
213 //Vec3D drik(atom.neighbors[k].dr);
214 //Vec3D drjk = drik - drij;
215 double const* const dr2 = nk.dr.r;
216 double const dr30 = dr2[0] - dr1[0];
217 double const dr31 = dr2[1] - dr1[1];
218 double const dr32 = dr2[2] - dr1[2];
219
220 // Energy calculation.
221 double pfcik;
222 double pdfcik;
223#ifndef N2P2_NO_SF_CACHE
224 if (cacheIndices[nek].size() == 0)
225 {
226 fc.fdf(rik, pfcik, pdfcik);
227 }
228 else
229 {
230 double& cfc = nk.cache[cacheIndices[nek][0]];
231 double& cdfc = nk.cache[cacheIndices[nek][1]];
232 if (cfc < 0) fc.fdf(rik, cfc, cdfc);
233 pfcik = cfc;
234 pdfcik = cdfc;
235 }
236#else
237 fc.fdf(rik, pfcik, pdfcik);
238#endif
239 double const rinvijik = 1.0 / rij / rik;
240 // SIMPLE EXPRESSIONS:
241 //double const costijk = drij * drik * rinvijik;
242 double const costijk = (dr1[0] * dr2[0] +
243 dr1[1] * dr2[1] +
244 dr1[2] * dr2[2]) * rinvijik;
245 double const pfc = pfcij * pfcik;
246 double const r2ik = rik * rik;
247 double const r2sum = r2ij + r2ik;
248 double const pr1 = pfcik * pdfcij / rij;
249 double const pr2 = pfcij * pdfcik / rik;
250 double vexp = 0.0;
251 double rijs = 0.0;
252 double riks = 0.0;
253
254 for (size_t l = 0; l < members.size(); ++l)
255 {
256 if (calculateExp[l])
257 {
258 if (rs[l] > 0.0)
259 {
260 rijs = rij - rs[l];
261 riks = rik - rs[l];
262 vexp = exp(-eta[l] * (rijs * rijs
263 + riks * riks));
264 }
265 else
266 {
267 vexp = exp(-eta[l] * r2sum);
268 }
269 }
270 double const plambda = 1.0 + lambda[l] * costijk;
271 double fg = vexp;
272 if (plambda <= 0.0) fg = 0.0;
273 else
274 {
275 if (useIntegerPow[l])
276 {
277 fg *= pow_int(plambda, zetaInt[l] - 1);
278 }
279 else
280 {
281 fg *= pow(plambda, zeta[l] - 1.0);
282 }
283 }
284 result[l] += fg * plambda * pfc;
285
286 // Force calculation.
287 if (!derivatives) continue;
288 fg *= factorNorm[l];
289 double const pfczl = pfc * zetaLambda[l];
290 double const p2etapl = plambda * factorDeriv[l];
291 double p1;
292 double p2;
293 if (rs[l] > 0)
294 {
295 p1 = fg * (pfczl * (rinvijik
296 - costijk / r2ij - p2etapl
297 * rijs / rij) + pr1 * plambda);
298 p2 = fg * (pfczl * (rinvijik
299 - costijk / r2ik - p2etapl
300 * riks / rik) + pr2 * plambda);
301 }
302 else
303 {
304 p1 = fg * (pfczl * (rinvijik - costijk / r2ij
305 - p2etapl) + pr1 * plambda);
306 p2 = fg * (pfczl * (rinvijik - costijk / r2ik
307 - p2etapl) + pr2 * plambda);
308
309 }
310 double const p3 = fg * pfczl * rinvijik;
311
312 // SIMPLE EXPRESSIONS:
313 // Save force contributions in Atom storage.
314 //atom.dGdr[memberIndex[l]] += p1 * drij
315 // + p2 * drik;
316 //atom.neighbors[j].
317 // dGdr[memberIndex[l]] -= p1 * drij
318 // + p3 * drjk;
319 //atom.neighbors[k].
320 // dGdr[memberIndex[l]] -= p2 * drik
321 // - p3 * drjk;
322
323 double const p1drijx = p1 * dr1[0];
324 double const p1drijy = p1 * dr1[1];
325 double const p1drijz = p1 * dr1[2];
326
327 double const p2drikx = p2 * dr2[0];
328 double const p2driky = p2 * dr2[1];
329 double const p2drikz = p2 * dr2[2];
330
331 double const p3drjkx = p3 * dr30;
332 double const p3drjky = p3 * dr31;
333 double const p3drjkz = p3 * dr32;
334
335#ifndef N2P2_FULL_SFD_MEMORY
336 size_t li = memberIndex[l];
337#else
338 size_t const li = memberIndex[l];
339#endif
340 double* dGdr = atom.dGdr[li].r;
341 dGdr[0] += p1drijx + p2drikx;
342 dGdr[1] += p1drijy + p2driky;
343 dGdr[2] += p1drijz + p2drikz;
344
345#ifndef N2P2_FULL_SFD_MEMORY
346 li = memberIndexPerElement[l][nej];
347#endif
348 dGdr = nj.dGdr[li].r;
349 dGdr[0] -= p1drijx + p3drjkx;
350 dGdr[1] -= p1drijy + p3drjky;
351 dGdr[2] -= p1drijz + p3drjkz;
352
353#ifndef N2P2_FULL_SFD_MEMORY
354 li = memberIndexPerElement[l][nek];
355#endif
356 dGdr = nk.dGdr[li].r;
357 dGdr[0] -= p2drikx - p3drjkx;
358 dGdr[1] -= p2driky - p3drjky;
359 dGdr[2] -= p2drikz - p3drjkz;
360 } // l
361 } // rik <= rc
362 } // elem
363 } // k
364 } // rij <= rc
365 } // j
366
367 for (size_t l = 0; l < members.size(); ++l)
368 {
369 result[l] *= factorNorm[l] / scalingFactors[l];
370 atom.G[memberIndex[l]] = members[l]->scale(result[l]);
371 }
372
373 delete[] result;
374
375 return;
376}
void fdf(double r, double &fc, double &dfc) const
Calculate cutoff function and derivative .
std::vector< double > scalingFactors
Scaling factors of all member symmetry functions.
Definition: SymGrp.h:118
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
double r[3]
cartesian coordinates.
Definition: Vec3D.h:31

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

Here is the call graph for this function:

◆ getMembers()

std::vector< SymFncBaseExpAng const * > nnp::SymGrpExpAngw::getMembers ( ) const
inlineprivatevirtual

Get symmetry function members.

Returns
Vector of pointers casted to base class.

Implements nnp::SymGrpBaseExpAng.

Definition at line 94 of file SymGrpExpAngw.h.

95{
96 std::vector<SymFncBaseExpAng const*> cast;
97
98 for (auto p : members)
99 {
100 cast.push_back(dynamic_cast<SymFncBaseExpAng const*>(p));
101 }
102
103 return cast;
104}
size_t p
Definition: nnp-cutoff.cpp:33

References members, and p.

Member Data Documentation

◆ members

std::vector<SymFncExpAngw const*> nnp::SymGrpExpAngw::members
private

Vector of all group member pointers.

Definition at line 91 of file SymGrpExpAngw.h.

Referenced by addMember(), calculate(), getMembers(), and sortMembers().


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