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 780 by mmeineke, Mon Sep 22 21:23:25 2003 UTC vs.
Revision 857 by mmeineke, Fri Nov 7 17:09:48 2003 UTC

# 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  
# 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 void rotationPropagation( DirectionalAtom* dAtom, double ji[3] );
49  
50    void checkConstraints( void );
51 <  void rotate( int axes1, int axes2, double angle, double j[3],
51 >  void rotate( int axes1, int axes2, double angle, double j[3],
52           double A[3][3] );
53 <        
53 >
54    ForceFields* myFF;
55  
56    SimInfo *info; // all the info we'll ever need
# Line 61 | Line 62 | template<typename T = BaseIntegrator> class Integrator
62  
63    int isConstrained; // boolean to know whether the systems contains
64           // constraints.
65 <  int nConstrained;  // counter for number of constraints
66 <  int *constrainedA; // the i of a constraint pair
67 <  int *constrainedB; // the j of a constraint pair
68 <  double *constrainedDsqr; // the square of the constraint distance
69 <  
65 >  int nConstrained;  // counter for number of constraints
66 >  int *constrainedA; // the i of a constraint pair
67 >  int *constrainedB; // the j of a constraint pair
68 >  double *constrainedDsqr; // the square of the constraint distance
69 >
70    int* moving; // tells whether we are moving atom i
71    int* moved;  // tells whether we have moved atom i
72 <  double* oldPos; // pre constrained positions
72 >  double* oldPos; // pre constrained positions
73  
74    short isFirst; /*boolean for the first time integrate is called */
75 <  
75 >
76    double dt;
77    double dt2;
78  
79    Thermo *tStats;
80    StatWriter*  statOut;
81    DumpWriter*  dumpOut;
82 <  
82 >
83   };
84  
85   typedef Integrator<BaseIntegrator> RealIntegrator;
# Line 88 | Line 89 | template<typename T> class NVE : public T { (public)
89   public:
90    NVE ( SimInfo *theInfo, ForceFields* the_ff ):
91      T( theInfo, the_ff ){}
92 <  virtual ~NVE(){}  
92 >  virtual ~NVE(){}
93   };
94  
95  
# Line 103 | Line 104 | template<typename T> class NVT : public T { (public)
104    void setTargetTemp(double tt) {targetTemp = tt; have_target_temp = 1;}
105    void setChiTolerance(double tol) {chiTolerance = tol;}
106    virtual double  getConservedQuantity(void);
107 +  virtual string getAdditionalParameters(void);
108  
109   protected:
110  
# Line 124 | Line 126 | template<typename T> class NVT : public T { (public)
126  
127    double targetTemp;
128    double tauThermostat;
129 <  
129 >
130    short int have_tau_thermostat, have_target_temp;
131  
132    double *oldVel;
# Line 143 | Line 145 | template<typename T> class NPT : public T{ (public)
145  
146    NPT ( SimInfo *theInfo, ForceFields* the_ff);
147    virtual ~NPT();
148 <  
148 >
149    virtual void integrateStep( int calcPot, int calcStress ){
150      calcStress = 1;
151      T::integrateStep( calcPot, calcStress );
152    }
153  
154    virtual double getConservedQuantity(void) = 0;
155 +  virtual string getAdditionalParameters(void) = 0;
156 +  
157 +  double myTauThermo( void ) { return tauThermostat; }
158 +  double myTauBaro( void ) { return tauBarostat; }
159  
160    void setTauThermostat(double tt) {tauThermostat = tt; have_tau_thermostat=1;}
161    void setTauBarostat(double tb) {tauBarostat = tb; have_tau_barostat=1;}
# Line 170 | Line 176 | template<typename T> class NPT : public T{ (public)
176  
177    virtual void getVelScaleA( double sc[3], double vel[3] ) = 0;
178    virtual void getVelScaleB( double sc[3], int index ) = 0;
179 <  virtual void getPosScale(double pos[3], double COM[3],
179 >  virtual void getPosScale(double pos[3], double COM[3],
180                             int index, double sc[3]) = 0;
181  
182 +  virtual void calcVelScale( void ) = 0;
183 +
184    virtual bool chiConverged( void );
185    virtual bool etaConverged( void ) = 0;
186 <  
186 >
187    virtual void evolveChiA( void );
188    virtual void evolveEtaA( void ) = 0;
189    virtual void evolveChiB( void );
# Line 201 | Line 209 | template<typename T> class NPT : public T{ (public)
209  
210    double integralOfChidt;
211  
212 <  // targetTemp, targetPressure, and tauBarostat must be set.  
212 >  // targetTemp, targetPressure, and tauBarostat must be set.
213    // One of qmass or tauThermostat must be set;
214  
215    double targetTemp;
# Line 226 | Line 234 | template<typename T> class NPTi : public T{
234   };
235  
236   template<typename T> class NPTi : public T{
237 <  
237 >
238   public:
239    NPTi( SimInfo *theInfo, ForceFields* the_ff);
240    ~NPTi();
241  
242    virtual double getConservedQuantity(void);
243    virtual void resetIntegrator(void);
244 <
244 >  virtual string getAdditionalParameters(void);
245   protected:
246  
239
247  
248 +
249    virtual void evolveEtaA(void);
250    virtual void evolveEtaB(void);
251  
# Line 247 | Line 255 | template<typename T> class NPTi : public T{
255  
256    virtual void getVelScaleA( double sc[3], double vel[3] );
257    virtual void getVelScaleB( double sc[3], int index );
258 <  virtual void getPosScale(double pos[3], double COM[3],
258 >  virtual void getPosScale(double pos[3], double COM[3],
259                             int index, double sc[3]);
260  
261 <  double eta, oldEta, prevEta;
254 < };
261 >  virtual void calcVelScale( void );
262  
263 < template<typename T> class NPTzm : public T{
264 <
258 < public:
259 <
260 <  NPTzm ( SimInfo *theInfo, ForceFields* the_ff);
261 <  virtual ~NPTzm() {};
262 <
263 <  virtual void integrateStep( int calcPot, int calcStress ){
264 <    calcStress = 1;
265 <    T::integrateStep( calcPot, calcStress );
266 <  }
267 <
268 <  void setTauThermostat(double tt) {tauThermostat = tt; have_tau_thermostat=1;}
269 <  void setTauBarostat(double tb) {tauBarostat = tb; have_tau_barostat=1;}
270 <  void setTargetTemp(double tt) {targetTemp = tt; have_target_temp = 1;}
271 <  void setTargetPressure(double tp) {targetPressure = tp; have_target_pressure = 1;}
272 <
273 < protected:
274 <
275 <  virtual void moveA( void );
276 <  virtual void moveB( void );
277 <
278 <  virtual int readyCheck();
279 <
280 <  virtual void resetIntegrator( void );
281 <
282 <  Molecule* myMolecules;
283 <  Atom** myAtoms;
284 <
285 <  // chi and eta are the propagated degrees of freedom
286 <
287 <  double chi;
288 <  double eta;
289 <  double etaZ;
290 <  double NkBT;
291 <
292 <  // targetTemp, targetPressure, and tauBarostat must be set.  
293 <  // One of qmass or tauThermostat must be set;
294 <
295 <  double targetTemp;
296 <  double targetPressure;
297 <  double tauThermostat;
298 <  double tauBarostat;
299 <
300 <  short int have_tau_thermostat, have_tau_barostat, have_target_temp;
301 <  short int have_target_pressure;
302 <
263 >  double eta, oldEta, prevEta;
264 >  double vScale;
265   };
266  
267   template<typename T> class NPTf : public T{
# Line 310 | Line 272 | template<typename T> class NPTf : public T{ (public)
272    virtual ~NPTf();
273  
274    virtual double getConservedQuantity(void);
275 +  virtual string getAdditionalParameters(void);
276    virtual void resetIntegrator(void);
277  
278   protected:
# Line 323 | Line 286 | template<typename T> class NPTf : public T{ (public)
286  
287    virtual void getVelScaleA( double sc[3], double vel[3] );
288    virtual void getVelScaleB( double sc[3], int index );
289 <  virtual void getPosScale(double pos[3], double COM[3],
289 >  virtual void getPosScale(double pos[3], double COM[3],
290                             int index, double sc[3]);
291  
292 +  virtual void calcVelScale( void );
293 +
294    double eta[3][3];
295    double oldEta[3][3];
296    double prevEta[3][3];
297 +  double vScale[3][3];
298   };
299  
300 < template<typename T> class NPTxym : public T{
300 > template<typename T> class NPTxyz : public T{
301  
302   public:
303  
304 <  NPTxym ( SimInfo *theInfo, ForceFields* the_ff);
305 <  virtual ~NPTxym() {};
304 >  NPTxyz ( SimInfo *theInfo, ForceFields* the_ff);
305 >  virtual ~NPTxyz();
306  
307 <  virtual void integrateStep( int calcPot, int calcStress ){
308 <    calcStress = 1;
309 <    T::integrateStep( calcPot, calcStress );
344 <  }
307 >  virtual double getConservedQuantity(void);
308 >  virtual string getAdditionalParameters(void);
309 >  virtual void resetIntegrator(void);
310  
346  void setTauThermostat(double tt) {tauThermostat = tt; have_tau_thermostat=1;}
347  void setTauBarostat(double tb) {tauBarostat = tb; have_tau_barostat=1;}
348  void setTargetTemp(double tt) {targetTemp = tt; have_target_temp = 1;}
349  void setTargetPressure(double tp) {targetPressure = tp; have_target_pressure = 1;}
350
311   protected:
312  
313 <  virtual void moveA( void );
314 <  virtual void moveB( void );
313 >  virtual void evolveEtaA(void);
314 >  virtual void evolveEtaB(void);
315  
316 <  virtual int readyCheck();
316 >  virtual bool etaConverged( void );
317  
318 <  virtual void resetIntegrator( void );
318 >  virtual void scaleSimBox( void );
319  
320 <  Molecule* myMolecules;
321 <  Atom** myAtoms;
320 >  virtual void getVelScaleA( double sc[3], double vel[3] );
321 >  virtual void getVelScaleB( double sc[3], int index );
322 >  virtual void getPosScale(double pos[3], double COM[3],
323 >                           int index, double sc[3]);
324  
325 <  // chi and eta are the propagated degrees of freedom
364 <
365 <  double chi;
366 <  double eta;
367 <  double etaX;
368 <  double etaY;
369 <  double NkBT;
370 <
371 <  // targetTemp, targetPressure, and tauBarostat must be set.  
372 <  // One of qmass or tauThermostat must be set;
373 <
374 <  double targetTemp;
375 <  double targetPressure;
376 <  double tauThermostat;
377 <  double tauBarostat;
378 <
379 <  short int have_tau_thermostat, have_tau_barostat, have_target_temp;
380 <  short int have_target_pressure;
381 <
382 < };
383 <
384 <
385 < template<typename T> class NPTfm : public T{
386 <
387 < public:
388 <
389 <  NPTfm ( SimInfo *theInfo, ForceFields* the_ff);
390 <  virtual ~NPTfm() {};
391 <
392 <  virtual void integrateStep( int calcPot, int calcStress ){
393 <    calcStress = 1;
394 <    T::integrateStep( calcPot, calcStress );
395 <    accIntegralOfChidt();
396 <  }
397 <
398 <  virtual double getConservedQuantity(void);
399 <  
400 <  void setTauThermostat(double tt) {tauThermostat = tt; have_tau_thermostat=1;}
401 <  void setTauBarostat(double tb) {tauBarostat = tb; have_tau_barostat=1;}
402 <  void setTargetTemp(double tt) {targetTemp = tt; have_target_temp = 1;}
403 <  void setTargetPressure(double tp) {targetPressure = tp; have_target_pressure = 1;}
404 <  void setChiTolerance(double tol) {chiTolerance = tol;}
405 <  void setPosIterTolerance(double tol) {posIterTolerance = tol;}
406 <
407 < protected:
325 >  virtual void calcVelScale( void );
326  
409  virtual void  moveA( void );
410  virtual void moveB( void );
411
412  virtual void resetIntegrator( void );
413
414  virtual int readyCheck();
415
416  void accIntegralOfChidt(void) { integralOfChidt += dt * chi;}
417
418  Molecule* myMolecules;
419  Atom** myAtoms;
420
421  // chi and eta are the propagated degrees of freedom
422
423  double chi;
327    double eta[3][3];
328 <  double NkBT;
329 <  double integralOfChidt;
330 <
428 <  // targetTemp, targetPressure, and tauBarostat must be set.  
429 <  // One of qmass or tauThermostat must be set;
430 <
431 <  double targetTemp;
432 <  double targetPressure;
433 <  double tauThermostat;
434 <  double tauBarostat;
435 <
436 <  short int have_tau_thermostat, have_tau_barostat, have_target_temp;
437 <  short int have_target_pressure;
438 <  double chiTolerance;
439 <  short int have_chi_tolerance;
440 <  double posIterTolerance;
441 <  short int have_pos_iter_tolerance;
442 <
328 >  double oldEta[3][3];
329 >  double prevEta[3][3];
330 >  double vScale[3][3];
331   };
332  
333  
446 template<typename T> class NPTpr : public T{
447
448 public:
449
450  NPTpr ( SimInfo *theInfo, ForceFields* the_ff);
451  virtual ~NPTpr() {};
452
453  virtual void integrateStep( int calcPot, int calcStress ){
454    calcStress = 1;
455    T::integrateStep( calcPot, calcStress );
456  }
457
458  void setTauThermostat(double tt) {tauThermostat = tt; have_tau_thermostat=1;}
459  void setTauBarostat(double tb) {tauBarostat = tb; have_tau_barostat=1;}
460  void setTargetTemp(double tt) {targetTemp = tt; have_target_temp = 1;}
461  void setTargetPressure(double tp) {targetPressure = tp; have_target_pressure = 1;}
462  void setChiTolerance(double tol) {chiTolerance = tol;}
463  void setPosIterTolerance(double tol) {posIterTolerance = tol;}
464
465 protected:
466
467  virtual void  moveA( void );
468  virtual void moveB( void );
469
470  virtual int readyCheck();
471
472  virtual void resetIntegrator( void );
473
474  // chi and eta are the propagated degrees of freedom
475
476  double chi;
477  double eta[3][3];
478  double NkBT;
479
480  // targetTemp, targetPressure, and tauBarostat must be set.  
481  // One of qmass or tauThermostat must be set;
482
483  double targetTemp;
484  double targetPressure;
485  double tauThermostat;
486  double tauBarostat;
487
488  short int have_tau_thermostat, have_tau_barostat, have_target_temp;
489  short int have_target_pressure;
490  double chiTolerance;
491  short int have_chi_tolerance;
492  double posIterTolerance;
493  short int have_pos_iter_tolerance;
494
495 };
496
497
334   template<typename T> class ZConstraint : public T {
335 <  
336 <  public:
335 >
336 >  public:
337    class ForceSubtractionPolicy{
338      public:
339        ForceSubtractionPolicy(ZConstraint<T>* integrator) {zconsIntegrator = integrator;}
340  
341 <      virtual void update() = 0;    
341 >      virtual void update() = 0;
342        virtual double getZFOfFixedZMols(Molecule* mol, Atom* atom, double totalForce) = 0;
343        virtual double getZFOfMovingMols(Atom* atom, double totalForce) = 0;
344        virtual double getHFOfFixedZMols(Molecule* mol, Atom* atom, double totalForce) = 0;
345        virtual double getHFOfUnconsMols(Atom* atom, double totalForce) = 0;
346 <    
346 >
347     protected:
348 <     ZConstraint<T>* zconsIntegrator;;
348 >     ZConstraint<T>* zconsIntegrator;
349    };
350  
351    class PolicyByNumber : public ForceSubtractionPolicy{
352  
353      public:
354 <      PolicyByNumber(ZConstraint<T>* integrator) :ForceSubtractionPolicy(integrator) {}    
355 <      virtual void update();    
354 >      PolicyByNumber(ZConstraint<T>* integrator) :ForceSubtractionPolicy(integrator) {}
355 >      virtual void update();
356        virtual double getZFOfFixedZMols(Molecule* mol, Atom* atom, double totalForce) ;
357        virtual double getZFOfMovingMols(Atom* atom, double totalForce) ;
358        virtual double getHFOfFixedZMols(Molecule* mol, Atom* atom, double totalForce);
359        virtual double getHFOfUnconsMols(Atom* atom, double totalForce);
360 <    
360 >
361      private:
362        int totNumOfMovingAtoms;
363    };
# Line 529 | Line 365 | template<typename T> class ZConstraint : public T {
365    class PolicyByMass : public ForceSubtractionPolicy{
366  
367      public:
368 <      PolicyByMass(ZConstraint<T>* integrator) :ForceSubtractionPolicy(integrator) {}  
369 <      
370 <      virtual void update();    
368 >      PolicyByMass(ZConstraint<T>* integrator) :ForceSubtractionPolicy(integrator) {}
369 >
370 >      virtual void update();
371        virtual double getZFOfFixedZMols(Molecule* mol, Atom* atom, double totalForce) ;
372        virtual double getZFOfMovingMols(Atom* atom, double totalForce) ;
373        virtual double getHFOfFixedZMols(Molecule* mol, Atom* atom, double totalForce);
# Line 545 | Line 381 | template<typename T> class ZConstraint : public T {
381  
382    ZConstraint( SimInfo *theInfo, ForceFields* the_ff);
383    ~ZConstraint();
384 <    
384 >
385    void setZConsTime(double time)                  {this->zconsTime = time;}
386    void getZConsTime()                             {return zconsTime;}
387 <  
387 >
388    void setIndexOfAllZConsMols(vector<int> index) {indexOfAllZConsMols = index;}
389    void getIndexOfAllZConsMols()                  {return indexOfAllZConsMols;}
390 <  
390 >
391    void setZConsOutput(const char * fileName)          {zconsOutput = fileName;}
392    string getZConsOutput()                         {return zconsOutput;}
393 <  
393 >
394    virtual void integrate();
559  
395  
396 +
397   #ifdef IS_MPI
398    virtual void update();                      //which is called to indicate the molecules' migration
399   #endif
400  
401 +  enum ZConsState {zcsMoving, zcsFixed};
402 +
403 +  vector<Molecule*> zconsMols;              //z-constraint molecules array
404 +  vector<ZConsState> states;                 //state of z-constraint molecules
405 +
406 +
407 +
408 +  int totNumOfUnconsAtoms;              //total number of uncontraint atoms
409 +  double totalMassOfUncons;                //total mas of unconstraint molecules
410 +
411 +
412   protected:
413  
414 <  enum ZConsState {zcsMoving, zcsFixed};  
415 <
416 <  virtual void calcForce( int calcPot, int calcStress );
414 >
415 >
416 >  virtual void calcForce( int calcPot, int calcStress );
417    virtual void thermalize(void);
418 <  
418 >
419    void zeroOutVel();
420    void doZconstraintForce();
421    void doHarmonic();
# Line 586 | Line 433 | template<typename T> class ZConstraint : public T {
433    double zconsTol;                                 //tolerance of z-contratint
434    double zForceConst;                           //base force constant term
435                                                            //which is estimate by OOPSE
436 <  
437 <  vector<Molecule*> zconsMols;              //z-constraint molecules array
438 <  vector<double> massOfZConsMols;       //mass of z-constraint molecule
436 >
437 >
438 >  vector<double> massOfZConsMols;       //mass of z-constraint molecule
439    vector<double> kz;                              //force constant array
440 <  vector<ZConsState> states;                 //state of z-constraint molecules
440 >
441    vector<double> zPos;                          //
442 <  
443 <  
442 >
443 >
444    vector<Molecule*> unconsMols;           //unconstraint molecules array
445    vector<double> massOfUnconsMols;    //mass array of unconstraint molecules
599  double totalMassOfUncons;                //total mas of unconstraint molecules
446  
447 +
448    vector<ZConsParaItem>* parameters; //
449 <  
449 >
450    vector<int> indexOfAllZConsMols;     //index of All Z-Constraint Molecuels
451  
452 <  int* indexOfZConsMols;                   //index of local Z-Constraint Molecules  
452 >  int* indexOfZConsMols;                   //index of local Z-Constraint Molecules
453    double* fz;
454    double* curZPos;
608  
609  int totNumOfUnconsAtoms;              //total number of uncontraint atoms
455  
456 <  int whichDirection;                           //constraint direction
457 <  
456 >
457 >
458 >  int whichDirection;                           //constraint direction
459 >
460   private:
461 <  
461 >
462    string zconsOutput;                         //filename of zconstraint output
463    ZConsWriter* fzOut;                         //z-constraint writer
464  
465 <  double curZconsTime;                      
465 >  double curZconsTime;
466  
467    double calcMovingMolsCOMVel();
468    double calcSysCOMVel();
469    double calcTotalForce();
470 <  
470 >
471    ForceSubtractionPolicy* forcePolicy; //force subtraction policy
472    friend class ForceSubtractionPolicy;
473  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines