ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/branches/new-templateless/OOPSE/libmdtools/Integrator.hpp
Revision: 850
Committed: Mon Nov 3 22:07:17 2003 UTC (21 years, 9 months ago) by mmeineke
File size: 12639 byte(s)
Log Message:
begun work on removing templates and most of standard template library from OOPSE.

File Contents

# User Rev Content
1 mmeineke 377 #ifndef _INTEGRATOR_H_
2     #define _INTEGRATOR_H_
3    
4     #include "Atom.hpp"
5 gezelter 604 #include "Molecule.hpp"
6 mmeineke 377 #include "SRI.hpp"
7     #include "AbstractClasses.hpp"
8     #include "SimInfo.hpp"
9     #include "ForceFields.hpp"
10 mmeineke 540 #include "Thermo.hpp"
11     #include "ReadWrite.hpp"
12 mmeineke 849 // #include "ZConsWriter.hpp"
13 mmeineke 377
14 tim 658 using namespace std;
15 mmeineke 561 const double kB = 8.31451e-7;// boltzmann constant amu*Ang^2*fs^-2/K
16     const double eConvert = 4.184e-4; // converts kcal/mol -> amu*A^2/fs^2
17 mmeineke 586 const double p_convert = 1.63882576e8; //converts amu*fs^-2*Ang^-1 -> atm
18 mmeineke 561 const int maxIteration = 300;
19     const double tol = 1.0e-6;
20    
21 mmeineke 377
22 mmeineke 849 class Integrator : public BaseIntegrator{
23    
24 mmeineke 377 public:
25 mmeineke 561 Integrator( SimInfo *theInfo, ForceFields* the_ff );
26 mmeineke 548 virtual ~Integrator();
27 mmeineke 377 void integrate( void );
28 tim 763 virtual double getConservedQuantity(void);
29 tim 837 virtual string getAdditionalParameters(void);
30 mmeineke 377
31 mmeineke 540 protected:
32 mmeineke 778
33 mmeineke 540 virtual void integrateStep( int calcPot, int calcStress );
34 mmeineke 548 virtual void preMove( void );
35 mmeineke 540 virtual void moveA( void );
36     virtual void moveB( void );
37     virtual void constrainA( void );
38     virtual void constrainB( void );
39 mmeineke 559 virtual int readyCheck( void ) { return 1; }
40 tim 677
41 mmeineke 746 virtual void resetIntegrator( void ) { }
42 tim 837
43     virtual void calcForce( int calcPot, int calcStress );
44 tim 677 virtual void thermalize();
45 tim 837
46 mmeineke 778 virtual void rotationPropagation( DirectionalAtom* dAtom, double ji[3] );
47    
48 mmeineke 540 void checkConstraints( void );
49 tim 837 void rotate( int axes1, int axes2, double angle, double j[3],
50 tim 701 double A[3][3] );
51 tim 837
52 mmeineke 377 ForceFields* myFF;
53    
54 mmeineke 540 SimInfo *info; // all the info we'll ever need
55     int nAtoms; /* the number of atoms */
56 mmeineke 548 int oldAtoms;
57 mmeineke 540 Atom **atoms; /* array of atom pointers */
58 mmeineke 423 Molecule* molecules;
59     int nMols;
60    
61 mmeineke 548 int isConstrained; // boolean to know whether the systems contains
62 tim 701 // constraints.
63 tim 837 int nConstrained; // counter for number of constraints
64     int *constrainedA; // the i of a constraint pair
65     int *constrainedB; // the j of a constraint pair
66     double *constrainedDsqr; // the square of the constraint distance
67    
68 mmeineke 548 int* moving; // tells whether we are moving atom i
69     int* moved; // tells whether we have moved atom i
70 tim 837 double* oldPos; // pre constrained positions
71 mmeineke 548
72 mmeineke 540 short isFirst; /*boolean for the first time integrate is called */
73 tim 837
74 mmeineke 540 double dt;
75 mmeineke 541 double dt2;
76 gezelter 560
77 mmeineke 540 Thermo *tStats;
78     StatWriter* statOut;
79     DumpWriter* dumpOut;
80 tim 837
81 mmeineke 377 };
82    
83 mmeineke 849 class NVE : public Integrator {
84 mmeineke 540
85 mmeineke 561 public:
86     NVE ( SimInfo *theInfo, ForceFields* the_ff ):
87 mmeineke 849 Integrator( theInfo, the_ff ){}
88 tim 837 virtual ~NVE(){}
89 tim 645 };
90 mmeineke 555
91    
92 mmeineke 849 class NVT : public Integrator {
93 mmeineke 555
94 gezelter 560 public:
95    
96 mmeineke 561 NVT ( SimInfo *theInfo, ForceFields* the_ff);
97 tim 763 virtual ~NVT();
98 mmeineke 540
99 gezelter 560 void setTauThermostat(double tt) {tauThermostat = tt; have_tau_thermostat=1;}
100     void setTargetTemp(double tt) {targetTemp = tt; have_target_temp = 1;}
101 tim 763 void setChiTolerance(double tol) {chiTolerance = tol;}
102     virtual double getConservedQuantity(void);
103 mmeineke 850 virtual char* getAdditionalParameters(void);
104 gezelter 560
105 mmeineke 540 protected:
106 gezelter 560
107 mmeineke 561 virtual void moveA( void );
108     virtual void moveB( void );
109 mmeineke 540
110 mmeineke 561 virtual int readyCheck();
111 gezelter 560
112 mmeineke 746 virtual void resetIntegrator( void );
113    
114 gezelter 565 // chi is a propagated degree of freedom.
115 gezelter 560
116 gezelter 565 double chi;
117 gezelter 560
118 tim 763 //integral of chi(t)dt
119     double integralOfChidt;
120    
121 gezelter 565 // targetTemp must be set. tauThermostat must also be set;
122 gezelter 560
123     double targetTemp;
124     double tauThermostat;
125 tim 837
126 gezelter 565 short int have_tau_thermostat, have_target_temp;
127 gezelter 560
128 tim 763 double *oldVel;
129     double *oldJi;
130    
131     double chiTolerance;
132     short int have_chi_tolerance;
133    
134 mmeineke 850 char addParamBuffer[1000];
135    
136 mmeineke 540 };
137    
138    
139    
140 mmeineke 849 class NPT : public Integrator{
141 tim 645
142 gezelter 560 public:
143    
144 mmeineke 778 NPT ( SimInfo *theInfo, ForceFields* the_ff);
145     virtual ~NPT();
146 tim 837
147 mmeineke 594 virtual void integrateStep( int calcPot, int calcStress ){
148     calcStress = 1;
149 mmeineke 850 Integrator::integrateStep( calcPot, calcStress );
150 mmeineke 594 }
151    
152 mmeineke 778 virtual double getConservedQuantity(void) = 0;
153 tim 837 virtual string getAdditionalParameters(void) = 0;
154 mmeineke 843
155     double myTauThermo( void ) { return tauThermostat; }
156     double myTauBaro( void ) { return tauBarostat; }
157    
158 gezelter 560 void setTauThermostat(double tt) {tauThermostat = tt; have_tau_thermostat=1;}
159     void setTauBarostat(double tb) {tauBarostat = tb; have_tau_barostat=1;}
160     void setTargetTemp(double tt) {targetTemp = tt; have_target_temp = 1;}
161     void setTargetPressure(double tp) {targetPressure = tp; have_target_pressure = 1;}
162 tim 763 void setChiTolerance(double tol) {chiTolerance = tol; have_chi_tolerance = 1;}
163     void setPosIterTolerance(double tol) {posIterTolerance = tol; have_pos_iter_tolerance = 1;}
164     void setEtaTolerance(double tol) {etaTolerance = tol; have_eta_tolerance = 1;}
165 gezelter 560
166     protected:
167    
168 mmeineke 561 virtual void moveA( void );
169     virtual void moveB( void );
170 gezelter 560
171 mmeineke 561 virtual int readyCheck();
172 gezelter 560
173 mmeineke 746 virtual void resetIntegrator( void );
174    
175 mmeineke 778 virtual void getVelScaleA( double sc[3], double vel[3] ) = 0;
176     virtual void getVelScaleB( double sc[3], int index ) = 0;
177 tim 837 virtual void getPosScale(double pos[3], double COM[3],
178 mmeineke 778 int index, double sc[3]) = 0;
179    
180     virtual bool chiConverged( void );
181     virtual bool etaConverged( void ) = 0;
182 tim 837
183 mmeineke 778 virtual void evolveChiA( void );
184     virtual void evolveEtaA( void ) = 0;
185     virtual void evolveChiB( void );
186     virtual void evolveEtaB( void ) = 0;
187    
188     virtual void scaleSimBox( void ) = 0;
189    
190 tim 763 void accIntegralOfChidt(void) { integralOfChidt += dt * chi;}
191    
192 gezelter 565 // chi and eta are the propagated degrees of freedom
193 gezelter 560
194 mmeineke 778 double oldChi;
195     double prevChi;
196 gezelter 565 double chi;
197 gezelter 574 double NkBT;
198 tim 763 double fkBT;
199 gezelter 560
200 mmeineke 778 double tt2, tb2;
201     double instaTemp, instaPress, instaVol;
202 mmeineke 780 double press[3][3];
203 mmeineke 778
204 tim 763 int Nparticles;
205    
206     double integralOfChidt;
207    
208 tim 837 // targetTemp, targetPressure, and tauBarostat must be set.
209 gezelter 560 // One of qmass or tauThermostat must be set;
210    
211     double targetTemp;
212     double targetPressure;
213     double tauThermostat;
214     double tauBarostat;
215    
216     short int have_tau_thermostat, have_tau_barostat, have_target_temp;
217 gezelter 565 short int have_target_pressure;
218 gezelter 560
219 tim 763 double *oldPos;
220     double *oldVel;
221     double *oldJi;
222    
223     double chiTolerance;
224     short int have_chi_tolerance;
225     double posIterTolerance;
226     short int have_pos_iter_tolerance;
227     double etaTolerance;
228     short int have_eta_tolerance;
229    
230 mmeineke 850 char addParamBuffer[1000];
231    
232 gezelter 560 };
233    
234 mmeineke 849 class NPTi : public NPT{
235 tim 837
236 mmeineke 778 public:
237     NPTi( SimInfo *theInfo, ForceFields* the_ff);
238     ~NPTi();
239    
240     virtual double getConservedQuantity(void);
241     virtual void resetIntegrator(void);
242 tim 837 virtual string getAdditionalParameters(void);
243 mmeineke 778 protected:
244    
245    
246 tim 837
247 mmeineke 778 virtual void evolveEtaA(void);
248     virtual void evolveEtaB(void);
249    
250     virtual bool etaConverged( void );
251    
252     virtual void scaleSimBox( void );
253    
254     virtual void getVelScaleA( double sc[3], double vel[3] );
255     virtual void getVelScaleB( double sc[3], int index );
256 tim 837 virtual void getPosScale(double pos[3], double COM[3],
257 mmeineke 778 int index, double sc[3]);
258    
259     double eta, oldEta, prevEta;
260     };
261    
262 mmeineke 849 class NPTf : public NPT{
263 gezelter 576
264     public:
265    
266     NPTf ( SimInfo *theInfo, ForceFields* the_ff);
267 tim 767 virtual ~NPTf();
268 gezelter 576
269 tim 763 virtual double getConservedQuantity(void);
270 tim 837 virtual string getAdditionalParameters(void);
271 mmeineke 780 virtual void resetIntegrator(void);
272 mmeineke 594
273 gezelter 576 protected:
274    
275 mmeineke 780 virtual void evolveEtaA(void);
276     virtual void evolveEtaB(void);
277 gezelter 576
278 mmeineke 780 virtual bool etaConverged( void );
279 mmeineke 746
280 mmeineke 780 virtual void scaleSimBox( void );
281 gezelter 576
282 mmeineke 780 virtual void getVelScaleA( double sc[3], double vel[3] );
283     virtual void getVelScaleB( double sc[3], int index );
284 tim 837 virtual void getPosScale(double pos[3], double COM[3],
285 mmeineke 780 int index, double sc[3]);
286 tim 763
287 gezelter 588 double eta[3][3];
288 mmeineke 780 double oldEta[3][3];
289     double prevEta[3][3];
290 gezelter 576 };
291    
292 mmeineke 849 class NPTxyz : public NPT{
293 mmeineke 755
294     public:
295    
296 mmeineke 812 NPTxyz ( SimInfo *theInfo, ForceFields* the_ff);
297     virtual ~NPTxyz();
298 mmeineke 755
299 mmeineke 812 virtual double getConservedQuantity(void);
300 tim 837 virtual string getAdditionalParameters(void);
301 mmeineke 812 virtual void resetIntegrator(void);
302 mmeineke 755
303     protected:
304    
305 mmeineke 812 virtual void evolveEtaA(void);
306     virtual void evolveEtaB(void);
307 mmeineke 755
308 mmeineke 812 virtual bool etaConverged( void );
309 mmeineke 755
310 mmeineke 812 virtual void scaleSimBox( void );
311 mmeineke 755
312 mmeineke 812 virtual void getVelScaleA( double sc[3], double vel[3] );
313     virtual void getVelScaleB( double sc[3], int index );
314 tim 837 virtual void getPosScale(double pos[3], double COM[3],
315 mmeineke 812 int index, double sc[3]);
316 mmeineke 755
317 mmeineke 812 double eta[3][3];
318     double oldEta[3][3];
319     double prevEta[3][3];
320     };
321 mmeineke 755
322    
323 mmeineke 849 // template<typename T> class ZConstraint : public T {
324 tim 837
325 mmeineke 849 // public:
326     // class ForceSubtractionPolicy{
327     // public:
328     // ForceSubtractionPolicy(ZConstraint<T>* integrator) {zconsIntegrator = integrator;}
329 tim 658
330 mmeineke 849 // virtual void update() = 0;
331     // virtual double getZFOfFixedZMols(Molecule* mol, Atom* atom, double totalForce) = 0;
332     // virtual double getZFOfMovingMols(Atom* atom, double totalForce) = 0;
333     // virtual double getHFOfFixedZMols(Molecule* mol, Atom* atom, double totalForce) = 0;
334     // virtual double getHFOfUnconsMols(Atom* atom, double totalForce) = 0;
335 tim 837
336 mmeineke 849 // protected:
337     // ZConstraint<T>* zconsIntegrator;
338     // };
339 tim 699
340 mmeineke 849 // class PolicyByNumber : public ForceSubtractionPolicy{
341 gezelter 747
342 mmeineke 849 // public:
343     // PolicyByNumber(ZConstraint<T>* integrator) :ForceSubtractionPolicy(integrator) {}
344     // virtual void update();
345     // virtual double getZFOfFixedZMols(Molecule* mol, Atom* atom, double totalForce) ;
346     // virtual double getZFOfMovingMols(Atom* atom, double totalForce) ;
347     // virtual double getHFOfFixedZMols(Molecule* mol, Atom* atom, double totalForce);
348     // virtual double getHFOfUnconsMols(Atom* atom, double totalForce);
349 tim 837
350 mmeineke 849 // private:
351     // int totNumOfMovingAtoms;
352     // };
353 tim 699
354 mmeineke 849 // class PolicyByMass : public ForceSubtractionPolicy{
355 gezelter 747
356 mmeineke 849 // public:
357     // PolicyByMass(ZConstraint<T>* integrator) :ForceSubtractionPolicy(integrator) {}
358 tim 837
359 mmeineke 849 // virtual void update();
360     // virtual double getZFOfFixedZMols(Molecule* mol, Atom* atom, double totalForce) ;
361     // virtual double getZFOfMovingMols(Atom* atom, double totalForce) ;
362     // virtual double getHFOfFixedZMols(Molecule* mol, Atom* atom, double totalForce);
363     // virtual double getHFOfUnconsMols(Atom* atom, double totalForce);
364 tim 699
365 mmeineke 849 // private:
366     // double totMassOfMovingAtoms;
367     // };
368 tim 699
369 mmeineke 849 // public:
370 tim 658
371 mmeineke 849 // ZConstraint( SimInfo *theInfo, ForceFields* the_ff);
372     // ~ZConstraint();
373 tim 837
374 mmeineke 849 // void setZConsTime(double time) {this->zconsTime = time;}
375     // void getZConsTime() {return zconsTime;}
376 tim 837
377 mmeineke 849 // void setIndexOfAllZConsMols(vector<int> index) {indexOfAllZConsMols = index;}
378     // void getIndexOfAllZConsMols() {return indexOfAllZConsMols;}
379 tim 837
380 mmeineke 849 // void setZConsOutput(const char * fileName) {zconsOutput = fileName;}
381     // string getZConsOutput() {return zconsOutput;}
382 tim 837
383 mmeineke 849 // virtual void integrate();
384 tim 658
385 tim 837
386 mmeineke 849 // #ifdef IS_MPI
387     // virtual void update(); //which is called to indicate the molecules' migration
388     // #endif
389 tim 658
390 mmeineke 849 // enum ZConsState {zcsMoving, zcsFixed};
391 mmeineke 790
392 mmeineke 849 // vector<Molecule*> zconsMols; //z-constraint molecules array
393     // vector<ZConsState> states; //state of z-constraint molecules
394 mmeineke 790
395    
396 tim 837
397 mmeineke 849 // int totNumOfUnconsAtoms; //total number of uncontraint atoms
398     // double totalMassOfUncons; //total mas of unconstraint molecules
399 mmeineke 790
400    
401 mmeineke 849 // protected:
402 tim 658
403 mmeineke 790
404 tim 837
405 mmeineke 849 // virtual void calcForce( int calcPot, int calcStress );
406     // virtual void thermalize(void);
407 tim 837
408 mmeineke 849 // void zeroOutVel();
409     // void doZconstraintForce();
410     // void doHarmonic();
411     // bool checkZConsState();
412 tim 677
413 mmeineke 849 // bool haveFixedZMols();
414     // bool haveMovingZMols();
415 tim 677
416 mmeineke 849 // double calcZSys();
417 tim 677
418 mmeineke 849 // int isZConstraintMol(Molecule* mol);
419 tim 677
420    
421 mmeineke 849 // double zconsTime; //sample time
422     // double zconsTol; //tolerance of z-contratint
423     // double zForceConst; //base force constant term
424     // //which is estimate by OOPSE
425 mmeineke 790
426 tim 837
427 mmeineke 849 // vector<double> massOfZConsMols; //mass of z-constraint molecule
428     // vector<double> kz; //force constant array
429 mmeineke 790
430 mmeineke 849 // vector<double> zPos; //
431 tim 837
432    
433 mmeineke 849 // vector<Molecule*> unconsMols; //unconstraint molecules array
434     // vector<double> massOfUnconsMols; //mass array of unconstraint molecules
435 tim 682
436 mmeineke 790
437 mmeineke 849 // vector<ZConsParaItem>* parameters; //
438 tim 837
439 mmeineke 849 // vector<int> indexOfAllZConsMols; //index of All Z-Constraint Molecuels
440 tim 677
441 mmeineke 849 // int* indexOfZConsMols; //index of local Z-Constraint Molecules
442     // double* fz;
443     // double* curZPos;
444 tim 677
445 mmeineke 790
446 tim 837
447 mmeineke 849 // int whichDirection; //constraint direction
448 tim 837
449 mmeineke 849 // private:
450 tim 837
451 mmeineke 849 // string zconsOutput; //filename of zconstraint output
452     // ZConsWriter* fzOut; //z-constraint writer
453 tim 677
454 mmeineke 849 // double curZconsTime;
455 tim 699
456 mmeineke 849 // double calcMovingMolsCOMVel();
457     // double calcSysCOMVel();
458     // double calcTotalForce();
459 tim 837
460 mmeineke 849 // ForceSubtractionPolicy* forcePolicy; //force subtraction policy
461     // friend class ForceSubtractionPolicy;
462 tim 677
463 mmeineke 849 // };
464 tim 658
465     #endif