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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines