ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/branches/no-template-branch/OOPSE/libmdtools/Integrator.hpp
Revision: 833
Committed: Tue Oct 28 17:08:18 2003 UTC (21 years, 6 months ago) by mmeineke
File size: 12338 byte(s)
Log Message:
started work on template removal

File Contents

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