30SymFncExpAngn::SymFncExpAngn(
ElementMap const& elementMap) :
37 if (
ec != rhs.
getEc() )
return false;
42 if (
rc != c.
rc )
return false;
43 if (
eta != c.
eta )
return false;
46 if (
e1 != c.
e1 )
return false;
47 if (
e2 != c.
e2 )
return false;
53 if (
ec < rhs.
getEc() )
return true;
54 else if (
ec > rhs.
getEc() )
return false;
62 if (
rc < c.
rc )
return true;
63 else if (
rc > c.
rc )
return false;
64 if (
eta < c.
eta )
return true;
65 else if (
eta > c.
eta )
return false;
66 if (
rs < c.
rs )
return true;
67 else if (
rs > c.
rs )
return false;
69 else if (
zeta > c.
zeta )
return false;
72 if (
e1 < c.
e1 )
return true;
73 else if (
e1 > c.
e1 )
return false;
74 if (
e2 < c.
e2 )
return true;
75 else if (
e2 > c.
e2 )
return false;
81 double const pnorm = pow(2.0, 1.0 -
zeta);
83 double const rc2 =
rc *
rc;
89 if (numNeighbors == 0) numNeighbors = 1;
91 for (
size_t j = 0; j < numNeighbors - 1; j++)
95 double const rij = nj.
d;
96 if ((
e1 == nej ||
e2 == nej) && rij <
rc)
98 double const r2ij = rij * rij;
103#ifndef N2P2_NO_SF_CACHE
109 if (cfc < 0)
fc.
fdf(rij, cfc, cdfc);
114 fc.
fdf(rij, pfcij, pdfcij);
116 for (
size_t k = j + 1; k < numNeighbors; k++)
120 if ((
e1 == nej &&
e2 == nek) ||
121 (
e2 == nej &&
e1 == nek))
123 double const rik = nk.
d;
127 double rjk = drjk.
norm2();;
133#ifndef N2P2_NO_SF_CACHE
136 fc.
fdf(rik, pfcik, pdfcik);
142 if (cfc < 0)
fc.
fdf(rik, cfc, cdfc);
147 fc.
fdf(rik, pfcik, pdfcik);
152 fc.
fdf(rjk, pfcjk, pdfcjk);
156 double costijk = drij * drik;;
157 double rinvijik = 1.0 / rij / rik;
160 double const pfc = pfcij * pfcik * pfcjk;
161 double const r2ik = rik * rik;
162 double const rijs = rij -
rs;
163 double const riks = rik -
rs;
164 double const rjks = rjk -
rs;
165 double const pexp = exp(-
eta * (rijs * rijs +
168 double const plambda = 1.0 +
lambda * costijk;
170 if (plambda <= 0.0) fg = 0.0;
179 fg *= pow(plambda,
zeta - 1.0);
182 result += fg * plambda * pfc;
185 if (!derivatives)
continue;
189 double const p2etapl = 2.0 *
eta * plambda;
190 double const p1 = fg * (pfc * (rinvijik - costijk
191 / r2ij - p2etapl * rijs / rij)
192 + pfcik * pfcjk * pdfcij * plambda
194 double const p2 = fg * (pfc * (rinvijik - costijk
195 / r2ik - p2etapl * riks / rik)
196 + pfcij * pfcjk * pdfcik * plambda
198 double const p3 = fg * (pfc * (rinvijik + p2etapl
199 * rjks / rjk) - pfcij * pfcik
200 * pdfcjk * plambda / rjk);
207#ifndef N2P2_FULL_SFD_MEMORY
void fdf(double r, double &fc, double &dfc) const
Calculate cutoff function and derivative .
CutoffFunction fc
Cutoff function used by this symmetry function.
CutoffFunction::CutoffType cutoffType
Cutoff type used by this symmetry function.
double cutoffAlpha
Cutoff parameter .
Intermediate class for angular SFs based on cutoffs and exponentials.
double lambda
Cosine shift factor.
double zeta
Exponent of cosine term.
double eta
Width of gaussian.
std::size_t e1
Element index of neighbor atom 1.
std::size_t e2
Element index of neighbor atom 2.
int zetaInt
Integer version of .
double rs
Shift of gaussian.
bool useIntegerPow
Whether to use integer version of power function (faster).
Angular symmetry function (type 3)
virtual bool operator==(SymFnc const &rhs) const
Overload == operator.
virtual void calculate(Atom &atom, bool const derivatives) const
Calculate symmetry function for one atom.
virtual bool operator<(SymFnc const &rhs) const
Overload < operator.
Symmetry function base class.
std::size_t type
Symmetry function type.
std::size_t index
Symmetry function index (per element).
double scalingFactor
Scaling factor.
std::size_t getType() const
Get private type member variable.
std::vector< std::vector< std::size_t > > cacheIndices
Cache indices for each element.
double scale(double value) const
Apply symmetry function scaling and/or centering.
std::size_t getEc() const
Get private ec member variable.
std::vector< std::size_t > indexPerElement
Per-element index for derivative memory in Atom::Neighbor::dGdr arrays.
std::size_t ec
Element index of center atom.
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::size_t getStoredMinNumNeighbors(double const cutoffRadius) const
Return needed number of neighbors for a given cutoff radius from neighborCutoffs map.
std::vector< Vec3D > dGdr
Derivative of symmetry functions with respect to this atom's coordinates.
std::vector< double > G
Symmetry function values.
Vector in 3 dimensional real space.
double norm2() const
Calculate square of norm of vector.