Tinker9 70bd052 (Thu Nov 9 12:11:35 2023 -0800)
Loading...
Searching...
No Matches
integrator.h
1#pragma once
2#include "ff/precision.h"
3#include <cstdio>
4#include <string>
5#include <tinker/detail/bath.hh>
6
7namespace tinker {
10{
11protected:
12 static bool applyBaro;
13 static bool printPressure;
14 static bool atomic;
15 static bool aniso;
16 static bool semiiso;
17 static int nrespa;
18 static double dofP;
19
20 static int arrayLength;
21 static const int (*indexArray)[2];
22
23 static const int AnisoArray[6][2];
24 static constexpr int AnisoOrthoOrOct = 3;
25 static constexpr int AnisoMono = 4;
26 static constexpr int AnisoTri = 6;
27
28 static const int SemiArray[4][2];
29 static constexpr int SemiOrthoOrOct = 2;
30 static constexpr int SemiMono = 3;
31 static constexpr int SemiTri = 4;
32};
33
34//====================================================================//
35
38{
39 RESPA,
40 VERLET,
41 m_LOGV,
42};
43
47{
48protected:
49 BasicPropagator(int nrspa);
50
51public:
53
56 bool ifSave(int istep) const;
57
60 virtual void pos(time_prec t);
61
64 virtual void vel1(time_prec t);
67 virtual void vel2(time_prec t);
68
71 virtual void velR0(time_prec t) {}
75 virtual void velR1(time_prec t, int nrespa) {}
79 virtual void velR2(time_prec t, int nrespa) {}
80
81 void rattleSave();
82 void rattle(time_prec dt);
83 void rattle2(time_prec dt, bool useVirial);
84
85 static BasicPropagator* create(int nRespaLogV, PropagatorEnum pe);
86};
87
90{
91public:
94};
95
98{
99protected:
100 RespaDevice(int nrspa);
101
102public:
105
106 void velR0(time_prec t) override;
107 void velR1(time_prec t, int nrespa) override;
108 void velR2(time_prec t, int nrespa) override;
109};
110
113{
114protected:
115 void velImpl(time_prec t, int idx, int nrespa);
116
117public:
118 LogVDevice(int nrspa);
120
121 void pos(time_prec t) override;
122 void vel1(time_prec t) override;
123 void vel2(time_prec t) override;
124 void velR0(time_prec t) override;
125 void velR1(time_prec t, int nrespa) override;
126 void velR2(time_prec t, int nrespa) override;
127};
128}
129
130namespace tinker {
133{
134 NONE,
135 ANDERSEN, // empty
136 BERENDSEN, // empty
137 BUSSI,
138 NHC,
140 m_LP2022,
141 m_NHC1996,
142 m_NHC2006,
143};
144
147{
148protected:
149 void printBasic(FILE*);
150
151public:
154 virtual void printDetail(FILE*);
155 virtual void control1(time_prec timeStep);
156 virtual void control2(time_prec timeStep, bool calcEkin);
157
159};
160
163{
164public:
165 void printDetail(FILE*) override;
166 void control2(double timeStep, bool) override;
167};
168
171constexpr int maxnose = bath::maxnose;
172
184{
185protected:
186 static constexpr int nhc_nsy = 3;
188 double g0;
190 double* m_kin_ptr;
191 double (*f_kin)();
192 void (*scale_vel)(double);
193 std::string name;
194
195 void controlImpl(double timeStep, bool calcEkin);
196
197public:
198 NhcDevice(int nhclen, int nc, double dfree, double* kin_ptr, double (*kin)(), void (*scale)(double), std::string str);
199 void printDetail(FILE*) override;
201 void control2(time_prec time_prec, bool) override;
202
203 static double kineticAtomic();
204 static void scaleVelocityAtomic(double scale);
205};
206
209{
210protected:
213
214public:
217
218 void printDetail(FILE*) override;
219 void control1(time_prec dt) override;
220 void control2(time_prec dt, bool) override;
221
222 static double kineticRattleGroup();
223 static void scaleVelocityRattleGroup(double scale);
224
225 static double kineticVbar();
226 static void scaleVelocityVbar(double scale);
227
228 static double dofVbar();
229};
230}
231
232namespace tinker {
234enum class BarostatEnum
235{
236 NONE,
237 BERENDSEN,
238 BUSSI, // empty
239 LP2022,
241 NHC2006,
243 m_LOGVISO,
245 m_NHC1996,
246};
247
250{
251protected:
254 void printBasic(FILE*);
255
256public:
258 virtual ~BasicBarostat();
259 virtual void printDetail(FILE*);
261
262 virtual void control1(time_prec timeStep) {}
263 virtual void control2(time_prec timeStep) {}
264 virtual void control3(time_prec timeStep) {}
265 virtual void control4(time_prec timeStep) {}
266
267 virtual bool ifApply(int istep);
268 bool ifApply() const;
269 virtual void setPrintPressure(int istep);
270
272};
273
276{
277public:
280 void printDetail(FILE*) override;
282 void control4(time_prec) override;
283 bool ifApply(int istep) override;
284 void setPrintPressure(int) override;
285};
286
289{
290public:
291 void printDetail(FILE*) override;
293 void control2(time_prec timeStep) override;
294};
295
298{
299protected:
300 double* m_vir;
301 double* m_eksum;
302 double (*f_kin)();
303
304 double m_fric;
305 double m_rnd;
307
308 void control_1_2(time_prec dt, int idx);
309
310public:
311 IsoBaroDevice(double fric);
313 void printDetail(FILE*) override;
314 void control1(time_prec dt) override;
315 void control2(time_prec dt) override;
316 void control3(time_prec dt) override;
317};
318
321{
322protected:
323 double* m_vir;
324 double* m_eksum;
325 double (*m_ekin)[3];
326 void (*f_kin)();
327
328 double m_fric;
329 double m_rnd[3][3];
331
332 void control_1_2(time_prec dt, int idx);
333
334public:
335 AnisoBaroDevice(double fric);
337 void printDetail(FILE*) override;
338 void control1(time_prec dt) override;
339 void control2(time_prec dt) override;
340 void control3(time_prec dt) override;
341};
342
345{
346protected:
349
350public:
353 void printDetail(FILE*) override;
355 void control1(time_prec timeStep) override;
356 void control2(time_prec timeStep) override;
357 void control3(time_prec timeStep) override;
358};
359
362{
363protected:
366
367public:
370 void printDetail(FILE*) override;
372 void control1(time_prec timeStep) override;
373 void control2(time_prec timeStep) override;
374 void control3(time_prec timeStep) override;
375};
376}
377
378namespace tinker {
381{
382 BEEMAN,
383 RESPA,
384 VERLET,
386 LP2022,
387 NHC1996,
388 NHC2006, // J. Phys. A, 39 5629 (2006),
389 // https://doi.org/10.1088/0305-4470/39/19/S18
390};
391
394{
395protected:
399
400 int vers1;
401 bool save;
402
403 void plan(int istep);
404 virtual const char* name() const = 0;
405 virtual void kickoff() = 0;
406
407public:
408 void printDetail(FILE*);
412 virtual void dynamic(int istep, time_prec dt);
413};
414
417{
418protected:
419 const char* name() const override;
420 void kickoff() override;
421
422public:
424 static void KickOff();
425};
426
429{
430protected:
431 const char* name() const override;
432 void kickoff() override;
433
434public:
436 static void KickOff();
437};
438
441{
442protected:
443 const char* name() const override;
444 void kickoff() override;
445
446public:
448 void dynamic(int, time_prec) override;
449};
450
452{
453protected:
454 const char* name() const override;
455 void kickoff() override;
456
457public:
458 Nhc06Integrator(int nrspa);
459};
460
463{
464protected:
465 const char* name() const override;
466 void kickoff() override;
467
468public:
469 LP22Integrator(int nrspa);
470};
471
474{
475protected:
476 const char* name() const override;
477 void kickoff() override;
478
479public:
482 void dynamic(int, time_prec) override;
483};
484}
Definition: integrator.h:452
const char * name() const override
void kickoff() override
void dynamic(int, time_prec) override
static constexpr int SemiOrthoOrOct
Definition: integrator.h:29
static const int SemiArray[4][2]
Definition: integrator.h:28
void kickoff() override
void velR0(time_prec t) override
Velocity update for the inner RESPA time steps.
const char * name() const override
static const int(* indexArray)[2]
Definition: integrator.h:21
static bool atomic
Definition: integrator.h:14
static BasicPropagator * create(int nRespaLogV, PropagatorEnum pe)
static bool printPressure
Definition: integrator.h:13
RespaIntegrator(ThermostatEnum te, BarostatEnum be)
static constexpr int AnisoTri
Definition: integrator.h:26
virtual void vel2(time_prec t)
The second half-step velocity update.
virtual void pos(time_prec t)
Position update.
BasicThermostat * m_thermo
Definition: integrator.h:397
void vel1(time_prec t) override
The first half-step velocity update.
int vers1
Definition: integrator.h:400
virtual void velR1(time_prec t, int nrespa)
The first half-step velocity update for RESPA.
Definition: integrator.h:75
static constexpr int SemiMono
Definition: integrator.h:30
static const int AnisoArray[6][2]
Definition: integrator.h:23
const char * name() const override
void dynamic(int, time_prec) override
const char * name() const override
virtual void dynamic(int istep, time_prec dt)
const char * name() const override
bool save
Definition: integrator.h:401
static constexpr int AnisoOrthoOrOct
Definition: integrator.h:24
void vel2(time_prec t) override
The second half-step velocity update.
static int arrayLength
Definition: integrator.h:20
void velR0(time_prec t) override
Velocity update for the inner RESPA time steps.
LogVDevice(int nrspa)
static constexpr int AnisoMono
Definition: integrator.h:25
static bool semiiso
Definition: integrator.h:16
void velR1(time_prec t, int nrespa) override
The first half-step velocity update for RESPA.
void plan(int istep)
virtual void kickoff()=0
void pos(time_prec t) override
Position update.
static bool aniso
Definition: integrator.h:15
void kickoff() override
void kickoff() override
virtual void vel1(time_prec t)
The first half-step velocity update.
void printDetail(FILE *)
virtual void velR2(time_prec t, int nrespa)
The second half-step velocity update for RESPA.
Definition: integrator.h:79
RespaDevice(int nrspa)
void velR2(time_prec t, int nrespa) override
The second half-step velocity update for RESPA.
void rattle(time_prec dt)
void rattle2(time_prec dt, bool useVirial)
BasicPropagator * m_prop
Definition: integrator.h:396
BasicBarostat * m_baro
Definition: integrator.h:398
void velR1(time_prec t, int nrespa) override
The first half-step velocity update for RESPA.
void velImpl(time_prec t, int idx, int nrespa)
BasicIntegrator(int nRespaLogV, PropagatorEnum pe, ThermostatEnum te, BarostatEnum be)
bool ifSave(int istep) const
Logical flag governing saving an MD step.
const char * name() const override
void velR2(time_prec t, int nrespa) override
The second half-step velocity update for RESPA.
static double dofP
Definition: integrator.h:18
virtual const char * name() const =0
void kickoff() override
virtual void velR0(time_prec t)
Velocity update for the inner RESPA time steps.
Definition: integrator.h:71
static bool applyBaro
Definition: integrator.h:12
static int nrespa
Definition: integrator.h:17
VerletIntegrator(ThermostatEnum te, BarostatEnum be)
static constexpr int SemiTri
Definition: integrator.h:31
Definition: integrator.h:394
The interface class of a Verlet or an RESPA-Verlet MD step.
Definition: integrator.h:47
Definition: integrator.h:10
Definition: integrator.h:463
Definition: integrator.h:474
Definition: integrator.h:113
Definition: integrator.h:441
Definition: integrator.h:98
Definition: integrator.h:429
Definition: integrator.h:90
Definition: integrator.h:417
IntegratorEnum
Definition: integrator.h:381
PropagatorEnum
Definition: integrator.h:38
void controlImpl(double timeStep, bool calcEkin)
void(* f_kin)()
Definition: integrator.h:326
double m_fric
Definition: integrator.h:304
void control4(time_prec) override
NhcDevice * m_tpart
Definition: integrator.h:211
void printDetail(FILE *) override
void control3(time_prec dt) override
void control2(time_prec timeStep) override
static void scaleVelocityAtomic(double scale)
void printDetail(FILE *) override
void printDetail(FILE *) override
double(* m_ekin)[3]
Definition: integrator.h:325
double g0
Definition: integrator.h:188
virtual void control2(time_prec timeStep)
Definition: integrator.h:263
double m_rnd
Definition: integrator.h:305
BarostatEnum getBarostatEnum() const override
AnisoBaroDevice(double fric)
int m_nbaro
Definition: integrator.h:252
void printDetail(FILE *) override
virtual void control1(time_prec timeStep)
bool ifApply(int istep) override
static BasicThermostat * create(ThermostatEnum)
void control2(time_prec time_prec, bool) override
Nhc06Thermostat * m_thermo
Definition: integrator.h:347
BarostatEnum getBarostatEnum() const override
Nhc06Thermostat * m_thermo
Definition: integrator.h:364
void control2(time_prec dt) override
double(* f_kin)()
Definition: integrator.h:302
void control2(double timeStep, bool) override
static constexpr int nhc_nsy
Definition: integrator.h:186
virtual void control1(time_prec timeStep)
Definition: integrator.h:262
void control1(time_prec time_prec) override
virtual BarostatEnum getBarostatEnum() const
IsoBaroDevice(double fric)
double vnh[maxnose]
Definition: integrator.h:189
void control2(time_prec dt) override
void control1(time_prec dt) override
void control1(time_prec timeStep) override
bool m_langevin
Definition: integrator.h:330
void control1(time_prec dt) override
void(* scale_vel)(double)
Definition: integrator.h:192
bool m_langevin
Definition: integrator.h:306
double(* f_kin)()
Definition: integrator.h:191
BarostatEnum getBarostatEnum() const override
static double kineticRattleGroup()
bool ifApply() const
virtual void printDetail(FILE *)
NhcDevice * m_tbaro
Definition: integrator.h:212
virtual void control2(time_prec timeStep, bool calcEkin)
double m_rnd[3][3]
Definition: integrator.h:329
NhcDevice(int nhclen, int nc, double dfree, double *kin_ptr, double(*kin)(), void(*scale)(double), std::string str)
void setPrintPressure(int) override
void printBasic(FILE *)
virtual void control3(time_prec timeStep)
Definition: integrator.h:264
int nnose
Definition: integrator.h:187
void control3(time_prec timeStep) override
BarostatEnum getBarostatEnum() const override
void control_1_2(time_prec dt, int idx)
static BasicBarostat * create(BarostatEnum)
virtual void printDetail(FILE *)
void printDetail(FILE *) override
double qnh[maxnose]
Definition: integrator.h:189
void control1(time_prec timeStep) override
void control2(time_prec dt, bool) override
BasicBarostat * m_baro
Definition: integrator.h:365
static void scaleVelocityVbar(double scale)
double * m_eksum
Definition: integrator.h:324
double * m_eksum
Definition: integrator.h:301
void control_1_2(time_prec dt, int idx)
virtual void setPrintPressure(int istep)
virtual void control4(time_prec timeStep)
Definition: integrator.h:265
void control3(time_prec timeStep) override
IsoBaroDevice * m_baro
Definition: integrator.h:348
void printDetail(FILE *) override
int nhc_nc
Definition: integrator.h:187
void control1(time_prec dt) override
static double kineticVbar()
virtual bool ifApply(int istep)
int m_iprint
Definition: integrator.h:253
double * m_vir
Definition: integrator.h:300
static double kineticAtomic()
void control3(time_prec dt) override
void control2(time_prec timeStep) override
void control2(time_prec timeStep) override
void printDetail(FILE *) override
static void scaleVelocityRattleGroup(double scale)
static double dofVbar()
double * m_kin_ptr
Definition: integrator.h:190
BarostatEnum getBarostatEnum() const override
double * m_vir
Definition: integrator.h:323
void printDetail(FILE *) override
double m_fric
Definition: integrator.h:328
std::string name
Definition: integrator.h:193
void printDetail(FILE *) override
BarostatEnum getBarostatEnum() const override
Definition: integrator.h:321
Definition: integrator.h:250
Definition: integrator.h:147
Definition: integrator.h:289
Definition: integrator.h:163
Definition: integrator.h:298
Definition: integrator.h:362
Definition: integrator.h:276
Definition: integrator.h:345
Definition: integrator.h:209
Applies a velocity correction as needed for the Nose-Hoover Chains at the half time step.
Definition: integrator.h:184
BarostatEnum
Definition: integrator.h:235
constexpr int maxnose
Maximum length of the NH chain.
Definition: integrator.h:171
ThermostatEnum
Definition: integrator.h:133
@ VERLET
Verlet neighbor list.
mixed time_prec
Floating-point type for time.
Definition: precision.h:90
Definition: testrt.h:9