24#include <Cabana_Core.hpp>
25#include <Kokkos_Core.hpp>
45template <
class t_device>
54 using exe_space =
typename device_type::execution_space;
56 typedef typename exe_space::array_layout
layout;
60 using d_t_mass = Kokkos::View<T_V_FLOAT *, memory_space>;
61 using h_t_mass = Kokkos::View<T_V_FLOAT *, layout, host_space>;
62 using d_t_int = Kokkos::View<T_INT *, memory_space>;
63 using h_t_int = Kokkos::View<T_INT *, layout, host_space>;
66 using d_t_SF = Kokkos::View<T_FLOAT * * [15], memory_space>;
67 using t_SF = Kokkos::View<T_FLOAT * * [15], layout, host_space>;
69 using t_SFscaling = Kokkos::View<T_FLOAT * * [8], layout, host_space>;
74 using d_t_bias = Kokkos::View<T_FLOAT ***, memory_space>;
75 using t_bias = Kokkos::View<T_FLOAT ***, layout, host_space>;
77 using t_weights = Kokkos::View<T_FLOAT ****, layout, host_space>;
78 using d_t_NN = Kokkos::View<T_FLOAT ***, memory_space>;
109 std::string
const &fileName =
"scaling.data")
override;
133 std::string
const &fileNameFormat =
"weights.%03zu.data")
override;
146 KOKKOS_INLINE_FUNCTION
148 double &
fc,
double &dfc,
double r,
double rc,
149 bool derivative)
const;
160 KOKKOS_INLINE_FUNCTION
177 template <
class t_slice_x,
class t_slice_f,
class t_slice_type,
178 class t_slice_dEdG,
class t_neigh_list,
class t_neigh_parallel,
179 class t_angle_parallel>
181 t_slice_dEdG dEdG, t_neigh_list neigh_list,
int N_local,
182 t_neigh_parallel neigh_op, t_angle_parallel angle_op);
195 template <
class t_slice_type,
class t_slice_G,
class t_slice_dEdG,
198 t_slice_dEdG dEdG, t_slice_E E,
215 template <
class t_slice_x,
class t_slice_type,
class t_slice_G,
216 class t_neigh_list,
class t_neigh_parallel,
class t_angle_parallel>
218 t_slice_G G, t_neigh_list neigh_list,
219 int N_local, t_neigh_parallel neigh_op,
220 t_angle_parallel angle_op);
227 "H",
"He",
"Li",
"Be",
"B",
"C",
"N",
"O",
"F",
"Ne",
"Na",
"Mg",
228 "Al",
"Si",
"P",
"S",
"Cl",
"Ar",
"K",
"Ca",
"Sc",
"Ti",
"V",
"Cr",
229 "Mn",
"Fe",
"Co",
"Ni",
"Cu",
"Zn",
"Ga",
"Ge",
"As",
"Se",
"Br",
"Kr",
230 "Rb",
"Sr",
"Y",
"Zr",
"Nb",
"Mo",
"Tc",
"Ru",
"Rh",
"Pd",
"Ag",
"Cd",
231 "In",
"Sn",
"Sb",
"Te",
"I",
"Xe",
"Cs",
"Ba",
"La",
"Ce",
"Pr",
"Nd",
232 "Pm",
"Sm",
"Eu",
"Gd",
"Tb",
"Dy",
"Ho",
"Er",
"Tm",
"Yb",
"Lu",
"Hf",
233 "Ta",
"W",
"Re",
"Os",
"Ir",
"Pt",
"Au",
"Hg",
"Tl",
"Pb",
"Bi",
"Po",
234 "At",
"Rn",
"Fr",
"Ra",
"Ac",
"Th",
"Pa",
"U",
"Np",
"Pu",
"Am",
"Cm",
235 "Bk",
"Cf",
"Es",
"Fm",
"Md",
"No"};
283template <
class t_device>
284KOKKOS_INLINE_FUNCTION
void
286 double cutoffAlpha,
double &
fc,
double &dfc,
287 double r,
double rc,
bool derivative)
const
291 temp = tanh(1.0 - r / rc);
292 fc = temp * temp * temp;
294 dfc = 3.0 * temp * temp * (temp * temp - 1.0) / rc;
299 double rci = rc * cutoffAlpha;
300 double iw = 1.0 / (rc - rci);
301 double PI = 4.0 * atan(1.0);
306 temp = cos(PI * (r - rci) * iw);
307 fc = 0.5 * (temp + 1.0);
309 dfc = -0.5 * iw * PI * sqrt(1.0 - temp * temp);
314template <
class t_device>
315KOKKOS_INLINE_FUNCTION
double
319 double scalingType = SFscaling_(attype, k, 7);
320 double scalingFactor = SFscaling_(attype, k, 6);
321 double Gmin = SFscaling_(attype, k, 0);
323 double Gmean = SFscaling_(attype, k, 2);
325 double Smin = SFscaling_(attype, k, 4);
328 if (scalingType == 0.0) {
330 }
else if (scalingType == 1.0) {
331 return Smin + scalingFactor * (value - Gmin);
332 }
else if (scalingType == 2.0) {
333 return value - Gmean;
334 }
else if (scalingType == 3.0) {
335 return Smin + scalingFactor * (value - Gmean);
336 }
else if (scalingType == 4.0) {
337 return Smin + scalingFactor * (value - Gmean);
CutoffType
List of available cutoff function types.
Derived Cabana main NNP class.
void calculateSymmetryFunctionGroups(t_slice_x x, t_slice_type type, t_slice_G G, t_neigh_list neigh_list, int N_local, t_neigh_parallel neigh_op, t_angle_parallel angle_op)
Calculate all symmetry function groups for all atoms in given structure.
std::vector< std::string > knownElements
list of element symbols in order of periodic table
std::vector< std::string > elementStrings
void setupSymmetryFunctions() override
Set up all symmetry functions.
d_t_SFGmemberlist d_SFGmemberlist
d_t_int numNeuronsPerLayer
void setupSymmetryFunctionGroups() override
Set up symmetry function groups.
void setupNeuralNetworkWeights(std::string const &fileNameFormat="weights.%03zu.data") override
Set up neural network weights from files.
void setupElementMap() override
Set up the element map.
Kokkos::View< T_FLOAT **[15], layout, host_space > t_SF
void calculateForces(t_slice_x x, t_slice_f f, t_slice_type type, t_slice_dEdG dEdG, t_neigh_list neigh_list, int N_local, t_neigh_parallel neigh_op, t_angle_parallel angle_op)
Calculate forces for all atoms in given structure.
h_t_mass atomicEnergyOffset
t_SFGmemberlist SFGmemberlist
typename device_type::execution_space exe_space
Kokkos::View< T_FLOAT ***, layout, host_space > t_bias
typename device_type::memory_space memory_space
Kokkos::View< T_INT *, layout, host_space > h_t_int
Kokkos::View< T_INT ***, memory_space > d_t_SFGmemberlist
Kokkos::View< T_FLOAT **[15], memory_space > d_t_SF
Kokkos::View< T_INT ***, layout, host_space > t_SFGmemberlist
Kokkos::View< T_FLOAT ****, layout, host_space > t_weights
Kokkos::View< T_FLOAT ***, memory_space > d_t_NN
Kokkos::View< T_V_FLOAT *, layout, host_space > h_t_mass
d_t_SFscaling d_SFscaling
KOKKOS_INLINE_FUNCTION double scale(int attype, double value, int k, d_t_SFscaling SFscaling) const
Kokkos::View< T_FLOAT **[8], memory_space > d_t_SFscaling
KOKKOS_INLINE_FUNCTION void compute_cutoff(CutoffFunction::CutoffType cutoffType, double cutoffAlpha, double &fc, double &dfc, double r, double rc, bool derivative) const
Kokkos::View< T_INT *, memory_space > d_t_int
h_t_int h_numNeuronsPerLayer
Kokkos::View< T_FLOAT **[8], layout, host_space > t_SFscaling
void calculateAtomicNeuralNetworks(t_slice_type type, t_slice_G G, t_slice_dEdG dEdG, t_slice_E E, int N_local)
Calculate atomic neural networks for all atoms in given structure.
Kokkos::View< T_FLOAT ****, memory_space > d_t_weights
Kokkos::View< T_V_FLOAT *, memory_space > d_t_mass
Kokkos::HostSpace host_space
std::vector< ElementCabana > elements
void setupSymmetryFunctionScaling(std::string const &fileName="scaling.data") override
Set up symmetry function scaling from file.
Kokkos::View< T_FLOAT ***, memory_space > d_t_bias
void setupElements() override
Set up all Element instances.
CutoffFunction::CutoffType cutoffType
exe_space::array_layout layout
void setupNeuralNetwork() override
Set up neural networks for all elements.
Base class for all NNP applications.
std::vector< double > minCutoffRadius
settings::Settings settings
std::vector< std::size_t > minNeighbors
CutoffFunction::CutoffType cutoffType