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 658 by tim, Thu Jul 31 15:35:07 2003 UTC vs.
Revision 812 by mmeineke, Wed Oct 22 21:17:32 2003 UTC

# Line 27 | Line 27 | template<typename T = BaseIntegrator> class Integrator
27    Integrator( SimInfo *theInfo, ForceFields* the_ff );
28    virtual ~Integrator();
29    void integrate( void );
30 +  virtual double  getConservedQuantity(void);
31  
31
32   protected:
33 <  
33 >
34    virtual void integrateStep( int calcPot, int calcStress );
35    virtual void preMove( void );
36    virtual void moveA( void );
# Line 38 | Line 38 | template<typename T = BaseIntegrator> class Integrator
38    virtual void constrainA( void );
39    virtual void constrainB( void );
40    virtual int  readyCheck( void ) { return 1; }
41 +
42 +  virtual void resetIntegrator( void ) { }
43 +
44 +  virtual void calcForce( int calcPot, int calcStress );  
45 +  virtual void thermalize();
46    
47 +  virtual void rotationPropagation( DirectionalAtom* dAtom, double ji[3] );
48 +
49    void checkConstraints( void );
50    void rotate( int axes1, int axes2, double angle, double j[3],
51 <               double A[3][3] );
52 <
46 <
51 >         double A[3][3] );
52 >        
53    ForceFields* myFF;
54  
55    SimInfo *info; // all the info we'll ever need
# Line 54 | Line 60 | template<typename T = BaseIntegrator> class Integrator
60    int nMols;
61  
62    int isConstrained; // boolean to know whether the systems contains
63 <                     // constraints.
63 >         // constraints.
64    int nConstrained;  // counter for number of constraints
65    int *constrainedA; // the i of a constraint pair
66    int *constrainedB; // the j of a constraint pair
# Line 91 | Line 97 | template<typename T> class NVT : public T { (public)
97   public:
98  
99    NVT ( SimInfo *theInfo, ForceFields* the_ff);
100 <  virtual ~NVT() {}
100 >  virtual ~NVT();
101  
102    void setTauThermostat(double tt) {tauThermostat = tt; have_tau_thermostat=1;}
103    void setTargetTemp(double tt) {targetTemp = tt; have_target_temp = 1;}
104 +  void setChiTolerance(double tol) {chiTolerance = tol;}
105 +  virtual double  getConservedQuantity(void);
106  
107   protected:
108  
# Line 103 | Line 111 | template<typename T> class NVT : public T { (public)
111  
112    virtual int readyCheck();
113  
114 +  virtual void resetIntegrator( void );
115 +
116    // chi is a propagated degree of freedom.
117  
118    double chi;
119  
120 +  //integral of chi(t)dt
121 +  double integralOfChidt;
122 +
123    // targetTemp must be set.  tauThermostat must also be set;
124  
125    double targetTemp;
# Line 114 | Line 127 | template<typename T> class NVT : public T { (public)
127    
128    short int have_tau_thermostat, have_target_temp;
129  
130 +  double *oldVel;
131 +  double *oldJi;
132 +
133 +  double chiTolerance;
134 +  short int have_chi_tolerance;
135 +
136   };
137  
138  
139  
140 < template<typename T> class NPTi : public T{
140 > template<typename T> class NPT : public T{
141  
142   public:
143  
144 <  NPTi ( SimInfo *theInfo, ForceFields* the_ff);
145 <  virtual ~NPTi() {};
146 <
144 >  NPT ( SimInfo *theInfo, ForceFields* the_ff);
145 >  virtual ~NPT();
146 >  
147    virtual void integrateStep( int calcPot, int calcStress ){
148      calcStress = 1;
149      T::integrateStep( calcPot, calcStress );
150    }
151  
152 +  virtual double getConservedQuantity(void) = 0;
153 +
154    void setTauThermostat(double tt) {tauThermostat = tt; have_tau_thermostat=1;}
155    void setTauBarostat(double tb) {tauBarostat = tb; have_tau_barostat=1;}
156    void setTargetTemp(double tt) {targetTemp = tt; have_target_temp = 1;}
157    void setTargetPressure(double tp) {targetPressure = tp; have_target_pressure = 1;}
158 +  void setChiTolerance(double tol) {chiTolerance = tol; have_chi_tolerance = 1;}
159 +  void setPosIterTolerance(double tol) {posIterTolerance = tol; have_pos_iter_tolerance = 1;}
160 +  void setEtaTolerance(double tol) {etaTolerance = tol; have_eta_tolerance = 1;}
161  
162   protected:
163  
# Line 142 | Line 166 | template<typename T> class NPTi : public T{ (protected
166  
167    virtual int readyCheck();
168  
169 +  virtual void resetIntegrator( void );
170 +
171 +  virtual void getVelScaleA( double sc[3], double vel[3] ) = 0;
172 +  virtual void getVelScaleB( double sc[3], int index ) = 0;
173 +  virtual void getPosScale(double pos[3], double COM[3],
174 +                           int index, double sc[3]) = 0;
175 +
176 +  virtual bool chiConverged( void );
177 +  virtual bool etaConverged( void ) = 0;
178 +  
179 +  virtual void evolveChiA( void );
180 +  virtual void evolveEtaA( void ) = 0;
181 +  virtual void evolveChiB( void );
182 +  virtual void evolveEtaB( void ) = 0;
183 +
184 +  virtual void scaleSimBox( void ) = 0;
185 +
186 +  void accIntegralOfChidt(void) { integralOfChidt += dt * chi;}
187 +
188    // chi and eta are the propagated degrees of freedom
189  
190 +  double oldChi;
191 +  double prevChi;
192    double chi;
148  double eta;
193    double NkBT;
194 +  double fkBT;
195  
196 +  double tt2, tb2;
197 +  double instaTemp, instaPress, instaVol;
198 +  double press[3][3];
199 +
200 +  int Nparticles;
201 +
202 +  double integralOfChidt;
203 +
204    // targetTemp, targetPressure, and tauBarostat must be set.  
205    // One of qmass or tauThermostat must be set;
206  
# Line 159 | Line 212 | template<typename T> class NPTi : public T{ (protected
212    short int have_tau_thermostat, have_tau_barostat, have_target_temp;
213    short int have_target_pressure;
214  
215 < };
215 >  double *oldPos;
216 >  double *oldVel;
217 >  double *oldJi;
218  
219 < template<typename T> class NPTim : public T{
219 >  double chiTolerance;
220 >  short int have_chi_tolerance;
221 >  double posIterTolerance;
222 >  short int have_pos_iter_tolerance;
223 >  double etaTolerance;
224 >  short int have_eta_tolerance;
225  
226 + };
227 +
228 + template<typename T> class NPTi : public T{
229 +  
230   public:
231 +  NPTi( SimInfo *theInfo, ForceFields* the_ff);
232 +  ~NPTi();
233  
234 <  NPTim ( SimInfo *theInfo, ForceFields* the_ff);
235 <  virtual ~NPTim() {};
234 >  virtual double getConservedQuantity(void);
235 >  virtual void resetIntegrator(void);
236  
237 <  virtual void integrateStep( int calcPot, int calcStress ){
172 <    calcStress = 1;
173 <    T::integrateStep( calcPot, calcStress );
174 <  }
237 > protected:
238  
239 <  void setTauThermostat(double tt) {tauThermostat = tt; have_tau_thermostat=1;}
177 <  void setTauBarostat(double tb) {tauBarostat = tb; have_tau_barostat=1;}
178 <  void setTargetTemp(double tt) {targetTemp = tt; have_target_temp = 1;}
179 <  void setTargetPressure(double tp) {targetPressure = tp; have_target_pressure = 1;}
239 >
240  
241 < protected:
241 >  virtual void evolveEtaA(void);
242 >  virtual void evolveEtaB(void);
243  
244 <  virtual void moveA( void );
184 <  virtual void moveB( void );
244 >  virtual bool etaConverged( void );
245  
246 <  virtual int readyCheck();
246 >  virtual void scaleSimBox( void );
247  
248 <  Molecule* myMolecules;
249 <  Atom** myAtoms;
248 >  virtual void getVelScaleA( double sc[3], double vel[3] );
249 >  virtual void getVelScaleB( double sc[3], int index );
250 >  virtual void getPosScale(double pos[3], double COM[3],
251 >                           int index, double sc[3]);
252  
253 <  // chi and eta are the propagated degrees of freedom
192 <
193 <  double chi;
194 <  double eta;
195 <  double NkBT;
196 <
197 <  // targetTemp, targetPressure, and tauBarostat must be set.  
198 <  // One of qmass or tauThermostat must be set;
199 <
200 <  double targetTemp;
201 <  double targetPressure;
202 <  double tauThermostat;
203 <  double tauBarostat;
204 <
205 <  short int have_tau_thermostat, have_tau_barostat, have_target_temp;
206 <  short int have_target_pressure;
207 <
253 >  double eta, oldEta, prevEta;
254   };
255  
256   template<typename T> class NPTf : public T{
# Line 212 | Line 258 | template<typename T> class NPTf : public T{ (public)
258   public:
259  
260    NPTf ( SimInfo *theInfo, ForceFields* the_ff);
261 <  virtual ~NPTf() {};
261 >  virtual ~NPTf();
262  
263 <  virtual void integrateStep( int calcPot, int calcStress ){
264 <    calcStress = 1;
219 <    T::integrateStep( calcPot, calcStress );
220 <  }
263 >  virtual double getConservedQuantity(void);
264 >  virtual void resetIntegrator(void);
265  
222  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
266   protected:
267  
268 <  virtual void  moveA( void );
269 <  virtual void moveB( void );
268 >  virtual void evolveEtaA(void);
269 >  virtual void evolveEtaB(void);
270  
271 <  virtual int readyCheck();
271 >  virtual bool etaConverged( void );
272  
273 <  // chi and eta are the propagated degrees of freedom
273 >  virtual void scaleSimBox( void );
274  
275 <  double chi;
276 <  double eta[3][3];
277 <  double NkBT;
275 >  virtual void getVelScaleA( double sc[3], double vel[3] );
276 >  virtual void getVelScaleB( double sc[3], int index );
277 >  virtual void getPosScale(double pos[3], double COM[3],
278 >                           int index, double sc[3]);
279  
280 <  // targetTemp, targetPressure, and tauBarostat must be set.  
281 <  // One of qmass or tauThermostat must be set;
282 <
243 <  double targetTemp;
244 <  double targetPressure;
245 <  double tauThermostat;
246 <  double tauBarostat;
247 <
248 <  short int have_tau_thermostat, have_tau_barostat, have_target_temp;
249 <  short int have_target_pressure;
250 <
280 >  double eta[3][3];
281 >  double oldEta[3][3];
282 >  double prevEta[3][3];
283   };
284  
285 < template<typename T> class NPTfm : public T{
285 > template<typename T> class NPTxyz : public T{
286  
287   public:
288  
289 <  NPTfm ( SimInfo *theInfo, ForceFields* the_ff);
290 <  virtual ~NPTfm() {};
289 >  NPTxyz ( SimInfo *theInfo, ForceFields* the_ff);
290 >  virtual ~NPTxyz();
291  
292 <  virtual void integrateStep( int calcPot, int calcStress ){
293 <    calcStress = 1;
262 <    T::integrateStep( calcPot, calcStress );
263 <  }
292 >  virtual double getConservedQuantity(void);
293 >  virtual void resetIntegrator(void);
294  
265  void setTauThermostat(double tt) {tauThermostat = tt; have_tau_thermostat=1;}
266  void setTauBarostat(double tb) {tauBarostat = tb; have_tau_barostat=1;}
267  void setTargetTemp(double tt) {targetTemp = tt; have_target_temp = 1;}
268  void setTargetPressure(double tp) {targetPressure = tp; have_target_pressure = 1;}
269
295   protected:
296  
297 <  virtual void  moveA( void );
298 <  virtual void moveB( void );
297 >  virtual void evolveEtaA(void);
298 >  virtual void evolveEtaB(void);
299  
300 <  virtual int readyCheck();
300 >  virtual bool etaConverged( void );
301  
302 <  Molecule* myMolecules;
278 <  Atom** myAtoms;
302 >  virtual void scaleSimBox( void );
303  
304 <  // chi and eta are the propagated degrees of freedom
304 >  virtual void getVelScaleA( double sc[3], double vel[3] );
305 >  virtual void getVelScaleB( double sc[3], int index );
306 >  virtual void getPosScale(double pos[3], double COM[3],
307 >                           int index, double sc[3]);
308  
282  double chi;
309    double eta[3][3];
310 <  double NkBT;
310 >  double oldEta[3][3];
311 >  double prevEta[3][3];
312 > };
313  
286  // targetTemp, targetPressure, and tauBarostat must be set.  
287  // One of qmass or tauThermostat must be set;
314  
315 <  double targetTemp;
316 <  double targetPressure;
317 <  double tauThermostat;
318 <  double tauBarostat;
315 > template<typename T> class ZConstraint : public T {
316 >  
317 >  public:
318 >  class ForceSubtractionPolicy{
319 >    public:
320 >      ForceSubtractionPolicy(ZConstraint<T>* integrator) {zconsIntegrator = integrator;}
321  
322 <  short int have_tau_thermostat, have_tau_barostat, have_target_temp;
323 <  short int have_target_pressure;
322 >      virtual void update() = 0;    
323 >      virtual double getZFOfFixedZMols(Molecule* mol, Atom* atom, double totalForce) = 0;
324 >      virtual double getZFOfMovingMols(Atom* atom, double totalForce) = 0;
325 >      virtual double getHFOfFixedZMols(Molecule* mol, Atom* atom, double totalForce) = 0;
326 >      virtual double getHFOfUnconsMols(Atom* atom, double totalForce) = 0;
327 >    
328 >   protected:
329 >     ZConstraint<T>* zconsIntegrator;
330 >  };
331  
332 < };
332 >  class PolicyByNumber : public ForceSubtractionPolicy{
333  
334 < template<typename T> class ZConstraint : public T {
334 >    public:
335 >      PolicyByNumber(ZConstraint<T>* integrator) :ForceSubtractionPolicy(integrator) {}    
336 >      virtual void update();    
337 >      virtual double getZFOfFixedZMols(Molecule* mol, Atom* atom, double totalForce) ;
338 >      virtual double getZFOfMovingMols(Atom* atom, double totalForce) ;
339 >      virtual double getHFOfFixedZMols(Molecule* mol, Atom* atom, double totalForce);
340 >      virtual double getHFOfUnconsMols(Atom* atom, double totalForce);
341 >    
342 >    private:
343 >      int totNumOfMovingAtoms;
344 >  };
345  
346 +  class PolicyByMass : public ForceSubtractionPolicy{
347 +
348 +    public:
349 +      PolicyByMass(ZConstraint<T>* integrator) :ForceSubtractionPolicy(integrator) {}  
350 +      
351 +      virtual void update();    
352 +      virtual double getZFOfFixedZMols(Molecule* mol, Atom* atom, double totalForce) ;
353 +      virtual double getZFOfMovingMols(Atom* atom, double totalForce) ;
354 +      virtual double getHFOfFixedZMols(Molecule* mol, Atom* atom, double totalForce);
355 +      virtual double getHFOfUnconsMols(Atom* atom, double totalForce);
356 +
357 +   private:
358 +     double totMassOfMovingAtoms;
359 +  };
360 +
361   public:
362  
363    ZConstraint( SimInfo *theInfo, ForceFields* the_ff);
364    ~ZConstraint();
365 <
306 <  virtual void integrateStep( int calcPot, int calcStress );
307 <  
308 <  
365 >    
366    void setZConsTime(double time)                  {this->zconsTime = time;}
367    void getZConsTime()                             {return zconsTime;}
368    
369 <  void setIndexOfAllZConsMols(vector<int> index)  {indexOfAllZConsMols = index;}
370 <  void getIndexOfAllZConsMols()                   {return indexOfAllZConsMols;}
369 >  void setIndexOfAllZConsMols(vector<int> index) {indexOfAllZConsMols = index;}
370 >  void getIndexOfAllZConsMols()                  {return indexOfAllZConsMols;}
371    
372 <  void setZConsOutput(const char * fileName)      {zconsOutput = fileName;}
372 >  void setZConsOutput(const char * fileName)          {zconsOutput = fileName;}
373    string getZConsOutput()                         {return zconsOutput;}
374 +  
375 +  virtual void integrate();
376 +  
377  
378   #ifdef IS_MPI
379 <  virtual void update(); //which is called to indicate the molecules' migration
379 >  virtual void update();                      //which is called to indicate the molecules' migration
380   #endif
381  
382 +  enum ZConsState {zcsMoving, zcsFixed};  
383 +
384 +  vector<Molecule*> zconsMols;              //z-constraint molecules array
385 +  vector<ZConsState> states;                 //state of z-constraint molecules
386 +
387 +
388 +
389 +  int totNumOfUnconsAtoms;              //total number of uncontraint atoms
390 +  double totalMassOfUncons;                //total mas of unconstraint molecules
391 +
392 +
393   protected:
394  
395 <  double zconsTime;
395 >
396 >
397 >  virtual void calcForce( int calcPot, int calcStress );
398 >  virtual void thermalize(void);
399    
400 <  void resetZ(void);
400 >  void zeroOutVel();
401 >  void doZconstraintForce();
402 >  void doHarmonic();
403 >  bool checkZConsState();
404 >
405 >  bool haveFixedZMols();
406 >  bool haveMovingZMols();
407 >
408 >  double calcZSys();
409 >
410 >  int isZConstraintMol(Molecule* mol);
411 >
412 >
413 >  double zconsTime;                              //sample time
414 >  double zconsTol;                                 //tolerance of z-contratint
415 >  double zForceConst;                           //base force constant term
416 >                                                          //which is estimate by OOPSE
417    
418 <  vector<Molecule*> zconsMols;
419 <  vector<double> massOfZConsMols;
418 >
419 >  vector<double> massOfZConsMols;       //mass of z-constraint molecule
420 >  vector<double> kz;                              //force constant array
421 >
422 >  vector<double> zPos;                          //
423    
424 <  vector<Molecule*> unconsMols;
425 <  vector<double> massOfUnconsMols;
426 <  double totalMassOfUncons;
424 >  
425 >  vector<Molecule*> unconsMols;           //unconstraint molecules array
426 >  vector<double> massOfUnconsMols;    //mass array of unconstraint molecules
427  
428 <  vector<double> allRefZ;    
429 <  vector<double> refZ;
428 >
429 >  vector<ZConsParaItem>* parameters; //
430    
431    vector<int> indexOfAllZConsMols;     //index of All Z-Constraint Molecuels
432 <  int* indexOfZConsMols;               //index of local Z-Constraint Molecules
433 <    
432 >
433 >  int* indexOfZConsMols;                   //index of local Z-Constraint Molecules  
434    double* fz;
435 +  double* curZPos;
436    
437 +
438 +
439 +  int whichDirection;                           //constraint direction
440 +  
441   private:
442 +  
443 +  string zconsOutput;                         //filename of zconstraint output
444 +  ZConsWriter* fzOut;                         //z-constraint writer
445  
446 <  int isZConstraintMol(Molecule* mol);
447 <  string zconsOutput;
448 <  ZConsWriter* fzOut;
446 >  double curZconsTime;                      
447 >
448 >  double calcMovingMolsCOMVel();
449 >  double calcSysCOMVel();
450 >  double calcTotalForce();
451 >  
452 >  ForceSubtractionPolicy* forcePolicy; //force subtraction policy
453 >  friend class ForceSubtractionPolicy;
454 >
455   };
456  
457   #endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines