30SymGrpCompAngnWeighted::
31SymGrpCompAngnWeighted(
ElementMap const& elementMap) :
38 if (
ec != rhs.
getEc() )
return false;
45 if (
ec < rhs.
getEc() )
return true;
46 else if (
ec > rhs.
getEc() )
return false;
54 if (symmetryFunction->
getType() !=
type)
return false;
65 if (sf->
getEc() !=
ec )
return false;
68 throw runtime_error(
"ERROR: Unable to add symmetry function members "
69 "with different conversion factors.\n");
85 comparePointerTargets<SymFncCompAngnWeighted const>);
91 for (
size_t i = 0; i <
members.size(); i++)
95 mal.at(i) =
members[i]->getAngleLeft() * M_PI / 180.0;
96 mar.at(i) =
members[i]->getAngleRight() * M_PI / 180.0;
117#ifndef N2P2_NO_SF_CACHE
119 for (
size_t k = 0; k <
members.size(); ++k)
137 double* result =
new double[
members.size()];
138 double* radij =
new double[
members.size()];
139 double* dradij =
new double[
members.size()];
140 for (
size_t l = 0; l <
members.size(); ++l)
152 if (numNeighbors == 0) numNeighbors = 1;
154 for (
size_t j = 0; j < numNeighbors - 1; j++)
158 double const rij = nj.
d;
160 if (rij < rmax && rij >
rmin)
164 for (
size_t l = 0; l <
members.size(); ++l)
166 if (rij >
mrl[l] && rij <
mrc[l])
169#ifndef N2P2_NO_SF_CACHE
170 if (
mci[l][nej].size() == 0)
176 double& crad = nj.
cache[
mci[l][nej][0]];
177 double& cdrad = nj.
cache[
mci[l][nej][1]];
191 double const*
const dr1 = nj.
dr.
r;
193 for (
size_t k = j + 1; k < numNeighbors; k++)
197 double const rik = nk.
d;
198 if (rik < rmax && rik >
rmin)
203 double const*
const dr2 = nk.
dr.
r;
204 double const dr30 = dr2[0] - dr1[0];
205 double const dr31 = dr2[1] - dr1[1];
206 double const dr32 = dr2[2] - dr1[2];
208 double rjk = dr30 * dr30
211 if ((rjk >= r2max) || (rjk <= r2min))
continue;
215 double const rinvijik = 1.0 / (rij * rik);
216 double const costijk = (dr1[0] * dr2[0] +
218 dr1[2] * dr2[2]) * rinvijik;
222 if (costijk <= -1.0 || costijk >= 1.0)
continue;
224 double const acostijk = acos(costijk);
226 double const rinvij = rinvijik * rik;
227 double const rinvik = rinvijik * rij;
228 double const rinvjk = 1.0 / rjk;
229 double const phiijik0 = rinvij
230 * (rinvik - rinvij * costijk);
231 double const phiikij0 = rinvik
232 * (rinvij - rinvik * costijk);
233 double dacostijk = 0.0;
236 dacostijk = -1.0 / sqrt(1.0 - costijk * costijk);
247 for (
size_t l = 0; l <
members.size(); ++l)
250 if (radij[l] == 0.0 ||
251 rik <=
mrl[l] || rik >=
mrc[l] ||
252 rjk <=
mrl[l] || rjk >=
mrc[l] ||
253 acostijk <=
mal[l] || acostijk >=
mar[l])
261#ifndef N2P2_NO_SF_CACHE
262 if (
mci[l][nek].size() == 0)
268 double& crad = nk.
cache[
mci[l][nek][0]];
269 double& cdrad = nk.
cache[
mci[l][nek][1]];
289 double rad = radij[l] * radik * radjk;
290 result[l] += rad * ang;
293 if (!derivatives)
continue;
296 double const phiijik = phiijik0 * dang;
297 double const phiikij = phiikij0 * dang;
298 double const psiijik = rinvijik * dang;
300 double const chiij = rinvij * dradij[l]
302 double const chiik = rinvik * radij[l]
304 double const chijk = -rinvjk * radij[l]
311 if (dang != 0.0 && rad != 0.0)
315 p1 = rad * phiijik + ang * chiij;
316 p2 = rad * phiikij + ang * chiik;
317 p3 = rad * psiijik + ang * chijk;
340 double const p1drijx = p1 * dr1[0];
341 double const p1drijy = p1 * dr1[1];
342 double const p1drijz = p1 * dr1[2];
344 double const p2drikx = p2 * dr2[0];
345 double const p2driky = p2 * dr2[1];
346 double const p2drikz = p2 * dr2[2];
348 double const p3drjkx = p3 * dr30;
349 double const p3drjky = p3 * dr31;
350 double const p3drjkz = p3 * dr32;
352#ifndef N2P2_FULL_SFD_MEMORY
357 double* dGdr = atom.
dGdr[li].r;
358 dGdr[0] += p1drijx + p2drikx;
359 dGdr[1] += p1drijy + p2driky;
360 dGdr[2] += p1drijz + p2drikz;
362#ifndef N2P2_FULL_SFD_MEMORY
365 dGdr = nj.
dGdr[li].r;
366 dGdr[0] -= p1drijx + p3drjkx;
367 dGdr[1] -= p1drijy + p3drjky;
368 dGdr[2] -= p1drijz + p3drjkz;
370#ifndef N2P2_FULL_SFD_MEMORY
373 dGdr = nk.
dGdr[li].r;
374 dGdr[0] -= p2drikx - p3drjkx;
375 dGdr[1] -= p2driky - p3drjky;
376 dGdr[2] -= p2drikz - p3drjkz;
383 for (
size_t l = 0; l <
members.size(); ++l)
std::size_t atomicNumber(std::size_t index) const
Get atomic number from element index.
void getCompactRadial(double const x, double &fx, double &dfx) const
void getCompactAngle(double const x, double &fx, double &dfx) const
double getRl() const
Get private rl member variable.
Weighted narrow angular symmetry function with compact support (type 24)
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.
std::vector< double > mal
Member angleLeft.
std::vector< double > mrc
Member rc.
std::vector< bool > calculateComp
Vector indicating whether compact function needs to be recalculated.
std::vector< double > mrl
Member rl.
std::vector< std::vector< std::vector< std::size_t > > > mci
Member cache indices for actual neighbor element.
std::vector< double > mar
Member angleRight.
double rmin
Minimum radius within group.
double rmax
Maximum radius within group.
virtual bool addMember(SymFnc const *const symmetryFunction)
Potentially add a member to group.
virtual void calculate(Atom &atom, bool const derivatives) const
Calculate all symmetry functions of this group for one atom.
std::vector< SymFncCompAngnWeighted const * > members
Vector of all group member pointers.
virtual bool operator==(SymGrp const &rhs) const
Overload == operator.
virtual bool operator<(SymGrp const &rhs) const
Overload < operator.
virtual void sortMembers()
Sort member symmetry functions.
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.
ElementMap elementMap
Copy of element map.
std::size_t getIndex() const
Get private index member variable.
std::vector< double > scalingFactors
Scaling factors of all member symmetry functions.
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.