30SymGrpCompAngwWeighted::
31SymGrpCompAngwWeighted(
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<SymFncCompAngwWeighted 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;
102#ifndef N2P2_NO_SF_CACHE
104 for (
size_t k = 0; k <
members.size(); ++k)
122 double* result =
new double[
members.size()];
123 double* radij =
new double[
members.size()];
124 double* dradij =
new double[
members.size()];
125 for (
size_t l = 0; l <
members.size(); ++l)
134 if (numNeighbors == 0) numNeighbors = 1;
136 for (
size_t j = 0; j < numNeighbors - 1; j++)
140 double const rij = nj.
d;
142 if (rij < rmax && rij >
rmin)
146 for (
size_t l = 0; l <
members.size(); ++l)
148 if (rij >
mrl[l] && rij <
mrc[l])
151#ifndef N2P2_NO_SF_CACHE
152 if (
mci[l][nej].size() == 0)
158 double& crad = nj.
cache[
mci[l][nej][0]];
159 double& cdrad = nj.
cache[
mci[l][nej][1]];
173 double const*
const dr1 = nj.
dr.
r;
175 for (
size_t k = j + 1; k < numNeighbors; k++)
179 double const rik = nk.
d;
180 if (rik < rmax && rik >
rmin)
185 double const*
const dr2 = nk.
dr.
r;
186 double const dr30 = dr2[0] - dr1[0];
187 double const dr31 = dr2[1] - dr1[1];
188 double const dr32 = dr2[2] - dr1[2];
191 double const rinvijik = 1.0 / (rij * rik);
192 double const costijk = (dr1[0] * dr2[0] +
194 dr1[2] * dr2[2]) * rinvijik;
198 if (costijk <= -1.0 || costijk >= 1.0)
continue;
200 double const acostijk = acos(costijk);
202 double const rinvij = rinvijik * rik;
203 double const rinvik = rinvijik * rij;
204 double const phiijik0 = rinvij
205 * (rinvik - rinvij * costijk);
206 double const phiikij0 = rinvik
207 * (rinvij - rinvik * costijk);
208 double dacostijk = 0.0;
211 dacostijk = -1.0 / sqrt(1.0 - costijk * costijk);
219 for (
size_t l = 0; l <
members.size(); ++l)
222 if (radij[l] == 0.0 ||
223 rik <=
mrl[l] || rik >=
mrc[l] ||
224 acostijk <=
mal[l] || acostijk >=
mar[l])
230#ifndef N2P2_NO_SF_CACHE
231 if (
mci[l][nek].size() == 0)
237 double& crad = nk.
cache[
mci[l][nek][0]];
238 double& cdrad = nk.
cache[
mci[l][nek][1]];
251 double rad = radij[l] * radik;
252 result[l] += rad * ang;
255 if (!derivatives)
continue;
258 double const phiijik = phiijik0 * dang;
259 double const phiikij = phiikij0 * dang;
260 double const psiijik = rinvijik * dang;
262 double const chiij = rinvij * dradij[l] * radik;
263 double const chiik = rinvik * radij[l] * dradik;
269 if (dang != 0.0 && rad != 0.0)
273 p1 = rad * phiijik + ang * chiij;
274 p2 = rad * phiikij + ang * chiik;
298 double const p1drijx = p1 * dr1[0];
299 double const p1drijy = p1 * dr1[1];
300 double const p1drijz = p1 * dr1[2];
302 double const p2drikx = p2 * dr2[0];
303 double const p2driky = p2 * dr2[1];
304 double const p2drikz = p2 * dr2[2];
306 double const p3drjkx = p3 * dr30;
307 double const p3drjky = p3 * dr31;
308 double const p3drjkz = p3 * dr32;
310#ifndef N2P2_FULL_SFD_MEMORY
315 double* dGdr = atom.
dGdr[li].r;
316 dGdr[0] += p1drijx + p2drikx;
317 dGdr[1] += p1drijy + p2driky;
318 dGdr[2] += p1drijz + p2drikz;
320#ifndef N2P2_FULL_SFD_MEMORY
323 dGdr = nj.
dGdr[li].r;
324 dGdr[0] -= p1drijx + p3drjkx;
325 dGdr[1] -= p1drijy + p3drjky;
326 dGdr[2] -= p1drijz + p3drjkz;
328#ifndef N2P2_FULL_SFD_MEMORY
331 dGdr = nk.
dGdr[li].r;
332 dGdr[0] -= p2drikx - p3drjkx;
333 dGdr[1] -= p2driky - p3drjky;
334 dGdr[2] -= p2drikz - p3drjkz;
341 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 wide angular symmetry function with compact support (type 25)
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< SymFncCompAngwWeighted const * > members
Vector of all group member pointers.
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.
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.