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

Derived Cabana class for element-specific data. More...

#include <ElementCabana.h>

Inheritance diagram for nnp::ElementCabana:
Collaboration diagram for nnp::ElementCabana:

Public Member Functions

 ElementCabana (std::size_t const index)
 Constructor using index. More...
 
 ~ElementCabana ()
 Destructor. More...
 
template<class t_SF , class h_t_int >
void addSymmetryFunction (std::string const &parameters, std::vector< std::string > elementStrings, int attype, t_SF SF, double convLength, h_t_int h_numSFperElem)
 Add one symmetry function. More...
 
void changeLengthUnitSymmetryFunctions (double convLength)
 Change length unit for all symmetry functions. More...
 
template<class t_SF , class h_t_int >
void sortSymmetryFunctions (t_SF SF, h_t_int h_numSFperElem, int attype)
 Sort all symmetry function. More...
 
template<class t_SF >
bool compareSF (t_SF SF, int attype, int index1, int index2)
 Print symmetry function parameter value information. More...
 
template<class t_SF , class h_t_int >
std::vector< std::string > infoSymmetryFunctionParameters (t_SF SF, int attype, h_t_int h_numSFperElem) const
 Print symmetry function parameter value information. More...
 
template<class t_SF , class t_SFscaling , class h_t_int >
std::vector< std::string > infoSymmetryFunctionScaling (ScalingType scalingType, t_SF SF, t_SFscaling SFscaling, int attype, h_t_int h_numSFperElem) const
 Print symmetry function scaling information. More...
 
template<class t_SF , class t_SFGmemberlist , class h_t_int >
void setupSymmetryFunctionGroups (t_SF SF, t_SFGmemberlist SFGmemberlist, int attype, h_t_int h_numSFperElem, h_t_int h_numSFGperElem, int maxSFperElem)
 Set up symmetry function groups. More...
 
template<class t_SF , class t_SFGmemberlist , class h_t_int >
std::vector< std::string > infoSymmetryFunctionGroups (t_SF SF, t_SFGmemberlist SFGmemberlist, int attype, h_t_int h_numSFGperElem) const
 Print symmetry function group info. More...
 
template<class t_SF , class h_t_int >
void setCutoffFunction (CutoffFunction::CutoffType const cutoffType, double const cutoffAlpha, t_SF SF, int attype, h_t_int h_numSFperElem)
 Set cutoff function for all symmetry functions. More...
 
template<class t_SF , class t_SFscaling , class h_t_int >
void setScaling (ScalingType scalingType, std::vector< std::string > const &statisticsLine, double minS, double maxS, t_SF SF, t_SFscaling SFscaling, int attype, h_t_int h_numSFperElem) const
 Set scaling of all symmetry functions. More...
 
template<class h_t_int >
std::size_t numSymmetryFunctions (int attype, h_t_int h_numSFperElem) const
 Get number of symmetry functions. More...
 
template<class t_SF >
std::size_t getMinNeighbors (int attype, t_SF SF, int nSF) const
 Get maximum of required minimum number of neighbors for all symmetry functions for this element. More...
 
template<class t_SF , class h_t_int >
double getMinCutoffRadius (t_SF SF, int attype, h_t_int h_numSFperElem) const
 Get minimum cutoff radius of all symmetry functions. More...
 
template<class t_SF , class h_t_int >
double getMaxCutoffRadius (t_SF SF, int attype, h_t_int h_numSFperElem) const
 Get maximum cutoff radius of all symmetry functions. More...
 
template<class t_SFscaling >
void setScalingType (ScalingType scalingType, std::string statisticsLine, double Smin, double Smax, t_SFscaling SFscaling, int attype, int k) const
 Symmetry function statistics. More...
 
template<class t_SFscaling >
std::string scalingLine (ScalingType scalingType, t_SFscaling SFscaling, int attype, int k) const
 Print scaling for one symmetry function. More...
 
template<class t_SFscaling >
double unscale (int attype, double value, int k, t_SFscaling SFscaling)
 Unscale one symmetry function. More...
 
template<class t_SF , class h_t_int >
vector< string > infoSymmetryFunctionParameters (t_SF SF, int attype, h_t_int h_numSFperElem) const
 
template<class t_SF , class t_SFscaling , class h_t_int >
vector< string > infoSymmetryFunctionScaling (ScalingType scalingType, t_SF SF, t_SFscaling SFscaling, int attype, h_t_int h_numSFperElem) const
 
template<class t_SF , class t_SFGmemberlist , class h_t_int >
vector< string > infoSymmetryFunctionGroups (t_SF SF, t_SFGmemberlist SFGmemberlist, int attype, h_t_int h_numSFGperElem) const
 
template<class t_SF >
size_t getMinNeighbors (int attype, t_SF SF, int nSF) const
 
- Public Member Functions inherited from nnp::Element
 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...
 

Private Attributes

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...
 

Additional Inherited Members

- Public Attributes inherited from nnp::Element
std::map< std::string, NeuralNetworkneuralNetworks
 Neural networks for this element. More...
 
SymFncStatistics statistics
 Symmetry function statistics. More...
 
- Protected Attributes inherited from nnp::Element
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

Derived Cabana class for element-specific data.

Definition at line 35 of file ElementCabana.h.

Constructor & Destructor Documentation

◆ ElementCabana()

nnp::ElementCabana::ElementCabana ( std::size_t const  index)

Constructor using index.

Definition at line 31 of file ElementCabana_impl.h.

32 : Element()
33{
34 index = _index;
36 neuralNetwork = NULL;
37}
std::size_t index
Global index of this element.
Definition: Element.h:255
double atomicEnergyOffset
Offset energy for every atom of this element.
Definition: Element.h:259
Element()
Default constructor.
Definition: Element.h:57

References atomicEnergyOffset, and index.

◆ ~ElementCabana()

nnp::ElementCabana::~ElementCabana ( )

Destructor.

Definition at line 39 of file ElementCabana_impl.h.

39{}

Member Function Documentation

◆ addSymmetryFunction()

template<class t_SF , class h_t_int >
void nnp::ElementCabana::addSymmetryFunction ( std::string const &  parameters,
std::vector< std::string >  elementStrings,
int  attype,
t_SF  SF,
double  convLength,
h_t_int  h_numSFperElem 
)

Add one symmetry function.

Parameters
[in]parametersString containing settings for symmetry function.
[in]lineNumberLine number of symmetry function in settings file.
[in]attypeAtom type.
[in]SFKokkos host View of symmetry functions.
[in]convLengthLength unit conversion factor.
[in]h_numSFperElemKokkos host View of number of symmetry functions per element.

Definition at line 42 of file ElementCabana_impl.h.

46{
47 vector<string> args = split( reduce( parameters ) );
48 size_t type = (size_t)atoi( args.at( 1 ).c_str() );
49 const char *estring;
50 int el = 0;
51
52 vector<string> splitLine = split( reduce( parameters ) );
53 if ( type == 2 )
54 {
55 estring = splitLine.at( 0 ).c_str();
56 for ( size_t i = 0; i < elementStrings.size(); ++i )
57 {
58 if ( strcmp( elementStrings[i].c_str(), estring ) == 0 )
59 el = i;
60 }
61 SF( attype, h_numSFperElem( attype ), 0 ) = el; // ec
62 SF( attype, h_numSFperElem( attype ), 1 ) = type; // type
63
64 estring = splitLine.at( 2 ).c_str();
65 for ( size_t i = 0; i < elementStrings.size(); ++i )
66 {
67 if ( strcmp( elementStrings[i].c_str(), estring ) == 0 )
68 el = i;
69 }
70 SF( attype, h_numSFperElem( attype ), 2 ) = el; // e1
71 // set e2 to arbit high number for ease in creating groups
72 SF( attype, h_numSFperElem( attype ), 3 ) = 100000; // e2
73
74 SF( attype, h_numSFperElem( attype ), 4 ) =
75 atof( splitLine.at( 3 ).c_str() ) /
76 ( convLength * convLength ); // eta
77 SF( attype, h_numSFperElem( attype ), 8 ) =
78 atof( splitLine.at( 4 ).c_str() ) * convLength; // rs
79 SF( attype, h_numSFperElem( attype ), 7 ) =
80 atof( splitLine.at( 5 ).c_str() ) * convLength; // rc
81
82 SF( attype, h_numSFperElem( attype ), 13 ) = h_numSFperElem( attype );
83 h_numSFperElem( attype )++;
84 }
85
86 else if ( type == 3 )
87 {
88 if ( type != (size_t)atoi( splitLine.at( 1 ).c_str() ) )
89 throw runtime_error( "ERROR: Incorrect symmetry function type.\n" );
90 estring = splitLine.at( 0 ).c_str();
91 for ( size_t i = 0; i < elementStrings.size(); ++i )
92 {
93 if ( strcmp( elementStrings[i].c_str(), estring ) == 0 )
94 el = i;
95 }
96 SF( attype, h_numSFperElem( attype ), 0 ) = el; // ec
97 SF( attype, h_numSFperElem( attype ), 1 ) = type; // type
98
99 estring = splitLine.at( 2 ).c_str();
100 for ( size_t i = 0; i < elementStrings.size(); ++i )
101 {
102 if ( strcmp( elementStrings[i].c_str(), estring ) == 0 )
103 el = i;
104 }
105 SF( attype, h_numSFperElem( attype ), 2 ) = el; // e1
106
107 estring = splitLine.at( 3 ).c_str();
108 for ( size_t i = 0; i < elementStrings.size(); ++i )
109 {
110 if ( strcmp( elementStrings[i].c_str(), estring ) == 0 )
111 el = i;
112 }
113
114 SF( attype, h_numSFperElem( attype ), 3 ) = el; // e2
115 SF( attype, h_numSFperElem( attype ), 4 ) =
116 atof( splitLine.at( 4 ).c_str() ) /
117 ( convLength * convLength ); // eta
118 SF( attype, h_numSFperElem( attype ), 5 ) =
119 atof( splitLine.at( 5 ).c_str() ); // lambda
120 SF( attype, h_numSFperElem( attype ), 6 ) =
121 atof( splitLine.at( 6 ).c_str() ); // zeta
122 SF( attype, h_numSFperElem( attype ), 7 ) =
123 atof( splitLine.at( 7 ).c_str() ) * convLength; // rc
124 // Shift parameter is optional.
125 if ( splitLine.size() > 8 )
126 SF( attype, h_numSFperElem( attype ), 8 ) =
127 atof( splitLine.at( 8 ).c_str() ) * convLength; // rs
128
129 T_INT e1 = SF( attype, h_numSFperElem( attype ), 2 );
130 T_INT e2 = SF( attype, h_numSFperElem( attype ), 3 );
131 if ( e1 > e2 )
132 {
133 size_t tmp = e1;
134 e1 = e2;
135 e2 = tmp;
136 }
137 SF( attype, h_numSFperElem( attype ), 2 ) = e1;
138 SF( attype, h_numSFperElem( attype ), 3 ) = e2;
139
140 T_FLOAT zeta = SF( attype, h_numSFperElem( attype ), 6 );
141 T_INT zetaInt = round( zeta );
142 if ( fabs( zeta - zetaInt ) <= numeric_limits<double>::min() )
143 SF( attype, h_numSFperElem( attype ), 9 ) = 1;
144 else
145 SF( attype, h_numSFperElem( attype ), 9 ) = 0;
146
147 SF( attype, h_numSFperElem( attype ), 13 ) = h_numSFperElem( attype );
148 h_numSFperElem( attype )++;
149 }
150 // TODO: Add this later
151 else if ( type == 9 )
152 {
153 }
154 else if ( type == 12 )
155 {
156 }
157 else if ( type == 13 )
158 {
159 }
160 else
161 {
162 throw runtime_error( "ERROR: Unknown symmetry function type.\n" );
163 }
164
165 return;
166}
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 nnp::reduce(), and nnp::split().

Here is the call graph for this function:

◆ changeLengthUnitSymmetryFunctions()

void nnp::ElementCabana::changeLengthUnitSymmetryFunctions ( double  convLength)

Change length unit for all symmetry functions.

Parameters
[in]convLengthLength unit conversion factor.

◆ sortSymmetryFunctions()

template<class t_SF , class h_t_int >
void nnp::ElementCabana::sortSymmetryFunctions ( t_SF  SF,
h_t_int  h_numSFperElem,
int  attype 
)

Sort all symmetry function.

Parameters
[in]SFKokkos host View of symmetry functions.
[in]h_numSFperElemKokkos host View of number of symmetry functions per element.
[in]attypeAtom type.

Definition at line 169 of file ElementCabana_impl.h.

171{
172 int size = h_numSFperElem( attype );
173 h_t_int h_SFsort( "SortSort", size );
174 for ( int i = 0; i < size; ++i )
175 h_SFsort( i ) = i;
176
177 // naive insertion sort
178 int i, j, tmp;
179 for ( i = 1; i < size; ++i )
180 {
181 j = i;
182 // explicit condition for sort
183 while ( j > 0 &&
184 compareSF( SF, attype, h_SFsort( j - 1 ), h_SFsort( j ) ) )
185 {
186 tmp = h_SFsort( j );
187 h_SFsort( j ) = h_SFsort( j - 1 );
188 h_SFsort( j - 1 ) = tmp;
189 --j;
190 }
191 }
192
193 int tmpindex;
194 for ( int i = 0; i < size; ++i )
195 {
196 SF( attype, i, 13 ) = h_SFsort( i );
197 tmpindex = SF( attype, i, 13 );
198 SF( attype, tmpindex, 14 ) = i;
199 }
200
201 return;
202}
bool compareSF(t_SF SF, int attype, int index1, int index2)
Print symmetry function parameter value information.

References compareSF().

Here is the call graph for this function:

◆ compareSF()

template<class t_SF >
bool nnp::ElementCabana::compareSF ( t_SF  SF,
int  attype,
int  index1,
int  index2 
)

Print symmetry function parameter value information.

Parameters
[in]SFKokkos host View of symmetry functions.
[in]attypeAtom type.
[in]index1First symmetry function index.
[in]index2Second symmetry function index.

Definition at line 205 of file ElementCabana_impl.h.

206{
207 if ( SF( attype, index2, 0 ) < SF( attype, index1, 0 ) )
208 return true; // ec
209 else if ( SF( attype, index2, 0 ) > SF( attype, index1, 0 ) )
210 return false;
211
212 if ( SF( attype, index2, 1 ) < SF( attype, index1, 1 ) )
213 return true; // type
214 else if ( SF( attype, index2, 1 ) > SF( attype, index1, 1 ) )
215 return false;
216
217 if ( SF( attype, index2, 11 ) < SF( attype, index1, 11 ) )
218 return true; // cutofftype
219 else if ( SF( attype, index2, 11 ) > SF( attype, index1, 11 ) )
220 return false;
221
222 if ( SF( attype, index2, 12 ) < SF( attype, index1, 12 ) )
223 return true; // cutoffalpha
224 else if ( SF( attype, index2, 12 ) > SF( attype, index1, 12 ) )
225 return false;
226
227 if ( SF( attype, index2, 7 ) < SF( attype, index1, 7 ) )
228 return true; // rc
229 else if ( SF( attype, index2, 7 ) > SF( attype, index1, 7 ) )
230 return false;
231
232 if ( SF( attype, index2, 4 ) < SF( attype, index1, 4 ) )
233 return true; // eta
234 else if ( SF( attype, index2, 4 ) > SF( attype, index1, 4 ) )
235 return false;
236
237 if ( SF( attype, index2, 8 ) < SF( attype, index1, 8 ) )
238 return true; // rs
239 else if ( SF( attype, index2, 8 ) > SF( attype, index1, 8 ) )
240 return false;
241
242 if ( SF( attype, index2, 6 ) < SF( attype, index1, 6 ) )
243 return true; // zeta
244 else if ( SF( attype, index2, 6 ) > SF( attype, index1, 6 ) )
245 return false;
246
247 if ( SF( attype, index2, 5 ) < SF( attype, index1, 5 ) )
248 return true; // lambda
249 else if ( SF( attype, index2, 5 ) > SF( attype, index1, 5 ) )
250 return false;
251
252 if ( SF( attype, index2, 2 ) < SF( attype, index1, 2 ) )
253 return true; // e1
254 else if ( SF( attype, index2, 2 ) > SF( attype, index1, 2 ) )
255 return false;
256
257 if ( SF( attype, index2, 3 ) < SF( attype, index1, 3 ) )
258 return true; // e2
259 else if ( SF( attype, index2, 3 ) > SF( attype, index1, 3 ) )
260 return false;
261
262 else
263 return false;
264}

Referenced by sortSymmetryFunctions().

Here is the caller graph for this function:

◆ infoSymmetryFunctionParameters() [1/2]

template<class t_SF , class h_t_int >
std::vector< std::string > nnp::ElementCabana::infoSymmetryFunctionParameters ( t_SF  SF,
int  attype,
h_t_int  h_numSFperElem 
) const

Print symmetry function parameter value information.

Parameters
[in]SFKokkos host View of symmetry functions.
[in]attypeAtom type.
[in]h_numSFperElemKokkos host View of number of symmetry functions per element.

◆ infoSymmetryFunctionScaling() [1/2]

template<class t_SF , class t_SFscaling , class h_t_int >
std::vector< std::string > nnp::ElementCabana::infoSymmetryFunctionScaling ( ScalingType  scalingType,
t_SF  SF,
t_SFscaling  SFscaling,
int  attype,
h_t_int  h_numSFperElem 
) const

Print symmetry function scaling information.

Parameters
[in]scalingTypeType of scaling see SymmetryFunction::ScalingType.
[in]SFKokkos host View of symmetry functions.
[in]SFscalingKokkos host View of symmetry function scaling.
[in]attypeAtom type.
[in]h_numSFperElemKokkos host View of number of symmetry functions per element.

◆ setupSymmetryFunctionGroups()

template<class t_SF , class t_SFGmemberlist , class h_t_int >
void nnp::ElementCabana::setupSymmetryFunctionGroups ( t_SF  SF,
t_SFGmemberlist  SFGmemberlist,
int  attype,
h_t_int  h_numSFperElem,
h_t_int  h_numSFGperElem,
int  maxSFperElem 
)

Set up symmetry function groups.

Parameters
[in]SFKokkos host View of symmetry functions.
[in]SFGmemberlistKokkos host View of symmetry function groups.
[in]attypeAtom type.
[in]h_numSFperElemKokkos host View of number of symmetry functions per element.
[in]h_numSFGperElemKokkos host View of number of symmetry function groups per element.
[in]maxSFperElemMaximum number of symmetry functions per element.

Definition at line 308 of file ElementCabana_impl.h.

313{
314 int num_group = h_numSFperElem.extent( 0 );
315 h_t_int h_numGR( "RadialCounter", num_group );
316 h_t_int h_numGA( "AngularCounter", num_group );
317 int SFindex;
318 for ( int k = 0; k < h_numSFperElem( attype ); ++k )
319 {
320 bool createNewGroup = true;
321 SFindex = SF( attype, k, 13 );
322 for ( int l = 0; l < h_numSFGperElem( attype ); ++l )
323 {
324 if ( ( SF( attype, SFindex, 0 ) ==
325 SF( attype, SFGmemberlist( attype, l, 0 ),
326 0 ) ) && // same ec
327 ( SF( attype, SFindex, 2 ) ==
328 SF( attype, SFGmemberlist( attype, l, 0 ),
329 2 ) ) && // same e1
330 ( SF( attype, SFindex, 3 ) ==
331 SF( attype, SFGmemberlist( attype, l, 0 ),
332 3 ) ) && // same e2
333 ( SF( attype, SFindex, 7 ) ==
334 SF( attype, SFGmemberlist( attype, l, 0 ),
335 7 ) ) && // same rc
336 ( SF( attype, SFindex, 11 ) ==
337 SF( attype, SFGmemberlist( attype, l, 0 ),
338 11 ) ) && // same cutoffType
339 ( SF( attype, SFindex, 12 ) ==
340 SF( attype, SFGmemberlist( attype, l, 0 ),
341 12 ) ) ) // same cutoffAlpha
342 {
343 createNewGroup = false;
344 if ( SF( attype, SFindex, 1 ) == 2 )
345 {
346 SFGmemberlist( attype, l, h_numGR( l ) ) = SFindex;
347 h_numGR( l )++;
348 SFGmemberlist( attype, l, maxSFperElem )++;
349 break;
350 }
351
352 else if ( SF( attype, SFindex, 1 ) == 3 )
353 {
354 SFGmemberlist( attype, l, h_numGA( l ) ) = SFindex;
355 h_numGA( l )++;
356 SFGmemberlist( attype, l, maxSFperElem )++;
357 break;
358 }
359 }
360 }
361
362 if ( createNewGroup )
363 {
364 int l = h_numSFGperElem( attype );
365 h_numSFGperElem( attype )++;
366 if ( SF( attype, SFindex, 1 ) == 2 )
367 {
368 SFGmemberlist( attype, l, 0 ) = SFindex;
369 if ( l >= (int)h_numGR.extent( 0 ) )
370 Kokkos::resize( h_numGR, l+1 );
371 h_numGR( l ) = 1;
372 SFGmemberlist( attype, l, maxSFperElem )++;
373 }
374 else if ( SF( attype, SFindex, 1 ) == 3 )
375 {
376 SFGmemberlist( attype, l, 0 ) = SFindex;
377 if ( l >= (int)h_numGA.extent( 0 ) )
378 Kokkos::resize( h_numGA, l+1 );
379 h_numGA( l ) = 1;
380 SFGmemberlist( attype, l, maxSFperElem )++;
381 }
382 }
383 }
384
385 return;
386}

◆ infoSymmetryFunctionGroups() [1/2]

template<class t_SF , class t_SFGmemberlist , class h_t_int >
std::vector< std::string > nnp::ElementCabana::infoSymmetryFunctionGroups ( t_SF  SF,
t_SFGmemberlist  SFGmemberlist,
int  attype,
h_t_int  h_numSFGperElem 
) const

Print symmetry function group info.

Parameters
[in]SFKokkos host View of symmetry functions.
[in]SFGmemberlistKokkos host View of symmetry function groups.
[in]attypeAtom type.
[in]h_numSFGperElemKokkos host View of number of symmetry function groups per element.

◆ setCutoffFunction()

template<class t_SF , class h_t_int >
void nnp::ElementCabana::setCutoffFunction ( CutoffFunction::CutoffType const  cutoffType,
double const  cutoffAlpha,
t_SF  SF,
int  attype,
h_t_int  h_numSFperElem 
)

Set cutoff function for all symmetry functions.

Parameters
[in]cutoffTypeType of cutoff function.
[in]cutoffAlphaCutoff parameter for all functions.
[in]SFKokkos host View of symmetry functions.
[in]attypeAtom type.
[in]h_numSFperElemKokkos host View of number of symmetry functions per element.

Definition at line 412 of file ElementCabana_impl.h.

415{
416 for ( int k = 0; k < h_numSFperElem( attype ); ++k )
417 {
418 SF( attype, k, 10 ) = cutoffType;
419 SF( attype, k, 11 ) = cutoffAlpha;
420 }
421 return;
422}

◆ setScaling()

template<class t_SF , class t_SFscaling , class h_t_int >
void nnp::ElementCabana::setScaling ( ScalingType  scalingType,
std::vector< std::string > const &  statisticsLine,
double  minS,
double  maxS,
t_SF  SF,
t_SFscaling  SFscaling,
int  attype,
h_t_int  h_numSFperElem 
) const

Set scaling of all symmetry functions.

Parameters
[in]scalingTypeType of scaling, see SymmetryFunction::ScalingType.
[in]statisticsLineVector of strings containing statistics for all symmetry functions.
[in]minSMinimum for scaling range.
[in]maxSMaximum for scaling range.
[in]SFKokkos host View of symmetry functions.
[in]SFscalingKokkos host View of symmetry function scaling.
[in]attypeAtom type.
[in]h_numSFperElemKokkos host View of number of symmetry functions per element.

Definition at line 425 of file ElementCabana_impl.h.

429{
430 int index;
431 for ( int k = 0; k < h_numSFperElem( attype ); ++k )
432 {
433 index = SF( attype, k, 13 );
434 setScalingType( scalingType, statisticsLine.at( k ), Smin, Smax,
435 SFscaling, attype, index );
436 }
437 // TODO: groups
438 // for (int k = 0; k < h_numSFperElem(attype); ++k)
439 // setScalingFactors(SF,attype,k);
440
441 return;
442}
void setScalingType(ScalingType scalingType, std::string statisticsLine, double Smin, double Smax, t_SFscaling SFscaling, int attype, int k) const
Symmetry function statistics.

References index, and setScalingType().

Here is the call graph for this function:

◆ numSymmetryFunctions()

template<class h_t_int >
std::size_t nnp::ElementCabana::numSymmetryFunctions ( int  attype,
h_t_int  h_numSFperElem 
) const
inline

Get number of symmetry functions.

Parameters
[in]attypeAtom type.
[in]h_numSFperElemKokkos host View of number of symmetry functions per element.
Returns
Number of symmetry functions.

Definition at line 278 of file ElementCabana.h.

280{
281 return h_numSFperElem( attype );
282}

◆ getMinNeighbors() [1/2]

template<class t_SF >
std::size_t nnp::ElementCabana::getMinNeighbors ( int  attype,
t_SF  SF,
int  nSF 
) const

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

Parameters
[in]attypeAtom type.
[in]h_numSFperElemKokkos host View of number of symmetry functions per element.
[in]nSFNumber of symmetry function for this type.
Returns
Minimum number of neighbors required.

◆ getMinCutoffRadius()

template<class t_SF , class h_t_int >
double nnp::ElementCabana::getMinCutoffRadius ( t_SF  SF,
int  attype,
h_t_int  h_numSFperElem 
) const

Get minimum cutoff radius of all symmetry functions.

Parameters
[in]SFKokkos host View of symmetry functions.
[in]attypeAtom type.
[in]h_numSFperElemKokkos host View of number of symmetry functions per element.
Returns
Minimum cutoff radius.

Definition at line 465 of file ElementCabana_impl.h.

467{
468 double minCutoffRadius = numeric_limits<double>::max();
469
470 for ( int k = 0; k < h_numSFperElem( attype ); ++k )
471 minCutoffRadius = min( SF( attype, k, 7 ), minCutoffRadius );
472
473 return minCutoffRadius;
474}

◆ getMaxCutoffRadius()

template<class t_SF , class h_t_int >
double nnp::ElementCabana::getMaxCutoffRadius ( t_SF  SF,
int  attype,
h_t_int  h_numSFperElem 
) const

Get maximum cutoff radius of all symmetry functions.

Parameters
[in]SFKokkos host View of symmetry functions.
[in]attypeAtom type.
[in]h_numSFperElemKokkos host View of number of symmetry functions per element.
Returns
Maximum cutoff radius.

Definition at line 477 of file ElementCabana_impl.h.

479{
480 double maxCutoffRadius = 0.0;
481
482 for ( int k = 0; k < h_numSFperElem( attype ); ++k )
483 maxCutoffRadius = max( SF( attype, k, 7 ), maxCutoffRadius );
484
485 return maxCutoffRadius;
486}

◆ setScalingType()

template<class t_SFscaling >
void nnp::ElementCabana::setScalingType ( ScalingType  scalingType,
std::string  statisticsLine,
double  Smin,
double  Smax,
t_SFscaling  SFscaling,
int  attype,
int  k 
) const
inline

Symmetry function statistics.

Set scaling type of one symmetry function

Parameters
[in]scalingTypeType of scaling, see SymmetryFunction::ScalingType.
[in]statisticsLineOutput string for this symmetry function.
[in]SminMinimum for scaling range.
[in]SmaxMaximum for scaling range.
[in]SFscalingKokkos host View of symmetry function scaling.
[in]attypeAtom type.
[in]kSymmetry function index.

Definition at line 286 of file ElementCabana.h.

290{
291 double Gmin, Gmax, Gmean, Gsigma = 0, scalingFactor = 0;
292 std::vector<std::string> s = split( reduce( statisticsLine ) );
293
294 Gmin = atof( s.at( 2 ).c_str() );
295 Gmax = atof( s.at( 3 ).c_str() );
296 Gmean = atof( s.at( 4 ).c_str() );
297 SFscaling( attype, k, 0 ) = Gmin;
298 SFscaling( attype, k, 1 ) = Gmax;
299 SFscaling( attype, k, 2 ) = Gmean;
300
301 // Older versions may not supply sigma.
302 if ( s.size() > 5 )
303 Gsigma = atof( s.at( 5 ).c_str() );
304 SFscaling( attype, k, 3 ) = Gsigma;
305
306 SFscaling( attype, k, 4 ) = Smin;
307 SFscaling( attype, k, 5 ) = Smax;
308 SFscaling( attype, k, 7 ) = scalingType;
309
310 if ( scalingType == ST_NONE )
311 scalingFactor = 1.0;
312 else if ( scalingType == ST_SCALE )
313 scalingFactor = ( Smax - Smin ) / ( Gmax - Gmin );
314 else if ( scalingType == ST_CENTER )
315 scalingFactor = 1.0;
316 else if ( scalingType == ST_SCALECENTER )
317 scalingFactor = ( Smax - Smin ) / ( Gmax - Gmin );
318 else if ( scalingType == ST_SCALESIGMA )
319 scalingFactor = ( Smax - Smin ) / Gsigma;
320 SFscaling( attype, k, 6 ) = scalingFactor;
321
322 return;
323}
@ ST_CENTER
Definition: typesCabana.h:29
@ ST_SCALE
Definition: typesCabana.h:28
@ ST_SCALECENTER
Definition: typesCabana.h:30
@ ST_NONE
Definition: typesCabana.h:27
@ ST_SCALESIGMA
Definition: typesCabana.h:31

References nnp::reduce(), nnp::split(), ST_CENTER, ST_NONE, ST_SCALE, ST_SCALECENTER, and ST_SCALESIGMA.

Referenced by setScaling().

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

◆ scalingLine()

template<class t_SFscaling >
std::string nnp::ElementCabana::scalingLine ( ScalingType  scalingType,
t_SFscaling  SFscaling,
int  attype,
int  k 
) const
inline

Print scaling for one symmetry function.

Parameters
[in]scalingTypeType of scaling, see SymmetryFunction::ScalingType.
[in]SFscalingKokkos host View of symmetry function scaling.
[in]attypeAtom type.
[in]kSymmetry function index.

Definition at line 327 of file ElementCabana.h.

330{
331 return strpr( "%4zu %9.2E %9.2E %9.2E %9.2E %9.2E %5.2f %5.2f %d\n",
332 k + 1, SFscaling( attype, k, 0 ),
333 SFscaling( attype, k, 1 ), SFscaling( attype, k, 2 ),
334 SFscaling( attype, k, 3 ), SFscaling( attype, k, 6 ),
335 SFscaling( attype, k, 4 ), SFscaling( attype, k, 5 ),
336 scalingType );
337}
string strpr(const char *format,...)
String version of printf function.
Definition: utility.cpp:90

References nnp::strpr().

Referenced by infoSymmetryFunctionScaling().

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

◆ unscale()

template<class t_SFscaling >
double nnp::ElementCabana::unscale ( int  attype,
double  value,
int  k,
t_SFscaling  SFscaling 
)
inline

Unscale one symmetry function.

Parameters
[in]attypeAtom type.
[in]valueUnscaled symmetry function value.
[in]kSymmetry function index.
[in]SFscalingKokkos host View of symmetry function scaling.

Definition at line 340 of file ElementCabana.h.

342{
343 double scalingType = SFscaling( attype, k, 7 );
344 double scalingFactor = SFscaling( attype, k, 6 );
345 double Gmin = SFscaling( attype, k, 0 );
346 // double Gmax = SFscaling(attype,k,1);
347 double Gmean = SFscaling( attype, k, 2 );
348 // double Gsigma = SFscaling(attype,k,3);
349 double Smin = SFscaling( attype, k, 4 );
350 // double Smax = SFscaling(attype,k,5);
351
352 if ( scalingType == 0.0 )
353 {
354 return value;
355 }
356 else if ( scalingType == 1.0 )
357 {
358 return ( value - Smin ) / scalingFactor + Gmin;
359 }
360 else if ( scalingType == 2.0 )
361 {
362 return value + Gmean;
363 }
364 else if ( scalingType == 3.0 )
365 {
366 return ( value - Smin ) / scalingFactor + Gmean;
367 }
368 else if ( scalingType == 4.0 )
369 {
370 return ( value - Smin ) / scalingFactor + Gmean;
371 }
372 else
373 {
374 return 0.0;
375 }
376}

◆ infoSymmetryFunctionParameters() [2/2]

template<class t_SF , class h_t_int >
vector< string > nnp::ElementCabana::infoSymmetryFunctionParameters ( t_SF  SF,
int  attype,
h_t_int  h_numSFperElem 
) const

Definition at line 268 of file ElementCabana_impl.h.

270{
271 vector<string> v;
272 string pushstring = "";
273 int index;
274 float writestring;
275 for ( int i = 0; i < h_numSFperElem( attype ); ++i )
276 {
277 index = SF( attype, i, 13 );
278 // TODO: improve function
279 for ( int j = 1; j < 12; ++j )
280 {
281 writestring = SF( attype, index, j );
282 pushstring += to_string( writestring ) + " ";
283 }
284 pushstring += "\n";
285 }
286 v.push_back( pushstring );
287
288 return v;
289}

References index.

◆ infoSymmetryFunctionScaling() [2/2]

template<class t_SF , class t_SFscaling , class h_t_int >
vector< string > nnp::ElementCabana::infoSymmetryFunctionScaling ( ScalingType  scalingType,
t_SF  SF,
t_SFscaling  SFscaling,
int  attype,
h_t_int  h_numSFperElem 
) const

Definition at line 293 of file ElementCabana_impl.h.

296{
297 vector<string> v;
298 int index;
299 for ( int k = 0; k < h_numSFperElem( attype ); ++k )
300 {
301 index = SF( attype, k, 13 );
302 v.push_back( scalingLine( scalingType, SFscaling, attype, index ) );
303 }
304 return v;
305}
std::string scalingLine(ScalingType scalingType, t_SFscaling SFscaling, int attype, int k) const
Print scaling for one symmetry function.

References index, and scalingLine().

Here is the call graph for this function:

◆ infoSymmetryFunctionGroups() [2/2]

template<class t_SF , class t_SFGmemberlist , class h_t_int >
vector< string > nnp::ElementCabana::infoSymmetryFunctionGroups ( t_SF  SF,
t_SFGmemberlist  SFGmemberlist,
int  attype,
h_t_int  h_numSFGperElem 
) const

Definition at line 390 of file ElementCabana_impl.h.

392{
393 vector<string> v;
394 string pushstring = "";
395 for ( int groupIndex = 0; groupIndex < h_numSFGperElem( attype );
396 ++groupIndex )
397 {
398 // TODO: improve function
399 for ( int j = 0; j < 8; ++j )
400 pushstring +=
401 to_string(
402 SF( attype, SFGmemberlist( attype, groupIndex, 0 ), j ) ) +
403 " ";
404 pushstring += "\n";
405 }
406 v.push_back( pushstring );
407
408 return v;
409}

◆ getMinNeighbors() [2/2]

template<class t_SF >
size_t nnp::ElementCabana::getMinNeighbors ( int  attype,
t_SF  SF,
int  nSF 
) const

Definition at line 445 of file ElementCabana_impl.h.

446{
447 // get max number of minNeighbors
448 size_t global_minNeighbors = 0;
449 size_t minNeighbors = 0;
450 int SFtype;
451 for ( int k = 0; k < nSF; ++k )
452 {
453 SFtype = SF( attype, k, 1 );
454 if ( SFtype == 2 )
455 minNeighbors = 1;
456 else if ( SFtype == 3 )
457 minNeighbors = 2;
458 global_minNeighbors = max( minNeighbors, global_minNeighbors );
459 }
460
461 return global_minNeighbors;
462}

Member Data Documentation

◆ index

std::size_t nnp::Element::index
private

Global index of this element.

Definition at line 255 of file Element.h.

Referenced by ElementCabana(), infoSymmetryFunctionParameters(), infoSymmetryFunctionScaling(), and setScaling().

◆ atomicNumber

std::size_t nnp::Element::atomicNumber
private

Atomic number of this element.

Definition at line 257 of file Element.h.

◆ atomicEnergyOffset

double nnp::Element::atomicEnergyOffset
private

Offset energy for every atom of this element.

Definition at line 259 of file Element.h.

Referenced by ElementCabana().

◆ symbol

std::string nnp::Element::symbol
private

Element symbol.

Definition at line 265 of file Element.h.


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