1 |
|
#ifndef _INTEGRATOR_H_ |
2 |
|
#define _INTEGRATOR_H_ |
3 |
|
|
4 |
+ |
#include <string> |
5 |
+ |
#include <vector> |
6 |
|
#include "Atom.hpp" |
7 |
|
#include "Molecule.hpp" |
8 |
|
#include "SRI.hpp" |
11 |
|
#include "ForceFields.hpp" |
12 |
|
#include "Thermo.hpp" |
13 |
|
#include "ReadWrite.hpp" |
14 |
+ |
#include "ZConsWriter.hpp" |
15 |
|
|
16 |
+ |
using namespace std; |
17 |
|
const double kB = 8.31451e-7;// boltzmann constant amu*Ang^2*fs^-2/K |
18 |
|
const double eConvert = 4.184e-4; // converts kcal/mol -> amu*A^2/fs^2 |
19 |
|
const double p_convert = 1.63882576e8; //converts amu*fs^-2*Ang^-1 -> atm |
20 |
|
const int maxIteration = 300; |
21 |
|
const double tol = 1.0e-6; |
22 |
|
|
19 |
– |
class Integrator : public BaseIntegrator { |
23 |
|
|
24 |
+ |
template<typename T = BaseIntegrator> class Integrator : public T { |
25 |
+ |
|
26 |
|
public: |
27 |
|
Integrator( SimInfo *theInfo, ForceFields* the_ff ); |
28 |
|
virtual ~Integrator(); |
75 |
|
|
76 |
|
}; |
77 |
|
|
78 |
< |
class NVE : public Integrator{ |
78 |
> |
typedef Integrator<BaseIntegrator> RealIntegrator; |
79 |
|
|
80 |
+ |
template<typename T> class NVE : public T { |
81 |
+ |
|
82 |
|
public: |
83 |
|
NVE ( SimInfo *theInfo, ForceFields* the_ff ): |
84 |
< |
Integrator( theInfo, the_ff ){} |
85 |
< |
virtual ~NVE(){} |
79 |
< |
|
80 |
< |
|
81 |
< |
|
84 |
> |
T( theInfo, the_ff ){} |
85 |
> |
virtual ~NVE(){} |
86 |
|
}; |
87 |
|
|
84 |
– |
class NVT : public Integrator{ |
88 |
|
|
89 |
+ |
template<typename T> class NVT : public T { |
90 |
+ |
|
91 |
|
public: |
92 |
|
|
93 |
|
NVT ( SimInfo *theInfo, ForceFields* the_ff); |
117 |
|
}; |
118 |
|
|
119 |
|
|
120 |
< |
class NPTi : public Integrator{ |
120 |
> |
|
121 |
> |
template<typename T> class NPTi : public T{ |
122 |
|
|
123 |
|
public: |
124 |
|
|
127 |
|
|
128 |
|
virtual void integrateStep( int calcPot, int calcStress ){ |
129 |
|
calcStress = 1; |
130 |
< |
Integrator::integrateStep( calcPot, calcStress ); |
130 |
> |
T::integrateStep( calcPot, calcStress ); |
131 |
|
} |
132 |
|
|
133 |
|
void setTauThermostat(double tt) {tauThermostat = tt; have_tau_thermostat=1;} |
161 |
|
|
162 |
|
}; |
163 |
|
|
164 |
< |
class NPTim : public Integrator{ |
164 |
> |
template<typename T> class NPTim : public T{ |
165 |
|
|
166 |
|
public: |
167 |
|
|
170 |
|
|
171 |
|
virtual void integrateStep( int calcPot, int calcStress ){ |
172 |
|
calcStress = 1; |
173 |
< |
Integrator::integrateStep( calcPot, calcStress ); |
173 |
> |
T::integrateStep( calcPot, calcStress ); |
174 |
|
} |
175 |
|
|
176 |
|
void setTauThermostat(double tt) {tauThermostat = tt; have_tau_thermostat=1;} |
207 |
|
|
208 |
|
}; |
209 |
|
|
210 |
< |
class NPTf : public Integrator{ |
210 |
> |
template<typename T> class NPTf : public T{ |
211 |
|
|
212 |
|
public: |
213 |
|
|
216 |
|
|
217 |
|
virtual void integrateStep( int calcPot, int calcStress ){ |
218 |
|
calcStress = 1; |
219 |
< |
Integrator::integrateStep( calcPot, calcStress ); |
219 |
> |
T::integrateStep( calcPot, calcStress ); |
220 |
|
} |
221 |
|
|
222 |
|
void setTauThermostat(double tt) {tauThermostat = tt; have_tau_thermostat=1;} |
250 |
|
|
251 |
|
}; |
252 |
|
|
253 |
< |
class NPTfm : public Integrator{ |
253 |
> |
template<typename T> class NPTfm : public T{ |
254 |
|
|
255 |
|
public: |
256 |
|
|
259 |
|
|
260 |
|
virtual void integrateStep( int calcPot, int calcStress ){ |
261 |
|
calcStress = 1; |
262 |
< |
Integrator::integrateStep( calcPot, calcStress ); |
262 |
> |
T::integrateStep( calcPot, calcStress ); |
263 |
|
} |
264 |
|
|
265 |
|
void setTauThermostat(double tt) {tauThermostat = tt; have_tau_thermostat=1;} |
274 |
|
|
275 |
|
virtual int readyCheck(); |
276 |
|
|
277 |
+ |
Molecule* myMolecules; |
278 |
+ |
Atom** myAtoms; |
279 |
+ |
|
280 |
|
// chi and eta are the propagated degrees of freedom |
281 |
|
|
282 |
|
double chi; |
293 |
|
|
294 |
|
short int have_tau_thermostat, have_tau_barostat, have_target_temp; |
295 |
|
short int have_target_pressure; |
296 |
+ |
|
297 |
+ |
}; |
298 |
+ |
|
299 |
+ |
template<typename T> class ZConstraint : public T { |
300 |
+ |
|
301 |
+ |
public: |
302 |
|
|
303 |
+ |
ZConstraint( SimInfo *theInfo, ForceFields* the_ff); |
304 |
+ |
~ZConstraint(); |
305 |
+ |
|
306 |
+ |
virtual void integrateStep( int calcPot, int calcStress ); |
307 |
+ |
|
308 |
+ |
|
309 |
+ |
void setZConsTime(double time) {this->zconsTime = time;} |
310 |
+ |
void getZConsTime() {return zconsTime;} |
311 |
+ |
|
312 |
+ |
void setIndexOfAllZConsMols(vector<int> index) {indexOfAllZConsMols = index;} |
313 |
+ |
void getIndexOfAllZConsMols() {return indexOfAllZConsMols;} |
314 |
+ |
|
315 |
+ |
void setZConsOutput(const char * fileName) {zconsOutput = fileName;} |
316 |
+ |
string getZConsOutput() {return zconsOutput;} |
317 |
+ |
|
318 |
+ |
#ifdef IS_MPI |
319 |
+ |
virtual void update(); //which is called to indicate the molecules' migration |
320 |
+ |
#endif |
321 |
+ |
|
322 |
+ |
protected: |
323 |
+ |
|
324 |
+ |
double zconsTime; |
325 |
+ |
|
326 |
+ |
void resetZ(void); |
327 |
+ |
|
328 |
+ |
vector<Molecule*> zconsMols; |
329 |
+ |
vector<double> massOfZConsMols; |
330 |
+ |
|
331 |
+ |
vector<Molecule*> unconsMols; |
332 |
+ |
vector<double> massOfUnconsMols; |
333 |
+ |
double totalMassOfUncons; |
334 |
+ |
|
335 |
+ |
vector<double> allRefZ; |
336 |
+ |
vector<double> refZ; |
337 |
+ |
|
338 |
+ |
vector<int> indexOfAllZConsMols; //index of All Z-Constraint Molecuels |
339 |
+ |
int* indexOfZConsMols; //index of local Z-Constraint Molecules |
340 |
+ |
|
341 |
+ |
double* fz; |
342 |
+ |
|
343 |
+ |
private: |
344 |
+ |
|
345 |
+ |
int isZConstraintMol(Molecule* mol); |
346 |
+ |
string zconsOutput; |
347 |
+ |
ZConsWriter* fzOut; |
348 |
|
}; |
349 |
|
|
350 |
|
#endif |