n2p2 - A neural network potential package
nnp::SymFncStatistics Class Reference

#include <SymFncStatistics.h>

Collaboration diagram for nnp::SymFncStatistics:

Classes

struct  Container
 Struct containing statistics gathered during symmetry function calculation. More...
 

Public Member Functions

 SymFncStatistics ()
 Constructor, initializes bool variables. More...
 
void addValue (std::size_t index, double value)
 Update symmetry function statistics with one value. More...
 
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. More...
 
std::vector< std::string > getExtrapolationWarningLines () const
 Get lines with extrapolation warnings. More...
 
std::size_t countExtrapolationWarnings () const
 Count total number of extrapolation warnings. More...
 
void resetStatistics ()
 Reset statistics for all symmetry functions at once. More...
 
void resetExtrapolationWarnings ()
 Reset extrapolation warnings for all symmetry functions at once. More...
 
void clear ()
 Completely erase database. More...
 

Public Attributes

bool collectStatistics
 Whether statistics are gathered. More...
 
bool collectExtrapolationWarnings
 Whether extrapolation warnings are logged. More...
 
bool writeExtrapolationWarnings
 Whether to write out extrapolation warnings immediately as they occur. More...
 
bool stopOnExtrapolationWarnings
 Whether to raise an exception in case of extrapolation warnings. More...
 
std::map< std::size_t, Containerdata
 Map for all symmetry functions containing all gathered information. More...
 

Detailed Description

Definition at line 28 of file SymFncStatistics.h.

Constructor & Destructor Documentation

◆ SymFncStatistics()

SymFncStatistics::SymFncStatistics ( )

Constructor, initializes bool variables.

Defaults are collectStatistics = false, collectExtrapolationWarnings = false, writeExtrapolationWarnings = false, stopOnExtrapolationWarnings = false.

Definition at line 72 of file SymFncStatistics.cpp.

72 :
73 collectStatistics (false),
77{
78}
bool stopOnExtrapolationWarnings
Whether to raise an exception in case of extrapolation warnings.
bool collectStatistics
Whether statistics are gathered.
bool collectExtrapolationWarnings
Whether extrapolation warnings are logged.
bool writeExtrapolationWarnings
Whether to write out extrapolation warnings immediately as they occur.

Member Function Documentation

◆ addValue()

void SymFncStatistics::addValue ( std::size_t  index,
double  value 
)

Update symmetry function statistics with one value.

Parameters
[in]indexSymmetry function index.
[in]valueSymmetry function value.

Definition at line 80 of file SymFncStatistics.cpp.

81{
82 data[index].count++;
83 data[index].sum += value;
84 data[index].sum2 += value * value;
85 data[index].min = min(data[index].min, value);
86 data[index].max = max(data[index].max, value);
87
88 return;
89}
std::map< std::size_t, Container > data
Map for all symmetry functions containing all gathered information.

References data.

Referenced by nnp::Element::updateSymmetryFunctionStatistics().

Here is the caller graph for this function:

◆ addExtrapolationWarning()

void SymFncStatistics::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.

Parameters
[in]indexSymmetry function index.
[in]typeSymmetry function type.
[in]valueUnscaled symmetry function value.
[in]GminMinimum symmetry function value from scaling data.
[in]GmaxMaximum symmetry function value from scaling data.
[in]elementSymmetry function element string.
[in]indexStructureIndex of structure of affected atom.
[in]indexAtomIndex of affected atom.

Definition at line 91 of file SymFncStatistics.cpp.

99{
100 data[index].countEW++;
101 data[index].Gmin = Gmin;
102 data[index].Gmax = Gmax;
103 data[index].type = type;
104 data[index].element = element;
105 data[index].valueEW.push_back(value);
106 data[index].indexStructureEW.push_back(indexStructure);
107 data[index].indexAtomEW.push_back(indexAtom);
108
109 return;
110}

References data.

Referenced by nnp::Element::updateSymmetryFunctionStatistics().

Here is the caller graph for this function:

◆ getExtrapolationWarningLines()

vector< string > SymFncStatistics::getExtrapolationWarningLines ( ) const

Get lines with extrapolation warnings.

Returns
Extrapolation warning lines.

Definition at line 112 of file SymFncStatistics.cpp.

113{
114 vector<string> vs;
115 for (map<size_t, Container>::const_iterator it = data.begin();
116 it != data.end(); ++it)
117 {
118 SymFncStatistics::Container const& d = it->second;
119 for (size_t i = 0; i < d.valueEW.size(); ++i)
120 {
121 vs.push_back(strpr("### NNP EXTRAPOLATION WARNING ### "
122 "STRUCTURE: %6zu ATOM: %9zu ELEMENT: %2s "
123 "SYMFUNC: %4zu TYPE: %2zu VALUE: %10.3E "
124 "MIN: %10.3E MAX: %10.3E\n",
125 d.indexStructureEW[i],
126 d.indexAtomEW[i],
127 d.element.c_str(),
128 it->first + 1,
129 d.type,
130 d.valueEW[i],
131 d.Gmin,
132 d.Gmax));
133 }
134 }
135
136 return vs;
137}
string strpr(const char *format,...)
String version of printf function.
Definition: utility.cpp:90
double d
Definition: nnp-cutoff.cpp:34
Struct containing statistics gathered during symmetry function calculation.

References d, data, and nnp::strpr().

Here is the call graph for this function:

◆ countExtrapolationWarnings()

size_t SymFncStatistics::countExtrapolationWarnings ( ) const

Count total number of extrapolation warnings.

Returns
Sum of extrapolation warnings for all symmetry functions.

Definition at line 139 of file SymFncStatistics.cpp.

140{
141 size_t n = 0;
142
143 for (map<size_t, Container>::const_iterator it = data.begin();
144 it != data.end(); ++it)
145 {
146 n += it->second.countEW;
147 }
148
149 return n;
150}

References data.

◆ resetStatistics()

void SymFncStatistics::resetStatistics ( )

Reset statistics for all symmetry functions at once.

Definition at line 152 of file SymFncStatistics.cpp.

153{
154 for (map<size_t, Container>::iterator it = data.begin();
155 it != data.end(); ++it)
156 {
157 it->second.resetStatistics();
158 }
159
160 return;
161}

References data.

Referenced by nnp::SymFncStatistics::Container::reset().

Here is the caller graph for this function:

◆ resetExtrapolationWarnings()

void SymFncStatistics::resetExtrapolationWarnings ( )

Reset extrapolation warnings for all symmetry functions at once.

Definition at line 163 of file SymFncStatistics.cpp.

164{
165 for (map<size_t, Container>::iterator it = data.begin();
166 it != data.end(); ++it)
167 {
168 it->second.resetExtrapolationWarnings();
169 }
170
171 return;
172}

References data.

Referenced by nnp::SymFncStatistics::Container::reset().

Here is the caller graph for this function:

◆ clear()

void SymFncStatistics::clear ( )

Completely erase database.

Definition at line 174 of file SymFncStatistics.cpp.

175{
176 data.clear();
177 return;
178}

References data.

Member Data Documentation

◆ collectStatistics

bool nnp::SymFncStatistics::collectStatistics

Whether statistics are gathered.

Definition at line 81 of file SymFncStatistics.h.

Referenced by nnp::Element::updateSymmetryFunctionStatistics().

◆ collectExtrapolationWarnings

bool nnp::SymFncStatistics::collectExtrapolationWarnings

Whether extrapolation warnings are logged.

Definition at line 83 of file SymFncStatistics.h.

Referenced by nnp::Element::updateSymmetryFunctionStatistics().

◆ writeExtrapolationWarnings

bool nnp::SymFncStatistics::writeExtrapolationWarnings

Whether to write out extrapolation warnings immediately as they occur.

Definition at line 85 of file SymFncStatistics.h.

Referenced by nnp::Element::updateSymmetryFunctionStatistics().

◆ stopOnExtrapolationWarnings

bool nnp::SymFncStatistics::stopOnExtrapolationWarnings

Whether to raise an exception in case of extrapolation warnings.

Definition at line 87 of file SymFncStatistics.h.

Referenced by nnp::Element::updateSymmetryFunctionStatistics().

◆ data

std::map<std::size_t, Container> nnp::SymFncStatistics::data

Map for all symmetry functions containing all gathered information.

Definition at line 89 of file SymFncStatistics.h.

Referenced by addExtrapolationWarning(), addValue(), clear(), countExtrapolationWarnings(), getExtrapolationWarningLines(), resetExtrapolationWarnings(), and resetStatistics().


The documentation for this class was generated from the following files: