STORMM Source Documentation
Loading...
Searching...
No Matches
nml_precision.h
1// -*-c++-*-
2#ifndef STORMM_NML_PRECISION_H
3#define STORMM_NML_PRECISION_H
4
5#include "copyright.h"
6#include "Constants/behavior.h"
7#include "Constants/fixed_precision.h"
8#include "Parsing/textfile.h"
9#include "input.h"
10#include "namelist_emulator.h"
11
12namespace stormm {
13namespace namelist {
14
15using constants::PrecisionModel;
16using parse::WrapTextSearch;
17using numerics::default_charge_mesh_scale_bits;
18using numerics::default_energy_scale_bits;
19using numerics::default_force_scale_bits;
20using numerics::default_globalpos_scale_bits;
21using numerics::default_localpos_scale_bits;
22using numerics::default_velocity_scale_bits;
23
28constexpr char default_precision_valence_method[] = "single";
29constexpr char default_precision_nonbonded_method[] = "single";
30constexpr char default_precision_pme_method[] = "single";
31constexpr double default_precision_constraint_tol = 1.0e-5;
32constexpr double min_precision_constraint_tol = 5.0e-9;
34
41public:
42
54 PrecisionControls(ExceptionResponse policy_in = ExceptionResponse::DIE,
55 WrapTextSearch wrap = WrapTextSearch::NO);
56 PrecisionControls(const TextFile &tf, int *start_line, bool *found_nml,
57 ExceptionResponse policy_in = ExceptionResponse::DIE,
58 WrapTextSearch wrap = WrapTextSearch::NO);
60
64 PrecisionControls(const PrecisionControls &original) = default;
65 PrecisionControls(PrecisionControls &&original) = default;
66 PrecisionControls& operator=(const PrecisionControls &original) = default;
67 PrecisionControls& operator=(PrecisionControls &&original) = default;
69
71 int getGlobalPosScalingBits() const;
72
74 int getLocalPosScalingBits() const;
75
77 int getVelocityScalingBits() const;
78
80 int getForceScalingBits() const;
81
83 int getEnergyScalingBits() const;
84
86 int getChargeMeshScalingBits() const;
87
89 double getBondConstraintTolerance() const;
90
92 PrecisionModel getValenceMethod() const;
93
95 PrecisionModel getNonbondedMethod() const;
96
98 PrecisionModel getParticleMeshEwaldMethod() const;
99
101 const NamelistEmulator& getTranscript() const;
102
107 void setGlobalPosScalingBits(int bitval);
108
113 void setLocalPosScalingBits(int bitval);
114
119 void setVelocityScalingBits(int bitval);
120
125 void setForceScalingBits(int bitval);
126
131 void setEnergyScalingBits(int bitval);
132
137 void setChargeMeshScalingBits(int bitval);
138
143 void setBondConstraintTolerance(double tol);
144
148 void setValenceMethod(PrecisionModel pmodel);
149
153 void setNonbondedMethod(PrecisionModel pmodel);
154
159 void setParticleMeshEwaldMethod(PrecisionModel pmodel);
160
161private:
162 ExceptionResponse policy;
167 int globalpos_scale_bits;
168 int localpos_scale_bits;
169 int velocity_scale_bits;
170 int force_scale_bits;
171 int energy_scale_bits;
172 int charge_mesh_scale_bits;
173 double bond_constraint_tol;
174 PrecisionModel valence_method;
175 PrecisionModel nonbonded_method;
176 PrecisionModel pme_method;
177
179 NamelistEmulator nml_transcript;
180
183 void validateBondConstraintTol();
184};
185
199NamelistEmulator precisionInput(const TextFile &tf, int *start_line, bool *found,
200 ExceptionResponse policy = ExceptionResponse::DIE,
201 WrapTextSearch wrap = WrapTextSearch::NO);
202
203} // namespace namelist
204} // namespace stormm
205
206#endif
PrecisionControls(ExceptionResponse policy_in=ExceptionResponse::DIE, WrapTextSearch wrap=WrapTextSearch::NO)
The constructor can prepare an object with default settings or read the corresponding namelist to acc...
Definition nml_precision.cpp:24
Collection of variables to transcribe information contained within a namelist.
Definition namelist_emulator.h:30
int getEnergyScalingBits() const
Get the energy accumulation fixed-precision bits.
Definition nml_precision.cpp:93
void setForceScalingBits(int bitval)
Set the fixed-precision force accumulation bits.
Definition nml_precision.cpp:146
double getBondConstraintTolerance() const
Get the SHAKE / RATTLE convergence tolerance.
Definition nml_precision.cpp:103
int getForceScalingBits() const
Get the force accumulation fixed-precision bits.
Definition nml_precision.cpp:88
void setNonbondedMethod(PrecisionModel pmodel)
Set the precision model to use in non-bonded short-ranged pair computations.
Definition nml_precision.cpp:175
const NamelistEmulator & getTranscript() const
Get the original namelist emulator object as a transcript of the user input.
Definition nml_precision.cpp:123
PrecisionModel getParticleMeshEwaldMethod() const
Get the precision level for Particle-Mesh Ewald computations.
Definition nml_precision.cpp:118
PrecisionModel getValenceMethod() const
Get the precision level for valence computations.
Definition nml_precision.cpp:108
PrecisionControls(const PrecisionControls &original)=default
As with other control objects, copy and move constructors, plus copy and move assignment operators,...
PrecisionModel getNonbondedMethod() const
Get the precision level for short-ranged, non-bonded computations.
Definition nml_precision.cpp:113
void setChargeMeshScalingBits(int bitval)
Set the fixed-precision charge mesh accumulation bits.
Definition nml_precision.cpp:158
int getChargeMeshScalingBits() const
Get the PME charge accumulation fixed-precision bits.
Definition nml_precision.cpp:98
void setValenceMethod(PrecisionModel pmodel)
Set the precision model to use in valence term computations.
Definition nml_precision.cpp:170
void setEnergyScalingBits(int bitval)
Set the fixed-precision energy accumulation bits.
Definition nml_precision.cpp:152
int getGlobalPosScalingBits() const
Get the global position fixed-precision bits.
Definition nml_precision.cpp:73
void setParticleMeshEwaldMethod(PrecisionModel pmodel)
Set the precision model to use in Particle Mesh Ewald (charge density accumulation,...
Definition nml_precision.cpp:180
PrecisionControls(ExceptionResponse policy_in=ExceptionResponse::DIE, WrapTextSearch wrap=WrapTextSearch::NO)
The constructor can prepare an object with default settings or read the corresponding namelist to acc...
Definition nml_precision.cpp:24
void setGlobalPosScalingBits(int bitval)
Set the global position fixed-precision bits.
Definition nml_precision.cpp:128
void setVelocityScalingBits(int bitval)
Set the fixed-precision velocity scaling bits.
Definition nml_precision.cpp:140
int getLocalPosScalingBits() const
Get the local position fixed-precision bits.
Definition nml_precision.cpp:78
void setBondConstraintTolerance(double tol)
Set the bond constraint convergence tolerance.
Definition nml_precision.cpp:164
void setLocalPosScalingBits(int bitval)
Set the local position fixed-precision bits.
Definition nml_precision.cpp:134
int getVelocityScalingBits() const
Get the velocity fixed-precision bits.
Definition nml_precision.cpp:83
Structure for translating a text file into a compact, rapidly parsable vector of characters in CPU RA...
Definition textfile.h:45