ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE/libmdtools/Integrator.hpp
Revision: 778
Committed: Fri Sep 19 20:00:27 2003 UTC (20 years, 9 months ago) by mmeineke
File size: 19462 byte(s)
Log Message:
added NPT base class. NPTi is up to date. NPTf is not.

File Contents

# User Rev Content
1 mmeineke 377 #ifndef _INTEGRATOR_H_
2     #define _INTEGRATOR_H_
3    
4 tim 658 #include <string>
5     #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 tim 658 #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 tim 645 template<typename T = BaseIntegrator> class Integrator : public T {
25    
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 tim 645 typedef Integrator<BaseIntegrator> RealIntegrator;
85 mmeineke 540
86 tim 645 template<typename T> class NVE : public T {
87    
88 mmeineke 561 public:
89     NVE ( SimInfo *theInfo, ForceFields* the_ff ):
90 tim 645 T( theInfo, the_ff ){}
91     virtual ~NVE(){}
92     };
93 mmeineke 555
94    
95 tim 645 template<typename T> class NVT : public T {
96 mmeineke 555
97 gezelter 560 public:
98    
99 mmeineke 561 NVT ( SimInfo *theInfo, ForceFields* the_ff);
100 tim 763 virtual ~NVT();
101 mmeineke 540
102 gezelter 560 void setTauThermostat(double tt) {tauThermostat = tt; have_tau_thermostat=1;}
103     void setTargetTemp(double tt) {targetTemp = tt; have_target_temp = 1;}
104 tim 763 void setChiTolerance(double tol) {chiTolerance = tol;}
105     virtual double getConservedQuantity(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 mmeineke 561
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 540 };
137    
138    
139    
140 mmeineke 778 template<typename T> class NPT : public T{
141 tim 645
142 gezelter 560 public:
143    
144 mmeineke 778 NPT ( SimInfo *theInfo, ForceFields* the_ff);
145     virtual ~NPT();
146 tim 763
147 mmeineke 594 virtual void integrateStep( int calcPot, int calcStress ){
148     calcStress = 1;
149 tim 645 T::integrateStep( calcPot, calcStress );
150 mmeineke 594 }
151    
152 mmeineke 778 virtual double getConservedQuantity(void) = 0;
153 tim 763
154 gezelter 560 void setTauThermostat(double tt) {tauThermostat = tt; have_tau_thermostat=1;}
155     void setTauBarostat(double tb) {tauBarostat = tb; have_tau_barostat=1;}
156     void setTargetTemp(double tt) {targetTemp = tt; have_target_temp = 1;}
157     void setTargetPressure(double tp) {targetPressure = tp; have_target_pressure = 1;}
158 tim 763 void setChiTolerance(double tol) {chiTolerance = tol; have_chi_tolerance = 1;}
159     void setPosIterTolerance(double tol) {posIterTolerance = tol; have_pos_iter_tolerance = 1;}
160     void setEtaTolerance(double tol) {etaTolerance = tol; have_eta_tolerance = 1;}
161 gezelter 560
162     protected:
163    
164 mmeineke 561 virtual void moveA( void );
165     virtual void moveB( void );
166 gezelter 560
167 mmeineke 561 virtual int readyCheck();
168 gezelter 560
169 mmeineke 746 virtual void resetIntegrator( void );
170    
171 mmeineke 778 virtual void getVelScaleA( double sc[3], double vel[3] ) = 0;
172     virtual void getVelScaleB( double sc[3], int index ) = 0;
173     virtual void getPosScale(double pos[3], double COM[3],
174     int index, double sc[3]) = 0;
175    
176     virtual bool chiConverged( void );
177     virtual bool etaConverged( void ) = 0;
178    
179     virtual void evolveChiA( void );
180     virtual void evolveEtaA( void ) = 0;
181     virtual void evolveChiB( void );
182     virtual void evolveEtaB( void ) = 0;
183    
184     virtual void scaleSimBox( void ) = 0;
185    
186 tim 763 void accIntegralOfChidt(void) { integralOfChidt += dt * chi;}
187    
188 gezelter 565 // chi and eta are the propagated degrees of freedom
189 gezelter 560
190 mmeineke 778 double oldChi;
191     double prevChi;
192 gezelter 565 double chi;
193 gezelter 574 double NkBT;
194 tim 763 double fkBT;
195 gezelter 560
196 mmeineke 778 double tt2, tb2;
197     double instaTemp, instaPress, instaVol;
198    
199 tim 763 int Nparticles;
200    
201     double integralOfChidt;
202    
203 gezelter 560 // targetTemp, targetPressure, and tauBarostat must be set.
204     // One of qmass or tauThermostat must be set;
205    
206     double targetTemp;
207     double targetPressure;
208     double tauThermostat;
209     double tauBarostat;
210    
211     short int have_tau_thermostat, have_tau_barostat, have_target_temp;
212 gezelter 565 short int have_target_pressure;
213 gezelter 560
214 tim 763 double *oldPos;
215     double *oldVel;
216     double *oldJi;
217    
218     double chiTolerance;
219     short int have_chi_tolerance;
220     double posIterTolerance;
221     short int have_pos_iter_tolerance;
222     double etaTolerance;
223     short int have_eta_tolerance;
224    
225 gezelter 560 };
226    
227 mmeineke 778 template<typename T> class NPTi : public T{
228    
229     public:
230     NPTi( SimInfo *theInfo, ForceFields* the_ff);
231     ~NPTi();
232    
233     virtual double getConservedQuantity(void);
234     virtual void resetIntegrator(void);
235    
236     protected:
237    
238    
239    
240     virtual void evolveEtaA(void);
241     virtual void evolveEtaB(void);
242    
243     virtual bool etaConverged( void );
244    
245     virtual void scaleSimBox( void );
246    
247     virtual void getVelScaleA( double sc[3], double vel[3] );
248     virtual void getVelScaleB( double sc[3], int index );
249     virtual void getPosScale(double pos[3], double COM[3],
250     int index, double sc[3]);
251    
252     double eta, oldEta, prevEta;
253     };
254    
255    
256 tim 645 template<typename T> class NPTim : public T{
257 gezelter 596
258     public:
259    
260     NPTim ( SimInfo *theInfo, ForceFields* the_ff);
261 tim 763 virtual ~NPTim() {}
262 gezelter 596
263     virtual void integrateStep( int calcPot, int calcStress ){
264     calcStress = 1;
265 tim 645 T::integrateStep( calcPot, calcStress );
266 tim 763 accIntegralOfChidt();
267 gezelter 596 }
268    
269 tim 763 virtual double getConservedQuantity(void);
270    
271 gezelter 596 void setTauThermostat(double tt) {tauThermostat = tt; have_tau_thermostat=1;}
272     void setTauBarostat(double tb) {tauBarostat = tb; have_tau_barostat=1;}
273     void setTargetTemp(double tt) {targetTemp = tt; have_target_temp = 1;}
274     void setTargetPressure(double tp) {targetPressure = tp; have_target_pressure = 1;}
275 tim 763 void setChiTolerance(double tol) {chiTolerance = tol;}
276     void setPosIterTolerance(double tol) {posIterTolerance = tol;}
277 gezelter 596
278     protected:
279    
280 gezelter 604 virtual void moveA( void );
281 gezelter 596 virtual void moveB( void );
282    
283     virtual int readyCheck();
284    
285 mmeineke 746 virtual void resetIntegrator( void );
286    
287 tim 763 void accIntegralOfChidt(void) { integralOfChidt += dt * chi;}
288    
289 gezelter 604 Molecule* myMolecules;
290     Atom** myAtoms;
291    
292 gezelter 596 // chi and eta are the propagated degrees of freedom
293    
294     double chi;
295     double eta;
296     double NkBT;
297 tim 763 double integralOfChidt;
298 gezelter 596
299     // targetTemp, targetPressure, and tauBarostat must be set.
300     // One of qmass or tauThermostat must be set;
301    
302     double targetTemp;
303     double targetPressure;
304     double tauThermostat;
305     double tauBarostat;
306    
307     short int have_tau_thermostat, have_tau_barostat, have_target_temp;
308     short int have_target_pressure;
309 tim 763 double chiTolerance;
310     short int have_chi_tolerance;
311     double posIterTolerance;
312     short int have_pos_iter_tolerance;
313 gezelter 596
314     };
315    
316 mmeineke 755 template<typename T> class NPTzm : public T{
317    
318     public:
319    
320     NPTzm ( SimInfo *theInfo, ForceFields* the_ff);
321     virtual ~NPTzm() {};
322    
323     virtual void integrateStep( int calcPot, int calcStress ){
324     calcStress = 1;
325     T::integrateStep( calcPot, calcStress );
326     }
327    
328     void setTauThermostat(double tt) {tauThermostat = tt; have_tau_thermostat=1;}
329     void setTauBarostat(double tb) {tauBarostat = tb; have_tau_barostat=1;}
330     void setTargetTemp(double tt) {targetTemp = tt; have_target_temp = 1;}
331     void setTargetPressure(double tp) {targetPressure = tp; have_target_pressure = 1;}
332    
333     protected:
334    
335     virtual void moveA( void );
336     virtual void moveB( void );
337    
338     virtual int readyCheck();
339    
340     virtual void resetIntegrator( void );
341    
342     Molecule* myMolecules;
343     Atom** myAtoms;
344    
345     // chi and eta are the propagated degrees of freedom
346    
347     double chi;
348     double eta;
349     double etaZ;
350     double NkBT;
351    
352     // targetTemp, targetPressure, and tauBarostat must be set.
353     // One of qmass or tauThermostat must be set;
354    
355     double targetTemp;
356     double targetPressure;
357     double tauThermostat;
358     double tauBarostat;
359    
360     short int have_tau_thermostat, have_tau_barostat, have_target_temp;
361     short int have_target_pressure;
362    
363     };
364    
365 tim 645 template<typename T> class NPTf : public T{
366 gezelter 576
367     public:
368    
369     NPTf ( SimInfo *theInfo, ForceFields* the_ff);
370 tim 767 virtual ~NPTf();
371 gezelter 576
372 mmeineke 594 virtual void integrateStep( int calcPot, int calcStress ){
373     calcStress = 1;
374 tim 645 T::integrateStep( calcPot, calcStress );
375 mmeineke 594 }
376 tim 763
377     virtual double getConservedQuantity(void);
378 mmeineke 594
379 gezelter 576 void setTauThermostat(double tt) {tauThermostat = tt; have_tau_thermostat=1;}
380     void setTauBarostat(double tb) {tauBarostat = tb; have_tau_barostat=1;}
381     void setTargetTemp(double tt) {targetTemp = tt; have_target_temp = 1;}
382     void setTargetPressure(double tp) {targetPressure = tp; have_target_pressure = 1;}
383 tim 763 void setChiTolerance(double tol) {chiTolerance = tol;}
384     void setPosIterTolerance(double tol) {posIterTolerance = tol;}
385 gezelter 576
386     protected:
387    
388     virtual void moveA( void );
389     virtual void moveB( void );
390    
391 mmeineke 746 virtual void resetIntegrator( void );
392    
393 gezelter 576 virtual int readyCheck();
394    
395 tim 763
396 gezelter 576 // chi and eta are the propagated degrees of freedom
397    
398     double chi;
399 gezelter 588 double eta[3][3];
400 gezelter 576 double NkBT;
401 tim 767 double fkBT;
402 gezelter 576
403 tim 767 int Nparticles;
404    
405     double *oldPos;
406     double *oldVel;
407     double *oldJi;
408    
409 tim 763 double integralOfChidt;
410    
411 gezelter 576 // targetTemp, targetPressure, and tauBarostat must be set.
412     // One of qmass or tauThermostat must be set;
413    
414     double targetTemp;
415     double targetPressure;
416     double tauThermostat;
417     double tauBarostat;
418    
419     short int have_tau_thermostat, have_tau_barostat, have_target_temp;
420     short int have_target_pressure;
421 tim 763 double chiTolerance;
422     short int have_chi_tolerance;
423     double posIterTolerance;
424     short int have_pos_iter_tolerance;
425 tim 767 double etaTolerance;
426     short int have_eta_tolerance;
427 gezelter 576 };
428    
429 mmeineke 755 template<typename T> class NPTxym : public T{
430    
431     public:
432    
433     NPTxym ( SimInfo *theInfo, ForceFields* the_ff);
434     virtual ~NPTxym() {};
435    
436     virtual void integrateStep( int calcPot, int calcStress ){
437     calcStress = 1;
438     T::integrateStep( calcPot, calcStress );
439     }
440    
441     void setTauThermostat(double tt) {tauThermostat = tt; have_tau_thermostat=1;}
442     void setTauBarostat(double tb) {tauBarostat = tb; have_tau_barostat=1;}
443     void setTargetTemp(double tt) {targetTemp = tt; have_target_temp = 1;}
444     void setTargetPressure(double tp) {targetPressure = tp; have_target_pressure = 1;}
445    
446     protected:
447    
448     virtual void moveA( void );
449     virtual void moveB( void );
450    
451     virtual int readyCheck();
452    
453     virtual void resetIntegrator( void );
454    
455     Molecule* myMolecules;
456     Atom** myAtoms;
457    
458     // chi and eta are the propagated degrees of freedom
459    
460     double chi;
461     double eta;
462     double etaX;
463     double etaY;
464     double NkBT;
465    
466     // targetTemp, targetPressure, and tauBarostat must be set.
467     // One of qmass or tauThermostat must be set;
468    
469     double targetTemp;
470     double targetPressure;
471     double tauThermostat;
472     double tauBarostat;
473    
474     short int have_tau_thermostat, have_tau_barostat, have_target_temp;
475     short int have_target_pressure;
476    
477     };
478    
479    
480 tim 645 template<typename T> class NPTfm : public T{
481 gezelter 596
482     public:
483    
484     NPTfm ( SimInfo *theInfo, ForceFields* the_ff);
485     virtual ~NPTfm() {};
486    
487     virtual void integrateStep( int calcPot, int calcStress ){
488     calcStress = 1;
489 tim 645 T::integrateStep( calcPot, calcStress );
490 tim 763 accIntegralOfChidt();
491 gezelter 596 }
492    
493 tim 763 virtual double getConservedQuantity(void);
494    
495 gezelter 596 void setTauThermostat(double tt) {tauThermostat = tt; have_tau_thermostat=1;}
496     void setTauBarostat(double tb) {tauBarostat = tb; have_tau_barostat=1;}
497     void setTargetTemp(double tt) {targetTemp = tt; have_target_temp = 1;}
498     void setTargetPressure(double tp) {targetPressure = tp; have_target_pressure = 1;}
499 tim 763 void setChiTolerance(double tol) {chiTolerance = tol;}
500     void setPosIterTolerance(double tol) {posIterTolerance = tol;}
501 gezelter 596
502     protected:
503    
504     virtual void moveA( void );
505     virtual void moveB( void );
506    
507 mmeineke 746 virtual void resetIntegrator( void );
508    
509 gezelter 596 virtual int readyCheck();
510    
511 tim 763 void accIntegralOfChidt(void) { integralOfChidt += dt * chi;}
512    
513 gezelter 605 Molecule* myMolecules;
514     Atom** myAtoms;
515    
516 gezelter 596 // chi and eta are the propagated degrees of freedom
517    
518     double chi;
519     double eta[3][3];
520     double NkBT;
521 tim 763 double integralOfChidt;
522 gezelter 596
523     // targetTemp, targetPressure, and tauBarostat must be set.
524     // One of qmass or tauThermostat must be set;
525    
526     double targetTemp;
527     double targetPressure;
528     double tauThermostat;
529     double tauBarostat;
530    
531     short int have_tau_thermostat, have_tau_barostat, have_target_temp;
532     short int have_target_pressure;
533 tim 763 double chiTolerance;
534     short int have_chi_tolerance;
535     double posIterTolerance;
536     short int have_pos_iter_tolerance;
537 gezelter 596
538     };
539    
540 gezelter 718
541     template<typename T> class NPTpr : public T{
542    
543     public:
544    
545     NPTpr ( SimInfo *theInfo, ForceFields* the_ff);
546     virtual ~NPTpr() {};
547    
548     virtual void integrateStep( int calcPot, int calcStress ){
549     calcStress = 1;
550     T::integrateStep( calcPot, calcStress );
551     }
552    
553     void setTauThermostat(double tt) {tauThermostat = tt; have_tau_thermostat=1;}
554     void setTauBarostat(double tb) {tauBarostat = tb; have_tau_barostat=1;}
555     void setTargetTemp(double tt) {targetTemp = tt; have_target_temp = 1;}
556     void setTargetPressure(double tp) {targetPressure = tp; have_target_pressure = 1;}
557 tim 763 void setChiTolerance(double tol) {chiTolerance = tol;}
558     void setPosIterTolerance(double tol) {posIterTolerance = tol;}
559 gezelter 718
560     protected:
561    
562     virtual void moveA( void );
563     virtual void moveB( void );
564    
565     virtual int readyCheck();
566    
567 mmeineke 746 virtual void resetIntegrator( void );
568    
569 gezelter 718 // chi and eta are the propagated degrees of freedom
570    
571     double chi;
572     double eta[3][3];
573     double NkBT;
574    
575     // targetTemp, targetPressure, and tauBarostat must be set.
576     // One of qmass or tauThermostat must be set;
577    
578     double targetTemp;
579     double targetPressure;
580     double tauThermostat;
581     double tauBarostat;
582    
583     short int have_tau_thermostat, have_tau_barostat, have_target_temp;
584     short int have_target_pressure;
585 tim 763 double chiTolerance;
586     short int have_chi_tolerance;
587     double posIterTolerance;
588     short int have_pos_iter_tolerance;
589 gezelter 718
590     };
591    
592    
593 tim 658 template<typename T> class ZConstraint : public T {
594 tim 701
595     public:
596 tim 738 class ForceSubtractionPolicy{
597 tim 699 public:
598 tim 738 ForceSubtractionPolicy(ZConstraint<T>* integrator) {zconsIntegrator = integrator;}
599 tim 658
600 tim 701 virtual void update() = 0;
601 tim 699 virtual double getZFOfFixedZMols(Molecule* mol, Atom* atom, double totalForce) = 0;
602     virtual double getZFOfMovingMols(Atom* atom, double totalForce) = 0;
603 tim 701 virtual double getHFOfFixedZMols(Molecule* mol, Atom* atom, double totalForce) = 0;
604     virtual double getHFOfUnconsMols(Atom* atom, double totalForce) = 0;
605    
606     protected:
607     ZConstraint<T>* zconsIntegrator;;
608 tim 699 };
609    
610 tim 738 class PolicyByNumber : public ForceSubtractionPolicy{
611 gezelter 747
612 tim 699 public:
613 tim 738 PolicyByNumber(ZConstraint<T>* integrator) :ForceSubtractionPolicy(integrator) {}
614 tim 701 virtual void update();
615 tim 699 virtual double getZFOfFixedZMols(Molecule* mol, Atom* atom, double totalForce) ;
616     virtual double getZFOfMovingMols(Atom* atom, double totalForce) ;
617 tim 701 virtual double getHFOfFixedZMols(Molecule* mol, Atom* atom, double totalForce);
618     virtual double getHFOfUnconsMols(Atom* atom, double totalForce);
619    
620 tim 699 private:
621 tim 763 int totNumOfMovingAtoms;
622 tim 699 };
623    
624 tim 738 class PolicyByMass : public ForceSubtractionPolicy{
625 gezelter 747
626 tim 699 public:
627 tim 738 PolicyByMass(ZConstraint<T>* integrator) :ForceSubtractionPolicy(integrator) {}
628 tim 701
629     virtual void update();
630 tim 699 virtual double getZFOfFixedZMols(Molecule* mol, Atom* atom, double totalForce) ;
631     virtual double getZFOfMovingMols(Atom* atom, double totalForce) ;
632 tim 701 virtual double getHFOfFixedZMols(Molecule* mol, Atom* atom, double totalForce);
633     virtual double getHFOfUnconsMols(Atom* atom, double totalForce);
634 tim 699
635 tim 701 private:
636     double totMassOfMovingAtoms;
637 tim 699 };
638    
639 tim 658 public:
640    
641     ZConstraint( SimInfo *theInfo, ForceFields* the_ff);
642     ~ZConstraint();
643 tim 677
644 tim 658 void setZConsTime(double time) {this->zconsTime = time;}
645     void getZConsTime() {return zconsTime;}
646    
647 tim 701 void setIndexOfAllZConsMols(vector<int> index) {indexOfAllZConsMols = index;}
648     void getIndexOfAllZConsMols() {return indexOfAllZConsMols;}
649 tim 658
650 tim 701 void setZConsOutput(const char * fileName) {zconsOutput = fileName;}
651 tim 658 string getZConsOutput() {return zconsOutput;}
652 tim 677
653     virtual void integrate();
654    
655 tim 658
656     #ifdef IS_MPI
657 tim 701 virtual void update(); //which is called to indicate the molecules' migration
658 mmeineke 377 #endif
659 tim 658
660     protected:
661    
662 tim 701 enum ZConsState {zcsMoving, zcsFixed};
663 tim 677
664     virtual void calcForce( int calcPot, int calcStress );
665     virtual void thermalize(void);
666    
667     void zeroOutVel();
668     void doZconstraintForce();
669 tim 682 void doHarmonic();
670 tim 677 bool checkZConsState();
671    
672     bool haveFixedZMols();
673     bool haveMovingZMols();
674    
675     double calcZSys();
676    
677     int isZConstraintMol(Molecule* mol);
678    
679    
680 tim 701 double zconsTime; //sample time
681     double zconsTol; //tolerance of z-contratint
682     double zForceConst; //base force constant term
683     //which is estimate by OOPSE
684 tim 658
685 tim 701 vector<Molecule*> zconsMols; //z-constraint molecules array
686     vector<double> massOfZConsMols; //mass of z-constraint molecule
687     vector<double> kz; //force constant array
688     vector<ZConsState> states; //state of z-constraint molecules
689     vector<double> zPos; //
690 tim 658
691 tim 677
692 tim 701 vector<Molecule*> unconsMols; //unconstraint molecules array
693     vector<double> massOfUnconsMols; //mass array of unconstraint molecules
694     double totalMassOfUncons; //total mas of unconstraint molecules
695 tim 682
696 tim 701 vector<ZConsParaItem>* parameters; //
697 tim 658
698     vector<int> indexOfAllZConsMols; //index of All Z-Constraint Molecuels
699 tim 677
700     int* indexOfZConsMols; //index of local Z-Constraint Molecules
701 tim 658 double* fz;
702 tim 699 double* curZPos;
703 tim 658
704 tim 701 int totNumOfUnconsAtoms; //total number of uncontraint atoms
705 tim 677
706     int whichDirection; //constraint direction
707    
708 tim 658 private:
709 tim 677
710 tim 701 string zconsOutput; //filename of zconstraint output
711     ZConsWriter* fzOut; //z-constraint writer
712 tim 677
713 tim 701 double curZconsTime;
714 tim 699
715 tim 696 double calcMovingMolsCOMVel();
716     double calcSysCOMVel();
717     double calcTotalForce();
718 tim 701
719 gezelter 747 ForceSubtractionPolicy* forcePolicy; //force subtraction policy
720 tim 738 friend class ForceSubtractionPolicy;
721 tim 677
722 tim 658 };
723    
724     #endif