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 763 by tim, Mon Sep 15 16:52:02 2003 UTC vs.
Revision 1187 by chrisfen, Sat May 22 18:16:18 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   };
88  
89   typedef Integrator<BaseIntegrator> RealIntegrator;
90  
91 + // ansi instantiation
92 + template class Integrator<BaseIntegrator>;
93 +
94   template<typename T> class NVE : public T {
95  
96   public:
97    NVE ( SimInfo *theInfo, ForceFields* the_ff ):
98      T( theInfo, the_ff ){}
99 <  virtual ~NVE(){}  
99 >  virtual ~NVE(){}
100   };
101  
102  
# Line 101 | Line 111 | template<typename T> class NVT : public T { (public)
111    void setTargetTemp(double tt) {targetTemp = tt; have_target_temp = 1;}
112    void setChiTolerance(double tol) {chiTolerance = tol;}
113    virtual double  getConservedQuantity(void);
114 +  virtual string getAdditionalParameters(void);
115  
116   protected:
117  
# Line 122 | Line 133 | template<typename T> class NVT : public T { (public)
133  
134    double targetTemp;
135    double tauThermostat;
136 <  
136 >
137    short int have_tau_thermostat, have_target_temp;
138  
139    double *oldVel;
# Line 135 | Line 146 | template<typename T> class NPTi : public T{
146  
147  
148  
149 < template<typename T> class NPTi : public T{
149 > template<typename T> class NPT : public T{
150  
151   public:
152  
153 <  NPTi ( SimInfo *theInfo, ForceFields* the_ff);
154 <  virtual ~NPTi();
155 <  
153 >  NPT ( SimInfo *theInfo, ForceFields* the_ff);
154 >  virtual ~NPT();
155 >
156    virtual void integrateStep( int calcPot, int calcStress ){
157      calcStress = 1;
158      T::integrateStep( calcPot, calcStress );
148    /* accIntegralOfChidt(); */
159    }
160  
161 <  virtual double getConservedQuantity(void);
161 >  virtual double getConservedQuantity(void) = 0;
162 >  virtual string getAdditionalParameters(void) = 0;
163 >  
164 >  double myTauThermo( void ) { return tauThermostat; }
165 >  double myTauBaro( void ) { return tauBarostat; }
166  
167    void setTauThermostat(double tt) {tauThermostat = tt; have_tau_thermostat=1;}
168    void setTauBarostat(double tb) {tauBarostat = tb; have_tau_barostat=1;}
# Line 167 | Line 181 | template<typename T> class NPTi : public T{ (protected
181  
182    virtual void resetIntegrator( void );
183  
184 +  virtual void getVelScaleA( double sc[3], double vel[3] ) = 0;
185 +  virtual void getVelScaleB( double sc[3], int index ) = 0;
186 +  virtual void getPosScale(double pos[3], double COM[3],
187 +                           int index, double sc[3]) = 0;
188 +
189 +  virtual void calcVelScale( void ) = 0;
190 +
191 +  virtual bool chiConverged( void );
192 +  virtual bool etaConverged( void ) = 0;
193 +
194 +  virtual void evolveChiA( void );
195 +  virtual void evolveEtaA( void ) = 0;
196 +  virtual void evolveChiB( void );
197 +  virtual void evolveEtaB( void ) = 0;
198 +
199 +  virtual void scaleSimBox( void ) = 0;
200 +
201    void accIntegralOfChidt(void) { integralOfChidt += dt * chi;}
202  
203    // chi and eta are the propagated degrees of freedom
204  
205 +  double oldChi;
206 +  double prevChi;
207    double chi;
175  double eta;
208    double NkBT;
209    double fkBT;
210  
211 +  double tt2, tb2;
212 +  double instaTemp, instaPress, instaVol;
213 +  double press[3][3];
214 +
215    int Nparticles;
216  
217    double integralOfChidt;
218  
219 <  // targetTemp, targetPressure, and tauBarostat must be set.  
219 >  // targetTemp, targetPressure, and tauBarostat must be set.
220    // One of qmass or tauThermostat must be set;
221  
222    double targetTemp;
# Line 202 | Line 238 | template<typename T> class NPTi : public T{ (protected
238    double etaTolerance;
239    short int have_eta_tolerance;
240  
205  double volume;
206
241   };
242  
243 < template<typename T> class NPTim : public T{
243 > template<typename T> class NPTi : public T{
244  
245   public:
246 +  NPTi( SimInfo *theInfo, ForceFields* the_ff);
247 +  ~NPTi();
248  
213  NPTim ( SimInfo *theInfo, ForceFields* the_ff);
214  virtual ~NPTim() {}
215
216  virtual void integrateStep( int calcPot, int calcStress ){
217    calcStress = 1;
218    T::integrateStep( calcPot, calcStress );
219    accIntegralOfChidt();  
220  }
221
249    virtual double getConservedQuantity(void);
250 <
251 <  void setTauThermostat(double tt) {tauThermostat = tt; have_tau_thermostat=1;}
225 <  void setTauBarostat(double tb) {tauBarostat = tb; have_tau_barostat=1;}
226 <  void setTargetTemp(double tt) {targetTemp = tt; have_target_temp = 1;}
227 <  void setTargetPressure(double tp) {targetPressure = tp; have_target_pressure = 1;}
228 <  void setChiTolerance(double tol) {chiTolerance = tol;}
229 <  void setPosIterTolerance(double tol) {posIterTolerance = tol;}
230 <
250 >  virtual void resetIntegrator(void);
251 >  virtual string getAdditionalParameters(void);
252   protected:
253  
233  virtual void moveA( void );
234  virtual void moveB( void );
254  
236  virtual int readyCheck();
255  
256 <  virtual void resetIntegrator( void );
256 >  virtual void evolveEtaA(void);
257 >  virtual void evolveEtaB(void);
258  
259 <  void accIntegralOfChidt(void) { integralOfChidt += dt * chi;}
241 <  
242 <  Molecule* myMolecules;
243 <  Atom** myAtoms;
259 >  virtual bool etaConverged( void );
260  
261 <  // chi and eta are the propagated degrees of freedom
261 >  virtual void scaleSimBox( void );
262  
263 <  double chi;
264 <  double eta;
265 <  double NkBT;
266 <  double integralOfChidt;
263 >  virtual void getVelScaleA( double sc[3], double vel[3] );
264 >  virtual void getVelScaleB( double sc[3], int index );
265 >  virtual void getPosScale(double pos[3], double COM[3],
266 >                           int index, double sc[3]);
267  
268 <  // targetTemp, targetPressure, and tauBarostat must be set.  
253 <  // One of qmass or tauThermostat must be set;
254 <
255 <  double targetTemp;
256 <  double targetPressure;
257 <  double tauThermostat;
258 <  double tauBarostat;
259 <
260 <  short int have_tau_thermostat, have_tau_barostat, have_target_temp;
261 <  short int have_target_pressure;
262 <  double chiTolerance;
263 <  short int have_chi_tolerance;
264 <  double posIterTolerance;
265 <  short int have_pos_iter_tolerance;
266 <
267 < };
268 <
269 < template<typename T> class NPTzm : public T{
270 <
271 < public:
272 <
273 <  NPTzm ( SimInfo *theInfo, ForceFields* the_ff);
274 <  virtual ~NPTzm() {};
275 <
276 <  virtual void integrateStep( int calcPot, int calcStress ){
277 <    calcStress = 1;
278 <    T::integrateStep( calcPot, calcStress );
279 <  }
268 >  virtual void calcVelScale( void );
269  
270 <  void setTauThermostat(double tt) {tauThermostat = tt; have_tau_thermostat=1;}
271 <  void setTauBarostat(double tb) {tauBarostat = tb; have_tau_barostat=1;}
283 <  void setTargetTemp(double tt) {targetTemp = tt; have_target_temp = 1;}
284 <  void setTargetPressure(double tp) {targetPressure = tp; have_target_pressure = 1;}
285 <
286 < protected:
287 <
288 <  virtual void moveA( void );
289 <  virtual void moveB( void );
290 <
291 <  virtual int readyCheck();
292 <
293 <  virtual void resetIntegrator( void );
294 <
295 <  Molecule* myMolecules;
296 <  Atom** myAtoms;
297 <
298 <  // chi and eta are the propagated degrees of freedom
299 <
300 <  double chi;
301 <  double eta;
302 <  double etaZ;
303 <  double NkBT;
304 <
305 <  // targetTemp, targetPressure, and tauBarostat must be set.  
306 <  // One of qmass or tauThermostat must be set;
307 <
308 <  double targetTemp;
309 <  double targetPressure;
310 <  double tauThermostat;
311 <  double tauBarostat;
312 <
313 <  short int have_tau_thermostat, have_tau_barostat, have_target_temp;
314 <  short int have_target_pressure;
315 <
270 >  double eta, oldEta, prevEta;
271 >  double vScale;
272   };
273  
274   template<typename T> class NPTf : public T{
# Line 320 | Line 276 | template<typename T> class NPTf : public T{ (public)
276   public:
277  
278    NPTf ( SimInfo *theInfo, ForceFields* the_ff);
279 <  virtual ~NPTf() {};
279 >  virtual ~NPTf();
280  
325  virtual void integrateStep( int calcPot, int calcStress ){
326    calcStress = 1;
327    T::integrateStep( calcPot, calcStress );
328    accIntegralOfChidt();
329  }
330  
281    virtual double getConservedQuantity(void);
282 +  virtual string getAdditionalParameters(void);
283 +  virtual void resetIntegrator(void);
284  
333  void setTauThermostat(double tt) {tauThermostat = tt; have_tau_thermostat=1;}
334  void setTauBarostat(double tb) {tauBarostat = tb; have_tau_barostat=1;}
335  void setTargetTemp(double tt) {targetTemp = tt; have_target_temp = 1;}
336  void setTargetPressure(double tp) {targetPressure = tp; have_target_pressure = 1;}
337  void setChiTolerance(double tol) {chiTolerance = tol;}
338  void setPosIterTolerance(double tol) {posIterTolerance = tol;}
339
285   protected:
286  
287 <  virtual void  moveA( void );
288 <  virtual void moveB( void );
287 >  virtual void evolveEtaA(void);
288 >  virtual void evolveEtaB(void);
289  
290 <  virtual void resetIntegrator( void );
290 >  virtual bool etaConverged( void );
291  
292 <  virtual int readyCheck();
292 >  virtual void scaleSimBox( void );
293  
294 <  void accIntegralOfChidt(void) { integralOfChidt += dt * chi;}
294 >  virtual void getVelScaleA( double sc[3], double vel[3] );
295 >  virtual void getVelScaleB( double sc[3], int index );
296 >  virtual void getPosScale(double pos[3], double COM[3],
297 >                           int index, double sc[3]);
298  
299 <  // chi and eta are the propagated degrees of freedom
299 >  virtual void calcVelScale( void );
300  
353  double chi;
301    double eta[3][3];
302 <  double NkBT;
303 <
304 <  double integralOfChidt;
358 <  
359 <  // targetTemp, targetPressure, and tauBarostat must be set.  
360 <  // One of qmass or tauThermostat must be set;
361 <
362 <  double targetTemp;
363 <  double targetPressure;
364 <  double tauThermostat;
365 <  double tauBarostat;
366 <
367 <  short int have_tau_thermostat, have_tau_barostat, have_target_temp;
368 <  short int have_target_pressure;
369 <  double chiTolerance;
370 <  short int have_chi_tolerance;
371 <  double posIterTolerance;
372 <  short int have_pos_iter_tolerance;
373 <
302 >  double oldEta[3][3];
303 >  double prevEta[3][3];
304 >  double vScale[3][3];
305   };
306  
307 < template<typename T> class NPTxym : public T{
307 > template<typename T> class NPTxyz : public T{
308  
309   public:
310  
311 <  NPTxym ( SimInfo *theInfo, ForceFields* the_ff);
312 <  virtual ~NPTxym() {};
311 >  NPTxyz ( SimInfo *theInfo, ForceFields* the_ff);
312 >  virtual ~NPTxyz();
313  
314 <  virtual void integrateStep( int calcPot, int calcStress ){
315 <    calcStress = 1;
316 <    T::integrateStep( calcPot, calcStress );
386 <  }
314 >  virtual double getConservedQuantity(void);
315 >  virtual string getAdditionalParameters(void);
316 >  virtual void resetIntegrator(void);
317  
388  void setTauThermostat(double tt) {tauThermostat = tt; have_tau_thermostat=1;}
389  void setTauBarostat(double tb) {tauBarostat = tb; have_tau_barostat=1;}
390  void setTargetTemp(double tt) {targetTemp = tt; have_target_temp = 1;}
391  void setTargetPressure(double tp) {targetPressure = tp; have_target_pressure = 1;}
392
318   protected:
319  
320 <  virtual void moveA( void );
321 <  virtual void moveB( void );
320 >  virtual void evolveEtaA(void);
321 >  virtual void evolveEtaB(void);
322  
323 <  virtual int readyCheck();
323 >  virtual bool etaConverged( void );
324  
325 <  virtual void resetIntegrator( void );
325 >  virtual void scaleSimBox( void );
326  
327 <  Molecule* myMolecules;
328 <  Atom** myAtoms;
327 >  virtual void getVelScaleA( double sc[3], double vel[3] );
328 >  virtual void getVelScaleB( double sc[3], int index );
329 >  virtual void getPosScale(double pos[3], double COM[3],
330 >                           int index, double sc[3]);
331  
332 <  // chi and eta are the propagated degrees of freedom
332 >  virtual void calcVelScale( void );
333  
407  double chi;
408  double eta;
409  double etaX;
410  double etaY;
411  double NkBT;
412
413  // targetTemp, targetPressure, and tauBarostat must be set.  
414  // One of qmass or tauThermostat must be set;
415
416  double targetTemp;
417  double targetPressure;
418  double tauThermostat;
419  double tauBarostat;
420
421  short int have_tau_thermostat, have_tau_barostat, have_target_temp;
422  short int have_target_pressure;
423
424 };
425
426
427 template<typename T> class NPTfm : public T{
428
429 public:
430
431  NPTfm ( SimInfo *theInfo, ForceFields* the_ff);
432  virtual ~NPTfm() {};
433
434  virtual void integrateStep( int calcPot, int calcStress ){
435    calcStress = 1;
436    T::integrateStep( calcPot, calcStress );
437    accIntegralOfChidt();
438  }
439
440  virtual double getConservedQuantity(void);
441  
442  void setTauThermostat(double tt) {tauThermostat = tt; have_tau_thermostat=1;}
443  void setTauBarostat(double tb) {tauBarostat = tb; have_tau_barostat=1;}
444  void setTargetTemp(double tt) {targetTemp = tt; have_target_temp = 1;}
445  void setTargetPressure(double tp) {targetPressure = tp; have_target_pressure = 1;}
446  void setChiTolerance(double tol) {chiTolerance = tol;}
447  void setPosIterTolerance(double tol) {posIterTolerance = tol;}
448
449 protected:
450
451  virtual void  moveA( void );
452  virtual void moveB( void );
453
454  virtual void resetIntegrator( void );
455
456  virtual int readyCheck();
457
458  void accIntegralOfChidt(void) { integralOfChidt += dt * chi;}
459
460  Molecule* myMolecules;
461  Atom** myAtoms;
462
463  // chi and eta are the propagated degrees of freedom
464
465  double chi;
334    double eta[3][3];
335 <  double NkBT;
336 <  double integralOfChidt;
337 <
470 <  // targetTemp, targetPressure, and tauBarostat must be set.  
471 <  // One of qmass or tauThermostat must be set;
472 <
473 <  double targetTemp;
474 <  double targetPressure;
475 <  double tauThermostat;
476 <  double tauBarostat;
477 <
478 <  short int have_tau_thermostat, have_tau_barostat, have_target_temp;
479 <  short int have_target_pressure;
480 <  double chiTolerance;
481 <  short int have_chi_tolerance;
482 <  double posIterTolerance;
483 <  short int have_pos_iter_tolerance;
484 <
335 >  double oldEta[3][3];
336 >  double prevEta[3][3];
337 >  double vScale[3][3];
338   };
339  
340  
488 template<typename T> class NPTpr : public T{
489
490 public:
491
492  NPTpr ( SimInfo *theInfo, ForceFields* the_ff);
493  virtual ~NPTpr() {};
494
495  virtual void integrateStep( int calcPot, int calcStress ){
496    calcStress = 1;
497    T::integrateStep( calcPot, calcStress );
498  }
499
500  void setTauThermostat(double tt) {tauThermostat = tt; have_tau_thermostat=1;}
501  void setTauBarostat(double tb) {tauBarostat = tb; have_tau_barostat=1;}
502  void setTargetTemp(double tt) {targetTemp = tt; have_target_temp = 1;}
503  void setTargetPressure(double tp) {targetPressure = tp; have_target_pressure = 1;}
504  void setChiTolerance(double tol) {chiTolerance = tol;}
505  void setPosIterTolerance(double tol) {posIterTolerance = tol;}
506
507 protected:
508
509  virtual void  moveA( void );
510  virtual void moveB( void );
511
512  virtual int readyCheck();
513
514  virtual void resetIntegrator( void );
515
516  // chi and eta are the propagated degrees of freedom
517
518  double chi;
519  double eta[3][3];
520  double NkBT;
521
522  // targetTemp, targetPressure, and tauBarostat must be set.  
523  // One of qmass or tauThermostat must be set;
524
525  double targetTemp;
526  double targetPressure;
527  double tauThermostat;
528  double tauBarostat;
529
530  short int have_tau_thermostat, have_tau_barostat, have_target_temp;
531  short int have_target_pressure;
532  double chiTolerance;
533  short int have_chi_tolerance;
534  double posIterTolerance;
535  short int have_pos_iter_tolerance;
536
537 };
538
539
341   template<typename T> class ZConstraint : public T {
342 <  
343 <  public:
342 >
343 >  public:
344    class ForceSubtractionPolicy{
345      public:
346        ForceSubtractionPolicy(ZConstraint<T>* integrator) {zconsIntegrator = integrator;}
347  
348 <      virtual void update() = 0;    
348 >      virtual void update() = 0;
349        virtual double getZFOfFixedZMols(Molecule* mol, Atom* atom, double totalForce) = 0;
350        virtual double getZFOfMovingMols(Atom* atom, double totalForce) = 0;
351        virtual double getHFOfFixedZMols(Molecule* mol, Atom* atom, double totalForce) = 0;
352        virtual double getHFOfUnconsMols(Atom* atom, double totalForce) = 0;
353 <    
353 >
354     protected:
355 <     ZConstraint<T>* zconsIntegrator;;
355 >     ZConstraint<T>* zconsIntegrator;
356    };
357  
358    class PolicyByNumber : public ForceSubtractionPolicy{
359  
360      public:
361 <      PolicyByNumber(ZConstraint<T>* integrator) :ForceSubtractionPolicy(integrator) {}    
362 <      virtual void update();    
361 >      PolicyByNumber(ZConstraint<T>* integrator) :ForceSubtractionPolicy(integrator) {}
362 >      virtual void update();
363        virtual double getZFOfFixedZMols(Molecule* mol, Atom* atom, double totalForce) ;
364        virtual double getZFOfMovingMols(Atom* atom, double totalForce) ;
365        virtual double getHFOfFixedZMols(Molecule* mol, Atom* atom, double totalForce);
366        virtual double getHFOfUnconsMols(Atom* atom, double totalForce);
367 <    
367 >
368      private:
369        int totNumOfMovingAtoms;
370    };
# Line 571 | Line 372 | template<typename T> class ZConstraint : public T {
372    class PolicyByMass : public ForceSubtractionPolicy{
373  
374      public:
375 <      PolicyByMass(ZConstraint<T>* integrator) :ForceSubtractionPolicy(integrator) {}  
376 <      
377 <      virtual void update();    
375 >      PolicyByMass(ZConstraint<T>* integrator) :ForceSubtractionPolicy(integrator) {}
376 >
377 >      virtual void update();
378        virtual double getZFOfFixedZMols(Molecule* mol, Atom* atom, double totalForce) ;
379        virtual double getZFOfMovingMols(Atom* atom, double totalForce) ;
380        virtual double getHFOfFixedZMols(Molecule* mol, Atom* atom, double totalForce);
# Line 587 | Line 388 | template<typename T> class ZConstraint : public T {
388  
389    ZConstraint( SimInfo *theInfo, ForceFields* the_ff);
390    ~ZConstraint();
391 <    
391 >
392    void setZConsTime(double time)                  {this->zconsTime = time;}
393    void getZConsTime()                             {return zconsTime;}
394 <  
394 >
395    void setIndexOfAllZConsMols(vector<int> index) {indexOfAllZConsMols = index;}
396    void getIndexOfAllZConsMols()                  {return indexOfAllZConsMols;}
397 <  
397 >
398    void setZConsOutput(const char * fileName)          {zconsOutput = fileName;}
399    string getZConsOutput()                         {return zconsOutput;}
400 <  
400 >
401    virtual void integrate();
601  
402  
403 +
404   #ifdef IS_MPI
405    virtual void update();                      //which is called to indicate the molecules' migration
406   #endif
407  
408 +  enum ZConsState {zcsMoving, zcsFixed};
409 +
410 +  vector<Molecule*> zconsMols;              //z-constraint molecules array
411 +  vector<ZConsState> states;                 //state of z-constraint molecules
412 +
413 +
414 +
415 +  int totNumOfUnconsAtoms;              //total number of uncontraint atoms
416 +  double totalMassOfUncons;                //total mas of unconstraint molecules
417 +
418 +
419   protected:
420  
421 <  enum ZConsState {zcsMoving, zcsFixed};  
422 <
423 <  virtual void calcForce( int calcPot, int calcStress );
421 >
422 >
423 >  virtual void calcForce( int calcPot, int calcStress );
424    virtual void thermalize(void);
425 <  
425 >
426    void zeroOutVel();
427    void doZconstraintForce();
428 <  void doHarmonic();
428 >  void doHarmonic(vector<double>& resPos);
429    bool checkZConsState();
430  
431    bool haveFixedZMols();
# Line 628 | Line 440 | template<typename T> class ZConstraint : public T {
440    double zconsTol;                                 //tolerance of z-contratint
441    double zForceConst;                           //base force constant term
442                                                            //which is estimate by OOPSE
443 <  
444 <  vector<Molecule*> zconsMols;              //z-constraint molecules array
445 <  vector<double> massOfZConsMols;       //mass of z-constraint molecule
443 >
444 >
445 >  vector<double> massOfZConsMols;       //mass of z-constraint molecule
446    vector<double> kz;                              //force constant array
447 <  vector<ZConsState> states;                 //state of z-constraint molecules
447 >
448    vector<double> zPos;                          //
449 <  
450 <  
449 >
450 >
451    vector<Molecule*> unconsMols;           //unconstraint molecules array
452    vector<double> massOfUnconsMols;    //mass array of unconstraint molecules
641  double totalMassOfUncons;                //total mas of unconstraint molecules
453  
454 +
455    vector<ZConsParaItem>* parameters; //
456 <  
456 >
457    vector<int> indexOfAllZConsMols;     //index of All Z-Constraint Molecuels
458  
459 <  int* indexOfZConsMols;                   //index of local Z-Constraint Molecules  
460 <  double* fz;
461 <  double* curZPos;
650 <  
651 <  int totNumOfUnconsAtoms;              //total number of uncontraint atoms
459 >  vector<int> indexOfZConsMols;                   //index of local Z-Constraint Molecules
460 >  vector<double> fz;
461 >  vector<double> curZPos;
462  
463 <  int whichDirection;                           //constraint direction
463 >  bool usingSMD;
464 >  vector<double> prevCantPos;
465 >  vector<double> cantPos;
466 >  vector<double> cantVel;
467 >
468 >  double zconsFixTime;  
469 >  double zconsGap;
470 >  bool hasZConsGap;
471 >  vector<double> endFixTime;
472    
473 +  int whichDirection;                           //constraint direction
474 +
475   private:
476 <  
476 >
477    string zconsOutput;                         //filename of zconstraint output
478    ZConsWriter* fzOut;                         //z-constraint writer
479  
480 <  double curZconsTime;                      
480 >  double curZconsTime;
481  
482    double calcMovingMolsCOMVel();
483    double calcSysCOMVel();
484    double calcTotalForce();
485 +  void updateZPos();
486 +  void updateCantPos();
487    
488    ForceSubtractionPolicy* forcePolicy; //force subtraction policy
489    friend class ForceSubtractionPolicy;
490  
491   };
492  
493 + /*
494 + template<typename T> class SingleZConstrain : public T{
495 +
496 +
497 + };
498 + */
499 +
500 + template<typename T> class NonEquMD : public T {
501 +  public:
502 +    
503 +
504 +
505 + };
506 +
507 +
508 + //
509 + template<typename T> class SingleZConstraint : public T{
510 +  public:
511 +    SingleZConstraint(SimInfo *theInfo, ForceFields* the_ff);
512 +    ~SingleZConstraint();
513 +    
514 +    bool stopIntegrator();
515 +    
516 +  protected:
517 +    
518 + };
519 +
520 + //Steered Molecular Dynamics, curret implement only support one steered molecule
521 + template<typename T> class SMD : public T{
522 +  public:
523 +    SMD( SimInfo *theInfo, ForceFields* the_ff);
524 +    ~SMD();
525 +  
526 +    virtual void integrate();
527 +    virtual void calcForce( int calcPot, int calcStress );  
528 +    bool stopIntegrator();
529 +  private:
530 +    
531 + };
532 +
533 + //By using state pattern, Coordinate Drive is responsible for switching back and forth between
534 + //Driven Molecular Dynamics and ZConstraint Method.
535 + template<typename T> class CoordinateDriver : public T {
536 +  public:
537 +    typedef T ParentIntegrator;
538 +
539 +    CoordinateDriver(SimInfo*, ForceFields*, BaseIntegrator*, BaseIntegrator*);
540 +    ~CoordinateDriver();
541 +    
542 +    virtual void integrate();
543 +
544 +  private:    
545 +    BaseIntegrator* zconsIntegrator;
546 +    BaseIntegrator* drivenIntegrator;
547 +    
548 + };
549 +
550   #endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines