ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE/libmdtools/Integrator.hpp
(Generate patch)

Comparing trunk/OOPSE/libmdtools/Integrator.hpp (file contents):
Revision 767 by tim, Tue Sep 16 20:02:11 2003 UTC vs.
Revision 1180 by chrisfen, Thu May 20 20:24:07 2004 UTC

# Line 4 | Line 4
4   #include <string>
5   #include <vector>
6   #include "Atom.hpp"
7 + #include "StuntDouble.hpp"
8   #include "Molecule.hpp"
9   #include "SRI.hpp"
10   #include "AbstractClasses.hpp"
# Line 12 | Line 13
13   #include "Thermo.hpp"
14   #include "ReadWrite.hpp"
15   #include "ZConsWriter.hpp"
16 + #include "Restraints.hpp"
17  
18   using namespace std;
19   const double kB = 8.31451e-7;// boltzmann constant amu*Ang^2*fs^-2/K
# Line 20 | Line 22 | const double tol = 1.0e-6;
22   const int maxIteration = 300;
23   const double tol = 1.0e-6;
24  
23
25   template<typename T = BaseIntegrator> class Integrator : public T {
26  
27   public:
# Line 28 | Line 29 | template<typename T = BaseIntegrator> class Integrator
29    virtual ~Integrator();
30    void integrate( void );
31    virtual double  getConservedQuantity(void);
32 +  virtual string getAdditionalParameters(void);
33  
34   protected:
35 <  
35 >
36    virtual void integrateStep( int calcPot, int calcStress );
37    virtual void preMove( void );
38    virtual void moveA( void );
# Line 40 | Line 42 | template<typename T = BaseIntegrator> class Integrator
42    virtual int  readyCheck( void ) { return 1; }
43  
44    virtual void resetIntegrator( void ) { }
45 <
46 <  virtual void calcForce( int calcPot, int calcStress );  
45 >
46 >  virtual void calcForce( int calcPot, int calcStress );
47    virtual void thermalize();
48 <  
48 >
49 >  virtual bool stopIntegrator() {return false;}
50 >
51 >  virtual void rotationPropagation( StuntDouble* sd, double ji[3] );
52 >
53    void checkConstraints( void );
54 <  void rotate( int axes1, int axes2, double angle, double j[3],
54 >  void rotate( int axes1, int axes2, double angle, double j[3],
55           double A[3][3] );
56 <        
56 >
57    ForceFields* myFF;
58  
59    SimInfo *info; // all the info we'll ever need
60 +  vector<StuntDouble*> integrableObjects;
61    int nAtoms;  /* the number of atoms */
62    int oldAtoms;
63    Atom **atoms; /* array of atom pointers */
# Line 59 | Line 66 | template<typename T = BaseIntegrator> class Integrator
66  
67    int isConstrained; // boolean to know whether the systems contains
68           // constraints.
69 <  int nConstrained;  // counter for number of constraints
70 <  int *constrainedA; // the i of a constraint pair
71 <  int *constrainedB; // the j of a constraint pair
72 <  double *constrainedDsqr; // the square of the constraint distance
73 <  
69 >  int nConstrained;  // counter for number of constraints
70 >  int *constrainedA; // the i of a constraint pair
71 >  int *constrainedB; // the j of a constraint pair
72 >  double *constrainedDsqr; // the square of the constraint distance
73 >
74    int* moving; // tells whether we are moving atom i
75    int* moved;  // tells whether we have moved atom i
76 <  double* oldPos; // pre constrained positions
76 >  double* oldPos; // pre constrained positions
77  
78    short isFirst; /*boolean for the first time integrate is called */
79 <  
79 >
80    double dt;
81    double dt2;
82  
83    Thermo *tStats;
84    StatWriter*  statOut;
85    DumpWriter*  dumpOut;
86 <  
86 >
87 >  int i; // just an int
88   };
89  
90   typedef Integrator<BaseIntegrator> RealIntegrator;
91  
92 + // ansi instantiation
93 + template class Integrator<BaseIntegrator>;
94 +
95   template<typename T> class NVE : public T {
96  
97   public:
98    NVE ( SimInfo *theInfo, ForceFields* the_ff ):
99      T( theInfo, the_ff ){}
100 <  virtual ~NVE(){}  
100 >  virtual ~NVE(){}
101   };
102  
103  
# Line 101 | Line 112 | template<typename T> class NVT : public T { (public)
112    void setTargetTemp(double tt) {targetTemp = tt; have_target_temp = 1;}
113    void setChiTolerance(double tol) {chiTolerance = tol;}
114    virtual double  getConservedQuantity(void);
115 +  virtual string getAdditionalParameters(void);
116  
117   protected:
118  
# Line 122 | Line 134 | template<typename T> class NVT : public T { (public)
134  
135    double targetTemp;
136    double tauThermostat;
137 <  
137 >
138    short int have_tau_thermostat, have_target_temp;
139  
140    double *oldVel;
# Line 135 | Line 147 | template<typename T> class NVT : public T { (public)
147  
148  
149  
150 < template<typename T> class NPTi : public T{
150 > template<typename T> class NPT : public T{
151  
152   public:
153  
154 <  NPTi ( SimInfo *theInfo, ForceFields* the_ff);
155 <  virtual ~NPTi();
156 <  
154 >  NPT ( SimInfo *theInfo, ForceFields* the_ff);
155 >  virtual ~NPT();
156 >
157    virtual void integrateStep( int calcPot, int calcStress ){
158      calcStress = 1;
159      T::integrateStep( calcPot, calcStress );
148    /* accIntegralOfChidt(); */
160    }
161  
162 <  virtual double getConservedQuantity(void);
162 >  virtual double getConservedQuantity(void) = 0;
163 >  virtual string getAdditionalParameters(void) = 0;
164 >  
165 >  double myTauThermo( void ) { return tauThermostat; }
166 >  double myTauBaro( void ) { return tauBarostat; }
167  
168    void setTauThermostat(double tt) {tauThermostat = tt; have_tau_thermostat=1;}
169    void setTauBarostat(double tb) {tauBarostat = tb; have_tau_barostat=1;}
# Line 167 | Line 182 | template<typename T> class NPTi : public T{ (protected
182  
183    virtual void resetIntegrator( void );
184  
185 +  virtual void getVelScaleA( double sc[3], double vel[3] ) = 0;
186 +  virtual void getVelScaleB( double sc[3], int index ) = 0;
187 +  virtual void getPosScale(double pos[3], double COM[3],
188 +                           int index, double sc[3]) = 0;
189 +
190 +  virtual void calcVelScale( void ) = 0;
191 +
192 +  virtual bool chiConverged( void );
193 +  virtual bool etaConverged( void ) = 0;
194 +
195 +  virtual void evolveChiA( void );
196 +  virtual void evolveEtaA( void ) = 0;
197 +  virtual void evolveChiB( void );
198 +  virtual void evolveEtaB( void ) = 0;
199 +
200 +  virtual void scaleSimBox( void ) = 0;
201 +
202    void accIntegralOfChidt(void) { integralOfChidt += dt * chi;}
203  
204    // chi and eta are the propagated degrees of freedom
205  
206 +  double oldChi;
207 +  double prevChi;
208    double chi;
175  double eta;
209    double NkBT;
210    double fkBT;
211 +
212 +  double tt2, tb2;
213 +  double instaTemp, instaPress, instaVol;
214 +  double press[3][3];
215  
216    int Nparticles;
217  
218    double integralOfChidt;
219  
220 <  // targetTemp, targetPressure, and tauBarostat must be set.  
220 >  // targetTemp, targetPressure, and tauBarostat must be set.
221    // One of qmass or tauThermostat must be set;
222  
223    double targetTemp;
# Line 204 | Line 241 | template<typename T> class NPTi : public T{ (protected
241  
242   };
243  
244 < template<typename T> class NPTim : public T{
244 > template<typename T> class NPTi : public T{
245  
246   public:
247 +  NPTi( SimInfo *theInfo, ForceFields* the_ff);
248 +  ~NPTi();
249  
211  NPTim ( SimInfo *theInfo, ForceFields* the_ff);
212  virtual ~NPTim() {}
213
214  virtual void integrateStep( int calcPot, int calcStress ){
215    calcStress = 1;
216    T::integrateStep( calcPot, calcStress );
217    accIntegralOfChidt();  
218  }
219
250    virtual double getConservedQuantity(void);
251 <
252 <  void setTauThermostat(double tt) {tauThermostat = tt; have_tau_thermostat=1;}
223 <  void setTauBarostat(double tb) {tauBarostat = tb; have_tau_barostat=1;}
224 <  void setTargetTemp(double tt) {targetTemp = tt; have_target_temp = 1;}
225 <  void setTargetPressure(double tp) {targetPressure = tp; have_target_pressure = 1;}
226 <  void setChiTolerance(double tol) {chiTolerance = tol;}
227 <  void setPosIterTolerance(double tol) {posIterTolerance = tol;}
228 <
251 >  virtual void resetIntegrator(void);
252 >  virtual string getAdditionalParameters(void);
253   protected:
254  
231  virtual void moveA( void );
232  virtual void moveB( void );
255  
234  virtual int readyCheck();
256  
257 <  virtual void resetIntegrator( void );
257 >  virtual void evolveEtaA(void);
258 >  virtual void evolveEtaB(void);
259  
260 <  void accIntegralOfChidt(void) { integralOfChidt += dt * chi;}
239 <  
240 <  Molecule* myMolecules;
241 <  Atom** myAtoms;
260 >  virtual bool etaConverged( void );
261  
262 <  // chi and eta are the propagated degrees of freedom
262 >  virtual void scaleSimBox( void );
263  
264 <  double chi;
265 <  double eta;
266 <  double NkBT;
267 <  double integralOfChidt;
264 >  virtual void getVelScaleA( double sc[3], double vel[3] );
265 >  virtual void getVelScaleB( double sc[3], int index );
266 >  virtual void getPosScale(double pos[3], double COM[3],
267 >                           int index, double sc[3]);
268  
269 <  // targetTemp, targetPressure, and tauBarostat must be set.  
251 <  // One of qmass or tauThermostat must be set;
252 <
253 <  double targetTemp;
254 <  double targetPressure;
255 <  double tauThermostat;
256 <  double tauBarostat;
257 <
258 <  short int have_tau_thermostat, have_tau_barostat, have_target_temp;
259 <  short int have_target_pressure;
260 <  double chiTolerance;
261 <  short int have_chi_tolerance;
262 <  double posIterTolerance;
263 <  short int have_pos_iter_tolerance;
264 <
265 < };
266 <
267 < template<typename T> class NPTzm : public T{
268 <
269 < public:
270 <
271 <  NPTzm ( SimInfo *theInfo, ForceFields* the_ff);
272 <  virtual ~NPTzm() {};
273 <
274 <  virtual void integrateStep( int calcPot, int calcStress ){
275 <    calcStress = 1;
276 <    T::integrateStep( calcPot, calcStress );
277 <  }
269 >  virtual void calcVelScale( void );
270  
271 <  void setTauThermostat(double tt) {tauThermostat = tt; have_tau_thermostat=1;}
272 <  void setTauBarostat(double tb) {tauBarostat = tb; have_tau_barostat=1;}
281 <  void setTargetTemp(double tt) {targetTemp = tt; have_target_temp = 1;}
282 <  void setTargetPressure(double tp) {targetPressure = tp; have_target_pressure = 1;}
283 <
284 < protected:
285 <
286 <  virtual void moveA( void );
287 <  virtual void moveB( void );
288 <
289 <  virtual int readyCheck();
290 <
291 <  virtual void resetIntegrator( void );
292 <
293 <  Molecule* myMolecules;
294 <  Atom** myAtoms;
295 <
296 <  // chi and eta are the propagated degrees of freedom
297 <
298 <  double chi;
299 <  double eta;
300 <  double etaZ;
301 <  double NkBT;
302 <
303 <  // targetTemp, targetPressure, and tauBarostat must be set.  
304 <  // One of qmass or tauThermostat must be set;
305 <
306 <  double targetTemp;
307 <  double targetPressure;
308 <  double tauThermostat;
309 <  double tauBarostat;
310 <
311 <  short int have_tau_thermostat, have_tau_barostat, have_target_temp;
312 <  short int have_target_pressure;
313 <
271 >  double eta, oldEta, prevEta;
272 >  double vScale;
273   };
274  
275   template<typename T> class NPTf : public T{
# Line 320 | Line 279 | template<typename T> class NPTf : public T{ (public)
279    NPTf ( SimInfo *theInfo, ForceFields* the_ff);
280    virtual ~NPTf();
281  
323  virtual void integrateStep( int calcPot, int calcStress ){
324    calcStress = 1;
325    T::integrateStep( calcPot, calcStress );
326  }
327  
282    virtual double getConservedQuantity(void);
283 +  virtual string getAdditionalParameters(void);
284 +  virtual void resetIntegrator(void);
285  
330  void setTauThermostat(double tt) {tauThermostat = tt; have_tau_thermostat=1;}
331  void setTauBarostat(double tb) {tauBarostat = tb; have_tau_barostat=1;}
332  void setTargetTemp(double tt) {targetTemp = tt; have_target_temp = 1;}
333  void setTargetPressure(double tp) {targetPressure = tp; have_target_pressure = 1;}
334  void setChiTolerance(double tol) {chiTolerance = tol;}
335  void setPosIterTolerance(double tol) {posIterTolerance = tol;}
336
286   protected:
287  
288 <  virtual void  moveA( void );
289 <  virtual void moveB( void );
288 >  virtual void evolveEtaA(void);
289 >  virtual void evolveEtaB(void);
290  
291 <  virtual void resetIntegrator( void );
291 >  virtual bool etaConverged( void );
292  
293 <  virtual int readyCheck();
293 >  virtual void scaleSimBox( void );
294  
295 +  virtual void getVelScaleA( double sc[3], double vel[3] );
296 +  virtual void getVelScaleB( double sc[3], int index );
297 +  virtual void getPosScale(double pos[3], double COM[3],
298 +                           int index, double sc[3]);
299  
300 <  // chi and eta are the propagated degrees of freedom
300 >  virtual void calcVelScale( void );
301  
349  double chi;
302    double eta[3][3];
303 <  double NkBT;
304 <  double fkBT;
305 <
354 <  int Nparticles;
355 <
356 <  double *oldPos;
357 <  double *oldVel;
358 <  double *oldJi;
359 <
360 <  double integralOfChidt;
361 <  
362 <  // targetTemp, targetPressure, and tauBarostat must be set.  
363 <  // One of qmass or tauThermostat must be set;
364 <
365 <  double targetTemp;
366 <  double targetPressure;
367 <  double tauThermostat;
368 <  double tauBarostat;
369 <
370 <  short int have_tau_thermostat, have_tau_barostat, have_target_temp;
371 <  short int have_target_pressure;
372 <  double chiTolerance;
373 <  short int have_chi_tolerance;
374 <  double posIterTolerance;
375 <  short int have_pos_iter_tolerance;
376 <  double etaTolerance;
377 <  short int have_eta_tolerance;
303 >  double oldEta[3][3];
304 >  double prevEta[3][3];
305 >  double vScale[3][3];
306   };
307  
308 < template<typename T> class NPTxym : public T{
308 > template<typename T> class NPTxyz : public T{
309  
310   public:
311  
312 <  NPTxym ( SimInfo *theInfo, ForceFields* the_ff);
313 <  virtual ~NPTxym() {};
312 >  NPTxyz ( SimInfo *theInfo, ForceFields* the_ff);
313 >  virtual ~NPTxyz();
314  
315 <  virtual void integrateStep( int calcPot, int calcStress ){
316 <    calcStress = 1;
317 <    T::integrateStep( calcPot, calcStress );
390 <  }
315 >  virtual double getConservedQuantity(void);
316 >  virtual string getAdditionalParameters(void);
317 >  virtual void resetIntegrator(void);
318  
392  void setTauThermostat(double tt) {tauThermostat = tt; have_tau_thermostat=1;}
393  void setTauBarostat(double tb) {tauBarostat = tb; have_tau_barostat=1;}
394  void setTargetTemp(double tt) {targetTemp = tt; have_target_temp = 1;}
395  void setTargetPressure(double tp) {targetPressure = tp; have_target_pressure = 1;}
396
319   protected:
320  
321 <  virtual void moveA( void );
322 <  virtual void moveB( void );
321 >  virtual void evolveEtaA(void);
322 >  virtual void evolveEtaB(void);
323  
324 <  virtual int readyCheck();
324 >  virtual bool etaConverged( void );
325  
326 <  virtual void resetIntegrator( void );
326 >  virtual void scaleSimBox( void );
327  
328 <  Molecule* myMolecules;
329 <  Atom** myAtoms;
328 >  virtual void getVelScaleA( double sc[3], double vel[3] );
329 >  virtual void getVelScaleB( double sc[3], int index );
330 >  virtual void getPosScale(double pos[3], double COM[3],
331 >                           int index, double sc[3]);
332  
333 <  // chi and eta are the propagated degrees of freedom
410 <
411 <  double chi;
412 <  double eta;
413 <  double etaX;
414 <  double etaY;
415 <  double NkBT;
333 >  virtual void calcVelScale( void );
334  
417  // targetTemp, targetPressure, and tauBarostat must be set.  
418  // One of qmass or tauThermostat must be set;
419
420  double targetTemp;
421  double targetPressure;
422  double tauThermostat;
423  double tauBarostat;
424
425  short int have_tau_thermostat, have_tau_barostat, have_target_temp;
426  short int have_target_pressure;
427
428 };
429
430
431 template<typename T> class NPTfm : public T{
432
433 public:
434
435  NPTfm ( SimInfo *theInfo, ForceFields* the_ff);
436  virtual ~NPTfm() {};
437
438  virtual void integrateStep( int calcPot, int calcStress ){
439    calcStress = 1;
440    T::integrateStep( calcPot, calcStress );
441    accIntegralOfChidt();
442  }
443
444  virtual double getConservedQuantity(void);
445  
446  void setTauThermostat(double tt) {tauThermostat = tt; have_tau_thermostat=1;}
447  void setTauBarostat(double tb) {tauBarostat = tb; have_tau_barostat=1;}
448  void setTargetTemp(double tt) {targetTemp = tt; have_target_temp = 1;}
449  void setTargetPressure(double tp) {targetPressure = tp; have_target_pressure = 1;}
450  void setChiTolerance(double tol) {chiTolerance = tol;}
451  void setPosIterTolerance(double tol) {posIterTolerance = tol;}
452
453 protected:
454
455  virtual void  moveA( void );
456  virtual void moveB( void );
457
458  virtual void resetIntegrator( void );
459
460  virtual int readyCheck();
461
462  void accIntegralOfChidt(void) { integralOfChidt += dt * chi;}
463
464  Molecule* myMolecules;
465  Atom** myAtoms;
466
467  // chi and eta are the propagated degrees of freedom
468
469  double chi;
335    double eta[3][3];
336 <  double NkBT;
337 <  double integralOfChidt;
338 <
474 <  // targetTemp, targetPressure, and tauBarostat must be set.  
475 <  // One of qmass or tauThermostat must be set;
476 <
477 <  double targetTemp;
478 <  double targetPressure;
479 <  double tauThermostat;
480 <  double tauBarostat;
481 <
482 <  short int have_tau_thermostat, have_tau_barostat, have_target_temp;
483 <  short int have_target_pressure;
484 <  double chiTolerance;
485 <  short int have_chi_tolerance;
486 <  double posIterTolerance;
487 <  short int have_pos_iter_tolerance;
488 <
336 >  double oldEta[3][3];
337 >  double prevEta[3][3];
338 >  double vScale[3][3];
339   };
340  
341  
492 template<typename T> class NPTpr : public T{
493
494 public:
495
496  NPTpr ( SimInfo *theInfo, ForceFields* the_ff);
497  virtual ~NPTpr() {};
498
499  virtual void integrateStep( int calcPot, int calcStress ){
500    calcStress = 1;
501    T::integrateStep( calcPot, calcStress );
502  }
503
504  void setTauThermostat(double tt) {tauThermostat = tt; have_tau_thermostat=1;}
505  void setTauBarostat(double tb) {tauBarostat = tb; have_tau_barostat=1;}
506  void setTargetTemp(double tt) {targetTemp = tt; have_target_temp = 1;}
507  void setTargetPressure(double tp) {targetPressure = tp; have_target_pressure = 1;}
508  void setChiTolerance(double tol) {chiTolerance = tol;}
509  void setPosIterTolerance(double tol) {posIterTolerance = tol;}
510
511 protected:
512
513  virtual void  moveA( void );
514  virtual void moveB( void );
515
516  virtual int readyCheck();
517
518  virtual void resetIntegrator( void );
519
520  // chi and eta are the propagated degrees of freedom
521
522  double chi;
523  double eta[3][3];
524  double NkBT;
525
526  // targetTemp, targetPressure, and tauBarostat must be set.  
527  // One of qmass or tauThermostat must be set;
528
529  double targetTemp;
530  double targetPressure;
531  double tauThermostat;
532  double tauBarostat;
533
534  short int have_tau_thermostat, have_tau_barostat, have_target_temp;
535  short int have_target_pressure;
536  double chiTolerance;
537  short int have_chi_tolerance;
538  double posIterTolerance;
539  short int have_pos_iter_tolerance;
540
541 };
542
543
342   template<typename T> class ZConstraint : public T {
343 <  
344 <  public:
343 >
344 >  public:
345    class ForceSubtractionPolicy{
346      public:
347        ForceSubtractionPolicy(ZConstraint<T>* integrator) {zconsIntegrator = integrator;}
348  
349 <      virtual void update() = 0;    
349 >      virtual void update() = 0;
350        virtual double getZFOfFixedZMols(Molecule* mol, Atom* atom, double totalForce) = 0;
351        virtual double getZFOfMovingMols(Atom* atom, double totalForce) = 0;
352        virtual double getHFOfFixedZMols(Molecule* mol, Atom* atom, double totalForce) = 0;
353        virtual double getHFOfUnconsMols(Atom* atom, double totalForce) = 0;
354 <    
354 >
355     protected:
356 <     ZConstraint<T>* zconsIntegrator;;
356 >     ZConstraint<T>* zconsIntegrator;
357    };
358  
359    class PolicyByNumber : public ForceSubtractionPolicy{
360  
361      public:
362 <      PolicyByNumber(ZConstraint<T>* integrator) :ForceSubtractionPolicy(integrator) {}    
363 <      virtual void update();    
362 >      PolicyByNumber(ZConstraint<T>* integrator) :ForceSubtractionPolicy(integrator) {}
363 >      virtual void update();
364        virtual double getZFOfFixedZMols(Molecule* mol, Atom* atom, double totalForce) ;
365        virtual double getZFOfMovingMols(Atom* atom, double totalForce) ;
366        virtual double getHFOfFixedZMols(Molecule* mol, Atom* atom, double totalForce);
367        virtual double getHFOfUnconsMols(Atom* atom, double totalForce);
368 <    
368 >
369      private:
370        int totNumOfMovingAtoms;
371    };
# Line 575 | Line 373 | template<typename T> class ZConstraint : public T {
373    class PolicyByMass : public ForceSubtractionPolicy{
374  
375      public:
376 <      PolicyByMass(ZConstraint<T>* integrator) :ForceSubtractionPolicy(integrator) {}  
377 <      
378 <      virtual void update();    
376 >      PolicyByMass(ZConstraint<T>* integrator) :ForceSubtractionPolicy(integrator) {}
377 >
378 >      virtual void update();
379        virtual double getZFOfFixedZMols(Molecule* mol, Atom* atom, double totalForce) ;
380        virtual double getZFOfMovingMols(Atom* atom, double totalForce) ;
381        virtual double getHFOfFixedZMols(Molecule* mol, Atom* atom, double totalForce);
# Line 591 | Line 389 | template<typename T> class ZConstraint : public T {
389  
390    ZConstraint( SimInfo *theInfo, ForceFields* the_ff);
391    ~ZConstraint();
392 <    
392 >
393    void setZConsTime(double time)                  {this->zconsTime = time;}
394    void getZConsTime()                             {return zconsTime;}
395 <  
395 >
396    void setIndexOfAllZConsMols(vector<int> index) {indexOfAllZConsMols = index;}
397    void getIndexOfAllZConsMols()                  {return indexOfAllZConsMols;}
398 <  
398 >
399    void setZConsOutput(const char * fileName)          {zconsOutput = fileName;}
400    string getZConsOutput()                         {return zconsOutput;}
401 <  
401 >
402    virtual void integrate();
605  
403  
404 +
405   #ifdef IS_MPI
406    virtual void update();                      //which is called to indicate the molecules' migration
407   #endif
408  
409 +  enum ZConsState {zcsMoving, zcsFixed};
410 +
411 +  vector<Molecule*> zconsMols;              //z-constraint molecules array
412 +  vector<ZConsState> states;                 //state of z-constraint molecules
413 +
414 +
415 +
416 +  int totNumOfUnconsAtoms;              //total number of uncontraint atoms
417 +  double totalMassOfUncons;                //total mas of unconstraint molecules
418 +
419 +
420   protected:
421  
422 <  enum ZConsState {zcsMoving, zcsFixed};  
423 <
424 <  virtual void calcForce( int calcPot, int calcStress );
422 >
423 >
424 >  virtual void calcForce( int calcPot, int calcStress );
425    virtual void thermalize(void);
426 <  
426 >
427    void zeroOutVel();
428    void doZconstraintForce();
429 <  void doHarmonic();
429 >  void doHarmonic(vector<double>& resPos);
430    bool checkZConsState();
431  
432    bool haveFixedZMols();
# Line 632 | Line 441 | template<typename T> class ZConstraint : public T {
441    double zconsTol;                                 //tolerance of z-contratint
442    double zForceConst;                           //base force constant term
443                                                            //which is estimate by OOPSE
444 <  
445 <  vector<Molecule*> zconsMols;              //z-constraint molecules array
446 <  vector<double> massOfZConsMols;       //mass of z-constraint molecule
444 >
445 >
446 >  vector<double> massOfZConsMols;       //mass of z-constraint molecule
447    vector<double> kz;                              //force constant array
448 <  vector<ZConsState> states;                 //state of z-constraint molecules
448 >
449    vector<double> zPos;                          //
450 <  
451 <  
450 >
451 >
452    vector<Molecule*> unconsMols;           //unconstraint molecules array
453    vector<double> massOfUnconsMols;    //mass array of unconstraint molecules
645  double totalMassOfUncons;                //total mas of unconstraint molecules
454  
455 +
456    vector<ZConsParaItem>* parameters; //
457 <  
457 >
458    vector<int> indexOfAllZConsMols;     //index of All Z-Constraint Molecuels
459  
460 <  int* indexOfZConsMols;                   //index of local Z-Constraint Molecules  
461 <  double* fz;
462 <  double* curZPos;
654 <  
655 <  int totNumOfUnconsAtoms;              //total number of uncontraint atoms
460 >  vector<int> indexOfZConsMols;                   //index of local Z-Constraint Molecules
461 >  vector<double> fz;
462 >  vector<double> curZPos;
463  
464 <  int whichDirection;                           //constraint direction
464 >  bool usingSMD;
465 >  vector<double> prevCantPos;
466 >  vector<double> cantPos;
467 >  vector<double> cantVel;
468 >
469 >  double zconsFixTime;  
470 >  double zconsGap;
471 >  bool hasZConsGap;
472 >  vector<double> endFixTime;
473    
474 +  int whichDirection;                           //constraint direction
475 +
476   private:
477 <  
477 >
478    string zconsOutput;                         //filename of zconstraint output
479    ZConsWriter* fzOut;                         //z-constraint writer
480  
481 <  double curZconsTime;                      
481 >  double curZconsTime;
482  
483    double calcMovingMolsCOMVel();
484    double calcSysCOMVel();
485    double calcTotalForce();
486 +  void updateZPos();
487 +  void updateCantPos();
488    
489    ForceSubtractionPolicy* forcePolicy; //force subtraction policy
490    friend class ForceSubtractionPolicy;
491  
492   };
493  
494 + /*
495 + template<typename T> class SingleZConstrain : public T{
496 +
497 +
498 + };
499 + */
500 +
501 + template<typename T> class NonEquMD : public T {
502 +  public:
503 +    
504 +
505 +
506 + };
507 +
508 +
509 + //
510 + template<typename T> class SingleZConstraint : public T{
511 +  public:
512 +    SingleZConstraint(SimInfo *theInfo, ForceFields* the_ff);
513 +    ~SingleZConstraint();
514 +    
515 +    bool stopIntegrator();
516 +    
517 +  protected:
518 +    
519 + };
520 +
521 + //Steered Molecular Dynamics, curret implement only support one steered molecule
522 + template<typename T> class SMD : public T{
523 +  public:
524 +    SMD( SimInfo *theInfo, ForceFields* the_ff);
525 +    ~SMD();
526 +  
527 +    virtual void integrate();
528 +    virtual void calcForce( int calcPot, int calcStress );  
529 +    bool stopIntegrator();
530 +  private:
531 +    
532 + };
533 +
534 + //By using state pattern, Coordinate Drive is responsible for switching back and forth between
535 + //Driven Molecular Dynamics and ZConstraint Method.
536 + template<typename T> class CoordinateDriver : public T {
537 +  public:
538 +    typedef T ParentIntegrator;
539 +
540 +    CoordinateDriver(SimInfo*, ForceFields*, BaseIntegrator*, BaseIntegrator*);
541 +    ~CoordinateDriver();
542 +    
543 +    virtual void integrate();
544 +
545 +  private:    
546 +    BaseIntegrator* zconsIntegrator;
547 +    BaseIntegrator* drivenIntegrator;
548 +    
549 + };
550 +
551   #endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines