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

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

#include <SymGrpExpAngn.h>

Inheritance diagram for nnp::SymGrpExpAngn:
Collaboration diagram for nnp::SymGrpExpAngn:

Public Member Functions

 SymGrpExpAngn (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< SymFncExpAngn 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^3_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 + (r_{jk}-r_s)^2 ) } f_c(r_{ij}) f_c(r_{ik}) f_c(r_{jk}) \]

Common features:

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

Definition at line 50 of file SymGrpExpAngn.h.

Constructor & Destructor Documentation

◆ SymGrpExpAngn()

SymGrpExpAngn::SymGrpExpAngn ( ElementMap const &  elementMap)

Constructor, sets type = 3.

Definition at line 30 of file SymGrpExpAngn.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 SymGrpExpAngn::operator== ( SymGrp const &  rhs) const
virtual

Overload == operator.

Implements nnp::SymGrp.

Definition at line 35 of file SymGrpExpAngn.cpp.

36{
37 if (ec != rhs.getEc() ) return false;
38 if (type != rhs.getType()) return false;
39 SymGrpExpAngn const& c = dynamic_cast<SymGrpExpAngn 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: SymGrpExpAngn.h:51
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 SymGrpExpAngn::operator< ( SymGrp const &  rhs) const
virtual

Overload < operator.

Implements nnp::SymGrp.

Definition at line 48 of file SymGrpExpAngn.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 SymGrpExpAngn const& c = dynamic_cast<SymGrpExpAngn 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 SymGrpExpAngn::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 SymGrpExpAngn.cpp.

69{
70 if (symmetryFunction->getType() != type) return false;
71
72 SymFncExpAngn const* sf =
73 dynamic_cast<SymFncExpAngn 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 3)
Definition: SymFncExpAngn.h:55
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< SymFncExpAngn const * > members
Vector of all group member pointers.
Definition: SymGrpExpAngn.h:92
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 SymGrpExpAngn::sortMembers ( )
virtual

Sort member symmetry functions.

Also allocate and precalculate additional stuff.

Implements nnp::SymGrp.

Definition at line 108 of file SymGrpExpAngn.cpp.

109{
110 sort(members.begin(),
111 members.end(),
112 comparePointerTargets<SymFncExpAngn 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 SymGrpExpAngn::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 SymGrpExpAngn.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 double const rc2 = rc * rc;
170 size_t numNeighbors = atom.numNeighbors;
171 // Prevent problematic condition in loop test below (j < numNeighbors - 1).
172 if (numNeighbors == 0) numNeighbors = 1;
173
174 for (size_t j = 0; j < numNeighbors - 1; j++)
175 {
176 Atom::Neighbor& nj = atom.neighbors[j];
177 size_t const nej = nj.element;
178 double const rij = nj.d;
179 if ((e1 == nej || e2 == nej) && rij < rc)
180 {
181 double const r2ij = rij * rij;
182
183 // Calculate cutoff function and derivative.
184 double pfcij;
185 double pdfcij;
186#ifndef N2P2_NO_SF_CACHE
187 if (cacheIndices[nej].size() == 0) fc.fdf(rij, pfcij, pdfcij);
188 else
189 {
190 double& cfc = nj.cache[cacheIndices[nej][0]];
191 double& cdfc = nj.cache[cacheIndices[nej][1]];
192 if (cfc < 0) fc.fdf(rij, cfc, cdfc);
193 pfcij = cfc;
194 pdfcij = cdfc;
195 }
196#else
197 fc.fdf(rij, pfcij, pdfcij);
198#endif
199 // SIMPLE EXPRESSIONS:
200 //Vec3D const drij(atom.neighbors[j].dr);
201 //double const* const dr1 = drij.r;
202 double const* const dr1 = nj.dr.r;
203
204 for (size_t k = j + 1; k < numNeighbors; k++)
205 {
206 Atom::Neighbor& nk = atom.neighbors[k];
207 size_t const nek = nk.element;
208 if ((e1 == nej && e2 == nek) ||
209 (e2 == nej && e1 == nek))
210 {
211 double const rik = nk.d;
212 if (rik < rc)
213 {
214 // SIMPLE EXPRESSIONS:
215 //Vec3D const drjk(atom.neighbors[k].dr
216 // - atom.neighbors[j].dr);
217 //double rjk = drjk.norm2();
218 double const* const dr2 = nk.dr.r;
219 double dr3[3];
220 dr3[0] = dr2[0] - dr1[0];
221 dr3[1] = dr2[1] - dr1[1];
222 dr3[2] = dr2[2] - dr1[2];
223 double rjk = dr3[0] * dr3[0]
224 + dr3[1] * dr3[1]
225 + dr3[2] * dr3[2];
226 if (rjk < rc2)
227 {
228 // Energy calculation.
229 double pfcik;
230 double pdfcik;
231#ifndef N2P2_NO_SF_CACHE
232 if (cacheIndices[nek].size() == 0)
233 {
234 fc.fdf(rik, pfcik, pdfcik);
235 }
236 else
237 {
238 double& cfc = nk.cache[cacheIndices[nek][0]];
239 double& cdfc = nk.cache[cacheIndices[nek][1]];
240 if (cfc < 0) fc.fdf(rik, cfc, cdfc);
241 pfcik = cfc;
242 pdfcik = cdfc;
243 }
244#else
245 fc.fdf(rik, pfcik, pdfcik);
246#endif
247 rjk = sqrt(rjk);
248
249 double pfcjk;
250 double pdfcjk;
251 fc.fdf(rjk, pfcjk, pdfcjk);
252
253 // SIMPLE EXPRESSIONS:
254 //Vec3D const drik(atom.neighbors[k].dr);
255 //double const* const dr2 = drik.r;
256 //double const* const dr3 = drjk.r;
257 double const rinvijik = 1.0 / rij / rik;
258 // SIMPLE EXPRESSIONS:
259 //double const costijk = (drij * drik) * rinvijik;
260 double const costijk = (dr1[0] * dr2[0] +
261 dr1[1] * dr2[1] +
262 dr1[2] * dr2[2]) * rinvijik;
263 double const pfc = pfcij * pfcik * pfcjk;
264 double const r2ik = rik * rik;
265 double const r2sum = r2ij + r2ik + rjk * rjk;
266 double const pr1 = pfcik * pfcjk * pdfcij / rij;
267 double const pr2 = pfcij * pfcjk * pdfcik / rik;
268 double const pr3 = pfcij * pfcik * pdfcjk / rjk;
269 double vexp = 0.0;
270 double rijs = 0.0;
271 double riks = 0.0;
272 double rjks = 0.0;
273 for (size_t l = 0; l < members.size(); ++l)
274 {
275 if (calculateExp[l])
276 {
277 if (rs[l] > 0.0)
278 {
279 rijs = rij - rs[l];
280 riks = rik - rs[l];
281 rjks = rjk - rs[l];
282 vexp = exp(-eta[l] * (rijs * rijs
283 + riks * riks
284 + rjks * rjks));
285 }
286 else
287 {
288 vexp = exp(-eta[l] * r2sum);
289 }
290 }
291 double const plambda = 1.0
292 + lambda[l] * costijk;
293 double fg = vexp;
294 if (plambda <= 0.0) fg = 0.0;
295 else
296 {
297 if (useIntegerPow[l])
298 {
299 fg *= pow_int(plambda, zetaInt[l] - 1);
300 }
301 else
302 {
303 fg *= pow(plambda, zeta[l] - 1.0);
304 }
305 }
306 result[l] += fg * plambda * pfc;
307
308 // Force calculation.
309 if (!derivatives) continue;
310 fg *= factorNorm[l];
311 double const pfczl = pfc * zetaLambda[l];
312 double const p2etapl = plambda * factorDeriv[l];
313 double p1;
314 double p2;
315 double p3;
316 if (rs[l] > 0.0)
317 {
318 p1 = fg * (pfczl * (rinvijik
319 - costijk / r2ij - p2etapl
320 * rijs / rij) + pr1 * plambda);
321 p2 = fg * (pfczl * (rinvijik
322 - costijk / r2ik - p2etapl
323 * riks / rik) + pr2 * plambda);
324 p3 = fg * (pfczl * (rinvijik
325 + p2etapl * rjks / rjk)
326 - pr3 * plambda);
327 }
328 else
329 {
330 p1 = fg * (pfczl * (rinvijik - costijk
331 / r2ij - p2etapl) + pr1 * plambda);
332 p2 = fg * (pfczl * (rinvijik - costijk
333 / r2ik - p2etapl) + pr2 * plambda);
334 p3 = fg * (pfczl * (rinvijik + p2etapl)
335 - pr3 * plambda);
336 }
337
338 // Save force contributions in Atom storage.
339 //
340 // SIMPLE EXPRESSIONS:
341 //size_t const li = members[l]->getIndex();
342 //atom.dGdr[li] += p1 * drij + p2 * drik;
343 //atom.neighbors[j].dGdr[li] -= p1 * drij
344 // + p3 * drjk;
345 //atom.neighbors[k].dGdr[li] -= p2 * drik
346 // - p3 * drjk;
347
348 double const p1drijx = p1 * dr1[0];
349 double const p1drijy = p1 * dr1[1];
350 double const p1drijz = p1 * dr1[2];
351
352 double const p2drikx = p2 * dr2[0];
353 double const p2driky = p2 * dr2[1];
354 double const p2drikz = p2 * dr2[2];
355
356 double const p3drjkx = p3 * dr3[0];
357 double const p3drjky = p3 * dr3[1];
358 double const p3drjkz = p3 * dr3[2];
359
360#ifndef N2P2_FULL_SFD_MEMORY
361 size_t li = memberIndex[l];
362#else
363 size_t const li = memberIndex[l];
364#endif
365 double* dGdr = atom.dGdr[li].r;
366 dGdr[0] += p1drijx + p2drikx;
367 dGdr[1] += p1drijy + p2driky;
368 dGdr[2] += p1drijz + p2drikz;
369
370#ifndef N2P2_FULL_SFD_MEMORY
371 li = memberIndexPerElement[l][nej];
372#endif
373 dGdr = nj.dGdr[li].r;
374 dGdr[0] -= p1drijx + p3drjkx;
375 dGdr[1] -= p1drijy + p3drjky;
376 dGdr[2] -= p1drijz + p3drjkz;
377
378#ifndef N2P2_FULL_SFD_MEMORY
379 li = memberIndexPerElement[l][nek];
380#endif
381 dGdr = nk.dGdr[li].r;
382 dGdr[0] -= p2drikx - p3drjkx;
383 dGdr[1] -= p2driky - p3drjky;
384 dGdr[2] -= p2drikz - p3drjkz;
385 } // l
386 } // rjk <= rc
387 } // rik <= rc
388 } // elem
389 } // k
390 } // rij <= rc
391 } // j
392
393 for (size_t l = 0; l < members.size(); ++l)
394 {
395 result[l] *= factorNorm[l] / scalingFactors[l];
396 atom.G[memberIndex[l]] = members[l]->scale(result[l]);
397 }
398
399 delete[] result;
400
401 return;
402}
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::SymGrpExpAngn::getMembers ( ) const
inlineprivatevirtual

Get symmetry function members.

Returns
Vector of pointers casted to base class.

Implements nnp::SymGrpBaseExpAng.

Definition at line 95 of file SymGrpExpAngn.h.

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

References members, and p.

Member Data Documentation

◆ members

std::vector<SymFncExpAngn const*> nnp::SymGrpExpAngn::members
private

Vector of all group member pointers.

Definition at line 92 of file SymGrpExpAngn.h.

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


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