41template <
class t_SF,
class h_t_
int>
43 vector<string> elementStrings,
int attype,
44 t_SF SF,
double convLength,
45 h_t_int h_numSFperElem )
47 vector<string> args =
split(
reduce( parameters ) );
48 size_t type = (size_t)atoi( args.at( 1 ).c_str() );
52 vector<string> splitLine =
split(
reduce( parameters ) );
55 estring = splitLine.at( 0 ).c_str();
56 for (
size_t i = 0; i < elementStrings.size(); ++i )
58 if ( strcmp( elementStrings[i].c_str(), estring ) == 0 )
61 SF( attype, h_numSFperElem( attype ), 0 ) = el;
62 SF( attype, h_numSFperElem( attype ), 1 ) = type;
64 estring = splitLine.at( 2 ).c_str();
65 for (
size_t i = 0; i < elementStrings.size(); ++i )
67 if ( strcmp( elementStrings[i].c_str(), estring ) == 0 )
70 SF( attype, h_numSFperElem( attype ), 2 ) = el;
72 SF( attype, h_numSFperElem( attype ), 3 ) = 100000;
74 SF( attype, h_numSFperElem( attype ), 4 ) =
75 atof( splitLine.at( 3 ).c_str() ) /
76 ( convLength * convLength );
77 SF( attype, h_numSFperElem( attype ), 8 ) =
78 atof( splitLine.at( 4 ).c_str() ) * convLength;
79 SF( attype, h_numSFperElem( attype ), 7 ) =
80 atof( splitLine.at( 5 ).c_str() ) * convLength;
82 SF( attype, h_numSFperElem( attype ), 13 ) = h_numSFperElem( attype );
83 h_numSFperElem( attype )++;
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 )
93 if ( strcmp( elementStrings[i].c_str(), estring ) == 0 )
96 SF( attype, h_numSFperElem( attype ), 0 ) = el;
97 SF( attype, h_numSFperElem( attype ), 1 ) = type;
99 estring = splitLine.at( 2 ).c_str();
100 for (
size_t i = 0; i < elementStrings.size(); ++i )
102 if ( strcmp( elementStrings[i].c_str(), estring ) == 0 )
105 SF( attype, h_numSFperElem( attype ), 2 ) = el;
107 estring = splitLine.at( 3 ).c_str();
108 for (
size_t i = 0; i < elementStrings.size(); ++i )
110 if ( strcmp( elementStrings[i].c_str(), estring ) == 0 )
114 SF( attype, h_numSFperElem( attype ), 3 ) = el;
115 SF( attype, h_numSFperElem( attype ), 4 ) =
116 atof( splitLine.at( 4 ).c_str() ) /
117 ( convLength * convLength );
118 SF( attype, h_numSFperElem( attype ), 5 ) =
119 atof( splitLine.at( 5 ).c_str() );
120 SF( attype, h_numSFperElem( attype ), 6 ) =
121 atof( splitLine.at( 6 ).c_str() );
122 SF( attype, h_numSFperElem( attype ), 7 ) =
123 atof( splitLine.at( 7 ).c_str() ) * convLength;
125 if ( splitLine.size() > 8 )
126 SF( attype, h_numSFperElem( attype ), 8 ) =
127 atof( splitLine.at( 8 ).c_str() ) * convLength;
129 T_INT e1 = SF( attype, h_numSFperElem( attype ), 2 );
130 T_INT e2 = SF( attype, h_numSFperElem( attype ), 3 );
137 SF( attype, h_numSFperElem( attype ), 2 ) = e1;
138 SF( attype, h_numSFperElem( attype ), 3 ) = e2;
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;
145 SF( attype, h_numSFperElem( attype ), 9 ) = 0;
147 SF( attype, h_numSFperElem( attype ), 13 ) = h_numSFperElem( attype );
148 h_numSFperElem( attype )++;
151 else if ( type == 9 )
154 else if ( type == 12 )
157 else if ( type == 13 )
162 throw runtime_error(
"ERROR: Unknown symmetry function type.\n" );
168template <
class t_SF,
class h_t_
int>
172 int size = h_numSFperElem( attype );
173 h_t_int h_SFsort(
"SortSort", size );
174 for (
int i = 0; i < size; ++i )
179 for ( i = 1; i < size; ++i )
184 compareSF( SF, attype, h_SFsort( j - 1 ), h_SFsort( j ) ) )
187 h_SFsort( j ) = h_SFsort( j - 1 );
188 h_SFsort( j - 1 ) = tmp;
194 for (
int i = 0; i < size; ++i )
196 SF( attype, i, 13 ) = h_SFsort( i );
197 tmpindex = SF( attype, i, 13 );
198 SF( attype, tmpindex, 14 ) = i;
207 if ( SF( attype, index2, 0 ) < SF( attype, index1, 0 ) )
209 else if ( SF( attype, index2, 0 ) > SF( attype, index1, 0 ) )
212 if ( SF( attype, index2, 1 ) < SF( attype, index1, 1 ) )
214 else if ( SF( attype, index2, 1 ) > SF( attype, index1, 1 ) )
217 if ( SF( attype, index2, 11 ) < SF( attype, index1, 11 ) )
219 else if ( SF( attype, index2, 11 ) > SF( attype, index1, 11 ) )
222 if ( SF( attype, index2, 12 ) < SF( attype, index1, 12 ) )
224 else if ( SF( attype, index2, 12 ) > SF( attype, index1, 12 ) )
227 if ( SF( attype, index2, 7 ) < SF( attype, index1, 7 ) )
229 else if ( SF( attype, index2, 7 ) > SF( attype, index1, 7 ) )
232 if ( SF( attype, index2, 4 ) < SF( attype, index1, 4 ) )
234 else if ( SF( attype, index2, 4 ) > SF( attype, index1, 4 ) )
237 if ( SF( attype, index2, 8 ) < SF( attype, index1, 8 ) )
239 else if ( SF( attype, index2, 8 ) > SF( attype, index1, 8 ) )
242 if ( SF( attype, index2, 6 ) < SF( attype, index1, 6 ) )
244 else if ( SF( attype, index2, 6 ) > SF( attype, index1, 6 ) )
247 if ( SF( attype, index2, 5 ) < SF( attype, index1, 5 ) )
249 else if ( SF( attype, index2, 5 ) > SF( attype, index1, 5 ) )
252 if ( SF( attype, index2, 2 ) < SF( attype, index1, 2 ) )
254 else if ( SF( attype, index2, 2 ) > SF( attype, index1, 2 ) )
257 if ( SF( attype, index2, 3 ) < SF( attype, index1, 3 ) )
259 else if ( SF( attype, index2, 3 ) > SF( attype, index1, 3 ) )
266template <
class t_SF,
class h_t_
int>
269 h_t_int h_numSFperElem )
const
272 string pushstring =
"";
275 for (
int i = 0; i < h_numSFperElem( attype ); ++i )
277 index = SF( attype, i, 13 );
279 for (
int j = 1; j < 12; ++j )
281 writestring = SF( attype,
index, j );
282 pushstring += to_string( writestring ) +
" ";
286 v.push_back( pushstring );
291template <
class t_SF,
class t_SFscaling,
class h_t_
int>
294 t_SFscaling SFscaling,
int attype,
295 h_t_int h_numSFperElem )
const
299 for (
int k = 0; k < h_numSFperElem( attype ); ++k )
301 index = SF( attype, k, 13 );
307template <
class t_SF,
class t_SFGmemberlist,
class h_t_
int>
309 t_SFGmemberlist SFGmemberlist,
310 int attype, h_t_int h_numSFperElem,
311 h_t_int h_numSFGperElem,
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 );
318 for (
int k = 0; k < h_numSFperElem( attype ); ++k )
320 bool createNewGroup =
true;
321 SFindex = SF( attype, k, 13 );
322 for (
int l = 0; l < h_numSFGperElem( attype ); ++l )
324 if ( ( SF( attype, SFindex, 0 ) ==
325 SF( attype, SFGmemberlist( attype, l, 0 ),
327 ( SF( attype, SFindex, 2 ) ==
328 SF( attype, SFGmemberlist( attype, l, 0 ),
330 ( SF( attype, SFindex, 3 ) ==
331 SF( attype, SFGmemberlist( attype, l, 0 ),
333 ( SF( attype, SFindex, 7 ) ==
334 SF( attype, SFGmemberlist( attype, l, 0 ),
336 ( SF( attype, SFindex, 11 ) ==
337 SF( attype, SFGmemberlist( attype, l, 0 ),
339 ( SF( attype, SFindex, 12 ) ==
340 SF( attype, SFGmemberlist( attype, l, 0 ),
343 createNewGroup =
false;
344 if ( SF( attype, SFindex, 1 ) == 2 )
346 SFGmemberlist( attype, l, h_numGR( l ) ) = SFindex;
348 SFGmemberlist( attype, l, maxSFperElem )++;
352 else if ( SF( attype, SFindex, 1 ) == 3 )
354 SFGmemberlist( attype, l, h_numGA( l ) ) = SFindex;
356 SFGmemberlist( attype, l, maxSFperElem )++;
362 if ( createNewGroup )
364 int l = h_numSFGperElem( attype );
365 h_numSFGperElem( attype )++;
366 if ( SF( attype, SFindex, 1 ) == 2 )
368 SFGmemberlist( attype, l, 0 ) = SFindex;
369 if ( l >= (
int)h_numGR.extent( 0 ) )
370 Kokkos::resize( h_numGR, l+1 );
372 SFGmemberlist( attype, l, maxSFperElem )++;
374 else if ( SF( attype, SFindex, 1 ) == 3 )
376 SFGmemberlist( attype, l, 0 ) = SFindex;
377 if ( l >= (
int)h_numGA.extent( 0 ) )
378 Kokkos::resize( h_numGA, l+1 );
380 SFGmemberlist( attype, l, maxSFperElem )++;
388template <
class t_SF,
class t_SFGmemberlist,
class h_t_
int>
391 int attype, h_t_int h_numSFGperElem )
const
394 string pushstring =
"";
395 for (
int groupIndex = 0; groupIndex < h_numSFGperElem( attype );
399 for (
int j = 0; j < 8; ++j )
402 SF( attype, SFGmemberlist( attype, groupIndex, 0 ), j ) ) +
406 v.push_back( pushstring );
411template <
class t_SF,
class h_t_
int>
413 double const cutoffAlpha, t_SF SF,
int attype,
414 h_t_int h_numSFperElem )
416 for (
int k = 0; k < h_numSFperElem( attype ); ++k )
418 SF( attype, k, 10 ) = cutoffType;
419 SF( attype, k, 11 ) = cutoffAlpha;
424template <
class t_SF,
class t_SFscaling,
class h_t_
int>
426 vector<string>
const &statisticsLine,
double Smin,
427 double Smax, t_SF SF, t_SFscaling SFscaling,
428 int attype, h_t_int h_numSFperElem )
const
431 for (
int k = 0; k < h_numSFperElem( attype ); ++k )
433 index = SF( attype, k, 13 );
435 SFscaling, attype,
index );
448 size_t global_minNeighbors = 0;
449 size_t minNeighbors = 0;
451 for (
int k = 0; k < nSF; ++k )
453 SFtype = SF( attype, k, 1 );
456 else if ( SFtype == 3 )
458 global_minNeighbors = max( minNeighbors, global_minNeighbors );
461 return global_minNeighbors;
464template <
class t_SF,
class h_t_
int>
466 h_t_int h_numSFperElem )
const
468 double minCutoffRadius = numeric_limits<double>::max();
470 for (
int k = 0; k < h_numSFperElem( attype ); ++k )
471 minCutoffRadius = min( SF( attype, k, 7 ), minCutoffRadius );
473 return minCutoffRadius;
476template <
class t_SF,
class h_t_
int>
478 h_t_int h_numSFperElem )
const
480 double maxCutoffRadius = 0.0;
482 for (
int k = 0; k < h_numSFperElem( attype ); ++k )
483 maxCutoffRadius = max( SF( attype, k, 7 ), maxCutoffRadius );
485 return maxCutoffRadius;
CutoffType
List of available cutoff function types.
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.
~ElementCabana()
Destructor.
void setScalingType(ScalingType scalingType, std::string statisticsLine, double Smin, double Smax, t_SFscaling SFscaling, int attype, int k) const
Symmetry function statistics.
std::size_t index
Global index of this element.
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.
bool compareSF(t_SF SF, int attype, int index1, int index2)
Print symmetry function parameter value information.
ElementCabana(std::size_t const index)
Constructor using index.
double atomicEnergyOffset
Offset energy for every atom of this element.
std::string scalingLine(ScalingType scalingType, t_SFscaling SFscaling, int attype, int k) const
Print scaling for one symmetry function.
void addSymmetryFunction(std::string const ¶meters, std::vector< std::string > elementStrings, int attype, t_SF SF, double convLength, h_t_int h_numSFperElem)
Add one symmetry function.
Contains element-specific data.
std::vector< std::string > infoSymmetryFunctionParameters() const
Print symmetry function parameter value information.
void sortSymmetryFunctions()
Sort all symmetry function.
std::vector< std::string > infoSymmetryFunctionGroups() const
Print symmetry function group info.
std::vector< std::string > infoSymmetryFunctionScaling() const
Print symmetry function scaling information.
double getMinCutoffRadius() const
Get minimum cutoff radius of all symmetry functions.
void setupSymmetryFunctionGroups()
Set up symmetry function groups.
std::size_t getMinNeighbors() const
Get maximum of required minimum number of neighbors for all symmetry functions for this element.
double getMaxCutoffRadius() const
Get maximum cutoff radius of all symmetry functions.
vector< string > split(string const &input, char delimiter)
Split string at each delimiter.
string reduce(string const &line, string const &whitespace, string const &fill)
Replace multiple whitespaces with fill.