30SymFncExpAngnWeighted::SymFncExpAngnWeighted(
ElementMap const& elementMap) :
48 if (
ec != rhs.
getEc() )
return false;
54 if (
rc != c.
rc )
return false;
55 if (
eta != c.
eta )
return false;
56 if (
rs != c.
rs )
return false;
64 if (
ec < rhs.
getEc() )
return true;
65 else if (
ec > rhs.
getEc() )
return false;
74 if (
rc < c.
rc )
return true;
75 else if (
rc > c.
rc )
return false;
76 if (
eta < c.
eta )
return true;
77 else if (
eta > c.
eta )
return false;
78 if (
rs < c.
rs )
return true;
79 else if (
rs > c.
rs )
return false;
81 else if (
zeta > c.
zeta )
return false;
89 vector<string> splitLine =
split(
reduce(parameterString));
91 if (
type != (
size_t)atoi(splitLine.at(1).c_str()))
93 throw runtime_error(
"ERROR: Incorrect symmetry function type.\n");
97 eta = atof(splitLine.at(2).c_str());
98 rs = atof(splitLine.at(3).c_str());
99 lambda = atof(splitLine.at(4).c_str());
100 zeta = atof(splitLine.at(5).c_str());
101 rc = atof(splitLine.at(6).c_str());
107 if (fabs(
zeta -
zetaInt) <= numeric_limits<double>::min())
134 string s =
strpr(
"symfunction_short %2s %2zu %16.8E %16.8E %16.8E "
149 double const pnorm = pow(2.0, 1.0 -
zeta);
151 double const rc2 =
rc *
rc;
156 if (numNeighbors == 0) numNeighbors = 1;
158 for (
size_t j = 0; j < numNeighbors - 1; j++)
162 double const rij = nj.
d;
165 double const r2ij = rij * rij;
170#ifndef N2P2_NO_SF_CACHE
176 if (cfc < 0)
fc.
fdf(rij, cfc, cdfc);
181 fc.
fdf(rij, pfcij, pdfcij);
183 for (
size_t k = j + 1; k < numNeighbors; k++)
187 double const rik = nk.
d;
191 double rjk = drjk.
norm2();;
197#ifndef N2P2_NO_SF_CACHE
200 fc.
fdf(rik, pfcik, pdfcik);
206 if (cfc < 0)
fc.
fdf(rik, cfc, cdfc);
211 fc.
fdf(rik, pfcik, pdfcik);
216 fc.
fdf(rjk, pfcjk, pdfcjk);
220 double costijk = drij * drik;;
221 double rinvijik = 1.0 / rij / rik;
224 double const pfc = pfcij * pfcik * pfcjk;
225 double const r2ik = rik * rik;
226 double const rijs = rij -
rs;
227 double const riks = rik -
rs;
228 double const rjks = rjk -
rs;
231 * exp(-
eta * (rijs * rijs +
234 double const plambda = 1.0 +
lambda * costijk;
236 if (plambda <= 0.0) fg = 0.0;
245 fg *= pow(plambda,
zeta - 1.0);
248 result += fg * plambda * pfc;
251 if (!derivatives)
continue;
255 double const p2etapl = 2.0 *
eta * plambda;
256 double const p1 = fg * (pfc * (rinvijik - costijk
257 / r2ij - p2etapl * rijs / rij) + pfcik
258 * pfcjk * pdfcij * plambda / rij);
259 double const p2 = fg * (pfc * (rinvijik - costijk
260 / r2ik - p2etapl * riks / rik) + pfcij
261 * pfcjk * pdfcik * plambda / rik);
262 double const p3 = fg * (pfc * (rinvijik + p2etapl
263 * rjks / rjk) - pfcij * pfcik * pdfcjk
271#ifndef N2P2_FULL_SFD_MEMORY
313 v.push_back(
strpr((
pad(s, w) +
"%14.8E").c_str(),
318 v.push_back(
strpr((
pad(s, w) +
"%14.8E").c_str(),
zeta));
328 double const p = exp(-
eta * (r -
rs) * (r -
rs)) *
fc.
f(r);
335 return 2.0 * pow((1.0 +
lambda * cos(angle)) / 2.0,
zeta);
343#ifndef N2P2_NO_SF_CACHE
357 v.push_back(
strpr(
"%zu f ", i) + s);
358 v.push_back(
strpr(
"%zu df ", i) + s);
double f(double r) const
Cutoff function .
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 setCutoffRadius(double const cutoffRadius)
Set cutoff radius.
std::size_t size() const
Get element map size.
std::size_t atomicNumber(std::size_t index) const
Get atomic number from element index.
Intermediate class for SFs based on cutoff functions.
std::string subtype
Subtype string (specifies cutoff type).
CutoffFunction fc
Cutoff function used by this symmetry function.
CutoffFunction::CutoffType cutoffType
Cutoff type used by this symmetry function.
virtual std::vector< std::string > parameterInfo() const
Get description with parameter names and values.
double cutoffAlpha
Cutoff parameter .
Weighted angular symmetry function (type 13)
virtual double calculateAngularPart(double angle) const
Calculate (partial) symmetry function value for one given angle.
virtual bool checkRelevantElement(std::size_t index) const
Check whether symmetry function is relevant for given element.
int zetaInt
Integer version of .
virtual std::string getSettingsLine() const
Get settings file line from currently set parameters.
double rs
Shift of gaussian.
virtual double calculateRadialPart(double distance) const
Calculate (partial) symmetry function value for one given distance.
double lambda
Cosine shift factor.
virtual std::string parameterLine() const
Give symmetry function parameters in one line.
virtual bool operator==(SymFnc const &rhs) const
Overload == operator.
bool useIntegerPow
Whether to use integer version of power function (faster).
double eta
Width of gaussian.
virtual bool operator<(SymFnc const &rhs) const
Overload < operator.
double zeta
Exponent of cosine term.
virtual void setParameters(std::string const ¶meterString)
Set symmetry function parameters.
virtual void changeLengthUnit(double convLength)
Change length unit.
virtual std::vector< std::string > getCacheIdentifiers() const
Get unique cache identifiers.
virtual void calculate(Atom &atom, bool const derivatives) const
Calculate symmetry function for one atom.
virtual std::vector< std::string > parameterInfo() const
Get description with parameter names and values.
Symmetry function base class.
double convLength
Data set normalization length conversion factor.
std::size_t type
Symmetry function type.
std::set< std::string > parameters
Set with symmetry function parameter IDs (lookup for printing).
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.
ElementMap elementMap
Copy of element map.
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.
static std::size_t const sfinfoWidth
Width of the SFINFO parameter description field (see parameterInfo()).
std::size_t minNeighbors
Minimum number of neighbors required.
std::size_t lineNumber
Line number.
std::string getPrintFormat() const
Generate format string for symmetry function parameter printing.
string pad(string const &input, size_t num, char fill, bool right)
string strpr(const char *format,...)
String version of printf function.
vector< string > split(string const &input, char delimiter)
Split string at each delimiter.
string reduce(string const &line, string const &whitespace, string const &fill)
Replace multiple whitespaces with fill.
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.
Vector in 3 dimensional real space.
double norm2() const
Calculate square of norm of vector.