ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/branches/new-templateless/OOPSE/libmdtools/Integrator.hpp
Revision: 851
Committed: Wed Nov 5 19:18:17 2003 UTC (21 years, 9 months ago) by mmeineke
File size: 12658 byte(s)
Log Message:
some work on trying to find the compression bug

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 mmeineke 851 virtual char* 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 851
82     char addParams[100];
83 mmeineke 377 };
84    
85 mmeineke 849 class NVE : public Integrator {
86 mmeineke 540
87 mmeineke 561 public:
88     NVE ( SimInfo *theInfo, ForceFields* the_ff ):
89 mmeineke 849 Integrator( theInfo, the_ff ){}
90 tim 837 virtual ~NVE(){}
91 tim 645 };
92 mmeineke 555
93    
94 mmeineke 849 class NVT : public Integrator {
95 mmeineke 555
96 gezelter 560 public:
97    
98 mmeineke 561 NVT ( SimInfo *theInfo, ForceFields* the_ff);
99 tim 763 virtual ~NVT();
100 mmeineke 540
101 gezelter 560 void setTauThermostat(double tt) {tauThermostat = tt; have_tau_thermostat=1;}
102     void setTargetTemp(double tt) {targetTemp = tt; have_target_temp = 1;}
103 tim 763 void setChiTolerance(double tol) {chiTolerance = tol;}
104     virtual double getConservedQuantity(void);
105 mmeineke 850 virtual char* getAdditionalParameters(void);
106 gezelter 560
107 mmeineke 540 protected:
108 gezelter 560
109 mmeineke 561 virtual void moveA( void );
110     virtual void moveB( void );
111 mmeineke 540
112 mmeineke 561 virtual int readyCheck();
113 gezelter 560
114 mmeineke 746 virtual void resetIntegrator( void );
115    
116 gezelter 565 // chi is a propagated degree of freedom.
117 gezelter 560
118 gezelter 565 double chi;
119 gezelter 560
120 tim 763 //integral of chi(t)dt
121     double integralOfChidt;
122    
123 gezelter 565 // targetTemp must be set. tauThermostat must also be set;
124 gezelter 560
125     double targetTemp;
126     double tauThermostat;
127 tim 837
128 gezelter 565 short int have_tau_thermostat, have_target_temp;
129 gezelter 560
130 tim 763 double *oldVel;
131     double *oldJi;
132    
133     double chiTolerance;
134     short int have_chi_tolerance;
135    
136 mmeineke 850 char addParamBuffer[1000];
137    
138 mmeineke 540 };
139    
140    
141    
142 mmeineke 849 class NPT : public Integrator{
143 tim 645
144 gezelter 560 public:
145    
146 mmeineke 778 NPT ( SimInfo *theInfo, ForceFields* the_ff);
147     virtual ~NPT();
148 tim 837
149 mmeineke 594 virtual void integrateStep( int calcPot, int calcStress ){
150     calcStress = 1;
151 mmeineke 850 Integrator::integrateStep( calcPot, calcStress );
152 mmeineke 594 }
153    
154 mmeineke 778 virtual double getConservedQuantity(void) = 0;
155 mmeineke 851 virtual char* getAdditionalParameters(void) = 0;
156 mmeineke 843
157     double myTauThermo( void ) { return tauThermostat; }
158     double myTauBaro( void ) { return tauBarostat; }
159    
160 gezelter 560 void setTauThermostat(double tt) {tauThermostat = tt; have_tau_thermostat=1;}
161     void setTauBarostat(double tb) {tauBarostat = tb; have_tau_barostat=1;}
162     void setTargetTemp(double tt) {targetTemp = tt; have_target_temp = 1;}
163     void setTargetPressure(double tp) {targetPressure = tp; have_target_pressure = 1;}
164 tim 763 void setChiTolerance(double tol) {chiTolerance = tol; have_chi_tolerance = 1;}
165     void setPosIterTolerance(double tol) {posIterTolerance = tol; have_pos_iter_tolerance = 1;}
166     void setEtaTolerance(double tol) {etaTolerance = tol; have_eta_tolerance = 1;}
167 gezelter 560
168     protected:
169    
170 mmeineke 561 virtual void moveA( void );
171     virtual void moveB( void );
172 gezelter 560
173 mmeineke 561 virtual int readyCheck();
174 gezelter 560
175 mmeineke 746 virtual void resetIntegrator( void );
176    
177 mmeineke 778 virtual void getVelScaleA( double sc[3], double vel[3] ) = 0;
178     virtual void getVelScaleB( double sc[3], int index ) = 0;
179 tim 837 virtual void getPosScale(double pos[3], double COM[3],
180 mmeineke 778 int index, double sc[3]) = 0;
181    
182     virtual bool chiConverged( void );
183     virtual bool etaConverged( void ) = 0;
184 tim 837
185 mmeineke 778 virtual void evolveChiA( void );
186     virtual void evolveEtaA( void ) = 0;
187     virtual void evolveChiB( void );
188     virtual void evolveEtaB( void ) = 0;
189    
190     virtual void scaleSimBox( void ) = 0;
191    
192 tim 763 void accIntegralOfChidt(void) { integralOfChidt += dt * chi;}
193    
194 gezelter 565 // chi and eta are the propagated degrees of freedom
195 gezelter 560
196 mmeineke 778 double oldChi;
197     double prevChi;
198 gezelter 565 double chi;
199 gezelter 574 double NkBT;
200 tim 763 double fkBT;
201 gezelter 560
202 mmeineke 778 double tt2, tb2;
203     double instaTemp, instaPress, instaVol;
204 mmeineke 780 double press[3][3];
205 mmeineke 778
206 tim 763 int Nparticles;
207    
208     double integralOfChidt;
209    
210 tim 837 // targetTemp, targetPressure, and tauBarostat must be set.
211 gezelter 560 // One of qmass or tauThermostat must be set;
212    
213     double targetTemp;
214     double targetPressure;
215     double tauThermostat;
216     double tauBarostat;
217    
218     short int have_tau_thermostat, have_tau_barostat, have_target_temp;
219 gezelter 565 short int have_target_pressure;
220 gezelter 560
221 tim 763 double *oldPos;
222     double *oldVel;
223     double *oldJi;
224    
225     double chiTolerance;
226     short int have_chi_tolerance;
227     double posIterTolerance;
228     short int have_pos_iter_tolerance;
229     double etaTolerance;
230     short int have_eta_tolerance;
231    
232 mmeineke 850 char addParamBuffer[1000];
233    
234 gezelter 560 };
235    
236 mmeineke 849 class NPTi : public NPT{
237 tim 837
238 mmeineke 778 public:
239     NPTi( SimInfo *theInfo, ForceFields* the_ff);
240     ~NPTi();
241    
242     virtual double getConservedQuantity(void);
243     virtual void resetIntegrator(void);
244 mmeineke 851 virtual char* getAdditionalParameters(void);
245 mmeineke 778 protected:
246    
247    
248 tim 837
249 mmeineke 778 virtual void evolveEtaA(void);
250     virtual void evolveEtaB(void);
251    
252     virtual bool etaConverged( void );
253    
254     virtual void scaleSimBox( void );
255    
256     virtual void getVelScaleA( double sc[3], double vel[3] );
257     virtual void getVelScaleB( double sc[3], int index );
258 tim 837 virtual void getPosScale(double pos[3], double COM[3],
259 mmeineke 778 int index, double sc[3]);
260    
261     double eta, oldEta, prevEta;
262     };
263    
264 mmeineke 849 class NPTf : public NPT{
265 gezelter 576
266     public:
267    
268     NPTf ( SimInfo *theInfo, ForceFields* the_ff);
269 tim 767 virtual ~NPTf();
270 gezelter 576
271 tim 763 virtual double getConservedQuantity(void);
272 mmeineke 851 virtual char* getAdditionalParameters(void);
273 mmeineke 780 virtual void resetIntegrator(void);
274 mmeineke 594
275 gezelter 576 protected:
276    
277 mmeineke 780 virtual void evolveEtaA(void);
278     virtual void evolveEtaB(void);
279 gezelter 576
280 mmeineke 780 virtual bool etaConverged( void );
281 mmeineke 746
282 mmeineke 780 virtual void scaleSimBox( void );
283 gezelter 576
284 mmeineke 780 virtual void getVelScaleA( double sc[3], double vel[3] );
285     virtual void getVelScaleB( double sc[3], int index );
286 tim 837 virtual void getPosScale(double pos[3], double COM[3],
287 mmeineke 780 int index, double sc[3]);
288 tim 763
289 gezelter 588 double eta[3][3];
290 mmeineke 780 double oldEta[3][3];
291     double prevEta[3][3];
292 gezelter 576 };
293    
294 mmeineke 849 class NPTxyz : public NPT{
295 mmeineke 755
296     public:
297    
298 mmeineke 812 NPTxyz ( SimInfo *theInfo, ForceFields* the_ff);
299     virtual ~NPTxyz();
300 mmeineke 755
301 mmeineke 812 virtual double getConservedQuantity(void);
302 mmeineke 851 virtual char* getAdditionalParameters(void);
303 mmeineke 812 virtual void resetIntegrator(void);
304 mmeineke 755
305     protected:
306    
307 mmeineke 812 virtual void evolveEtaA(void);
308     virtual void evolveEtaB(void);
309 mmeineke 755
310 mmeineke 812 virtual bool etaConverged( void );
311 mmeineke 755
312 mmeineke 812 virtual void scaleSimBox( void );
313 mmeineke 755
314 mmeineke 812 virtual void getVelScaleA( double sc[3], double vel[3] );
315     virtual void getVelScaleB( double sc[3], int index );
316 tim 837 virtual void getPosScale(double pos[3], double COM[3],
317 mmeineke 812 int index, double sc[3]);
318 mmeineke 755
319 mmeineke 812 double eta[3][3];
320     double oldEta[3][3];
321     double prevEta[3][3];
322     };
323 mmeineke 755
324    
325 mmeineke 849 // template<typename T> class ZConstraint : public T {
326 tim 837
327 mmeineke 849 // public:
328     // class ForceSubtractionPolicy{
329     // public:
330     // ForceSubtractionPolicy(ZConstraint<T>* integrator) {zconsIntegrator = integrator;}
331 tim 658
332 mmeineke 849 // virtual void update() = 0;
333     // virtual double getZFOfFixedZMols(Molecule* mol, Atom* atom, double totalForce) = 0;
334     // virtual double getZFOfMovingMols(Atom* atom, double totalForce) = 0;
335     // virtual double getHFOfFixedZMols(Molecule* mol, Atom* atom, double totalForce) = 0;
336     // virtual double getHFOfUnconsMols(Atom* atom, double totalForce) = 0;
337 tim 837
338 mmeineke 849 // protected:
339     // ZConstraint<T>* zconsIntegrator;
340     // };
341 tim 699
342 mmeineke 849 // class PolicyByNumber : public ForceSubtractionPolicy{
343 gezelter 747
344 mmeineke 849 // public:
345     // PolicyByNumber(ZConstraint<T>* integrator) :ForceSubtractionPolicy(integrator) {}
346     // virtual void update();
347     // virtual double getZFOfFixedZMols(Molecule* mol, Atom* atom, double totalForce) ;
348     // virtual double getZFOfMovingMols(Atom* atom, double totalForce) ;
349     // virtual double getHFOfFixedZMols(Molecule* mol, Atom* atom, double totalForce);
350     // virtual double getHFOfUnconsMols(Atom* atom, double totalForce);
351 tim 837
352 mmeineke 849 // private:
353     // int totNumOfMovingAtoms;
354     // };
355 tim 699
356 mmeineke 849 // class PolicyByMass : public ForceSubtractionPolicy{
357 gezelter 747
358 mmeineke 849 // public:
359     // PolicyByMass(ZConstraint<T>* integrator) :ForceSubtractionPolicy(integrator) {}
360 tim 837
361 mmeineke 849 // virtual void update();
362     // virtual double getZFOfFixedZMols(Molecule* mol, Atom* atom, double totalForce) ;
363     // virtual double getZFOfMovingMols(Atom* atom, double totalForce) ;
364     // virtual double getHFOfFixedZMols(Molecule* mol, Atom* atom, double totalForce);
365     // virtual double getHFOfUnconsMols(Atom* atom, double totalForce);
366 tim 699
367 mmeineke 849 // private:
368     // double totMassOfMovingAtoms;
369     // };
370 tim 699
371 mmeineke 849 // public:
372 tim 658
373 mmeineke 849 // ZConstraint( SimInfo *theInfo, ForceFields* the_ff);
374     // ~ZConstraint();
375 tim 837
376 mmeineke 849 // void setZConsTime(double time) {this->zconsTime = time;}
377     // void getZConsTime() {return zconsTime;}
378 tim 837
379 mmeineke 849 // void setIndexOfAllZConsMols(vector<int> index) {indexOfAllZConsMols = index;}
380     // void getIndexOfAllZConsMols() {return indexOfAllZConsMols;}
381 tim 837
382 mmeineke 849 // void setZConsOutput(const char * fileName) {zconsOutput = fileName;}
383     // string getZConsOutput() {return zconsOutput;}
384 tim 837
385 mmeineke 849 // virtual void integrate();
386 tim 658
387 tim 837
388 mmeineke 849 // #ifdef IS_MPI
389     // virtual void update(); //which is called to indicate the molecules' migration
390     // #endif
391 tim 658
392 mmeineke 849 // enum ZConsState {zcsMoving, zcsFixed};
393 mmeineke 790
394 mmeineke 849 // vector<Molecule*> zconsMols; //z-constraint molecules array
395     // vector<ZConsState> states; //state of z-constraint molecules
396 mmeineke 790
397    
398 tim 837
399 mmeineke 849 // int totNumOfUnconsAtoms; //total number of uncontraint atoms
400     // double totalMassOfUncons; //total mas of unconstraint molecules
401 mmeineke 790
402    
403 mmeineke 849 // protected:
404 tim 658
405 mmeineke 790
406 tim 837
407 mmeineke 849 // virtual void calcForce( int calcPot, int calcStress );
408     // virtual void thermalize(void);
409 tim 837
410 mmeineke 849 // void zeroOutVel();
411     // void doZconstraintForce();
412     // void doHarmonic();
413     // bool checkZConsState();
414 tim 677
415 mmeineke 849 // bool haveFixedZMols();
416     // bool haveMovingZMols();
417 tim 677
418 mmeineke 849 // double calcZSys();
419 tim 677
420 mmeineke 849 // int isZConstraintMol(Molecule* mol);
421 tim 677
422    
423 mmeineke 849 // double zconsTime; //sample time
424     // double zconsTol; //tolerance of z-contratint
425     // double zForceConst; //base force constant term
426     // //which is estimate by OOPSE
427 mmeineke 790
428 tim 837
429 mmeineke 849 // vector<double> massOfZConsMols; //mass of z-constraint molecule
430     // vector<double> kz; //force constant array
431 mmeineke 790
432 mmeineke 849 // vector<double> zPos; //
433 tim 837
434    
435 mmeineke 849 // vector<Molecule*> unconsMols; //unconstraint molecules array
436     // vector<double> massOfUnconsMols; //mass array of unconstraint molecules
437 tim 682
438 mmeineke 790
439 mmeineke 849 // vector<ZConsParaItem>* parameters; //
440 tim 837
441 mmeineke 849 // vector<int> indexOfAllZConsMols; //index of All Z-Constraint Molecuels
442 tim 677
443 mmeineke 849 // int* indexOfZConsMols; //index of local Z-Constraint Molecules
444     // double* fz;
445     // double* curZPos;
446 tim 677
447 mmeineke 790
448 tim 837
449 mmeineke 849 // int whichDirection; //constraint direction
450 tim 837
451 mmeineke 849 // private:
452 tim 837
453 mmeineke 849 // string zconsOutput; //filename of zconstraint output
454     // ZConsWriter* fzOut; //z-constraint writer
455 tim 677
456 mmeineke 849 // double curZconsTime;
457 tim 699
458 mmeineke 849 // double calcMovingMolsCOMVel();
459     // double calcSysCOMVel();
460     // double calcTotalForce();
461 tim 837
462 mmeineke 849 // ForceSubtractionPolicy* forcePolicy; //force subtraction policy
463     // friend class ForceSubtractionPolicy;
464 tim 677
465 mmeineke 849 // };
466 tim 658
467     #endif