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 701 by tim, Wed Aug 20 14:34:04 2003 UTC vs.
Revision 843 by mmeineke, Wed Oct 29 20:41:39 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 +  virtual string getAdditionalParameters(void);
32  
31
33   protected:
34 <  
34 >
35    virtual void integrateStep( int calcPot, int calcStress );
36    virtual void preMove( void );
37    virtual void moveA( void );
# Line 39 | Line 40 | template<typename T = BaseIntegrator> class Integrator
40    virtual void constrainB( void );
41    virtual int  readyCheck( void ) { return 1; }
42  
43 <  virtual void calcForce( int calcPot, int calcStress );  
43 >  virtual void resetIntegrator( void ) { }
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 57 | 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 84 | 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 93 | Line 98 | template<typename T> class NVT : public T { (public)
98   public:
99  
100    NVT ( SimInfo *theInfo, ForceFields* the_ff);
101 <  virtual ~NVT() {}
101 >  virtual ~NVT();
102  
103    void setTauThermostat(double tt) {tauThermostat = tt; have_tau_thermostat=1;}
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 105 | Line 113 | template<typename T> class NVT : public T { (public)
113  
114    virtual int readyCheck();
115  
116 +  virtual void resetIntegrator( void );
117 +
118    // chi is a propagated degree of freedom.
119  
120    double chi;
121  
122 +  //integral of chi(t)dt
123 +  double integralOfChidt;
124 +
125    // targetTemp must be set.  tauThermostat must also be set;
126  
127    double targetTemp;
128    double tauThermostat;
129 <  
129 >
130    short int have_tau_thermostat, have_target_temp;
131  
132 +  double *oldVel;
133 +  double *oldJi;
134 +
135 +  double chiTolerance;
136 +  short int have_chi_tolerance;
137 +
138   };
139  
140  
141  
142 < template<typename T> class NPTi : public T{
142 > template<typename T> class NPT : public T{
143  
144   public:
145  
146 <  NPTi ( SimInfo *theInfo, ForceFields* the_ff);
147 <  virtual ~NPTi() {};
146 >  NPT ( SimInfo *theInfo, ForceFields* the_ff);
147 >  virtual ~NPT();
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;}
162    void setTargetTemp(double tt) {targetTemp = tt; have_target_temp = 1;}
163    void setTargetPressure(double tp) {targetPressure = tp; have_target_pressure = 1;}
164 +  void setChiTolerance(double tol) {chiTolerance = tol; have_chi_tolerance = 1;}
165 +  void setPosIterTolerance(double tol) {posIterTolerance = tol; have_pos_iter_tolerance = 1;}
166 +  void setEtaTolerance(double tol) {etaTolerance = tol; have_eta_tolerance = 1;}
167  
168   protected:
169  
# Line 144 | Line 172 | template<typename T> class NPTi : public T{ (protected
172  
173    virtual int readyCheck();
174  
175 <  // chi and eta are the propagated degrees of freedom
175 >  virtual void resetIntegrator( void );
176  
177 <  double chi;
178 <  double eta;
179 <  double NkBT;
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],
180 >                           int index, double sc[3]) = 0;
181  
182 <  // targetTemp, targetPressure, and tauBarostat must be set.  
183 <  // One of qmass or tauThermostat must be set;
182 >  virtual bool chiConverged( void );
183 >  virtual bool etaConverged( void ) = 0;
184  
185 <  double targetTemp;
186 <  double targetPressure;
187 <  double tauThermostat;
188 <  double tauBarostat;
185 >  virtual void evolveChiA( void );
186 >  virtual void evolveEtaA( void ) = 0;
187 >  virtual void evolveChiB( void );
188 >  virtual void evolveEtaB( void ) = 0;
189  
190 <  short int have_tau_thermostat, have_tau_barostat, have_target_temp;
162 <  short int have_target_pressure;
190 >  virtual void scaleSimBox( void ) = 0;
191  
192 < };
165 <
166 < template<typename T> class NPTim : public T{
167 <
168 < public:
169 <
170 <  NPTim ( SimInfo *theInfo, ForceFields* the_ff);
171 <  virtual ~NPTim() {};
172 <
173 <  virtual void integrateStep( int calcPot, int calcStress ){
174 <    calcStress = 1;
175 <    T::integrateStep( calcPot, calcStress );
176 <  }
177 <
178 <  void setTauThermostat(double tt) {tauThermostat = tt; have_tau_thermostat=1;}
179 <  void setTauBarostat(double tb) {tauBarostat = tb; have_tau_barostat=1;}
180 <  void setTargetTemp(double tt) {targetTemp = tt; have_target_temp = 1;}
181 <  void setTargetPressure(double tp) {targetPressure = tp; have_target_pressure = 1;}
192 >  void accIntegralOfChidt(void) { integralOfChidt += dt * chi;}
193  
183 protected:
184
185  virtual void moveA( void );
186  virtual void moveB( void );
187
188  virtual int readyCheck();
189
190  Molecule* myMolecules;
191  Atom** myAtoms;
192
194    // chi and eta are the propagated degrees of freedom
195  
196 +  double oldChi;
197 +  double prevChi;
198    double chi;
196  double eta;
199    double NkBT;
200 +  double fkBT;
201  
202 <  // targetTemp, targetPressure, and tauBarostat must be set.  
202 >  double tt2, tb2;
203 >  double instaTemp, instaPress, instaVol;
204 >  double press[3][3];
205 >
206 >  int Nparticles;
207 >
208 >  double integralOfChidt;
209 >
210 >  // targetTemp, targetPressure, and tauBarostat must be set.
211    // One of qmass or tauThermostat must be set;
212  
213    double targetTemp;
# Line 207 | Line 218 | template<typename T> class NPTim : public T{ (protecte
218    short int have_tau_thermostat, have_tau_barostat, have_target_temp;
219    short int have_target_pressure;
220  
221 +  double *oldPos;
222 +  double *oldVel;
223 +  double *oldJi;
224 +
225 +  double chiTolerance;
226 +  short int have_chi_tolerance;
227 +  double posIterTolerance;
228 +  short int have_pos_iter_tolerance;
229 +  double etaTolerance;
230 +  short int have_eta_tolerance;
231 +
232   };
233  
234 < template<typename T> class NPTf : public T{
234 > template<typename T> class NPTi : public T{
235  
236   public:
237 +  NPTi( SimInfo *theInfo, ForceFields* the_ff);
238 +  ~NPTi();
239  
240 <  NPTf ( SimInfo *theInfo, ForceFields* the_ff);
241 <  virtual ~NPTf() {};
240 >  virtual double getConservedQuantity(void);
241 >  virtual void resetIntegrator(void);
242 >  virtual string getAdditionalParameters(void);
243 > protected:
244  
219  virtual void integrateStep( int calcPot, int calcStress ){
220    calcStress = 1;
221    T::integrateStep( calcPot, calcStress );
222  }
245  
224  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;}
246  
247 < protected:
247 >  virtual void evolveEtaA(void);
248 >  virtual void evolveEtaB(void);
249  
250 <  virtual void  moveA( void );
232 <  virtual void moveB( void );
250 >  virtual bool etaConverged( void );
251  
252 <  virtual int readyCheck();
252 >  virtual void scaleSimBox( void );
253  
254 <  // chi and eta are the propagated degrees of freedom
254 >  virtual void getVelScaleA( double sc[3], double vel[3] );
255 >  virtual void getVelScaleB( double sc[3], int index );
256 >  virtual void getPosScale(double pos[3], double COM[3],
257 >                           int index, double sc[3]);
258  
259 <  double chi;
260 <  double eta[3][3];
240 <  double NkBT;
259 >  double eta, oldEta, prevEta;
260 > };
261  
262 <  // targetTemp, targetPressure, and tauBarostat must be set.  
243 <  // One of qmass or tauThermostat must be set;
262 > template<typename T> class NPTf : public T{
263  
264 <  double targetTemp;
265 <  double targetPressure;
266 <  double tauThermostat;
267 <  double tauBarostat;
264 > public:
265 >
266 >  NPTf ( SimInfo *theInfo, ForceFields* the_ff);
267 >  virtual ~NPTf();
268 >
269 >  virtual double getConservedQuantity(void);
270 >  virtual string getAdditionalParameters(void);
271 >  virtual void resetIntegrator(void);
272 >
273 > protected:
274 >
275 >  virtual void evolveEtaA(void);
276 >  virtual void evolveEtaB(void);
277 >
278 >  virtual bool etaConverged( void );
279 >
280 >  virtual void scaleSimBox( void );
281 >
282 >  virtual void getVelScaleA( double sc[3], double vel[3] );
283 >  virtual void getVelScaleB( double sc[3], int index );
284 >  virtual void getPosScale(double pos[3], double COM[3],
285 >                           int index, double sc[3]);
286  
287 <  short int have_tau_thermostat, have_tau_barostat, have_target_temp;
288 <  short int have_target_pressure;
289 <
287 >  double eta[3][3];
288 >  double oldEta[3][3];
289 >  double prevEta[3][3];
290   };
291  
292 < template<typename T> class NPTfm : public T{
292 > template<typename T> class NPTxyz : public T{
293  
294   public:
295  
296 <  NPTfm ( SimInfo *theInfo, ForceFields* the_ff);
297 <  virtual ~NPTfm() {};
296 >  NPTxyz ( SimInfo *theInfo, ForceFields* the_ff);
297 >  virtual ~NPTxyz();
298  
299 <  virtual void integrateStep( int calcPot, int calcStress ){
300 <    calcStress = 1;
301 <    T::integrateStep( calcPot, calcStress );
265 <  }
299 >  virtual double getConservedQuantity(void);
300 >  virtual string getAdditionalParameters(void);
301 >  virtual void resetIntegrator(void);
302  
267  void setTauThermostat(double tt) {tauThermostat = tt; have_tau_thermostat=1;}
268  void setTauBarostat(double tb) {tauBarostat = tb; have_tau_barostat=1;}
269  void setTargetTemp(double tt) {targetTemp = tt; have_target_temp = 1;}
270  void setTargetPressure(double tp) {targetPressure = tp; have_target_pressure = 1;}
271
303   protected:
304  
305 <  virtual void  moveA( void );
306 <  virtual void moveB( void );
305 >  virtual void evolveEtaA(void);
306 >  virtual void evolveEtaB(void);
307  
308 <  virtual int readyCheck();
308 >  virtual bool etaConverged( void );
309  
310 <  Molecule* myMolecules;
280 <  Atom** myAtoms;
310 >  virtual void scaleSimBox( void );
311  
312 <  // chi and eta are the propagated degrees of freedom
312 >  virtual void getVelScaleA( double sc[3], double vel[3] );
313 >  virtual void getVelScaleB( double sc[3], int index );
314 >  virtual void getPosScale(double pos[3], double COM[3],
315 >                           int index, double sc[3]);
316  
284  double chi;
317    double eta[3][3];
318 <  double NkBT;
319 <
288 <  // targetTemp, targetPressure, and tauBarostat must be set.  
289 <  // One of qmass or tauThermostat must be set;
290 <
291 <  double targetTemp;
292 <  double targetPressure;
293 <  double tauThermostat;
294 <  double tauBarostat;
295 <
296 <  short int have_tau_thermostat, have_tau_barostat, have_target_temp;
297 <  short int have_target_pressure;
298 <
318 >  double oldEta[3][3];
319 >  double prevEta[3][3];
320   };
321  
322 +
323   template<typename T> class ZConstraint : public T {
324 <  
325 <  public:
326 <  class ForceSubstractionPolicy{
324 >
325 >  public:
326 >  class ForceSubtractionPolicy{
327      public:
328 <      ForceSubstractionPolicy(ZConstraint<T>* integrator) {zconsIntegrator = integrator;}
328 >      ForceSubtractionPolicy(ZConstraint<T>* integrator) {zconsIntegrator = integrator;}
329  
330 <      virtual void update() = 0;    
330 >      virtual void update() = 0;
331        virtual double getZFOfFixedZMols(Molecule* mol, Atom* atom, double totalForce) = 0;
332        virtual double getZFOfMovingMols(Atom* atom, double totalForce) = 0;
333        virtual double getHFOfFixedZMols(Molecule* mol, Atom* atom, double totalForce) = 0;
334        virtual double getHFOfUnconsMols(Atom* atom, double totalForce) = 0;
335 <    
335 >
336     protected:
337 <     ZConstraint<T>* zconsIntegrator;;
337 >     ZConstraint<T>* zconsIntegrator;
338    };
339  
340 <  class PolicyByNumber : ForceSubstractionPolicy{
340 >  class PolicyByNumber : public ForceSubtractionPolicy{
341 >
342      public:
343 <      PolicyByNumber(ZConstraint<T>* integrator) :ForceSubstractionPolicy(integrator) {}    
344 <      virtual void update();    
343 >      PolicyByNumber(ZConstraint<T>* integrator) :ForceSubtractionPolicy(integrator) {}
344 >      virtual void update();
345        virtual double getZFOfFixedZMols(Molecule* mol, Atom* atom, double totalForce) ;
346        virtual double getZFOfMovingMols(Atom* atom, double totalForce) ;
347        virtual double getHFOfFixedZMols(Molecule* mol, Atom* atom, double totalForce);
348        virtual double getHFOfUnconsMols(Atom* atom, double totalForce);
349 <    
349 >
350      private:
351 <    int totNumOfMovingAtoms;
351 >      int totNumOfMovingAtoms;
352    };
353  
354 <  class PolicyByMass :ForceSubstractionPolicy{
354 >  class PolicyByMass : public ForceSubtractionPolicy{
355 >
356      public:
357 <      PolicyByMass(ZConstraint<T>* integrator) :ForceSubstractionPolicy(integrator) {}  
358 <      
359 <      virtual void update();    
357 >      PolicyByMass(ZConstraint<T>* integrator) :ForceSubtractionPolicy(integrator) {}
358 >
359 >      virtual void update();
360        virtual double getZFOfFixedZMols(Molecule* mol, Atom* atom, double totalForce) ;
361        virtual double getZFOfMovingMols(Atom* atom, double totalForce) ;
362        virtual double getHFOfFixedZMols(Molecule* mol, Atom* atom, double totalForce);
# Line 346 | Line 370 | template<typename T> class ZConstraint : public T { (p
370  
371    ZConstraint( SimInfo *theInfo, ForceFields* the_ff);
372    ~ZConstraint();
373 <    
373 >
374    void setZConsTime(double time)                  {this->zconsTime = time;}
375    void getZConsTime()                             {return zconsTime;}
376 <  
376 >
377    void setIndexOfAllZConsMols(vector<int> index) {indexOfAllZConsMols = index;}
378    void getIndexOfAllZConsMols()                  {return indexOfAllZConsMols;}
379 <  
379 >
380    void setZConsOutput(const char * fileName)          {zconsOutput = fileName;}
381    string getZConsOutput()                         {return zconsOutput;}
382 <  
382 >
383    virtual void integrate();
360  
384  
385 +
386   #ifdef IS_MPI
387    virtual void update();                      //which is called to indicate the molecules' migration
388   #endif
389  
390 +  enum ZConsState {zcsMoving, zcsFixed};
391 +
392 +  vector<Molecule*> zconsMols;              //z-constraint molecules array
393 +  vector<ZConsState> states;                 //state of z-constraint molecules
394 +
395 +
396 +
397 +  int totNumOfUnconsAtoms;              //total number of uncontraint atoms
398 +  double totalMassOfUncons;                //total mas of unconstraint molecules
399 +
400 +
401   protected:
402  
403 <  enum ZConsState {zcsMoving, zcsFixed};  
404 <
405 <  virtual void calcForce( int calcPot, int calcStress );
403 >
404 >
405 >  virtual void calcForce( int calcPot, int calcStress );
406    virtual void thermalize(void);
407 <  
407 >
408    void zeroOutVel();
409    void doZconstraintForce();
410    void doHarmonic();
# Line 387 | Line 422 | template<typename T> class ZConstraint : public T { (p
422    double zconsTol;                                 //tolerance of z-contratint
423    double zForceConst;                           //base force constant term
424                                                            //which is estimate by OOPSE
425 <  
426 <  vector<Molecule*> zconsMols;              //z-constraint molecules array
427 <  vector<double> massOfZConsMols;       //mass of z-constraint molecule
425 >
426 >
427 >  vector<double> massOfZConsMols;       //mass of z-constraint molecule
428    vector<double> kz;                              //force constant array
429 <  vector<ZConsState> states;                 //state of z-constraint molecules
429 >
430    vector<double> zPos;                          //
431 <  
432 <  
431 >
432 >
433    vector<Molecule*> unconsMols;           //unconstraint molecules array
434    vector<double> massOfUnconsMols;    //mass array of unconstraint molecules
400  double totalMassOfUncons;                //total mas of unconstraint molecules
435  
436 +
437    vector<ZConsParaItem>* parameters; //
438 <  
438 >
439    vector<int> indexOfAllZConsMols;     //index of All Z-Constraint Molecuels
440  
441 <  int* indexOfZConsMols;                   //index of local Z-Constraint Molecules  
441 >  int* indexOfZConsMols;                   //index of local Z-Constraint Molecules
442    double* fz;
443    double* curZPos;
409  
410  int totNumOfUnconsAtoms;              //total number of uncontraint atoms
444  
445 <  int whichDirection;                           //constraint direction
446 <  
445 >
446 >
447 >  int whichDirection;                           //constraint direction
448 >
449   private:
450 <  
450 >
451    string zconsOutput;                         //filename of zconstraint output
452    ZConsWriter* fzOut;                         //z-constraint writer
453  
454 <  double curZconsTime;                      
454 >  double curZconsTime;
455  
456    double calcMovingMolsCOMVel();
457    double calcSysCOMVel();
458    double calcTotalForce();
424  
425  ForceSubstractionPolicy* forcePolicy; //force substration policy
426  friend class ForceSubstractionPolicy;
459  
460 +  ForceSubtractionPolicy* forcePolicy; //force subtraction policy
461 +  friend class ForceSubtractionPolicy;
462 +
463   };
464  
465   #endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines