56Element::Element(
size_t const index,
ElementMap const& elementMap) :
57 elementMap (elementMap ),
59 atomicNumber (elementMap.atomicNumber(index)),
60 atomicEnergyOffset (0.0 ),
63 symbol (elementMap.symbol(index) )
83 size_t const& lineNumber)
86 size_t type = (size_t)atoi(args.at(1).c_str());
134 throw runtime_error(
"ERROR: Unknown symmetry function type.\n");
148 (*it)->changeLengthUnit(convLength);
158 comparePointerTargets<SymFnc>);
172 for (vector<SymFnc*>::const_iterator
175 v.push_back((*sf)->parameterLine());
185 for (vector<SymFnc*>::const_iterator
188 v.push_back((*sf)->scalingLine());
196 for (vector<SymFnc*>::const_iterator
199 bool createNewGroup =
true;
200 for (vector<SymGrp*>::const_iterator
204 if ((*sfg)->addMember((*sf)))
206 createNewGroup =
false;
212 if ((*sf)->getType() == 2)
217 else if ((*sf)->getType() == 3)
222 else if ((*sf)->getType() == 9)
227 else if ((*sf)->getType() == 12)
232 else if ((*sf)->getType() == 13)
237 else if ((*sf)->getType() == 20)
242 else if ((*sf)->getType() == 21)
247 else if ((*sf)->getType() == 22)
252 else if ((*sf)->getType() == 23)
257 else if ((*sf)->getType() == 24)
262 else if ((*sf)->getType() == 25)
269 throw runtime_error(
"ERROR: Unknown symmetry function group"
278 comparePointerTargets<SymGrp>);
297 if (s->checkRelevantElement(i))
317 for (vector<SymGrp*>::const_iterator
321 vector<string> lines = (*it)->parameterLines();
322 v.insert(v.end(), lines.begin(), lines.end());
329 double const cutoffAlpha)
331 for (vector<SymFnc*>::const_iterator
348 string scalingLine =
strpr(
"%d %d 0.0 0.0 0.0 0.0",
365 vector<string>
const& statisticsLine,
372 statisticsLine.at(i),
386 size_t minNeighbors = 0;
388 for (vector<SymFnc*>::const_iterator
391 minNeighbors = max((*it)->getMinNeighbors(), minNeighbors);
399 double minCutoffRadius = numeric_limits<double>::max();
405 for (vector<SymFnc*>::const_iterator
408 minCutoffRadius = min((*it)->getRc(), minCutoffRadius);
411 return minCutoffRadius;
416 double maxCutoffRadius = 0.0;
418 for (vector<SymFnc*>::const_iterator
421 maxCutoffRadius = max((*it)->getRc(), maxCutoffRadius);
424 return maxCutoffRadius;
431 double rc = sf->getRc();
437 bool const derivatives)
const
439 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 getCutoffRadii(std::vector< double > &cutoffs) const
Get all different cutoff radii belonging to this element.
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.
bool vectorContains(std::vector< T > const &stdVec, T value)
Test if vector contains specified value.
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.