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

Contains element-specific data. More...

#include <Element.h>

Inheritance diagram for nnp::Element:
Collaboration diagram for nnp::Element:

Classes

struct  SFCacheList
 List of symmetry functions corresponding to one cache identifier. More...
 

Public Member Functions

 Element ()
 Default constructor. More...
 
 Element (std::size_t const index, ElementMap const &elementMap)
 Constructor using index. More...
 
virtual ~Element ()
 Destructor. More...
 
void clearSymmetryFunctions ()
 Clear all symmetry functions and groups. More...
 
void setAtomicEnergyOffset (double atomicEnergyOffset)
 Set atomicEnergyOffset. More...
 
std::size_t getIndex () const
 Get index. More...
 
std::size_t getAtomicNumber () const
 Get atomicNumber. More...
 
double getAtomicEnergyOffset () const
 Get atomicEnergyOffset. More...
 
std::string getSymbol () const
 Get symbol. More...
 
void addSymmetryFunction (std::string const &parameters, std::size_t const &lineNumber)
 Add one symmetry function. More...
 
void changeLengthUnitSymmetryFunctions (double convLength)
 Change length unit for all symmetry functions. More...
 
void sortSymmetryFunctions ()
 Sort all symmetry function. More...
 
std::vector< std::string > infoSymmetryFunctionParameters () const
 Print symmetry function parameter value information. More...
 
std::vector< std::string > infoSymmetryFunction (std::size_t index) const
 Print symmetry function parameter names and values. More...
 
std::vector< std::string > infoSymmetryFunctionScaling () const
 Print symmetry function scaling information. More...
 
void setupSymmetryFunctionGroups ()
 Set up symmetry function groups. More...
 
void setupSymmetryFunctionMemory ()
 Extract relevant symmetry function combinations for derivative memory. More...
 
std::vector< std::string > infoSymmetryFunctionGroups () const
 Print symmetry function group info. More...
 
void setCutoffFunction (CutoffFunction::CutoffType const cutoffType, double const cutoffAlpha)
 Set cutoff function for all symmetry functions. More...
 
void setScalingNone () const
 Set no scaling of symmetry function. More...
 
void setScaling (SymFnc::ScalingType scalingType, std::vector< std::string > const &statisticsLine, double minS, double maxS) const
 Set scaling of all symmetry functions. More...
 
std::size_t numSymmetryFunctions () const
 Get number of symmetry functions. More...
 
std::size_t getMinNeighbors () const
 Get maximum of required minimum number of neighbors for all symmetry functions for this element. More...
 
double getMinCutoffRadius () const
 Get minimum cutoff radius of all symmetry functions. More...
 
double getMaxCutoffRadius () const
 Get maximum cutoff radius of all symmetry functions. More...
 
std::vector< std::size_t > const & getSymmetryFunctionNumTable () const
 Get number of relevant symmetry functions per element. More...
 
std::vector< std::vector< std::size_t > > const & getSymmetryFunctionTable () const
 Get symmetry function element relevance table. More...
 
void calculateSymmetryFunctions (Atom &atom, bool const derivatives) const
 Calculate symmetry functions. More...
 
void calculateSymmetryFunctionGroups (Atom &atom, bool const derivatives) const
 Calculate symmetry functions via groups. More...
 
std::size_t updateSymmetryFunctionStatistics (Atom const &atom)
 Update symmetry function statistics. More...
 
SymFnc const & getSymmetryFunction (std::size_t index) const
 Get symmetry function instance. More...
 
void setCacheIndices (std::vector< std::vector< SFCacheList > > cacheLists)
 Set cache indices for all symmetry functions of this element. More...
 
std::vector< std::size_t > getCacheSizes () const
 Get cache sizes for each neighbor atom element. More...
 

Public Attributes

std::map< std::string, NeuralNetworkneuralNetworks
 Neural networks for this element. More...
 
SymFncStatistics statistics
 Symmetry function statistics. More...
 

Protected Attributes

ElementMap elementMap
 Copy of element map. More...
 
std::size_t index
 Global index of this element. More...
 
std::size_t atomicNumber
 Atomic number of this element. More...
 
double atomicEnergyOffset
 Offset energy for every atom of this element. More...
 
std::string symbol
 Element symbol. More...
 
std::vector< std::size_t > symmetryFunctionNumTable
 Number of relevant symmetry functions for each neighbor element. More...
 
std::vector< std::vector< std::size_t > > symmetryFunctionTable
 List of symmetry function indices relevant for each neighbor element. More...
 
std::vector< std::vector< SFCacheList > > cacheLists
 Symmetry function cache lists. More...
 
std::vector< SymFnc * > symmetryFunctions
 Vector of pointers to symmetry functions. More...
 
std::vector< SymGrp * > symmetryFunctionGroups
 Vector of pointers to symmetry function groups. More...
 

Detailed Description

Contains element-specific data.

Definition at line 38 of file Element.h.

Constructor & Destructor Documentation

◆ Element() [1/2]

nnp::Element::Element ( )
inline

Default constructor.

Definition at line 57 of file Element.h.

57{}

◆ Element() [2/2]

nnp::Element::Element ( std::size_t const  index,
ElementMap const &  elementMap 
)

Constructor using index.

◆ ~Element()

Element::~Element ( )
virtual

Destructor.

Necessary because of symmetryFunctions vector of pointers.

Definition at line 65 of file Element.cpp.

66{
68}
void clearSymmetryFunctions()
Clear all symmetry functions and groups.
Definition: Element.cpp:70

References clearSymmetryFunctions().

Here is the call graph for this function:

Member Function Documentation

◆ clearSymmetryFunctions()

void Element::clearSymmetryFunctions ( )

Clear all symmetry functions and groups.

Definition at line 70 of file Element.cpp.

71{
72 for (auto& s : symmetryFunctions) delete s;
73 symmetryFunctions.clear();
74 for (auto& s : symmetryFunctionGroups) delete s;
76
77 return;
78}
std::vector< SymFnc * > symmetryFunctions
Vector of pointers to symmetry functions.
Definition: Element.h:254
std::vector< SymGrp * > symmetryFunctionGroups
Vector of pointers to symmetry function groups.
Definition: Element.h:256

References symmetryFunctionGroups, and symmetryFunctions.

Referenced by ~Element().

Here is the caller graph for this function:

◆ setAtomicEnergyOffset()

void nnp::Element::setAtomicEnergyOffset ( double  atomicEnergyOffset)
inline

Set atomicEnergyOffset.

Definition at line 263 of file Element.h.

264{
266
267 return;
268}
double atomicEnergyOffset
Offset energy for every atom of this element.
Definition: Element.h:242

References atomicEnergyOffset.

◆ getIndex()

size_t nnp::Element::getIndex ( ) const
inline

Get index.

Definition at line 270 of file Element.h.

271{
272 return index;
273}
std::size_t index
Global index of this element.
Definition: Element.h:238

References index.

Referenced by nnp::Mode::calculateSymmetryFunctionGroups(), and nnp::Mode::calculateSymmetryFunctions().

Here is the caller graph for this function:

◆ getAtomicNumber()

size_t nnp::Element::getAtomicNumber ( ) const
inline

Get atomicNumber.

Definition at line 275 of file Element.h.

276{
277 return atomicNumber;
278}
std::size_t atomicNumber
Atomic number of this element.
Definition: Element.h:240

References atomicNumber.

Referenced by nnp::SetupAnalysis::writeSymmetryFunctionShape().

Here is the caller graph for this function:

◆ getAtomicEnergyOffset()

double nnp::Element::getAtomicEnergyOffset ( ) const
inline

Get atomicEnergyOffset.

Definition at line 280 of file Element.h.

281{
282 return atomicEnergyOffset;
283}

References atomicEnergyOffset.

Referenced by nnp::InterfaceLammps::getAtomicEnergy().

Here is the caller graph for this function:

◆ getSymbol()

std::string nnp::Element::getSymbol ( ) const
inline

Get symbol.

Definition at line 285 of file Element.h.

286{
287 return symbol;
288}
std::string symbol
Element symbol.
Definition: Element.h:244

References symbol.

Referenced by nnp::Mode::setupNeuralNetwork(), and nnp::Mode::setupSymmetryFunctionCache().

Here is the caller graph for this function:

◆ addSymmetryFunction()

void Element::addSymmetryFunction ( std::string const &  parameters,
std::size_t const &  lineNumber 
)

Add one symmetry function.

Parameters
[in]parametersString containing settings for symmetry function.
[in]lineNumberLine number of symmetry function in settings file.

Definition at line 80 of file Element.cpp.

82{
83 vector<string> args = split(reduce(parameters));
84 size_t type = (size_t)atoi(args.at(1).c_str());
85
86 if (type == 2)
87 {
89 }
90 else if (type == 3)
91 {
93 }
94 else if (type == 9)
95 {
97 }
98 else if (type == 12)
99 {
101 }
102 else if (type == 13)
103 {
105 }
106 else if (type == 20)
107 {
109 }
110 else if (type == 21)
111 {
113 }
114 else if (type == 22)
115 {
117 }
118 else if (type == 23)
119 {
121 }
122 else if (type == 24)
123 {
125 }
126 else if (type == 25)
127 {
129 }
130 else
131 {
132 throw runtime_error("ERROR: Unknown symmetry function type.\n");
133 }
134
135 symmetryFunctions.back()->setParameters(parameters);
136 symmetryFunctions.back()->setLineNumber(lineNumber);
137
138 return;
139}
ElementMap elementMap
Copy of element map.
Definition: Element.h:236
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)
Definition: SymFncCompRad.h:56
Weighted angular symmetry function (type 13)
Angular symmetry function (type 3)
Definition: SymFncExpAngn.h:55
Angular symmetry function (type 9)
Definition: SymFncExpAngw.h:54
Weighted radial symmetry function (type 12)
Radial symmetry function (type 2)
Definition: SymFncExpRad.h:49
vector< string > split(string const &input, char delimiter)
Split string at each delimiter.
Definition: utility.cpp:33
string reduce(string const &line, string const &whitespace, string const &fill)
Replace multiple whitespaces with fill.
Definition: utility.cpp:60

References elementMap, nnp::reduce(), nnp::split(), and symmetryFunctions.

Here is the call graph for this function:

◆ changeLengthUnitSymmetryFunctions()

void Element::changeLengthUnitSymmetryFunctions ( double  convLength)

Change length unit for all symmetry functions.

Parameters
[in]convLengthLength unit conversion factor.

Definition at line 141 of file Element.cpp.

142{
143 for (vector<SymFnc*>::iterator it = symmetryFunctions.begin();
144 it != symmetryFunctions.end(); ++it)
145 {
146 (*it)->changeLengthUnit(convLength);
147 }
148
149 return;
150}

References symmetryFunctions.

◆ sortSymmetryFunctions()

void Element::sortSymmetryFunctions ( )

Sort all symmetry function.

Definition at line 152 of file Element.cpp.

153{
154 sort(symmetryFunctions.begin(),
155 symmetryFunctions.end(),
156 comparePointerTargets<SymFnc>);
157
158 for (size_t i = 0; i < symmetryFunctions.size(); ++i)
159 {
160 symmetryFunctions.at(i)->setIndex(i);
161 }
162
163 return;
164}

References symmetryFunctions.

◆ infoSymmetryFunctionParameters()

vector< string > Element::infoSymmetryFunctionParameters ( ) const

Print symmetry function parameter value information.

Definition at line 166 of file Element.cpp.

167{
168 vector<string> v;
169
170 for (vector<SymFnc*>::const_iterator
171 sf = symmetryFunctions.begin(); sf != symmetryFunctions.end(); ++sf)
172 {
173 v.push_back((*sf)->parameterLine());
174 }
175
176 return v;
177}

References symmetryFunctions.

◆ infoSymmetryFunction()

std::vector< std::string > nnp::Element::infoSymmetryFunction ( std::size_t  index) const
inline

Print symmetry function parameter names and values.

Definition at line 303 of file Element.h.

304{
305 return symmetryFunctions.at(index)->parameterInfo();
306}

References index, and symmetryFunctions.

Referenced by nnp::SetupAnalysis::writeSymmetryFunctionShape().

Here is the caller graph for this function:

◆ infoSymmetryFunctionScaling()

vector< string > Element::infoSymmetryFunctionScaling ( ) const

Print symmetry function scaling information.

Definition at line 179 of file Element.cpp.

180{
181 vector<string> v;
182
183 for (vector<SymFnc*>::const_iterator
184 sf = symmetryFunctions.begin(); sf != symmetryFunctions.end(); ++sf)
185 {
186 v.push_back((*sf)->scalingLine());
187 }
188
189 return v;
190}

References symmetryFunctions.

◆ setupSymmetryFunctionGroups()

void Element::setupSymmetryFunctionGroups ( )

Set up symmetry function groups.

Definition at line 192 of file Element.cpp.

193{
194 for (vector<SymFnc*>::const_iterator
195 sf = symmetryFunctions.begin(); sf != symmetryFunctions.end(); ++sf)
196 {
197 bool createNewGroup = true;
198 for (vector<SymGrp*>::const_iterator
199 sfg = symmetryFunctionGroups.begin();
200 sfg != symmetryFunctionGroups.end(); ++sfg)
201 {
202 if ((*sfg)->addMember((*sf)))
203 {
204 createNewGroup = false;
205 break;
206 }
207 }
208 if (createNewGroup)
209 {
210 if ((*sf)->getType() == 2)
211 {
212 symmetryFunctionGroups.push_back((SymGrp*)
214 }
215 else if ((*sf)->getType() == 3)
216 {
217 symmetryFunctionGroups.push_back((SymGrp*)
219 }
220 else if ((*sf)->getType() == 9)
221 {
222 symmetryFunctionGroups.push_back((SymGrp*)
224 }
225 else if ((*sf)->getType() == 12)
226 {
227 symmetryFunctionGroups.push_back((SymGrp*)
229 }
230 else if ((*sf)->getType() == 13)
231 {
232 symmetryFunctionGroups.push_back((SymGrp*)
234 }
235 else if ((*sf)->getType() == 20)
236 {
237 symmetryFunctionGroups.push_back((SymGrp*)
239 }
240 else if ((*sf)->getType() == 21)
241 {
242 symmetryFunctionGroups.push_back((SymGrp*)
244 }
245 else if ((*sf)->getType() == 22)
246 {
247 symmetryFunctionGroups.push_back((SymGrp*)
249 }
250 else if ((*sf)->getType() == 23)
251 {
252 symmetryFunctionGroups.push_back((SymGrp*)
254 }
255 else if ((*sf)->getType() == 24)
256 {
257 symmetryFunctionGroups.push_back((SymGrp*)
259 }
260 else if ((*sf)->getType() == 25)
261 {
262 symmetryFunctionGroups.push_back((SymGrp*)
264 }
265 else
266 {
267 throw runtime_error("ERROR: Unknown symmetry function group"
268 " type.\n");
269 }
270 symmetryFunctionGroups.back()->addMember(*sf);
271 }
272 }
273
274 sort(symmetryFunctionGroups.begin(),
276 comparePointerTargets<SymGrp>);
277
278 for (size_t i = 0; i < symmetryFunctionGroups.size(); ++i)
279 {
280 symmetryFunctionGroups.at(i)->sortMembers();
281 symmetryFunctionGroups.at(i)->setIndex(i);
282 }
283
284 return;
285}
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)
Definition: SymGrpCompRad.h:48
Weighted angular symmetry function group (type 13)
Angular symmetry function group (type 3)
Definition: SymGrpExpAngn.h:51
Angular symmetry function group (type 3)
Definition: SymGrpExpAngw.h:50
Weighted radial symmetry function group (type 12)
Radial symmetry function group (type 2)
Definition: SymGrpExpRad.h:47

References elementMap, symmetryFunctionGroups, and symmetryFunctions.

◆ setupSymmetryFunctionMemory()

void Element::setupSymmetryFunctionMemory ( )

Extract relevant symmetry function combinations for derivative memory.

Definition at line 287 of file Element.cpp.

288{
289 symmetryFunctionTable.clear();
291 for (auto const& s : symmetryFunctions)
292 {
293 for (size_t i = 0; i < elementMap.size(); ++i)
294 {
295 if (s->checkRelevantElement(i))
296 {
297 s->setIndexPerElement(i, symmetryFunctionTable.at(i).size());
298 symmetryFunctionTable.at(i).push_back(s->getIndex());
299 }
300 }
301 }
303 for (size_t i = 0; i < elementMap.size(); ++i)
304 {
305 symmetryFunctionNumTable.push_back(symmetryFunctionTable.at(i).size());
306 }
307
308 return;
309}
std::size_t size() const
Get element map size.
Definition: ElementMap.h:140
std::vector< std::vector< std::size_t > > symmetryFunctionTable
List of symmetry function indices relevant for each neighbor element.
Definition: Element.h:248
std::vector< std::size_t > symmetryFunctionNumTable
Number of relevant symmetry functions for each neighbor element.
Definition: Element.h:246

References elementMap, nnp::ElementMap::size(), symmetryFunctionNumTable, symmetryFunctions, and symmetryFunctionTable.

Here is the call graph for this function:

◆ infoSymmetryFunctionGroups()

vector< string > Element::infoSymmetryFunctionGroups ( ) const

Print symmetry function group info.

Definition at line 311 of file Element.cpp.

312{
313 vector<string> v;
314
315 for (vector<SymGrp*>::const_iterator
316 it = symmetryFunctionGroups.begin();
317 it != symmetryFunctionGroups.end(); ++it)
318 {
319 vector<string> lines = (*it)->parameterLines();
320 v.insert(v.end(), lines.begin(), lines.end());
321 }
322
323 return v;
324}

References symmetryFunctionGroups.

◆ setCutoffFunction()

void Element::setCutoffFunction ( CutoffFunction::CutoffType const  cutoffType,
double const  cutoffAlpha 
)

Set cutoff function for all symmetry functions.

Parameters
[in]cutoffTypeType of cutoff function.
[in]cutoffAlphaCutoff parameter for all functions.

Definition at line 326 of file Element.cpp.

328{
329 for (vector<SymFnc*>::const_iterator
330 it = symmetryFunctions.begin(); it != symmetryFunctions.end(); ++it)
331 {
332 SymFncBaseCutoff* sfcb = dynamic_cast<SymFncBaseCutoff*>(*it);
333 if (sfcb != nullptr)
334 {
335 sfcb->setCutoffFunction(cutoffType, cutoffAlpha);
336 }
337 }
338
339 return;
340}
Intermediate class for SFs based on cutoff functions.
void setCutoffFunction(CutoffFunction::CutoffType cutoffType, double cutoffAlpha)
Set cutoff function type and parameter.

References nnp::SymFncBaseCutoff::setCutoffFunction(), and symmetryFunctions.

Here is the call graph for this function:

◆ setScalingNone()

void Element::setScalingNone ( ) const

Set no scaling of symmetry function.

Still scaling factors need to be initialized.

Definition at line 342 of file Element.cpp.

343{
344 for (size_t i = 0; i < symmetryFunctions.size(); ++i)
345 {
346 string scalingLine = strpr("%d %d 0.0 0.0 0.0 0.0",
347 symmetryFunctions.at(i)->getEc(),
348 i + 1);
349 symmetryFunctions.at(i)->setScalingType(SymFnc::ST_NONE,
350 scalingLine,
351 0.0,
352 0.0);
353 }
354 for (size_t i = 0; i < symmetryFunctionGroups.size(); ++i)
355 {
356 symmetryFunctionGroups.at(i)->setScalingFactors();
357 }
358
359 return;
360}
@ ST_NONE
Definition: SymFnc.h:47
string strpr(const char *format,...)
String version of printf function.
Definition: utility.cpp:90

References nnp::SymFnc::ST_NONE, nnp::strpr(), symmetryFunctionGroups, and symmetryFunctions.

Here is the call graph for this function:

◆ setScaling()

void Element::setScaling ( SymFnc::ScalingType  scalingType,
std::vector< std::string > const &  statisticsLine,
double  minS,
double  maxS 
) const

Set scaling of all symmetry functions.

Parameters
[in]scalingTypeType of scaling, see SymFnc::ScalingType.
[in]statisticsLineVector of strings containing statistics for all symmetry functions.
[in]minSMinimum for scaling range.
[in]maxSMaximum for scaling range.

Definition at line 362 of file Element.cpp.

366{
367 for (size_t i = 0; i < symmetryFunctions.size(); ++i)
368 {
369 symmetryFunctions.at(i)->setScalingType(scalingType,
370 statisticsLine.at(i),
371 Smin,
372 Smax);
373 }
374 for (size_t i = 0; i < symmetryFunctionGroups.size(); ++i)
375 {
376 symmetryFunctionGroups.at(i)->setScalingFactors();
377 }
378
379 return;
380}

References symmetryFunctionGroups, and symmetryFunctions.

◆ numSymmetryFunctions()

size_t nnp::Element::numSymmetryFunctions ( ) const
inline

Get number of symmetry functions.

Returns
Number of symmetry functions.

Definition at line 308 of file Element.h.

309{
310 return symmetryFunctions.size();
311}

References symmetryFunctions.

Referenced by nnp::Mode::calculateSymmetryFunctionGroups(), nnp::Mode::calculateSymmetryFunctions(), nnp::Mode::setupNeuralNetwork(), nnp::Mode::setupSymmetryFunctionCache(), and nnp::SetupAnalysis::writeSymmetryFunctionShape().

Here is the caller graph for this function:

◆ getMinNeighbors()

size_t Element::getMinNeighbors ( ) const

Get maximum of required minimum number of neighbors for all symmetry functions for this element.

Returns
Minimum number of neighbors required.

Definition at line 382 of file Element.cpp.

383{
384 size_t minNeighbors = 0;
385
386 for (vector<SymFnc*>::const_iterator
387 it = symmetryFunctions.begin(); it != symmetryFunctions.end(); ++it)
388 {
389 minNeighbors = max((*it)->getMinNeighbors(), minNeighbors);
390 }
391
392 return minNeighbors;
393}

References symmetryFunctions.

◆ getMinCutoffRadius()

double Element::getMinCutoffRadius ( ) const

Get minimum cutoff radius of all symmetry functions.

Returns
Minimum cutoff radius.

Definition at line 395 of file Element.cpp.

396{
397 double minCutoffRadius = numeric_limits<double>::max();
398
399 // MPB: Hack to work with negative radii
400 // Exploit the fact that all allowed symmetry functions are either
401 // defined for a domain > 0 or have to be symmetric around 0.
402
403 for (vector<SymFnc*>::const_iterator
404 it = symmetryFunctions.begin(); it != symmetryFunctions.end(); ++it)
405 {
406 minCutoffRadius = min((*it)->getRc(), minCutoffRadius);
407 }
408
409 return minCutoffRadius;
410}

References symmetryFunctions.

◆ getMaxCutoffRadius()

double Element::getMaxCutoffRadius ( ) const

Get maximum cutoff radius of all symmetry functions.

Returns
Maximum cutoff radius.

Definition at line 412 of file Element.cpp.

413{
414 double maxCutoffRadius = 0.0;
415
416 for (vector<SymFnc*>::const_iterator
417 it = symmetryFunctions.begin(); it != symmetryFunctions.end(); ++it)
418 {
419 maxCutoffRadius = max((*it)->getRc(), maxCutoffRadius);
420 }
421
422 return maxCutoffRadius;
423}

References symmetryFunctions.

◆ getSymmetryFunctionNumTable()

std::vector< std::size_t > const & nnp::Element::getSymmetryFunctionNumTable ( ) const
inline

Get number of relevant symmetry functions per element.

Returns
symmetryFunctionNumTable

Definition at line 291 of file Element.h.

292{
294}

References symmetryFunctionNumTable.

Referenced by nnp::Mode::calculateSymmetryFunctionGroups(), and nnp::Mode::calculateSymmetryFunctions().

Here is the caller graph for this function:

◆ getSymmetryFunctionTable()

std::vector< std::vector< std::size_t > > const & nnp::Element::getSymmetryFunctionTable ( ) const
inline

Get symmetry function element relevance table.

Returns
symmetryFunctionTable

Definition at line 297 of file Element.h.

298{
300}

References symmetryFunctionTable.

◆ calculateSymmetryFunctions()

void Element::calculateSymmetryFunctions ( Atom atom,
bool const  derivatives 
) const

Calculate symmetry functions.

Parameters
[in]atomAtom whose symmetry functions are calculated.
[in]derivativesIf symmetry function derivatives will be calculated.

Definition at line 425 of file Element.cpp.

427{
428 for (vector<SymFnc*>::const_iterator
429 it = symmetryFunctions.begin();
430 it != symmetryFunctions.end(); ++it)
431 {
432 //cerr << (*it)->getIndex() << " "
433 // << elementMap[(*it)->getEc()] << " "
434 // << (*it)->getUnique() << "\n";
435 //auto cid = (*it)->getCacheIdentifiers();
436 //for (auto icid : cid) cerr << icid << "\n";
437 //auto ci = (*it)->getCacheIndices();
438 //for (auto eci : ci)
439 //{
440 // for (auto ici : eci) cerr << ici << " ";
441 // cerr << "\n";
442 //}
443 (*it)->calculate(atom, derivatives);
444 }
445
446 return;
447}

References symmetryFunctions.

Referenced by nnp::Mode::calculateSymmetryFunctions().

Here is the caller graph for this function:

◆ calculateSymmetryFunctionGroups()

void Element::calculateSymmetryFunctionGroups ( Atom atom,
bool const  derivatives 
) const

Calculate symmetry functions via groups.

Parameters
[in]atomAtom whose symmetry functions are calculated.
[in]derivativesIf symmetry function derivatives will be calculated.

Definition at line 449 of file Element.cpp.

451{
452 for (vector<SymGrp*>::const_iterator
453 it = symmetryFunctionGroups.begin();
454 it != symmetryFunctionGroups.end(); ++it)
455 {
456 (*it)->calculate(atom, derivatives);
457 }
458
459 return;
460}

References symmetryFunctionGroups.

Referenced by nnp::Mode::calculateSymmetryFunctionGroups().

Here is the caller graph for this function:

◆ updateSymmetryFunctionStatistics()

size_t Element::updateSymmetryFunctionStatistics ( Atom const &  atom)

Update symmetry function statistics.

Parameters
[in]atomAtom with symmetry function values.
Returns
Number of extrapolation warnings encountered.

This function checks also for extrapolation warnings.

Definition at line 462 of file Element.cpp.

463{
464 size_t countExtrapolationWarnings = 0;
465 double epsilon = 1000.0 * numeric_limits<double>::epsilon();
466
467 if (atom.element != index)
468 {
469 throw runtime_error("ERROR: Atom has a different element index.\n");
470 }
471
472 if (atom.numSymmetryFunctions != symmetryFunctions.size())
473 {
474 throw runtime_error("ERROR: Number of symmetry functions"
475 " does not match.\n");
476 }
477
478 for (size_t i = 0; i < atom.G.size(); ++i)
479 {
480 double const Gmin = symmetryFunctions.at(i)->getGmin();
481 double const Gmax = symmetryFunctions.at(i)->getGmax();
482 double const value = symmetryFunctions.at(i)->unscale(atom.G.at(i));
483 size_t const sfindex = symmetryFunctions.at(i)->getIndex();
484 size_t const type = symmetryFunctions.at(i)->getType();
486 {
487 statistics.addValue(sfindex, atom.G.at(i));
488 }
489
490 // Avoid "fake" EWs at the boundaries.
491 if (value + epsilon < Gmin || value - epsilon > Gmax)
492 {
493 countExtrapolationWarnings++;
495 {
497 type,
498 value,
499 Gmin,
500 Gmax,
501 symbol,
502 atom.indexStructure,
503 atom.tag);
504 }
506 {
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",
511 atom.indexStructure,
512 atom.tag,
513 symbol.c_str(),
514 sfindex + 1,
515 type,
516 value,
517 Gmin,
518 Gmax);
519 }
521 {
522 throw out_of_range(
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",
528 atom.indexStructure,
529 atom.tag,
530 symbol.c_str(),
531 sfindex + 1,
532 type,
533 value,
534 Gmin,
535 Gmax));
536 }
537 }
538 }
539
540 return countExtrapolationWarnings;
541}
SymFncStatistics statistics
Symmetry function statistics.
Definition: Element.h:232
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.

References nnp::SymFncStatistics::addExtrapolationWarning(), nnp::SymFncStatistics::addValue(), nnp::SymFncStatistics::collectExtrapolationWarnings, nnp::SymFncStatistics::collectStatistics, nnp::Atom::element, nnp::Atom::G, index, nnp::Atom::indexStructure, nnp::Atom::numSymmetryFunctions, statistics, nnp::SymFncStatistics::stopOnExtrapolationWarnings, nnp::strpr(), symbol, symmetryFunctions, nnp::Atom::tag, and nnp::SymFncStatistics::writeExtrapolationWarnings.

Referenced by nnp::Mode::calculateSymmetryFunctionGroups(), and nnp::Mode::calculateSymmetryFunctions().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getSymmetryFunction()

SymFnc const & nnp::Element::getSymmetryFunction ( std::size_t  index) const
inline

Get symmetry function instance.

Parameters
[in]indexSymmetry function index.
Returns
Symmetry function object.

Definition at line 313 of file Element.h.

315{
316 return *(symmetryFunctions.at(index));
317}

References index, and symmetryFunctions.

Referenced by nnp::Mode::setupSymmetryFunctionCache(), and nnp::SetupAnalysis::writeSymmetryFunctionShape().

Here is the caller graph for this function:

◆ setCacheIndices()

void Element::setCacheIndices ( std::vector< std::vector< SFCacheList > >  cacheLists)

Set cache indices for all symmetry functions of this element.

Parameters
[in]cacheListsList of cache identifier strings and corresponding SF indices for each neighbor element.

Definition at line 544 of file Element.cpp.

545{
546 this->cacheLists = cacheLists;
547 for (size_t i = 0; i < cacheLists.size(); ++i)
548 {
549 for (size_t j = 0; j < cacheLists.at(i).size(); ++j)
550 {
551 SFCacheList const& c = cacheLists.at(i).at(j);
552 for (size_t k = 0; k < c.indices.size(); ++k)
553 {
554 SymFnc*& sf = symmetryFunctions.at(c.indices.at(k));
555 sf->addCacheIndex(c.element, j, c.identifier);
556 }
557 }
558 }
559
560 return;
561}
std::vector< std::vector< SFCacheList > > cacheLists
Symmetry function cache lists.
Definition: Element.h:251
Symmetry function base class.
Definition: SymFnc.h:40
void addCacheIndex(std::size_t element, std::size_t cacheIndex, std::string cacheIdentifier)
Add one cache index for given neighbor element and check identifier.
Definition: SymFnc.cpp:106

References nnp::SymFnc::addCacheIndex(), cacheLists, nnp::Element::SFCacheList::element, nnp::Element::SFCacheList::identifier, nnp::Element::SFCacheList::indices, and symmetryFunctions.

Referenced by nnp::Mode::setupSymmetryFunctionCache().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getCacheSizes()

vector< size_t > Element::getCacheSizes ( ) const

Get cache sizes for each neighbor atom element.

Returns
Vector with cache sizes.

Definition at line 563 of file Element.cpp.

564{
565 vector<size_t> cacheSizes;
566 for (auto const& c : cacheLists)
567 {
568 cacheSizes.push_back(c.size());
569 }
570
571 return cacheSizes;
572}

References cacheLists.

Referenced by nnp::Mode::calculateSymmetryFunctionGroups(), and nnp::Mode::calculateSymmetryFunctions().

Here is the caller graph for this function:

Member Data Documentation

◆ neuralNetworks

std::map<std::string, NeuralNetwork> nnp::Element::neuralNetworks

Neural networks for this element.

Definition at line 230 of file Element.h.

Referenced by nnp::Mode::setupNeuralNetwork().

◆ statistics

SymFncStatistics nnp::Element::statistics

Symmetry function statistics.

Definition at line 232 of file Element.h.

Referenced by updateSymmetryFunctionStatistics().

◆ elementMap

ElementMap nnp::Element::elementMap
protected

Copy of element map.

Definition at line 236 of file Element.h.

Referenced by addSymmetryFunction(), setupSymmetryFunctionGroups(), and setupSymmetryFunctionMemory().

◆ index

std::size_t nnp::Element::index
protected

Global index of this element.

Definition at line 238 of file Element.h.

Referenced by getIndex(), getSymmetryFunction(), infoSymmetryFunction(), and updateSymmetryFunctionStatistics().

◆ atomicNumber

std::size_t nnp::Element::atomicNumber
protected

Atomic number of this element.

Definition at line 240 of file Element.h.

Referenced by getAtomicNumber().

◆ atomicEnergyOffset

double nnp::Element::atomicEnergyOffset
protected

Offset energy for every atom of this element.

Definition at line 242 of file Element.h.

Referenced by getAtomicEnergyOffset(), and setAtomicEnergyOffset().

◆ symbol

std::string nnp::Element::symbol
protected

Element symbol.

Definition at line 244 of file Element.h.

Referenced by getSymbol(), and updateSymmetryFunctionStatistics().

◆ symmetryFunctionNumTable

std::vector<std::size_t> nnp::Element::symmetryFunctionNumTable
protected

Number of relevant symmetry functions for each neighbor element.

Definition at line 246 of file Element.h.

Referenced by getSymmetryFunctionNumTable(), and setupSymmetryFunctionMemory().

◆ symmetryFunctionTable

std::vector<std::vector<std::size_t> > nnp::Element::symmetryFunctionTable
protected

List of symmetry function indices relevant for each neighbor element.

Definition at line 248 of file Element.h.

Referenced by getSymmetryFunctionTable(), and setupSymmetryFunctionMemory().

◆ cacheLists

std::vector<std::vector<SFCacheList> > nnp::Element::cacheLists
protected

Symmetry function cache lists.

Definition at line 251 of file Element.h.

Referenced by getCacheSizes(), and setCacheIndices().

◆ symmetryFunctions

◆ symmetryFunctionGroups

std::vector<SymGrp*> nnp::Element::symmetryFunctionGroups
protected

Vector of pointers to symmetry function groups.

Definition at line 256 of file Element.h.

Referenced by calculateSymmetryFunctionGroups(), clearSymmetryFunctions(), infoSymmetryFunctionGroups(), setScaling(), setScalingNone(), and setupSymmetryFunctionGroups().


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