30SymGrpExpAngnWeighted::SymGrpExpAngnWeighted(
ElementMap const& elementMap) :
44 if (
ec != rhs.
getEc() )
return false;
50 if (
rc != c.
rc )
return false;
56 if (
ec < rhs.
getEc() )
return true;
57 else if (
ec > rhs.
getEc() )
return false;
66 if (
rc < c.
rc )
return true;
67 else if (
rc > c.
rc )
return false;
73 if (symmetryFunction->
getType() !=
type)
return false;
94 if (sf->
getEc() !=
ec )
return false;
95 if (sf->
getRc() !=
rc )
return false;
98 throw runtime_error(
"ERROR: Unable to add symmetry function members "
99 "with different conversion factors.\n");
111 comparePointerTargets<SymFncExpAngnWeighted const>);
114 for (
size_t i = 0; i <
members.size(); i++)
152 for (
size_t i = 0; i <
members.size(); i++)
169#ifndef N2P2_NO_SF_CACHE
172 auto cacheIndices =
members.at(0)->getCacheIndices();
174 double* result =
new double[
members.size()];
175 for (
size_t l = 0; l <
members.size(); ++l)
180 double const rc2 =
rc *
rc;
183 if (numNeighbors == 0) numNeighbors = 1;
185 for (
size_t j = 0; j < numNeighbors - 1; j++)
189 double const rij = nj.
d;
192 double const r2ij = rij * rij;
197#ifndef N2P2_NO_SF_CACHE
198 if (cacheIndices[nej].size() == 0)
fc.
fdf(rij, pfcij, pdfcij);
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);
208 fc.
fdf(rij, pfcij, pdfcij);
213 double const*
const dr1 = nj.
dr.
r;
215 for (
size_t k = j + 1; k < numNeighbors; k++)
219 double const rik = nk.
d;
226 double const*
const dr2 = nk.
dr.
r;
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]
239#ifndef N2P2_NO_SF_CACHE
240 if (cacheIndices[nej].size() == 0)
242 fc.
fdf(rik, pfcik, pdfcik);
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);
253 fc.
fdf(rik, pfcik, pdfcik);
259 fc.
fdf(rjk, pfcjk, pdfcjk);
265 double const rinvijik = 1.0 / rij / rik;
268 double const costijk = (dr1[0] * dr2[0] +
270 dr1[2] * dr2[2]) * rinvijik;
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;
283 for (
size_t l = 0; l <
members.size(); ++l)
290 double const r2sum = rijs * rijs
293 vexp = exp(-
eta[l] * r2sum);
295 double const plambda = 1.0
298 if (plambda <= 0.0) fg = 0.0;
307 fg *= pow(plambda,
zeta[l] - 1.0);
310 result[l] += fg * plambda * pfc;
313 if (!derivatives)
continue;
317 double const p1 = fg * (pfczl * (rinvijik - costijk
318 / r2ij - p2etapl * rijs / rij)
320 double const p2 = fg * (pfczl * (rinvijik - costijk
321 / r2ik - p2etapl * riks / rik)
323 double const p3 = fg * (pfczl * (rinvijik + p2etapl
324 * rjks / rjk) - pr3 * plambda);
336 double const p1drijx = p1 * dr1[0];
337 double const p1drijy = p1 * dr1[1];
338 double const p1drijz = p1 * dr1[2];
340 double const p2drikx = p2 * dr2[0];
341 double const p2driky = p2 * dr2[1];
342 double const p2drikz = p2 * dr2[2];
344 double const p3drjkx = p3 * dr3[0];
345 double const p3drjky = p3 * dr3[1];
346 double const p3drjkz = p3 * dr3[2];
348#ifndef N2P2_FULL_SFD_MEMORY
353 double* dGdr = atom.
dGdr[li].r;
354 dGdr[0] += p1drijx + p2drikx;
355 dGdr[1] += p1drijy + p2driky;
356 dGdr[2] += p1drijz + p2drikz;
358#ifndef N2P2_FULL_SFD_MEMORY
361 dGdr = nj.
dGdr[li].r;
362 dGdr[0] -= p1drijx + p3drjkx;
363 dGdr[1] -= p1drijy + p3drjky;
364 dGdr[2] -= p1drijz + p3drjkz;
366#ifndef N2P2_FULL_SFD_MEMORY
369 dGdr = nk.
dGdr[li].r;
370 dGdr[0] -= p2drikx - p3drjkx;
371 dGdr[1] -= p2driky - p3drjky;
372 dGdr[2] -= p2drikz - p3drjkz;
380 for (
size_t l = 0; l <
members.size(); ++l)
403 for (
size_t i = 0; i <
members.size(); ++i)
410 members[i]->getLineNumber() + 1,
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::size_t atomicNumber(std::size_t index) const
Get atomic number from element index.
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)
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).
Weighted angular symmetry function group (type 13)
std::vector< double > zetaLambda
Vector containing values of all member symmetry functions.
virtual bool addMember(SymFnc const *const symmetryFunction)
Potentially add a member to group.
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.
virtual void setScalingFactors()
Fill scalingFactors with values from member symmetry functions.
virtual bool operator==(SymGrp const &rhs) const
Overload == operator.
std::vector< int > zetaInt
Vector containing values of all member symmetry functions.
virtual void calculate(Atom &atom, bool const derivatives) const
Calculate all symmetry functions of this group for one atom.
std::vector< bool > calculateExp
Vector indicating whether exponential term needs to be calculated.
std::vector< double > factorDeriv
Vector containing precalculated normalizing factor for derivatives.
virtual bool operator<(SymGrp const &rhs) const
Overload < operator.
virtual void sortMembers()
Sort member symmetry functions.
std::vector< SymFncExpAngnWeighted const * > members
Vector of all group member pointers.
std::vector< double > factorNorm
Vector containing precalculated normalizing factor for each zeta.
virtual std::vector< std::string > parameterLines() const
Give symmetry function group parameters on multiple lines.
std::size_t type
Symmetry function type.
std::size_t getType() const
Get private type member variable.
std::size_t index
Symmetry function group index.
std::vector< size_t > memberIndex
Vector containing indices of all member symmetry functions.
std::string getPrintFormatCommon() const
Get common parameter line format string.
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.
ElementMap elementMap
Copy of element map.
std::size_t getIndex() const
Get private index member variable.
std::string getPrintFormatMember() const
Get member parameter line format string.
std::vector< double > scalingFactors
Scaling factors of all member symmetry functions.
std::set< std::string > parametersMember
Set of common parameters IDs.
string strpr(const char *format,...)
String version of printf function.
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.