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 378 by mmeineke, Fri Mar 21 17:42:12 2003 UTC vs.
Revision 778 by mmeineke, Fri Sep 19 20:00:27 2003 UTC

# Line 1 | Line 1
1   #ifndef _INTEGRATOR_H_
2   #define _INTEGRATOR_H_
3  
4 + #include <string>
5 + #include <vector>
6   #include "Atom.hpp"
7 + #include "Molecule.hpp"
8   #include "SRI.hpp"
9   #include "AbstractClasses.hpp"
10   #include "SimInfo.hpp"
11   #include "ForceFields.hpp"
12 + #include "Thermo.hpp"
13 + #include "ReadWrite.hpp"
14 + #include "ZConsWriter.hpp"
15  
16 < class Verlet : public Integrator {
16 > using namespace std;
17 > const double kB = 8.31451e-7;// boltzmann constant amu*Ang^2*fs^-2/K
18 > const double eConvert = 4.184e-4; // converts kcal/mol -> amu*A^2/fs^2
19 > const double p_convert = 1.63882576e8; //converts amu*fs^-2*Ang^-1 -> atm
20 > const int maxIteration = 300;
21 > const double tol = 1.0e-6;
22  
23 +
24 + template<typename T = BaseIntegrator> class Integrator : public T {
25 +
26   public:
27 <  Verlet( SimInfo &info, ForceFields* the_ff );
28 <  ~Verlet();
27 >  Integrator( SimInfo *theInfo, ForceFields* the_ff );
28 >  virtual ~Integrator();
29    void integrate( void );
30 +  virtual double  getConservedQuantity(void);
31  
32 < private:
32 > protected:
33 >
34 >  virtual void integrateStep( int calcPot, int calcStress );
35 >  virtual void preMove( void );
36 >  virtual void moveA( void );
37 >  virtual void moveB( void );
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 <  void move_a( double dt );
20 <  void move_b( double dt );
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 +        
53    ForceFields* myFF;
54  
55 <  SimInfo *entry_plug; // all the info we'll ever need
56 <  int c_natoms;  /* the number of atoms */
57 <  Atom **c_atoms; /* array of atom pointers */
58 <  SRI **c_sr_interactions; /* array of SRI pointers */
59 <  int c_n_SRI; /* the number of short range interactions */
55 >  SimInfo *info; // all the info we'll ever need
56 >  int nAtoms;  /* the number of atoms */
57 >  int oldAtoms;
58 >  Atom **atoms; /* array of atom pointers */
59 >  Molecule* molecules;
60 >  int nMols;
61  
62 <  int c_is_constrained; /*boolean to know whether the systems contains
63 <                          constraints. */
64 <  int c_n_constrained; /*counter for number of constraints */
65 <  int *c_constrained_i; /* the i of a constraint pair */
66 <  int *c_constrained_j; /* the j of a constraint pair */
67 <  double *c_constrained_dsqr; /* the square of the constraint distance */
68 <  double *c_mass; /* the array of masses */
69 <  short is_first; /*boolean for the first time integrate is called */
70 <  double c_box_x;
71 <  double c_box_y;
72 <  double c_box_z;
62 >  int isConstrained; // boolean to know whether the systems contains
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
67 >  double *constrainedDsqr; // the square of the constraint distance
68 >  
69 >  int* moving; // tells whether we are moving atom i
70 >  int* moved;  // tells whether we have moved atom i
71 >  double* oldPos; // pre constrained positions
72 >
73 >  short isFirst; /*boolean for the first time integrate is called */
74 >  
75 >  double dt;
76 >  double dt2;
77 >
78 >  Thermo *tStats;
79 >  StatWriter*  statOut;
80 >  DumpWriter*  dumpOut;
81 >  
82   };
83  
84 < class Symplectic : public Integrator {
84 > typedef Integrator<BaseIntegrator> RealIntegrator;
85 >
86 > template<typename T> class NVE : public T {
87 >
88 > public:
89 >  NVE ( SimInfo *theInfo, ForceFields* the_ff ):
90 >    T( theInfo, the_ff ){}
91 >  virtual ~NVE(){}  
92 > };
93 >
94 >
95 > template<typename T> class NVT : public T {
96 >
97 > public:
98 >
99 >  NVT ( SimInfo *theInfo, ForceFields* the_ff);
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 >
109 >  virtual void moveA( void );
110 >  virtual void moveB( void );
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;
126 >  double tauThermostat;
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 NPT : public T{
141 +
142   public:
143 <  Symplectic( SimInfo* the_entry_plug,  ForceFields* the_ff );
144 <  ~Symplectic();
143 >
144 >  NPT ( SimInfo *theInfo, ForceFields* the_ff);
145 >  virtual ~NPT();
146    
147 <  void integrate( void );
147 >  virtual void integrateStep( int calcPot, int calcStress ){
148 >    calcStress = 1;
149 >    T::integrateStep( calcPot, calcStress );
150 >  }
151  
152 < private:
152 >  virtual double getConservedQuantity(void) = 0;
153  
154 <  void rotate( int axes1, int axes2, double angle, double j[3],
155 <               double A[3][3] );
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 <  SimInfo* entry_plug;
57 <  ForceFields* myFF;
162 > protected:
163  
164 <  int is_constrained; /*boolean to know whether the systems contains
165 <                          constraints. */
61 <  int n_constrained; /*counter for number of constraints */
62 <  int *constrained_i; /* the i of a constraint pair */
63 <  int *constrained_j; /* the j of a constraint pair */
64 <  double *constrained_dsqr; /* the square of the constraint distance */
65 <  double *mass; /* the array of masses */
164 >  virtual void  moveA( void );
165 >  virtual void moveB( void );
166  
167 <  short int isFirst;
167 >  virtual int readyCheck();
168  
169 <  SRI **srInteractions; /* array of SRI pointers */
170 <  int nSRI; /* the number of short range interactions */
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;
193 >  double NkBT;
194 >  double fkBT;
195 >
196 >  double tt2, tb2;
197 >  double instaTemp, instaPress, instaVol;
198 >
199 >  int Nparticles;
200 >
201 >  double integralOfChidt;
202 >
203 >  // targetTemp, targetPressure, and tauBarostat must be set.  
204 >  // One of qmass or tauThermostat must be set;
205 >
206 >  double targetTemp;
207 >  double targetPressure;
208 >  double tauThermostat;
209 >  double tauBarostat;
210 >
211 >  short int have_tau_thermostat, have_tau_barostat, have_target_temp;
212 >  short int have_target_pressure;
213 >
214 >  double *oldPos;
215 >  double *oldVel;
216 >  double *oldJi;
217 >
218 >  double chiTolerance;
219 >  short int have_chi_tolerance;
220 >  double posIterTolerance;
221 >  short int have_pos_iter_tolerance;
222 >  double etaTolerance;
223 >  short int have_eta_tolerance;
224 >
225 > };
226 >
227 > template<typename T> class NPTi : public T{
228 >  
229 > public:
230 >  NPTi( SimInfo *theInfo, ForceFields* the_ff);
231 >  ~NPTi();
232 >
233 >  virtual double getConservedQuantity(void);
234 >  virtual void resetIntegrator(void);
235 >
236 > protected:
237 >
238 >
239 >
240 >  virtual void evolveEtaA(void);
241 >  virtual void evolveEtaB(void);
242 >
243 >  virtual bool etaConverged( void );
244 >
245 >  virtual void scaleSimBox( void );
246 >
247 >  virtual void getVelScaleA( double sc[3], double vel[3] );
248 >  virtual void getVelScaleB( double sc[3], int index );
249 >  virtual void getPosScale(double pos[3], double COM[3],
250 >                           int index, double sc[3]);
251 >
252 >  double eta, oldEta, prevEta;
253 > };
254 >
255 >
256 > template<typename T> class NPTim : public T{
257 >
258 > public:
259 >
260 >  NPTim ( SimInfo *theInfo, ForceFields* the_ff);
261 >  virtual ~NPTim() {}
262 >
263 >  virtual void integrateStep( int calcPot, int calcStress ){
264 >    calcStress = 1;
265 >    T::integrateStep( calcPot, calcStress );
266 >    accIntegralOfChidt();  
267 >  }
268 >
269 >  virtual double getConservedQuantity(void);
270 >
271 >  void setTauThermostat(double tt) {tauThermostat = tt; have_tau_thermostat=1;}
272 >  void setTauBarostat(double tb) {tauBarostat = tb; have_tau_barostat=1;}
273 >  void setTargetTemp(double tt) {targetTemp = tt; have_target_temp = 1;}
274 >  void setTargetPressure(double tp) {targetPressure = tp; have_target_pressure = 1;}
275 >  void setChiTolerance(double tol) {chiTolerance = tol;}
276 >  void setPosIterTolerance(double tol) {posIterTolerance = tol;}
277 >
278 > protected:
279 >
280 >  virtual void moveA( void );
281 >  virtual void moveB( void );
282 >
283 >  virtual int readyCheck();
284 >
285 >  virtual void resetIntegrator( void );
286 >
287 >  void accIntegralOfChidt(void) { integralOfChidt += dt * chi;}
288 >  
289 >  Molecule* myMolecules;
290 >  Atom** myAtoms;
291 >
292 >  // chi and eta are the propagated degrees of freedom
293 >
294 >  double chi;
295 >  double eta;
296 >  double NkBT;
297 >  double integralOfChidt;
298 >
299 >  // targetTemp, targetPressure, and tauBarostat must be set.  
300 >  // One of qmass or tauThermostat must be set;
301 >
302 >  double targetTemp;
303 >  double targetPressure;
304 >  double tauThermostat;
305 >  double tauBarostat;
306 >
307 >  short int have_tau_thermostat, have_tau_barostat, have_target_temp;
308 >  short int have_target_pressure;
309 >  double chiTolerance;
310 >  short int have_chi_tolerance;
311 >  double posIterTolerance;
312 >  short int have_pos_iter_tolerance;
313 >
314 > };
315 >
316 > template<typename T> class NPTzm : public T{
317 >
318 > public:
319 >
320 >  NPTzm ( SimInfo *theInfo, ForceFields* the_ff);
321 >  virtual ~NPTzm() {};
322 >
323 >  virtual void integrateStep( int calcPot, int calcStress ){
324 >    calcStress = 1;
325 >    T::integrateStep( calcPot, calcStress );
326 >  }
327 >
328 >  void setTauThermostat(double tt) {tauThermostat = tt; have_tau_thermostat=1;}
329 >  void setTauBarostat(double tb) {tauBarostat = tb; have_tau_barostat=1;}
330 >  void setTargetTemp(double tt) {targetTemp = tt; have_target_temp = 1;}
331 >  void setTargetPressure(double tp) {targetPressure = tp; have_target_pressure = 1;}
332 >
333 > protected:
334 >
335 >  virtual void moveA( void );
336 >  virtual void moveB( void );
337 >
338 >  virtual int readyCheck();
339 >
340 >  virtual void resetIntegrator( void );
341 >
342 >  Molecule* myMolecules;
343 >  Atom** myAtoms;
344 >
345 >  // chi and eta are the propagated degrees of freedom
346 >
347 >  double chi;
348 >  double eta;
349 >  double etaZ;
350 >  double NkBT;
351 >
352 >  // targetTemp, targetPressure, and tauBarostat must be set.  
353 >  // One of qmass or tauThermostat must be set;
354 >
355 >  double targetTemp;
356 >  double targetPressure;
357 >  double tauThermostat;
358 >  double tauBarostat;
359 >
360 >  short int have_tau_thermostat, have_tau_barostat, have_target_temp;
361 >  short int have_target_pressure;
362 >
363 > };
364 >
365 > template<typename T> class NPTf : public T{
366 >
367 > public:
368 >
369 >  NPTf ( SimInfo *theInfo, ForceFields* the_ff);
370 >  virtual ~NPTf();
371 >
372 >  virtual void integrateStep( int calcPot, int calcStress ){
373 >    calcStress = 1;
374 >    T::integrateStep( calcPot, calcStress );
375 >  }
376    
377 +  virtual double getConservedQuantity(void);
378 +
379 +  void setTauThermostat(double tt) {tauThermostat = tt; have_tau_thermostat=1;}
380 +  void setTauBarostat(double tb) {tauBarostat = tb; have_tau_barostat=1;}
381 +  void setTargetTemp(double tt) {targetTemp = tt; have_target_temp = 1;}
382 +  void setTargetPressure(double tp) {targetPressure = tp; have_target_pressure = 1;}
383 +  void setChiTolerance(double tol) {chiTolerance = tol;}
384 +  void setPosIterTolerance(double tol) {posIterTolerance = tol;}
385 +
386 + protected:
387 +
388 +  virtual void  moveA( void );
389 +  virtual void moveB( void );
390 +
391 +  virtual void resetIntegrator( void );
392 +
393 +  virtual int readyCheck();
394 +
395 +
396 +  // chi and eta are the propagated degrees of freedom
397 +
398 +  double chi;
399 +  double eta[3][3];
400 +  double NkBT;
401 +  double fkBT;
402 +
403 +  int Nparticles;
404 +
405 +  double *oldPos;
406 +  double *oldVel;
407 +  double *oldJi;
408 +
409 +  double integralOfChidt;
410 +  
411 +  // targetTemp, targetPressure, and tauBarostat must be set.  
412 +  // One of qmass or tauThermostat must be set;
413 +
414 +  double targetTemp;
415 +  double targetPressure;
416 +  double tauThermostat;
417 +  double tauBarostat;
418 +
419 +  short int have_tau_thermostat, have_tau_barostat, have_target_temp;
420 +  short int have_target_pressure;
421 +  double chiTolerance;
422 +  short int have_chi_tolerance;
423 +  double posIterTolerance;
424 +  short int have_pos_iter_tolerance;
425 +  double etaTolerance;
426 +  short int have_eta_tolerance;
427   };
428  
429 + template<typename T> class NPTxym : public T{
430 +
431 + public:
432 +
433 +  NPTxym ( SimInfo *theInfo, ForceFields* the_ff);
434 +  virtual ~NPTxym() {};
435 +
436 +  virtual void integrateStep( int calcPot, int calcStress ){
437 +    calcStress = 1;
438 +    T::integrateStep( calcPot, calcStress );
439 +  }
440 +
441 +  void setTauThermostat(double tt) {tauThermostat = tt; have_tau_thermostat=1;}
442 +  void setTauBarostat(double tb) {tauBarostat = tb; have_tau_barostat=1;}
443 +  void setTargetTemp(double tt) {targetTemp = tt; have_target_temp = 1;}
444 +  void setTargetPressure(double tp) {targetPressure = tp; have_target_pressure = 1;}
445 +
446 + protected:
447 +
448 +  virtual void moveA( void );
449 +  virtual void moveB( void );
450 +
451 +  virtual int readyCheck();
452 +
453 +  virtual void resetIntegrator( void );
454 +
455 +  Molecule* myMolecules;
456 +  Atom** myAtoms;
457 +
458 +  // chi and eta are the propagated degrees of freedom
459 +
460 +  double chi;
461 +  double eta;
462 +  double etaX;
463 +  double etaY;
464 +  double NkBT;
465 +
466 +  // targetTemp, targetPressure, and tauBarostat must be set.  
467 +  // One of qmass or tauThermostat must be set;
468 +
469 +  double targetTemp;
470 +  double targetPressure;
471 +  double tauThermostat;
472 +  double tauBarostat;
473 +
474 +  short int have_tau_thermostat, have_tau_barostat, have_target_temp;
475 +  short int have_target_pressure;
476 +
477 + };
478 +
479 +
480 + template<typename T> class NPTfm : public T{
481 +
482 + public:
483 +
484 +  NPTfm ( SimInfo *theInfo, ForceFields* the_ff);
485 +  virtual ~NPTfm() {};
486 +
487 +  virtual void integrateStep( int calcPot, int calcStress ){
488 +    calcStress = 1;
489 +    T::integrateStep( calcPot, calcStress );
490 +    accIntegralOfChidt();
491 +  }
492 +
493 +  virtual double getConservedQuantity(void);
494 +  
495 +  void setTauThermostat(double tt) {tauThermostat = tt; have_tau_thermostat=1;}
496 +  void setTauBarostat(double tb) {tauBarostat = tb; have_tau_barostat=1;}
497 +  void setTargetTemp(double tt) {targetTemp = tt; have_target_temp = 1;}
498 +  void setTargetPressure(double tp) {targetPressure = tp; have_target_pressure = 1;}
499 +  void setChiTolerance(double tol) {chiTolerance = tol;}
500 +  void setPosIterTolerance(double tol) {posIterTolerance = tol;}
501 +
502 + protected:
503 +
504 +  virtual void  moveA( void );
505 +  virtual void moveB( void );
506 +
507 +  virtual void resetIntegrator( void );
508 +
509 +  virtual int readyCheck();
510 +
511 +  void accIntegralOfChidt(void) { integralOfChidt += dt * chi;}
512 +
513 +  Molecule* myMolecules;
514 +  Atom** myAtoms;
515 +
516 +  // chi and eta are the propagated degrees of freedom
517 +
518 +  double chi;
519 +  double eta[3][3];
520 +  double NkBT;
521 +  double integralOfChidt;
522 +
523 +  // targetTemp, targetPressure, and tauBarostat must be set.  
524 +  // One of qmass or tauThermostat must be set;
525 +
526 +  double targetTemp;
527 +  double targetPressure;
528 +  double tauThermostat;
529 +  double tauBarostat;
530 +
531 +  short int have_tau_thermostat, have_tau_barostat, have_target_temp;
532 +  short int have_target_pressure;
533 +  double chiTolerance;
534 +  short int have_chi_tolerance;
535 +  double posIterTolerance;
536 +  short int have_pos_iter_tolerance;
537 +
538 + };
539 +
540 +
541 + template<typename T> class NPTpr : public T{
542 +
543 + public:
544 +
545 +  NPTpr ( SimInfo *theInfo, ForceFields* the_ff);
546 +  virtual ~NPTpr() {};
547 +
548 +  virtual void integrateStep( int calcPot, int calcStress ){
549 +    calcStress = 1;
550 +    T::integrateStep( calcPot, calcStress );
551 +  }
552 +
553 +  void setTauThermostat(double tt) {tauThermostat = tt; have_tau_thermostat=1;}
554 +  void setTauBarostat(double tb) {tauBarostat = tb; have_tau_barostat=1;}
555 +  void setTargetTemp(double tt) {targetTemp = tt; have_target_temp = 1;}
556 +  void setTargetPressure(double tp) {targetPressure = tp; have_target_pressure = 1;}
557 +  void setChiTolerance(double tol) {chiTolerance = tol;}
558 +  void setPosIterTolerance(double tol) {posIterTolerance = tol;}
559 +
560 + protected:
561 +
562 +  virtual void  moveA( void );
563 +  virtual void moveB( void );
564 +
565 +  virtual int readyCheck();
566 +
567 +  virtual void resetIntegrator( void );
568 +
569 +  // chi and eta are the propagated degrees of freedom
570 +
571 +  double chi;
572 +  double eta[3][3];
573 +  double NkBT;
574 +
575 +  // targetTemp, targetPressure, and tauBarostat must be set.  
576 +  // One of qmass or tauThermostat must be set;
577 +
578 +  double targetTemp;
579 +  double targetPressure;
580 +  double tauThermostat;
581 +  double tauBarostat;
582 +
583 +  short int have_tau_thermostat, have_tau_barostat, have_target_temp;
584 +  short int have_target_pressure;
585 +  double chiTolerance;
586 +  short int have_chi_tolerance;
587 +  double posIterTolerance;
588 +  short int have_pos_iter_tolerance;
589 +
590 + };
591 +
592 +
593 + template<typename T> class ZConstraint : public T {
594 +  
595 +  public:
596 +  class ForceSubtractionPolicy{
597 +    public:
598 +      ForceSubtractionPolicy(ZConstraint<T>* integrator) {zconsIntegrator = integrator;}
599 +
600 +      virtual void update() = 0;    
601 +      virtual double getZFOfFixedZMols(Molecule* mol, Atom* atom, double totalForce) = 0;
602 +      virtual double getZFOfMovingMols(Atom* atom, double totalForce) = 0;
603 +      virtual double getHFOfFixedZMols(Molecule* mol, Atom* atom, double totalForce) = 0;
604 +      virtual double getHFOfUnconsMols(Atom* atom, double totalForce) = 0;
605 +    
606 +   protected:
607 +     ZConstraint<T>* zconsIntegrator;;
608 +  };
609 +
610 +  class PolicyByNumber : public ForceSubtractionPolicy{
611 +
612 +    public:
613 +      PolicyByNumber(ZConstraint<T>* integrator) :ForceSubtractionPolicy(integrator) {}    
614 +      virtual void update();    
615 +      virtual double getZFOfFixedZMols(Molecule* mol, Atom* atom, double totalForce) ;
616 +      virtual double getZFOfMovingMols(Atom* atom, double totalForce) ;
617 +      virtual double getHFOfFixedZMols(Molecule* mol, Atom* atom, double totalForce);
618 +      virtual double getHFOfUnconsMols(Atom* atom, double totalForce);
619 +    
620 +    private:
621 +      int totNumOfMovingAtoms;
622 +  };
623 +
624 +  class PolicyByMass : public ForceSubtractionPolicy{
625 +
626 +    public:
627 +      PolicyByMass(ZConstraint<T>* integrator) :ForceSubtractionPolicy(integrator) {}  
628 +      
629 +      virtual void update();    
630 +      virtual double getZFOfFixedZMols(Molecule* mol, Atom* atom, double totalForce) ;
631 +      virtual double getZFOfMovingMols(Atom* atom, double totalForce) ;
632 +      virtual double getHFOfFixedZMols(Molecule* mol, Atom* atom, double totalForce);
633 +      virtual double getHFOfUnconsMols(Atom* atom, double totalForce);
634 +
635 +   private:
636 +     double totMassOfMovingAtoms;
637 +  };
638 +
639 + public:
640 +
641 +  ZConstraint( SimInfo *theInfo, ForceFields* the_ff);
642 +  ~ZConstraint();
643 +    
644 +  void setZConsTime(double time)                  {this->zconsTime = time;}
645 +  void getZConsTime()                             {return zconsTime;}
646 +  
647 +  void setIndexOfAllZConsMols(vector<int> index) {indexOfAllZConsMols = index;}
648 +  void getIndexOfAllZConsMols()                  {return indexOfAllZConsMols;}
649 +  
650 +  void setZConsOutput(const char * fileName)          {zconsOutput = fileName;}
651 +  string getZConsOutput()                         {return zconsOutput;}
652 +  
653 +  virtual void integrate();
654 +  
655 +
656 + #ifdef IS_MPI
657 +  virtual void update();                      //which is called to indicate the molecules' migration
658   #endif
659 +
660 + protected:
661 +
662 +  enum ZConsState {zcsMoving, zcsFixed};  
663 +
664 +  virtual void calcForce( int calcPot, int calcStress );
665 +  virtual void thermalize(void);
666 +  
667 +  void zeroOutVel();
668 +  void doZconstraintForce();
669 +  void doHarmonic();
670 +  bool checkZConsState();
671 +
672 +  bool haveFixedZMols();
673 +  bool haveMovingZMols();
674 +
675 +  double calcZSys();
676 +
677 +  int isZConstraintMol(Molecule* mol);
678 +
679 +
680 +  double zconsTime;                              //sample time
681 +  double zconsTol;                                 //tolerance of z-contratint
682 +  double zForceConst;                           //base force constant term
683 +                                                          //which is estimate by OOPSE
684 +  
685 +  vector<Molecule*> zconsMols;              //z-constraint molecules array
686 +  vector<double> massOfZConsMols;       //mass of z-constraint molecule
687 +  vector<double> kz;                              //force constant array
688 +  vector<ZConsState> states;                 //state of z-constraint molecules
689 +  vector<double> zPos;                          //
690 +  
691 +  
692 +  vector<Molecule*> unconsMols;           //unconstraint molecules array
693 +  vector<double> massOfUnconsMols;    //mass array of unconstraint molecules
694 +  double totalMassOfUncons;                //total mas of unconstraint molecules
695 +
696 +  vector<ZConsParaItem>* parameters; //
697 +  
698 +  vector<int> indexOfAllZConsMols;     //index of All Z-Constraint Molecuels
699 +
700 +  int* indexOfZConsMols;                   //index of local Z-Constraint Molecules  
701 +  double* fz;
702 +  double* curZPos;
703 +  
704 +  int totNumOfUnconsAtoms;              //total number of uncontraint atoms
705 +
706 +  int whichDirection;                           //constraint direction
707 +  
708 + private:
709 +  
710 +  string zconsOutput;                         //filename of zconstraint output
711 +  ZConsWriter* fzOut;                         //z-constraint writer
712 +
713 +  double curZconsTime;                      
714 +
715 +  double calcMovingMolsCOMVel();
716 +  double calcSysCOMVel();
717 +  double calcTotalForce();
718 +  
719 +  ForceSubtractionPolicy* forcePolicy; //force subtraction policy
720 +  friend class ForceSubtractionPolicy;
721 +
722 + };
723 +
724 + #endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines