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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines