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 586 by mmeineke, Wed Jul 9 22:14:06 2003 UTC vs.
Revision 658 by tim, Thu Jul 31 15:35:07 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 + 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  
18 class Integrator : public BaseIntegrator {
23  
24 + template<typename T = BaseIntegrator> class Integrator : public T {
25 +
26   public:
27    Integrator( SimInfo *theInfo, ForceFields* the_ff );
28    virtual ~Integrator();
# Line 35 | Line 41 | class Integrator : public BaseIntegrator { (protected)
41    
42    void checkConstraints( void );
43    void rotate( int axes1, int axes2, double angle, double j[3],
44 <               double A[9] );
44 >               double A[3][3] );
45  
46  
47    ForceFields* myFF;
# Line 63 | Line 69 | class Integrator : public BaseIntegrator { (protected)
69    double dt;
70    double dt2;
71  
66  double* pos;
67  double* vel;
68  double* frc;
69  double* trq;
70  double* Amat;
71
72    Thermo *tStats;
73    StatWriter*  statOut;
74    DumpWriter*  dumpOut;
75    
76   };
77  
78 < class NVE : public Integrator{
78 > typedef Integrator<BaseIntegrator> RealIntegrator;
79  
80 + template<typename T> class NVE : public T {
81 +
82   public:
83    NVE ( SimInfo *theInfo, ForceFields* the_ff ):
84 <    Integrator( theInfo, the_ff ){}
85 <  virtual ~NVE(){}
84 <
85 <  
86 <
84 >    T( theInfo, the_ff ){}
85 >  virtual ~NVE(){}  
86   };
87  
89 class NVT : public Integrator{
88  
89 + template<typename T> class NVT : public T {
90 +
91   public:
92  
93    NVT ( SimInfo *theInfo, ForceFields* the_ff);
# Line 117 | Line 117 | class NPTi : public Integrator{
117   };
118  
119  
120 class NPTi : public Integrator{
120  
121 + template<typename T> class NPTi : public T{
122 +
123   public:
124  
125    NPTi ( SimInfo *theInfo, ForceFields* the_ff);
126    virtual ~NPTi() {};
127  
128 +  virtual void integrateStep( int calcPot, int calcStress ){
129 +    calcStress = 1;
130 +    T::integrateStep( calcPot, calcStress );
131 +  }
132 +
133    void setTauThermostat(double tt) {tauThermostat = tt; have_tau_thermostat=1;}
134    void setTauBarostat(double tb) {tauBarostat = tb; have_tau_barostat=1;}
135    void setTargetTemp(double tt) {targetTemp = tt; have_target_temp = 1;}
# Line 155 | Line 161 | class NPTf : public Integrator{
161  
162   };
163  
164 < class NPTf : public Integrator{
164 > template<typename T> class NPTim : public T{
165  
166   public:
167  
168 +  NPTim ( SimInfo *theInfo, ForceFields* the_ff);
169 +  virtual ~NPTim() {};
170 +
171 +  virtual void integrateStep( int calcPot, int calcStress ){
172 +    calcStress = 1;
173 +    T::integrateStep( calcPot, calcStress );
174 +  }
175 +
176 +  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;}
180 +
181 + protected:
182 +
183 +  virtual void moveA( void );
184 +  virtual void moveB( void );
185 +
186 +  virtual int readyCheck();
187 +
188 +  Molecule* myMolecules;
189 +  Atom** myAtoms;
190 +
191 +  // 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 +
208 + };
209 +
210 + template<typename T> class NPTf : public T{
211 +
212 + public:
213 +
214    NPTf ( SimInfo *theInfo, ForceFields* the_ff);
215    virtual ~NPTf() {};
216  
217 +  virtual void integrateStep( int calcPot, int calcStress ){
218 +    calcStress = 1;
219 +    T::integrateStep( calcPot, calcStress );
220 +  }
221 +
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;}
# Line 177 | Line 234 | class NPTf : public Integrator{ (protected)
234    // chi and eta are the propagated degrees of freedom
235  
236    double chi;
237 <  double eta[9];
237 >  double eta[3][3];
238 >  double NkBT;
239 >
240 >  // targetTemp, targetPressure, and tauBarostat must be set.  
241 >  // One of qmass or tauThermostat must be set;
242 >
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 >
251 > };
252 >
253 > template<typename T> class NPTfm : public T{
254 >
255 > public:
256 >
257 >  NPTfm ( SimInfo *theInfo, ForceFields* the_ff);
258 >  virtual ~NPTfm() {};
259 >
260 >  virtual void integrateStep( int calcPot, int calcStress ){
261 >    calcStress = 1;
262 >    T::integrateStep( calcPot, calcStress );
263 >  }
264 >
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 >
270 > protected:
271 >
272 >  virtual void  moveA( void );
273 >  virtual void moveB( void );
274 >
275 >  virtual int readyCheck();
276 >
277 >  Molecule* myMolecules;
278 >  Atom** myAtoms;
279 >
280 >  // chi and eta are the propagated degrees of freedom
281 >
282 >  double chi;
283 >  double eta[3][3];
284    double NkBT;
285  
286    // targetTemp, targetPressure, and tauBarostat must be set.  
# Line 193 | Line 296 | class NPTf : public Integrator{ (protected)
296  
297   };
298  
299 + template<typename T> class ZConstraint : public T {
300 +
301 + public:
302 +
303 +  ZConstraint( SimInfo *theInfo, ForceFields* the_ff);
304 +  ~ZConstraint();
305 +
306 +  virtual void integrateStep( int calcPot, int calcStress );
307 +  
308 +  
309 +  void setZConsTime(double time)                  {this->zconsTime = time;}
310 +  void getZConsTime()                             {return zconsTime;}
311 +  
312 +  void setIndexOfAllZConsMols(vector<int> index)  {indexOfAllZConsMols = index;}
313 +  void getIndexOfAllZConsMols()                   {return indexOfAllZConsMols;}
314 +  
315 +  void setZConsOutput(const char * fileName)      {zconsOutput = fileName;}
316 +  string getZConsOutput()                         {return zconsOutput;}
317 +
318 + #ifdef IS_MPI
319 +  virtual void update(); //which is called to indicate the molecules' migration
320   #endif
321 +
322 + protected:
323 +
324 +  double zconsTime;
325 +  
326 +  void resetZ(void);
327 +  
328 +  vector<Molecule*> zconsMols;
329 +  vector<double> massOfZConsMols;
330 +  
331 +  vector<Molecule*> unconsMols;
332 +  vector<double> massOfUnconsMols;
333 +  double totalMassOfUncons;
334 +
335 +  vector<double> allRefZ;    
336 +  vector<double> refZ;
337 +  
338 +  vector<int> indexOfAllZConsMols;     //index of All Z-Constraint Molecuels
339 +  int* indexOfZConsMols;               //index of local Z-Constraint Molecules
340 +    
341 +  double* fz;
342 +  
343 + private:
344 +
345 +  int isZConstraintMol(Molecule* mol);
346 +  string zconsOutput;
347 +  ZConsWriter* fzOut;
348 + };
349 +
350 + #endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines