56Element::Element(
size_t const index,
ElementMap const& elementMap) :
57 elementMap (elementMap ),
59 atomicNumber (elementMap.atomicNumber(index)),
60 atomicEnergyOffset (0.0 ),
61 symbol (elementMap.symbol(index) )
81 size_t const& lineNumber)
84 size_t type = (size_t)atoi(args.at(1).c_str());
132 throw runtime_error(
"ERROR: Unknown symmetry function type.\n");
146 (*it)->changeLengthUnit(convLength);
156 comparePointerTargets<SymFnc>);
170 for (vector<SymFnc*>::const_iterator
173 v.push_back((*sf)->parameterLine());
183 for (vector<SymFnc*>::const_iterator
186 v.push_back((*sf)->scalingLine());
194 for (vector<SymFnc*>::const_iterator
197 bool createNewGroup =
true;
198 for (vector<SymGrp*>::const_iterator
202 if ((*sfg)->addMember((*sf)))
204 createNewGroup =
false;
210 if ((*sf)->getType() == 2)
215 else if ((*sf)->getType() == 3)
220 else if ((*sf)->getType() == 9)
225 else if ((*sf)->getType() == 12)
230 else if ((*sf)->getType() == 13)
235 else if ((*sf)->getType() == 20)
240 else if ((*sf)->getType() == 21)
245 else if ((*sf)->getType() == 22)
250 else if ((*sf)->getType() == 23)
255 else if ((*sf)->getType() == 24)
260 else if ((*sf)->getType() == 25)
267 throw runtime_error(
"ERROR: Unknown symmetry function group"
276 comparePointerTargets<SymGrp>);
295 if (s->checkRelevantElement(i))
315 for (vector<SymGrp*>::const_iterator
319 vector<string> lines = (*it)->parameterLines();
320 v.insert(v.end(), lines.begin(), lines.end());
327 double const cutoffAlpha)
329 for (vector<SymFnc*>::const_iterator
346 string scalingLine =
strpr(
"%d %d 0.0 0.0 0.0 0.0",
363 vector<string>
const& statisticsLine,
370 statisticsLine.at(i),
384 size_t minNeighbors = 0;
386 for (vector<SymFnc*>::const_iterator
389 minNeighbors = max((*it)->getMinNeighbors(), minNeighbors);
397 double minCutoffRadius = numeric_limits<double>::max();
403 for (vector<SymFnc*>::const_iterator
406 minCutoffRadius = min((*it)->getRc(), minCutoffRadius);
409 return minCutoffRadius;
414 double maxCutoffRadius = 0.0;
416 for (vector<SymFnc*>::const_iterator
419 maxCutoffRadius = max((*it)->getRc(), maxCutoffRadius);
422 return maxCutoffRadius;
426 bool const derivatives)
const
428 for (vector<SymFnc*>::const_iterator
443 (*it)->calculate(atom, derivatives);
450 bool const derivatives)
const
452 for (vector<SymGrp*>::const_iterator
456 (*it)->calculate(atom, derivatives);
464 size_t countExtrapolationWarnings = 0;
465 double epsilon = 1000.0 * numeric_limits<double>::epsilon();
469 throw runtime_error(
"ERROR: Atom has a different element index.\n");
474 throw runtime_error(
"ERROR: Number of symmetry functions"
475 " does not match.\n");
478 for (
size_t i = 0; i < atom.
G.size(); ++i)
491 if (value + epsilon < Gmin || value - epsilon > Gmax)
493 countExtrapolationWarnings++;
507 cerr <<
strpr(
"### NNP EXTRAPOLATION WARNING ### "
508 "STRUCTURE: %6zu ATOM: %9" PRId64
" ELEMENT: "
509 "%2s SYMFUNC: %4zu TYPE: %2zu VALUE: %10.3E "
510 "MIN: %10.3E MAX: %10.3E\n",
523 strpr(
"### NNP EXTRAPOLATION WARNING ### "
524 "STRUCTURE: %6zu ATOM: %9" PRId64
" ELEMENT: "
525 "%2s SYMFUNC: %4zu TYPE: %2zu VALUE: %10.3E "
526 "MIN: %10.3E MAX: %10.3E\n"
527 "ERROR: Symmetry function value out of range.\n",
540 return countExtrapolationWarnings;
543#ifndef N2P2_NO_SF_CACHE
547 for (
size_t i = 0; i <
cacheLists.size(); ++i)
549 for (
size_t j = 0; j <
cacheLists.at(i).size(); ++j)
552 for (
size_t k = 0; k < c.
indices.size(); ++k)
565 vector<size_t> cacheSizes;
568 cacheSizes.push_back(c.size());
CutoffType
List of available cutoff function types.
std::size_t size() const
Get element map size.
void calculateSymmetryFunctions(Atom &atom, bool const derivatives) const
Calculate symmetry functions.
void setCutoffFunction(CutoffFunction::CutoffType const cutoffType, double const cutoffAlpha)
Set cutoff function for all symmetry functions.
std::vector< std::string > infoSymmetryFunctionParameters() const
Print symmetry function parameter value information.
ElementMap elementMap
Copy of element map.
void calculateSymmetryFunctionGroups(Atom &atom, bool const derivatives) const
Calculate symmetry functions via groups.
std::vector< std::size_t > getCacheSizes() const
Get cache sizes for each neighbor atom element.
SymFncStatistics statistics
Symmetry function statistics.
void sortSymmetryFunctions()
Sort all symmetry function.
std::vector< SymFnc * > symmetryFunctions
Vector of pointers to symmetry functions.
std::vector< std::string > infoSymmetryFunctionGroups() const
Print symmetry function group info.
void setupSymmetryFunctionMemory()
Extract relevant symmetry function combinations for derivative memory.
std::vector< std::string > infoSymmetryFunctionScaling() const
Print symmetry function scaling information.
double getMinCutoffRadius() const
Get minimum cutoff radius of all symmetry functions.
std::vector< std::vector< SFCacheList > > cacheLists
Symmetry function cache lists.
void setupSymmetryFunctionGroups()
Set up symmetry function groups.
void addSymmetryFunction(std::string const ¶meters, std::size_t const &lineNumber)
Add one symmetry function.
void setCacheIndices(std::vector< std::vector< SFCacheList > > cacheLists)
Set cache indices for all symmetry functions of this element.
std::size_t updateSymmetryFunctionStatistics(Atom const &atom)
Update symmetry function statistics.
std::size_t index
Global index of this element.
void setScaling(SymFnc::ScalingType scalingType, std::vector< std::string > const &statisticsLine, double minS, double maxS) const
Set scaling of all symmetry functions.
std::vector< std::vector< std::size_t > > symmetryFunctionTable
List of symmetry function indices relevant for each neighbor element.
std::string symbol
Element symbol.
std::size_t getMinNeighbors() const
Get maximum of required minimum number of neighbors for all symmetry functions for this element.
std::vector< SymGrp * > symmetryFunctionGroups
Vector of pointers to symmetry function groups.
std::vector< std::size_t > symmetryFunctionNumTable
Number of relevant symmetry functions for each neighbor element.
double getMaxCutoffRadius() const
Get maximum cutoff radius of all symmetry functions.
void clearSymmetryFunctions()
Clear all symmetry functions and groups.
void setScalingNone() const
Set no scaling of symmetry function.
void changeLengthUnitSymmetryFunctions(double convLength)
Change length unit for all symmetry functions.
Intermediate class for SFs based on cutoff functions.
void setCutoffFunction(CutoffFunction::CutoffType cutoffType, double cutoffAlpha)
Set cutoff function type and parameter.
Weighted narrow angular symmetry function with compact support (type 24)
Narrow angular symmetry function with compact support (type 21)
Weighted wide angular symmetry function with compact support (type 25)
Wide angular symmetry function with compact support (type 22)
Weighted radial symmetry function with compact support (type 23)
Radial symmetry function with compact support (type 20)
Weighted angular symmetry function (type 13)
Angular symmetry function (type 3)
Angular symmetry function (type 9)
Weighted radial symmetry function (type 12)
Radial symmetry function (type 2)
bool stopOnExtrapolationWarnings
Whether to raise an exception in case of extrapolation warnings.
void addValue(std::size_t index, double value)
Update symmetry function statistics with one value.
bool collectStatistics
Whether statistics are gathered.
void addExtrapolationWarning(std::size_t index, std::size_t type, double value, double Gmin, double Gmax, std::string element, std::size_t indexStructure, std::size_t indexAtom)
Add extrapolation warning entry.
bool collectExtrapolationWarnings
Whether extrapolation warnings are logged.
bool writeExtrapolationWarnings
Whether to write out extrapolation warnings immediately as they occur.
Symmetry function base class.
ScalingType
List of available scaling types.
void addCacheIndex(std::size_t element, std::size_t cacheIndex, std::string cacheIdentifier)
Add one cache index for given neighbor element and check identifier.
Weighted narrow angular symmetry function with compact support (type 24)
Narrow angular symmetry function with compact support (type 21)
Weighted wide angular symmetry function with compact support (type 25)
Wide angular symmetry function with compact support (type 22)
Weighted radial symmetry function with compact support (type 23)
Radial symmetry function with compact support (type 20)
Weighted angular symmetry function group (type 13)
Angular symmetry function group (type 3)
Angular symmetry function group (type 3)
Weighted radial symmetry function group (type 12)
Radial symmetry function group (type 2)
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.
Storage for a single atom.
std::size_t numSymmetryFunctions
Number of symmetry functions used to describe the atom environment.
std::size_t indexStructure
Index number of structure this atom belongs to.
int64_t tag
Tag number of this atom.
std::size_t element
Element index of this atom.
std::vector< double > G
Symmetry function values.
List of symmetry functions corresponding to one cache identifier.
std::size_t element
Neighbor element index.
std::string identifier
Cache identifier string.
std::vector< std::size_t > indices
Symmetry function indices for this cache.