30SymGrpExpAngw::SymGrpExpAngw(
ElementMap const& elementMap) :
37 if (
ec != rhs.
getEc() )
return false;
42 if (
rc != c.
rc )
return false;
43 if (
e1 != c.
e1 )
return false;
44 if (
e2 != c.
e2 )
return false;
50 if (
ec < rhs.
getEc() )
return true;
51 else if (
ec > rhs.
getEc() )
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;
70 if (symmetryFunction->
getType() !=
type)
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;
99 throw runtime_error(
"ERROR: Unable to add symmetry function members "
100 "with different conversion factors.\n");
112 comparePointerTargets<SymFncExpAngw const>);
115 for (
size_t i = 0; i <
members.size(); i++)
158#ifndef N2P2_NO_SF_CACHE
161 auto cacheIndices =
members.at(0)->getCacheIndices();
163 double* result =
new double[
members.size()];
164 for (
size_t l = 0; l <
members.size(); ++l)
171 if (numNeighbors == 0) numNeighbors = 1;
173 for (
size_t j = 0; j < numNeighbors - 1; j++)
177 double const rij = nj.
d;
178 if ((
e1 == nej ||
e2 == nej) && rij <
rc)
180 double const r2ij = rij * rij;
185#ifndef N2P2_NO_SF_CACHE
186 if (cacheIndices[nej].size() == 0)
fc.
fdf(rij, pfcij, pdfcij);
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);
196 fc.
fdf(rij, pfcij, pdfcij);
200 double const*
const dr1 = nj.
dr.
r;
202 for (
size_t k = j + 1; k < numNeighbors; k++)
206 if ((
e1 == nej &&
e2 == nek) ||
207 (
e2 == nej &&
e1 == nek))
209 double const rik = nk.
d;
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];
223#ifndef N2P2_NO_SF_CACHE
224 if (cacheIndices[nek].size() == 0)
226 fc.
fdf(rik, pfcik, pdfcik);
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);
237 fc.
fdf(rik, pfcik, pdfcik);
239 double const rinvijik = 1.0 / rij / rik;
242 double const costijk = (dr1[0] * dr2[0] +
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;
254 for (
size_t l = 0; l <
members.size(); ++l)
262 vexp = exp(-
eta[l] * (rijs * rijs
267 vexp = exp(-
eta[l] * r2sum);
270 double const plambda = 1.0 +
lambda[l] * costijk;
272 if (plambda <= 0.0) fg = 0.0;
281 fg *= pow(plambda,
zeta[l] - 1.0);
284 result[l] += fg * plambda * pfc;
287 if (!derivatives)
continue;
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);
304 p1 = fg * (pfczl * (rinvijik - costijk / r2ij
305 - p2etapl) + pr1 * plambda);
306 p2 = fg * (pfczl * (rinvijik - costijk / r2ik
307 - p2etapl) + pr2 * plambda);
310 double const p3 = fg * pfczl * rinvijik;
323 double const p1drijx = p1 * dr1[0];
324 double const p1drijy = p1 * dr1[1];
325 double const p1drijz = p1 * dr1[2];
327 double const p2drikx = p2 * dr2[0];
328 double const p2driky = p2 * dr2[1];
329 double const p2drikz = p2 * dr2[2];
331 double const p3drjkx = p3 * dr30;
332 double const p3drjky = p3 * dr31;
333 double const p3drjkz = p3 * dr32;
335#ifndef N2P2_FULL_SFD_MEMORY
340 double* dGdr = atom.
dGdr[li].r;
341 dGdr[0] += p1drijx + p2drikx;
342 dGdr[1] += p1drijy + p2driky;
343 dGdr[2] += p1drijz + p2drikz;
345#ifndef N2P2_FULL_SFD_MEMORY
348 dGdr = nj.
dGdr[li].r;
349 dGdr[0] -= p1drijx + p3drjkx;
350 dGdr[1] -= p1drijy + p3drjky;
351 dGdr[2] -= p1drijz + p3drjkz;
353#ifndef N2P2_FULL_SFD_MEMORY
356 dGdr = nk.
dGdr[li].r;
357 dGdr[0] -= p2drikx - p3drjkx;
358 dGdr[1] -= p2driky - p3drjky;
359 dGdr[2] -= p2drikz - p3drjkz;
367 for (
size_t l = 0; l <
members.size(); ++l)
void fdf(double r, double &fc, double &dfc) const
Calculate cutoff function and derivative .
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)
Symmetry function base class.
double getConvLength() const
Get private convLength member variable.
double getRc() const
Get private rc member variable.
std::size_t getType() const
Get private type member variable.
std::size_t getEc() const
Get private ec member variable.
double cutoffAlpha
Cutoff function parameter (common feature).
std::string subtype
Subtype string (specifies cutoff type) (common feature).
CutoffFunction fc
Cutoff function used by this symmetry function group.
double rc
Cutoff radius (common feature).
CutoffFunction::CutoffType cutoffType
Cutoff type used by this symmetry function group (common feature).
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::size_t e2
Element index of neighbor atom 2 (common feature).
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::size_t e1
Element index of neighbor atom 1 (common feature).
Angular symmetry function group (type 3)
std::vector< SymFncExpAngw const * > members
Vector of all group member pointers.
virtual void calculate(Atom &atom, bool const derivatives) const
Calculate all symmetry functions of this group for one atom.
virtual bool operator==(SymGrp const &rhs) const
Overload == operator.
virtual void sortMembers()
Sort member symmetry functions.
virtual bool operator<(SymGrp const &rhs) const
Overload < operator.
virtual bool addMember(SymFnc const *const symmetryFunction)
Potentially add a member to group.
std::size_t type
Symmetry function type.
std::size_t getType() const
Get private type member variable.
std::vector< size_t > memberIndex
Vector containing indices of all member symmetry functions.
std::size_t ec
Element index of center atom (common feature).
std::vector< std::vector< std::size_t > > memberIndexPerElement
Vector containing per-element indices of all member symmetry functions.
std::size_t getEc() const
Get private ec member variable.
double convLength
Data set normalization length conversion factor.
std::size_t getIndex() const
Get private index member variable.
std::vector< double > scalingFactors
Scaling factors of all member symmetry functions.
double pow_int(double x, int n)
Integer version of power function, "fast exponentiation algorithm".
Struct to store information on neighbor atoms.
std::vector< double > cache
Symmetry function cache (e.g. for cutoffs, compact functions).
std::size_t element
Element index of neighbor atom.
double d
Distance to neighbor atom.
Vec3D dr
Distance vector to neighbor atom.
std::vector< Vec3D > dGdr
Derivatives of symmetry functions with respect to neighbor coordinates.
Storage for a single atom.
std::vector< Neighbor > neighbors
Neighbor array (maximum number defined in macros.h.
std::vector< Vec3D > dGdr
Derivative of symmetry functions with respect to this atom's coordinates.
std::vector< double > G
Symmetry function values.
std::size_t numNeighbors
Total number of neighbors.
double r[3]
cartesian coordinates.