STORMM Source Documentation
Loading...
Searching...
No Matches
ppitable.h
1// -*-c++-*-
2#ifndef STORMM_PPI_TABLE_H
3#define STORMM_PPI_TABLE_H
4
5#include <vector>
6#include "copyright.h"
7#include "Constants/behavior.h"
8#include "Constants/symbol_values.h"
9#include "DataTypes/common_types.h"
10#include "Math/log_scale_spline.h"
11#include "Math/math_enumerators.h"
12#include "Parsing/parsing_enumerators.h"
13#include "energy_enumerators.h"
14#include "pme_util.h"
15
16namespace stormm {
17namespace energy {
18
19using constants::ExceptionResponse;
20using constants::PrecisionModel;
21using symbols::amber_ancient_bioq;
22using card::Hybrid;
23using card::HybridKind;
24using card::HybridTargetLevel;
25using parse::NumberFormat;
26using stmath::BasisFunctions;
27using stmath::LogScaleSpline;
28using stmath::LogSplineForm;
29using stmath::LogSplineTable;
30using stmath::TableIndexing;
31using stmath::doublePrecisionSplineDetailMask;
32using stmath::singlePrecisionSplineDetailMask;
33
37template <typename T, typename T4> struct PPIKit {
38
40 PPIKit(NonbondedTheme theme_in, BasisFunctions basis_in, TableIndexing lookup_in,
41 int index_bound_in, int excl_offset_in, int index_shift_bits_in, ullint dp_detail_mask_in,
42 uint sp_detail_mask_in, T arg_offset_in, const T4* energy_in, const T4* force_in,
43 const T4* energy_excl_in, const T4* force_excl_in);
44
50 PPIKit(const PPIKit &original) = default;
51 PPIKit(PPIKit &&original) = default;
53
54 const NonbondedTheme theme;
56 const BasisFunctions basis;
58 const TableIndexing lookup;
60 const int index_bound;
62 const int excl_offset;
65 const int index_shift_bits;
68 const ullint dp_detail_mask;
71 const uint sp_detail_mask;
74 const T arg_offset;
76 const T4* energy;
80 const T4* force;
83 const T4* energy_excl;
84 const T4* force_excl;
85};
86
90template <typename T> struct PPIeKit {
91
93 PPIeKit(NonbondedTheme theme_in, BasisFunctions basis_in, TableIndexing lookup_in,
94 int index_bound_in, int excl_offset_in, int index_shift_bits_in,
95 ullint dp_detail_mask_in, uint sp_detail_mask_in, T arg_offset_in, const T* energy_x_in,
96 const T* energy_y_in, const T* energy_z_in, const T* energy_w_in, const T* force_x_in,
97 const T* force_y_in, const T* force_z_in, const T* force_w_in, const T* energy_excl_x_in,
98 const T* energy_excl_y_in, const T* energy_excl_z_in, const T* energy_excl_w_in,
99 const T* force_excl_x_in, const T* force_excl_y_in, const T* force_excl_z_in,
100 const T* force_excl_w_in);
101
107 PPIeKit(const PPIeKit &original) = default;
108 PPIeKit(PPIeKit &&original) = default;
110
111 const NonbondedTheme theme;
113 const BasisFunctions basis;
115 const TableIndexing lookup;
117 const int index_bound;
119 const int excl_offset;
125 const ullint dp_detail_mask;
128 const uint sp_detail_mask;
131 const T arg_offset;
133 const T* energy_x;
137 const T* energy_y;
138 const T* energy_z;
139 const T* energy_w;
140 const T* force_x;
143 const T* force_y;
144 const T* force_z;
145 const T* force_w;
146 const T* energy_excl_x;
147 const T* energy_excl_y;
148 const T* energy_excl_z;
149 const T* energy_excl_w;
150 const T* force_excl_x;
151 const T* force_excl_y;
152 const T* force_excl_z;
153 const T* force_excl_w;
154};
155
163class PPITable {
164public:
165
170 PPITable(NonbondedTheme theme_in = NonbondedTheme::ELECTROSTATIC,
171 BasisFunctions basis_set_in = BasisFunctions::POLYNOMIAL,
172 TableIndexing indexing_method_in = TableIndexing::SQUARED_ARG,
173 double cutoff_in = default_pme_cutoff, double argument_offset_in = 0.0,
174 double dsum_tol_in = default_dsum_tol, int mantissa_bits_in = 5,
175 double coulomb_in = amber_ancient_bioq, double min_range_in = 0.015625);
176
177 template <typename T4>
178 PPITable(const LogScaleSpline<T4> &spl_a, const LogScaleSpline<T4> &spl_b,
179 const LogScaleSpline<T4> &spl_c, const LogScaleSpline<T4> &spl_d,
180 double cutoff_in = default_pme_cutoff);
181
182 template <typename T4>
183 PPITable(const LogScaleSpline<T4> &spl_a, const LogScaleSpline<T4> &spl_b,
184 const LogScaleSpline<T4> &spl_c);
185
186 template <typename T4>
187 PPITable(const LogScaleSpline<T4> &spl_a, const LogScaleSpline<T4> &spl_b);
188
189 template <typename T4>
190 PPITable(const LogScaleSpline<T4> &spl_a);
192
199 PPITable(const PPITable &original);
200 PPITable(PPITable &&original);
201 PPITable& operator=(const PPITable &original);
202 PPITable& operator=(PPITable &&original);
204
206 NonbondedTheme getTheme() const;
207
209 double getCutoff() const;
210
212 double getMaximumRange() const;
213
215 double getIndexingOffset() const;
216
218 double getDirectSumTolerance() const;
219
221 int getBitStride() const;
222
225 double getEwaldCoefficient() const;
226
229 double getGaussianWidth() const;
230
234 int getTableIndex(double arg, PrecisionModel prec = PrecisionModel::SINGLE) const;
235
239 int getTableIndexByRealArg(double arg, PrecisionModel prec = PrecisionModel::SINGLE) const;
240
256 double evaluate(double arg, LogSplineForm kind, PrecisionModel prec = PrecisionModel::SINGLE,
257 bool use_elemental_tables = false) const;
258
262 double evaluateByRealArg(double arg, LogSplineForm kind,
263 PrecisionModel prec = PrecisionModel::SINGLE,
264 bool use_elemental_tables = false) const;
265
269 const PPIKit<double, double4> dpData(HybridTargetLevel tier = HybridTargetLevel::HOST) const;
270
274 const PPIKit<float, float4> spData(HybridTargetLevel tier = HybridTargetLevel::HOST) const;
275
281 const PPIeKit<double> dpeData(HybridTargetLevel tier = HybridTargetLevel::HOST) const;
282
288 const PPIeKit<float> speData(HybridTargetLevel tier = HybridTargetLevel::HOST) const;
289
290#ifdef STORMM_USE_HPC
292 void upload();
293
295 void download();
296#endif
297
298private:
299
300 NonbondedTheme theme;
302 BasisFunctions basis_set;
303 TableIndexing indexing_method;
305 double cutoff;
307 double max_range;
309 double min_range;
312 double argument_offset;
316 double dsum_tol;
319 double ew_coeff;
321 int mantissa_bits;
322 double coulomb;
323 int dp_exclusion_offset;
326 int sp_exclusion_offset;
329 ullint dp_detail_bitmask;
331 uint sp_detail_bitmask;
333
334 // The main arrays, in full (double) precision
335 Hybrid<double4> energy;
336 Hybrid<double4> force;
337
339 Hybrid<double4> energy_with_exclusions;
340
342 Hybrid<double4> force_with_exclusions;
343
344 // The main arrays, in single precision
345 Hybrid<float4> sp_energy;
346 Hybrid<float4> sp_force;
347
349 Hybrid<float4> sp_energy_with_exclusions;
350
352 Hybrid<float4> sp_force_with_exclusions;
353
356 Hybrid<double4> coeffs;
357
360 Hybrid<float4> sp_coeffs;
361
366 Hybrid<double> energy_x;
367 Hybrid<double> energy_y;
368 Hybrid<double> energy_z;
369 Hybrid<double> energy_w;
371
376 Hybrid<double> force_x;
377 Hybrid<double> force_y;
378 Hybrid<double> force_z;
379 Hybrid<double> force_w;
381
386 Hybrid<double> energy_with_excl_x;
387 Hybrid<double> energy_with_excl_y;
388 Hybrid<double> energy_with_excl_z;
389 Hybrid<double> energy_with_excl_w;
391
396 Hybrid<double> force_with_excl_x;
397 Hybrid<double> force_with_excl_y;
398 Hybrid<double> force_with_excl_z;
399 Hybrid<double> force_with_excl_w;
401
406 Hybrid<float> sp_energy_x;
407 Hybrid<float> sp_energy_y;
408 Hybrid<float> sp_energy_z;
409 Hybrid<float> sp_energy_w;
411
416 Hybrid<float> sp_force_x;
417 Hybrid<float> sp_force_y;
418 Hybrid<float> sp_force_z;
419 Hybrid<float> sp_force_w;
421
426 Hybrid<float> sp_energy_with_excl_x;
427 Hybrid<float> sp_energy_with_excl_y;
428 Hybrid<float> sp_energy_with_excl_z;
429 Hybrid<float> sp_energy_with_excl_w;
431
436 Hybrid<float> sp_force_with_excl_x;
437 Hybrid<float> sp_force_with_excl_y;
438 Hybrid<float> sp_force_with_excl_z;
439 Hybrid<float> sp_force_with_excl_w;
441
445 Hybrid<double> elemental_coeffs;
446
450 Hybrid<float> sp_elemental_coeffs;
451
457 template <typename T4> NonbondedTheme findTheme(const LogScaleSpline<T4> &spl) const;
458
461 template <typename T4> std::vector<LogScaleSpline<T4>> buildAllSplineTables() const;
462
469 template <typename T4>
470 const LogScaleSpline<T4>& findNonExclPotential(const LogScaleSpline<T4> &spl_a,
471 const LogScaleSpline<T4> &spl_b,
472 const LogScaleSpline<T4> &spl_c,
473 const LogScaleSpline<T4> &spl_d) const;
474
477 template <typename T4>
478 const LogScaleSpline<T4>& findExclPotential(const LogScaleSpline<T4> &spl_a,
479 const LogScaleSpline<T4> &spl_b,
480 const LogScaleSpline<T4> &spl_c,
481 const LogScaleSpline<T4> &spl_d) const;
482
485 template <typename T4>
486 const LogScaleSpline<T4>& findNonExclForce(const LogScaleSpline<T4> &spl_a,
487 const LogScaleSpline<T4> &spl_b,
488 const LogScaleSpline<T4> &spl_c,
489 const LogScaleSpline<T4> &spl_d) const;
490
493 template <typename T4>
494 const LogScaleSpline<T4>& findExclForce(const LogScaleSpline<T4> &spl_a,
495 const LogScaleSpline<T4> &spl_b,
496 const LogScaleSpline<T4> &spl_c,
497 const LogScaleSpline<T4> &spl_d) const;
498
502 template <typename T4> uint checkPriority(const LogScaleSpline<T4> &spl_x) const;
503
509 template <typename T4> void checkSplineCompatibility(const LogScaleSpline<T4> &spl_a,
510 const LogScaleSpline<T4> &spl_b) const;
511
517 LogSplineForm findMissingForm(const uint holdings) const;
518
529 template <typename T4>
530 LogScaleSpline<T4> getTablePriority(const LogScaleSpline<T4> &spl_a,
531 const LogScaleSpline<T4> &spl_b,
532 const LogScaleSpline<T4> &spl_c) const;
533
534 template <typename T4>
535 LogScaleSpline<T4> getTablePriority(const LogScaleSpline<T4> &spl_a,
536 const LogScaleSpline<T4> &spl_b) const;
537
538 template <typename T4>
539 LogScaleSpline<T4> getTablePriority(const LogScaleSpline<T4> &spl_a) const;
541
549 template <typename T4>
550 void populateCoefficients(const LogScaleSpline<T4> &u, const LogScaleSpline<T4> &du,
551 const LogScaleSpline<T4> &ux, const LogScaleSpline<T4> &dux);
552};
553
554} // namespace energy
555} // namespace stormm
556
557#include "ppitable.tpp"
558
559#endif
An evolution of GpuBuffer in pmemd.cuda, the Composite array has elements that are accessible from ei...
Definition hybrid.h:202
const PPIeKit< float > speData(HybridTargetLevel tier=HybridTargetLevel::HOST) const
Get the single-precision abstract for use of the splines in a C programming style,...
Definition ppitable.cpp:356
double getMaximumRange() const
Get the maximum range of the spline.
Definition ppitable.cpp:103
double getEwaldCoefficient() const
Get the Ewald coefficient used to perform the switching between short- and long-ranged potentials.
Definition ppitable.cpp:123
double getIndexingOffset() const
Get the indexing argument offset, consistent across all tables.
Definition ppitable.cpp:108
const PPIKit< double, double4 > dpData(HybridTargetLevel tier=HybridTargetLevel::HOST) const
Get the double-precision abstract for use of the splines in a C programming style.
Definition ppitable.cpp:319
const PPIeKit< double > dpeData(HybridTargetLevel tier=HybridTargetLevel::HOST) const
Get the double-precision abstract for use of the splines in a C programming style,...
Definition ppitable.cpp:341
int getTableIndexByRealArg(double arg, PrecisionModel prec=PrecisionModel::SINGLE) const
Get the spline index that would be accessed in order to evaluate a given argument.
Definition ppitable.cpp:304
const PPIKit< float, float4 > spData(HybridTargetLevel tier=HybridTargetLevel::HOST) const
Get the single-precision abstract for use of the splines in a C programming style.
Definition ppitable.cpp:330
int getTableIndex(double arg, PrecisionModel prec=PrecisionModel::SINGLE) const
Get the spline index that would be accessed in order to evaluate a given argument.
Definition ppitable.cpp:284
PPITable(NonbondedTheme theme_in=NonbondedTheme::ELECTROSTATIC, BasisFunctions basis_set_in=BasisFunctions::POLYNOMIAL, TableIndexing indexing_method_in=TableIndexing::SQUARED_ARG, double cutoff_in=default_pme_cutoff, double argument_offset_in=0.0, double dsum_tol_in=default_dsum_tol, int mantissa_bits_in=5, double coulomb_in=amber_ancient_bioq, double min_range_in=0.015625)
The constuctor can accept all of the arguments that might be useful for making a LosScaleSpline,...
Definition ppitable.cpp:11
PPITable(const PPITable &original)
The presence of POINTER-kind Hybrid objects implies pointer repairs that require the copy and move co...
double getGaussianWidth() const
Get the Gaussian RMS sigma parameter (one half the inverse of the Ewald coefficient) used to perform ...
Definition ppitable.cpp:128
double evaluate(double arg, LogSplineForm kind, PrecisionModel prec=PrecisionModel::SINGLE, bool use_elemental_tables=false) const
Evaluate the spline table at a given inter-particle distance expressed in the manner used for the cla...
Definition ppitable.cpp:133
int getBitStride() const
Get the number of bits of the mantissa used for table indexing.
Definition ppitable.cpp:118
double getDirectSumTolerance() const
Get the direct sum tolerance.
Definition ppitable.cpp:113
double evaluateByRealArg(double arg, LogSplineForm kind, PrecisionModel prec=PrecisionModel::SINGLE, bool use_elemental_tables=false) const
Evaluate the spline table at a given inter-particle distance expressed as the absolute value of the d...
Definition ppitable.cpp:266
NonbondedTheme getTheme() const
Get the non-bonded potential described by an object of this class.
Definition ppitable.cpp:93
double getCutoff() const
Get the cutoff on particle-particle interactions.
Definition ppitable.cpp:98
A logarithmic spline can be very useful for interpolating functions that are steepest at low values o...
Definition log_scale_spline.h:139
Abstract for the particle-particle interaction table, with pointers to energies and forces and sizing...
Definition ppitable.h:37
const T4 * energy_excl
Table of excluded energy coefficients.
Definition ppitable.h:83
const uint sp_detail_mask
Definition ppitable.h:71
const NonbondedTheme theme
Definition ppitable.h:54
PPIKit(NonbondedTheme theme_in, BasisFunctions basis_in, TableIndexing lookup_in, int index_bound_in, int excl_offset_in, int index_shift_bits_in, ullint dp_detail_mask_in, uint sp_detail_mask_in, T arg_offset_in, const T4 *energy_in, const T4 *force_in, const T4 *energy_excl_in, const T4 *force_excl_in)
The constructor takes the customary list of pointers and critical constants.
PPIKit(const PPIKit &original)=default
With all const members, the copy and move assignment operators are implicitly deleted,...
const int index_shift_bits
Definition ppitable.h:65
const TableIndexing lookup
Definition ppitable.h:58
const int index_bound
Definition ppitable.h:60
const T4 * force_excl
Table of excluded force coefficients.
Definition ppitable.h:84
const T4 * energy
Definition ppitable.h:76
const T4 * force
Definition ppitable.h:80
const ullint dp_detail_mask
Definition ppitable.h:68
const T arg_offset
Definition ppitable.h:74
const BasisFunctions basis
Definition ppitable.h:56
const int excl_offset
Definition ppitable.h:62
An equivalent abstract which delivers the tabulated data with all tuples broken into separate arrays ...
Definition ppitable.h:90
const T * force_x
Definition ppitable.h:140
const int excl_offset
Definition ppitable.h:119
const T * force_z
Table of force function spline z coefficients.
Definition ppitable.h:144
const T * force_excl_x
Excluded interation energy function spline x coefficients.
Definition ppitable.h:150
const T * energy_excl_x
Excluded interation energy function spline x coefficients.
Definition ppitable.h:146
const T * force_excl_z
Excluded interation energy function spline z coefficients.
Definition ppitable.h:152
const T * energy_excl_z
Excluded interation energy function spline z coefficients.
Definition ppitable.h:148
const T * energy_w
Table of energy function spline w coefficients.
Definition ppitable.h:139
const T * force_w
Table of force function spline w coefficients.
Definition ppitable.h:145
const T * energy_z
Table of energy function spline z coefficients.
Definition ppitable.h:138
const T * energy_y
Table of energy function spline y coefficients.
Definition ppitable.h:137
const T * energy_excl_w
Excluded interation energy function spline w coefficients.
Definition ppitable.h:149
PPIeKit(const PPIeKit &original)=default
With all const members, the copy and move assignment operators are implicitly deleted,...
const T * energy_x
Definition ppitable.h:133
const int index_shift_bits
Definition ppitable.h:122
const T * force_excl_y
Excluded interation energy function spline y coefficients.
Definition ppitable.h:151
const ullint dp_detail_mask
Definition ppitable.h:125
const T arg_offset
Definition ppitable.h:131
const T * energy_excl_y
Excluded interation energy function spline y coefficients.
Definition ppitable.h:147
const BasisFunctions basis
Definition ppitable.h:113
const TableIndexing lookup
Definition ppitable.h:115
const NonbondedTheme theme
Definition ppitable.h:111
const T * force_excl_w
Excluded interation energy function spline w coefficients.
Definition ppitable.h:153
const T * force_y
Table of force function spline y coefficients.
Definition ppitable.h:143
const uint sp_detail_mask
Definition ppitable.h:128
PPIeKit(NonbondedTheme theme_in, BasisFunctions basis_in, TableIndexing lookup_in, int index_bound_in, int excl_offset_in, int index_shift_bits_in, ullint dp_detail_mask_in, uint sp_detail_mask_in, T arg_offset_in, const T *energy_x_in, const T *energy_y_in, const T *energy_z_in, const T *energy_w_in, const T *force_x_in, const T *force_y_in, const T *force_z_in, const T *force_w_in, const T *energy_excl_x_in, const T *energy_excl_y_in, const T *energy_excl_z_in, const T *energy_excl_w_in, const T *force_excl_x_in, const T *force_excl_y_in, const T *force_excl_z_in, const T *force_excl_w_in)
The constructor takes the customary list of pointers and critical constants.
const int index_bound
Definition ppitable.h:117