Go to the documentation of this file.
7 #ifndef CONTROLLER_H
8 #define CONTROLLER_H
10 #include "converse.h"
11 #include "Node.h"
12 #include "common.h"
13 #include "fstream_namd.h"
14 #include <string>
15 #include <map>
18 class NamdState;
19 class SimParameters;
20 class RequireReduction;
21 class SubmitReduction;
24 class CollectionMasterHandler;
25 #else
26 class CollectionMaster;
27 #endif
29 class Random;
37 };
39 class Controller : protected ControllerState
40 {
41 public:
43  virtual ~Controller(void);
44  void run(void); // spawn thread, etc.
45  void awaken(void) { CthAwaken(thread); };
46  void resumeAfterTraceBarrier(int);
48  void resumeAfterPapiMeasureBarrier(int step);
49 #endif
50  BigReal accelMDdV; // this is used for on-the-fly reweighting in colvars
52 protected:
53  friend class ScriptTcl;
54  friend class Node;
55  friend class CheckpointMsg;
56  virtual void algorithm(void); // subclasses redefine this method
58  void integrate(int); // Verlet integrator
59  void minimize(); // CG minimizer
62  void receivePressure(int step, int minimize = 0);
63  void calcPressure(int step, int minimize,
64  const Tensor& virial_normal_in, const Tensor& virial_nbond_in, const Tensor& virial_slow_in,
65  const Tensor& intVirial_normal, const Tensor& intVirial_nbond, const Tensor& intVirial_slow,
66  const Vector& extForce_normal, const Vector& extForce_nbond, const Vector& extForce_slow);
79  int nbondFreq;
80  int slowFreq;
84  int avg_count;
88  void compareChecksums(int,int=0);
92  void printTiming(int);
93  void printMinimizeEnergies(int);
99  void printDynamicsEnergies(int);
100  void printEnergies(int step, int minimize);
101  int64_t numDegFreedom;
112 //fepb
117  BigReal ljEnergy_f_left; // used by WCA repulsive, [s1,s2]
122  int FepNo;
123  void printFepMessage(int);
125 //fepe
143  int TiNo;
153  void printTiMessage(int);
155  BigReal drudeBondTemp; // temperature of Drude bonds
165  // BigReal smooth2_avg;
166  BigReal smooth2_avg2; // avoid internal compiler error
171  void enqueueCollections(int);
172  void correctMomentum(int step);
173  void rescaleVelocities(int);
176  void reassignVelocities(int);
177  void tcoupleVelocities(int);
184  void stochRescaleVelocities(int);
190  double stochRescaleCoefficient();
199  void berendsenPressure(int);
200  // Tensor berendsenPressure_avg;
201  // int berendsenPressure_count;
202  void langevinPiston1(int);
203  void langevinPiston2(int);
205  Tensor strainRate_old; // for langevinPistonBarrier no
206  Tensor positionRescaleFactor; // for langevinPistonBarrier no
208  void multigratorPressure(int step, int callNumber);
212  void multigratorTemperature(int step, int callNumber);
213  std::vector<BigReal> multigratorNu;
214  std::vector<BigReal> multigratorNuT;
215  std::vector<BigReal> multigratorOmega;
216  std::vector<BigReal> multigratorZeta;
218  BigReal multigatorCalcEnthalpy(BigReal potentialEnergy, int step, int minimize);
220  int ldbSteps;
221  void rebalanceLoad(int);
223  void cycleBarrier(int,int);
225  void traceBarrier(int, int);
228  void papiMeasureBarrier(int, int);
229 #endif
231  // void suspend(void) { CthSuspend(); };
232  void terminate(void);
235  SimParameters *const simParams; // for convenience
236  NamdState *const state; // access data in state
241  // data for pressure profile reductions and output
253  void outputExtendedSystem(int step);
255  void writeExtendedSystemData(int step, ofstream_namd &file);
257 //fepb
259  void outputFepEnergy(int step);
260  void writeFepEnergyData(int step, ofstream_namd &file);
261 //fepe
263  void outputTiEnergy(int step);
264  BigReal computeAlchWork(const int step);
265  void writeTiEnergyData(int step, ofstream_namd &file);
267  // for checkpoint/revert
272  struct checkpoint {
275  };
276  std::map<std::string,checkpoint*> checkpoints;
278  void recvCheckpointReq(const char *key, int task, checkpoint &cp);
279  void recvCheckpointAck(checkpoint &cp);
283 //for accelMD
284  inline void calc_accelMDG_mean_std
285  (BigReal testV, int step_n,
286  BigReal *Vmax, BigReal *Vmin, BigReal *Vavg, BigReal *M2, BigReal *sigmaV);
288  inline void calc_accelMDG_E_k
289  (int iE, int V_n, BigReal sigma0, BigReal Vmax, BigReal Vmin, BigReal Vavg, BigReal sigmaV,
290  BigReal* k0, BigReal* k, BigReal* E, int* iEused, char *warn);
292  inline void calc_accelMDG_force_factor
293  (BigReal k, BigReal E, BigReal testV, Tensor vir_orig,
294  BigReal *dV, BigReal *factor, Tensor *vir);
297  (int step_n, char type, int V_n, BigReal Vmax, BigReal Vmin, BigReal Vavg, BigReal sigmaV, BigReal M2,
298  BigReal E, BigReal k, bool write_topic, bool lasttime);
300  void rescaleaccelMD (int step, int minimize = 0);
303 //JS for adaptive temperature sampling
304  void adaptTempInit(int step);
305  void adaptTempUpdate(int step, int minimize = 0);
306  void adaptTempWriteRestart(int step);
329 private:
330  CthThread thread;
331  static void threadRun(Controller*);
333  double startCTime;
334  double startWTime;
335  double firstCTime;
336  double firstWTime;
337  double startBenchTime;
339  int computesPartitioned;
340 };
342 //Modifications for alchemical fep
343 static char *FEPTITLE(int X)
344 {
345  static char tmp_string[21];
346  sprintf(tmp_string, "FepEnergy: %6d ",X);
347  return tmp_string;
348 }
350 static char *FEPTITLE_BACK(int X)
351 {
352  static char tmp_string[21];
353  sprintf(tmp_string, "FepE_back: %6d ",X);
354  return tmp_string;
355 }
357 static char *FEPTITLE2(int X)
358 {
359  static char tmp_string[21];
360  sprintf(tmp_string, "FEP: %7d",X);
361  return tmp_string;
362 }
364 static char *TITITLE(int X)
365 {
366  static char tmp_string[21];
367  sprintf(tmp_string, "TI: %7d",X);
368  return tmp_string;
369 }
370 //fepe
372 #endif // CONTROLLER_H
ofstream_namd tiFile
Definition: Controller.h:262
BigReal adaptTempBetaMin
Definition: Controller.h:317
int checkpoint_stored
Definition: Controller.h:268
void enqueueCollections(int)
Definition: Controller.C:3664
BigReal net_dE
Definition: Controller.h:120
Tensor controlPressure_slow
Definition: Controller.h:78
BigReal * adaptTempBetaN
Definition: Controller.h:313
int adaptTempBins
Definition: Controller.h:320
int pressureProfileSlabs
Definition: Controller.h:245
BigReal electEnergy_ti_1
Definition: Controller.h:128
void recvCheckpointReq(const char *key, int task, checkpoint &cp)
Definition: Controller.C:4087
void cycleBarrier(int, int)
Definition: Controller.C:4140
BigReal net_dEdl_lj_2
Definition: Controller.h:139
void rescaleVelocities(int)
Definition: Controller.C:1233
BigReal smooth2_avg
Definition: Controller.h:36
void rescaleaccelMD(int step, int minimize=0)
Definition: Controller.C:1839
BigReal dG
Definition: Controller.h:121
int nbondFreq
Definition: Controller.h:79
BigReal min_v_dot_v
Definition: Controller.h:97
void write_accelMDG_rest_file(int step_n, char type, int V_n, BigReal Vmax, BigReal Vmin, BigReal Vavg, BigReal sigmaV, BigReal M2, BigReal E, BigReal k, bool write_topic, bool lasttime)
Definition: Controller.C:1781
ControllerState state
Definition: Controller.h:274
void compareChecksums(int, int=0)
Definition: Controller.C:2775
Tensor groupPressure_nbond
Definition: Controller.h:74
BigReal goNativeEnergy
Definition: Controller.h:109
std::map< std::string, checkpoint * > checkpoints
Definition: Controller.h:276
void calcPressure(int step, int minimize, const Tensor &virial_normal_in, const Tensor &virial_nbond_in, const Tensor &virial_slow_in, const Tensor &intVirial_normal, const Tensor &intVirial_nbond, const Tensor &intVirial_slow, const Vector &extForce_normal, const Vector &extForce_nbond, const Vector &extForce_slow)
Definition: Controller.C:1598
BigReal fepSum
Definition: Controller.h:124
BigReal net_dEdl_lj_1
Definition: Controller.h:138
Definition: Node.h:78
void printTiMessage(int)
Definition: Controller.C:1294
BigReal temp_avg
Definition: Controller.h:81
int fflush_count
Definition: Controller.h:222
BigReal ljEnergy_f_left
Definition: Controller.h:117
BigReal adaptTempT
Definition: Controller.h:314
void adaptTempWriteRestart(int step)
Definition: Controller.C:2451
virtual void algorithm(void)
Definition: Controller.C:281
BigReal adaptTempDt
Definition: Controller.h:323
BigReal ljEnergy
Definition: Controller.h:106
void calc_accelMDG_mean_std(BigReal testV, int step_n, BigReal *Vmax, BigReal *Vmin, BigReal *Vavg, BigReal *M2, BigReal *sigmaV)
Definition: Controller.C:1716
Tensor controlPressure
Definition: Controller.h:170
void adaptTempInit(int step)
Definition: Controller.C:2351
void minimize()
Definition: Controller.C:594
BigReal totalEnergy0
Definition: Controller.h:164
Definition: Vector.h:64
void printMinimizeEnergies(int)
Definition: Controller.C:3004
void integrate(int)
Definition: Controller.C:429
int min_huge_count
Definition: Controller.h:98
double stochRescaleCoefficient()
Definition: Controller.C:1364
BigReal net_dEdl_bond_2
Definition: Controller.h:135
void writeExtendedSystemLabels(ofstream_namd &file)
Definition: Controller.C:3630
BigReal pressure_avg
Definition: Controller.h:82
std::vector< BigReal > multigratorOmega
Definition: Controller.h:215
BigReal electEnergySlow_f
Definition: Controller.h:115
#define X
Definition: msm_defn.h:29
std::vector< BigReal > multigratorNuT
Definition: Controller.h:214
BigReal recent_alchWork
Definition: Controller.h:150
Tensor groupPressure_tavg
Definition: Controller.h:86
BigReal * adaptTempPotEnergyAveNum
Definition: Controller.h:307
Tensor pressure_amd
Definition: Controller.h:71
int stochRescale_count
Definition: Controller.h:192
BigReal adaptTempDBeta
Definition: Controller.h:321
BigReal recent_dEdl_bond_2
Definition: Controller.h:145
BigReal electEnergySlow
Definition: Controller.h:105
RequireReduction * amd_reduction
Definition: Controller.h:238
void multigratorTemperature(int step, int callNumber)
Definition: Controller.C:853
BigReal min_energy
Definition: Controller.h:94
BigReal heat
Definition: Controller.h:162
Tensor pressure_slow
Definition: Controller.h:70
void langevinPiston1(int)
Definition: Controller.C:987
BigReal alchWork
Definition: Controller.h:151
void outputTiEnergy(int step)
Definition: Controller.C:3750
static char * FEPTITLE2(int X)
Definition: Controller.h:357
BigReal electEnergy_f
Definition: Controller.h:114
ofstream_namd xstFile
Definition: Controller.h:252
Tensor langevinPiston_strainRate
Definition: Controller.h:33
BigReal temperature
Definition: Controller.h:161
int pressureProfileCount
Definition: Controller.h:246
std::vector< BigReal > multigratorNu
Definition: Controller.h:213
NamdState *const state
Definition: Controller.h:236
BigReal adaptTempDTavenum
Definition: Controller.h:316
BigReal adaptTempDTave
Definition: Controller.h:315
Lattice checkpoint_lattice
Definition: Controller.h:269
PressureProfileReduction * ppint
Definition: Controller.h:244
ofstream_namd adaptTempRestartFile
Definition: Controller.h:327
int adaptTempBin
Definition: Controller.h:319
BigReal ljEnergy_ti_1
Definition: Controller.h:130
BigReal adaptTempDtMin
Definition: Controller.h:325
ControllerState checkpoint_state
Definition: Controller.h:270
Tensor pressure
Definition: Controller.h:167
Controller(NamdState *s)
Definition: Controller.C:128
Definition: Random.h:37
void writeExtendedSystemData(int step, ofstream_namd &file)
Definition: Controller.C:3643
ControllerBroadcasts * broadcast
Definition: Controller.h:251
BigReal computeAlchWork(const int step)
Definition: Controller.C:3879
Tensor groupPressure_slow
Definition: Controller.h:75
BigReal * adaptTempPotEnergyVar
Definition: Controller.h:311
BigReal groupPressure_avg
Definition: Controller.h:83
BigReal drudeBondTempAvg
Definition: Controller.h:156
int64_t numDegFreedom
Definition: Controller.h:101
std::vector< BigReal > multigratorZeta
Definition: Controller.h:216
void stochRescaleVelocities(int)
Definition: Controller.C:1348
BigReal recent_dEdl_elec_2
Definition: Controller.h:147
BigReal drudeBondTemp
Definition: Controller.h:155
BigReal bondedEnergyDiff_f
Definition: Controller.h:113
void correctMomentum(int step)
Definition: Controller.C:1255
BigReal recent_dEdl_elec_1
Definition: Controller.h:146
void berendsenPressure(int)
Definition: Controller.C:950
BigReal adaptTempDtMax
Definition: Controller.h:326
int recent_TiNo
Definition: Controller.h:152
void awaken(void)
Definition: Controller.h:45
void langevinPiston2(int)
Definition: Controller.C:1142
BigReal kineticEnergyCentered
Definition: Controller.h:160
void printTiming(int)
Definition: Controller.C:2967
int Bool
Definition: common.h:133
int computeChecksum
Definition: Controller.h:89
BigReal accelMDdV
Definition: Controller.h:50
BigReal electEnergySlow_ti_1
Definition: Controller.h:129
int marginViolations
Definition: Controller.h:90
SubmitReduction * submit_reduction
Definition: Controller.h:239
BigReal groLJEnergy
Definition: Controller.h:107
void recvCheckpointAck(checkpoint &cp)
Definition: Controller.C:4117
BigReal rescaleVelocities_sumTemps
Definition: Controller.h:174
BigReal goTotalEnergy
Definition: Controller.h:111
int berendsenPressure_count
Definition: Controller.h:35
RequireReduction * multigratorReduction
Definition: Controller.h:217
BigReal electEnergyPME_ti_1
Definition: Controller.h:141
Bool adaptTempAutoDt
Definition: Controller.h:324
void receivePressure(int step, int minimize=0)
Definition: Controller.C:1420
BigReal dE
Definition: Controller.h:119
BigReal groGaussEnergy
Definition: Controller.h:108
Tensor groupPressure_normal
Definition: Controller.h:73
BigReal exp_dE_ByRT
Definition: Controller.h:118
void run(void)
Definition: Controller.C:268
Tensor virial_amd
Definition: Controller.h:72
BigReal min_f_dot_f
Definition: Controller.h:95
void terminate(void)
Definition: Controller.C:4178
int ldbSteps
Definition: Controller.h:220
void reassignVelocities(int)
Definition: Controller.C:1308
int checkpoint_task
Definition: Controller.h:277
Random * random
Definition: Controller.h:234
void printEnergies(int step, int minimize)
Definition: Controller.C:3035
BigReal accelMDdVAverage
Definition: Controller.h:301
virtual ~Controller(void)
Definition: Controller.C:248
BigReal multigatorCalcEnthalpy(BigReal potentialEnergy, int step, int minimize)
Definition: Controller.C:919
static char * FEPTITLE(int X)
Definition: Controller.h:343
BigReal smooth2_avg2
Definition: Controller.h:166
BigReal electEnergy_ti_2
Definition: Controller.h:131
BigReal net_dEdl_elec_1
Definition: Controller.h:136
void outputFepEnergy(int step)
Definition: Controller.C:3676
int pairlistWarnings
Definition: Controller.h:91
CollectionMaster *const collection
Definition: Controller.h:249
BigReal * adaptTempPotEnergyAveDen
Definition: Controller.h:308
BigReal * pressureProfileAverage
Definition: Controller.h:247
RequireReduction * min_reduction
Definition: Controller.h:60
BigReal recent_dEdl_lj_1
Definition: Controller.h:148
void printFepMessage(int)
Definition: Controller.C:1274
BigReal stochRescaleTimefactor
Definition: Controller.h:195
BigReal * adaptTempPotEnergyVarNum
Definition: Controller.h:309
void calc_accelMDG_force_factor(BigReal k, BigReal E, BigReal testV, Tensor vir_orig, BigReal *dV, BigReal *factor, Tensor *vir)
Definition: Controller.C:1765
BigReal electEnergyPME_ti_2
Definition: Controller.h:142
BigReal cumAlchWork
Definition: Controller.h:140
Definition: Tensor.h:15
BigReal adaptTempCg
Definition: Controller.h:322
Tensor pressure_normal
Definition: Controller.h:68
Tensor strainRate_old
Definition: Controller.h:205
Tensor pressure_tavg
Definition: Controller.h:85
int rescaleVelocities_numTemps
Definition: Controller.h:175
BigReal electEnergy
Definition: Controller.h:104
void calc_accelMDG_E_k(int iE, int V_n, BigReal sigma0, BigReal Vmax, BigReal Vmin, BigReal Vavg, BigReal sigmaV, BigReal *k0, BigReal *k, BigReal *E, int *iEused, char *warn)
Definition: Controller.C:1736
Tensor groupPressure
Definition: Controller.h:168
BigReal ljEnergy_f
Definition: Controller.h:116
int slowFreq
Definition: Controller.h:80
void traceBarrier(int, int)
Definition: Controller.C:4150
int * adaptTempPotEnergySamples
Definition: Controller.h:312
PressureProfileReduction * ppnonbonded
Definition: Controller.h:243
void printDynamicsEnergies(int)
Definition: Controller.C:3023
void multigratorPressure(int step, int callNumber)
Definition: Controller.C:778
BigReal totalEnergy
Definition: Controller.h:103
BigReal kineticEnergyHalfstep
Definition: Controller.h:159
BigReal electEnergySlow_ti_2
Definition: Controller.h:132
void tcoupleVelocities(int)
Definition: Controller.C:1326
BigReal adaptTempBetaMax
Definition: Controller.h:318
SimParameters *const simParams
Definition: Controller.h:235
Tensor controlPressure_normal
Definition: Controller.h:76
BigReal net_dEdl_elec_2
Definition: Controller.h:137
static char * TITITLE(int X)
Definition: Controller.h:364
void resumeAfterTraceBarrier(int)
Definition: Controller.C:4157
BigReal recent_dEdl_lj_2
Definition: Controller.h:149
BigReal bondedEnergy_ti_2
Definition: Controller.h:127
int tavg_count
Definition: Controller.h:87
RequireReduction * reduction
Definition: Controller.h:237
PressureProfileReduction * ppbonded
Definition: Controller.h:242
BigReal * adaptTempPotEnergyAve
Definition: Controller.h:310
void writeTiEnergyData(int step, ofstream_namd &file)
Definition: Controller.C:3944
Lattice origLattice
Definition: Controller.h:281
ofstream_namd fepFile
Definition: Controller.h:258
void rebalanceLoad(int)
Definition: Controller.C:4126
void writeFepEnergyData(int step, ofstream_namd &file)
Definition: Controller.C:3908
BigReal net_dEdl_bond_1
Definition: Controller.h:134
void outputExtendedSystem(int step)
Definition: Controller.C:3968
BigReal bondedEnergy_ti_1
Definition: Controller.h:126
Tensor positionRescaleFactor
Definition: Controller.h:206
Tensor langevinPiston_origStrainRate
Definition: Controller.h:204
BigReal goNonnativeEnergy
Definition: Controller.h:110
int controlNumDegFreedom
Definition: Controller.h:169
Tensor berendsenPressure_avg
Definition: Controller.h:34
int stepInFullRun
Definition: Controller.h:102
int avg_count
Definition: Controller.h:84
static char * FEPTITLE_BACK(int X)
Definition: Controller.h:350
BigReal multigratorXiT
Definition: Controller.h:210
Tensor pressure_nbond
Definition: Controller.h:69
BigReal multigratorXi
Definition: Controller.h:209
Tensor controlPressure_nbond
Definition: Controller.h:77
BigReal kineticEnergy
Definition: Controller.h:158
void adaptTempUpdate(int step, int minimize=0)
Definition: Controller.C:2477
Tensor momentumSqrSum
Definition: Controller.h:211
double BigReal
Definition: common.h:114
BigReal min_f_dot_v
Definition: Controller.h:96
BigReal ljEnergy_ti_2
Definition: Controller.h:133
BigReal recent_dEdl_bond_1
Definition: Controller.h:144