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...
 
void setHardness (double hardness)
 Set hardness. More...
 
void setQsigma (double qsigma)
 Set qsigma. More...
 
std::size_t getIndex () const
 Get index. More...
 
std::size_t getAtomicNumber () const
 Get atomicNumber. More...
 
double getAtomicEnergyOffset () const
 Get atomicEnergyOffset. More...
 
double getHardness () const
 Get hardness. More...
 
double getQsigma () const
 Get qsigma. 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...
 
void getCutoffRadii (std::vector< double > &cutoffs) const
 Get all different cutoff radii belonging to this element. 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...
 
double hardness
 Atomic hardness for global charge equilibration. More...
 
double qsigma
 Gaussian width of charge distribution. 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 67 of file Element.cpp.

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

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 72 of file Element.cpp.

73{
74 for (auto& s : symmetryFunctions) delete s;
75 symmetryFunctions.clear();
76 for (auto& s : symmetryFunctionGroups) delete s;
78
79 return;
80}
std::vector< SymFnc * > symmetryFunctions
Vector of pointers to symmetry functions.
Definition: Element.h:275
std::vector< SymGrp * > symmetryFunctionGroups
Vector of pointers to symmetry function groups.
Definition: Element.h:277

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 284 of file Element.h.

285{
287
288 return;
289}
double atomicEnergyOffset
Offset energy for every atom of this element.
Definition: Element.h:259

References atomicEnergyOffset.

◆ setHardness()

void nnp::Element::setHardness ( double  hardness)
inline

Set hardness.

Definition at line 291 of file Element.h.

292{
293 this->hardness = hardness;
294
295 return;
296}
double hardness
Atomic hardness for global charge equilibration.
Definition: Element.h:261

References hardness.

◆ setQsigma()

void nnp::Element::setQsigma ( double  qsigma)
inline

Set qsigma.

Definition at line 298 of file Element.h.

299{
300 this->qsigma = qsigma;
301
302 return;
303}
double qsigma
Gaussian width of charge distribution.
Definition: Element.h:263

References qsigma.

◆ getIndex()

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

Get index.

Definition at line 305 of file Element.h.

306{
307 return index;
308}
std::size_t index
Global index of this element.
Definition: Element.h:255

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 310 of file Element.h.

311{
312 return atomicNumber;
313}
std::size_t atomicNumber
Atomic number of this element.
Definition: Element.h:257

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 315 of file Element.h.

316{
317 return atomicEnergyOffset;
318}

References atomicEnergyOffset.

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

Here is the caller graph for this function:

◆ getHardness()

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

Get hardness.

Definition at line 320 of file Element.h.

321{
322 return hardness;
323}

References hardness.

◆ getQsigma()

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

Get qsigma.

Definition at line 325 of file Element.h.

326{
327 return qsigma;
328}

References qsigma.

◆ getSymbol()

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

Get symbol.

Definition at line 330 of file Element.h.

331{
332 return symbol;
333}
std::string symbol
Element symbol.
Definition: Element.h:265

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 82 of file Element.cpp.

84{
85 vector<string> args = split(reduce(parameters));
86 size_t type = (size_t)atoi(args.at(1).c_str());
87
88 if (type == 2)
89 {
91 }
92 else if (type == 3)
93 {
95 }
96 else if (type == 9)
97 {
99 }
100 else if (type == 12)
101 {
103 }
104 else if (type == 13)
105 {
107 }
108 else if (type == 20)
109 {
111 }
112 else if (type == 21)
113 {
115 }
116 else if (type == 22)
117 {
119 }
120 else if (type == 23)
121 {
123 }
124 else if (type == 24)
125 {
127 }
128 else if (type == 25)
129 {
131 }
132 else
133 {
134 throw runtime_error("ERROR: Unknown symmetry function type.\n");
135 }
136
137 symmetryFunctions.back()->setParameters(parameters);
138 symmetryFunctions.back()->setLineNumber(lineNumber);
139
140 return;
141}
ElementMap elementMap
Copy of element map.
Definition: Element.h:253
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 143 of file Element.cpp.

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

References symmetryFunctions.

◆ sortSymmetryFunctions()

void Element::sortSymmetryFunctions ( )

Sort all symmetry function.

Definition at line 154 of file Element.cpp.

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

References symmetryFunctions.

◆ infoSymmetryFunctionParameters()

vector< string > Element::infoSymmetryFunctionParameters ( ) const

Print symmetry function parameter value information.

Definition at line 168 of file Element.cpp.

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

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 348 of file Element.h.

349{
350 return symmetryFunctions.at(index)->parameterInfo();
351}

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 181 of file Element.cpp.

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

References symmetryFunctions.

◆ setupSymmetryFunctionGroups()

void Element::setupSymmetryFunctionGroups ( )

Set up symmetry function groups.

Definition at line 194 of file Element.cpp.

195{
196 for (vector<SymFnc*>::const_iterator
197 sf = symmetryFunctions.begin(); sf != symmetryFunctions.end(); ++sf)
198 {
199 bool createNewGroup = true;
200 for (vector<SymGrp*>::const_iterator
201 sfg = symmetryFunctionGroups.begin();
202 sfg != symmetryFunctionGroups.end(); ++sfg)
203 {
204 if ((*sfg)->addMember((*sf)))
205 {
206 createNewGroup = false;
207 break;
208 }
209 }
210 if (createNewGroup)
211 {
212 if ((*sf)->getType() == 2)
213 {
214 symmetryFunctionGroups.push_back((SymGrp*)
216 }
217 else if ((*sf)->getType() == 3)
218 {
219 symmetryFunctionGroups.push_back((SymGrp*)
221 }
222 else if ((*sf)->getType() == 9)
223 {
224 symmetryFunctionGroups.push_back((SymGrp*)
226 }
227 else if ((*sf)->getType() == 12)
228 {
229 symmetryFunctionGroups.push_back((SymGrp*)
231 }
232 else if ((*sf)->getType() == 13)
233 {
234 symmetryFunctionGroups.push_back((SymGrp*)
236 }
237 else if ((*sf)->getType() == 20)
238 {
239 symmetryFunctionGroups.push_back((SymGrp*)
241 }
242 else if ((*sf)->getType() == 21)
243 {
244 symmetryFunctionGroups.push_back((SymGrp*)
246 }
247 else if ((*sf)->getType() == 22)
248 {
249 symmetryFunctionGroups.push_back((SymGrp*)
251 }
252 else if ((*sf)->getType() == 23)
253 {
254 symmetryFunctionGroups.push_back((SymGrp*)
256 }
257 else if ((*sf)->getType() == 24)
258 {
259 symmetryFunctionGroups.push_back((SymGrp*)
261 }
262 else if ((*sf)->getType() == 25)
263 {
264 symmetryFunctionGroups.push_back((SymGrp*)
266 }
267 else
268 {
269 throw runtime_error("ERROR: Unknown symmetry function group"
270 " type.\n");
271 }
272 symmetryFunctionGroups.back()->addMember(*sf);
273 }
274 }
275
276 sort(symmetryFunctionGroups.begin(),
278 comparePointerTargets<SymGrp>);
279
280 for (size_t i = 0; i < symmetryFunctionGroups.size(); ++i)
281 {
282 symmetryFunctionGroups.at(i)->sortMembers();
283 symmetryFunctionGroups.at(i)->setIndex(i);
284 }
285
286 return;
287}
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 289 of file Element.cpp.

290{
291 symmetryFunctionTable.clear();
293 for (auto const& s : symmetryFunctions)
294 {
295 for (size_t i = 0; i < elementMap.size(); ++i)
296 {
297 if (s->checkRelevantElement(i))
298 {
299 s->setIndexPerElement(i, symmetryFunctionTable.at(i).size());
300 symmetryFunctionTable.at(i).push_back(s->getIndex());
301 }
302 }
303 }
305 for (size_t i = 0; i < elementMap.size(); ++i)
306 {
307 symmetryFunctionNumTable.push_back(symmetryFunctionTable.at(i).size());
308 }
309
310 return;
311}
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:269
std::vector< std::size_t > symmetryFunctionNumTable
Number of relevant symmetry functions for each neighbor element.
Definition: Element.h:267

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 313 of file Element.cpp.

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

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 328 of file Element.cpp.

330{
331 for (vector<SymFnc*>::const_iterator
332 it = symmetryFunctions.begin(); it != symmetryFunctions.end(); ++it)
333 {
334 SymFncBaseCutoff* sfcb = dynamic_cast<SymFncBaseCutoff*>(*it);
335 if (sfcb != nullptr)
336 {
337 sfcb->setCutoffFunction(cutoffType, cutoffAlpha);
338 }
339 }
340
341 return;
342}
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 344 of file Element.cpp.

345{
346 for (size_t i = 0; i < symmetryFunctions.size(); ++i)
347 {
348 string scalingLine = strpr("%d %d 0.0 0.0 0.0 0.0",
349 symmetryFunctions.at(i)->getEc(),
350 i + 1);
351 symmetryFunctions.at(i)->setScalingType(SymFnc::ST_NONE,
352 scalingLine,
353 0.0,
354 0.0);
355 }
356 for (size_t i = 0; i < symmetryFunctionGroups.size(); ++i)
357 {
358 symmetryFunctionGroups.at(i)->setScalingFactors();
359 }
360
361 return;
362}
@ 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 364 of file Element.cpp.

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

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 353 of file Element.h.

354{
355 return symmetryFunctions.size();
356}

References symmetryFunctions.

Referenced by nnp::Mode::calculateSymmetryFunctionGroups(), nnp::Mode::calculateSymmetryFunctions(), 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 384 of file Element.cpp.

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

References symmetryFunctions.

◆ getMinCutoffRadius()

double Element::getMinCutoffRadius ( ) const

Get minimum cutoff radius of all symmetry functions.

Returns
Minimum cutoff radius.

Definition at line 397 of file Element.cpp.

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

References symmetryFunctions.

◆ getMaxCutoffRadius()

double Element::getMaxCutoffRadius ( ) const

Get maximum cutoff radius of all symmetry functions.

Returns
Maximum cutoff radius.

Definition at line 414 of file Element.cpp.

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

References symmetryFunctions.

◆ getCutoffRadii()

void Element::getCutoffRadii ( std::vector< double > &  cutoffs) const

Get all different cutoff radii belonging to this element.

Parameters
[in]cutoffsVector to append the result.

Definition at line 427 of file Element.cpp.

428{
429 for (auto const& sf : symmetryFunctions)
430 {
431 double rc = sf->getRc();
432 if (!vectorContains(cutoffs,rc)) cutoffs.push_back(rc);
433 }
434}
bool vectorContains(std::vector< T > const &stdVec, T value)
Test if vector contains specified value.
Definition: utility.h:166

References symmetryFunctions, and nnp::vectorContains().

Here is the call graph for this function:

◆ 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 336 of file Element.h.

337{
339}

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 342 of file Element.h.

343{
345}

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 436 of file Element.cpp.

438{
439 for (vector<SymFnc*>::const_iterator
440 it = symmetryFunctions.begin();
441 it != symmetryFunctions.end(); ++it)
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:249
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 358 of file Element.h.

360{
361 return *(symmetryFunctions.at(index));
362}

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:272
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 247 of file Element.h.

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

◆ statistics

SymFncStatistics nnp::Element::statistics

Symmetry function statistics.

Definition at line 249 of file Element.h.

Referenced by updateSymmetryFunctionStatistics().

◆ elementMap

ElementMap nnp::Element::elementMap
protected

Copy of element map.

Definition at line 253 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 255 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 257 of file Element.h.

Referenced by getAtomicNumber().

◆ atomicEnergyOffset

double nnp::Element::atomicEnergyOffset
protected

Offset energy for every atom of this element.

Definition at line 259 of file Element.h.

Referenced by getAtomicEnergyOffset(), and setAtomicEnergyOffset().

◆ hardness

double nnp::Element::hardness
protected

Atomic hardness for global charge equilibration.

Definition at line 261 of file Element.h.

Referenced by getHardness(), and setHardness().

◆ qsigma

double nnp::Element::qsigma
protected

Gaussian width of charge distribution.

Definition at line 263 of file Element.h.

Referenced by getQsigma(), and setQsigma().

◆ symbol

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

Element symbol.

Definition at line 265 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 267 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 269 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 272 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 277 of file Element.h.

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


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