| 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(); |
| 38 |
|
virtual void constrainA( void ); |
| 39 |
|
virtual void constrainB( void ); |
| 40 |
|
virtual int readyCheck( void ) { return 1; } |
| 41 |
+ |
|
| 42 |
+ |
virtual void calcForce( int calcPot, int calcStress ); |
| 43 |
+ |
virtual void thermalize(); |
| 44 |
|
|
| 45 |
|
void checkConstraints( void ); |
| 46 |
|
void rotate( int axes1, int axes2, double angle, double j[3], |
| 47 |
|
double A[3][3] ); |
| 48 |
< |
|
| 40 |
< |
|
| 48 |
> |
|
| 49 |
|
ForceFields* myFF; |
| 50 |
|
|
| 51 |
|
SimInfo *info; // all the info we'll ever need |
| 77 |
|
|
| 78 |
|
}; |
| 79 |
|
|
| 80 |
< |
class NVE : public Integrator{ |
| 80 |
> |
typedef Integrator<BaseIntegrator> RealIntegrator; |
| 81 |
|
|
| 82 |
+ |
template<typename T> class NVE : public T { |
| 83 |
+ |
|
| 84 |
|
public: |
| 85 |
|
NVE ( SimInfo *theInfo, ForceFields* the_ff ): |
| 86 |
< |
Integrator( theInfo, the_ff ){} |
| 87 |
< |
virtual ~NVE(){} |
| 78 |
< |
|
| 79 |
< |
|
| 80 |
< |
|
| 86 |
> |
T( theInfo, the_ff ){} |
| 87 |
> |
virtual ~NVE(){} |
| 88 |
|
}; |
| 89 |
|
|
| 83 |
– |
class NVT : public Integrator{ |
| 90 |
|
|
| 91 |
+ |
template<typename T> class NVT : public T { |
| 92 |
+ |
|
| 93 |
|
public: |
| 94 |
|
|
| 95 |
|
NVT ( SimInfo *theInfo, ForceFields* the_ff); |
| 119 |
|
}; |
| 120 |
|
|
| 121 |
|
|
| 114 |
– |
class NPTi : public Integrator{ |
| 122 |
|
|
| 123 |
+ |
template<typename T> class NPTi : public T{ |
| 124 |
+ |
|
| 125 |
|
public: |
| 126 |
|
|
| 127 |
|
NPTi ( SimInfo *theInfo, ForceFields* the_ff); |
| 129 |
|
|
| 130 |
|
virtual void integrateStep( int calcPot, int calcStress ){ |
| 131 |
|
calcStress = 1; |
| 132 |
< |
Integrator::integrateStep( calcPot, calcStress ); |
| 132 |
> |
T::integrateStep( calcPot, calcStress ); |
| 133 |
|
} |
| 134 |
|
|
| 135 |
|
void setTauThermostat(double tt) {tauThermostat = tt; have_tau_thermostat=1;} |
| 163 |
|
|
| 164 |
|
}; |
| 165 |
|
|
| 166 |
< |
class NPTim : public Integrator{ |
| 166 |
> |
template<typename T> class NPTim : public T{ |
| 167 |
|
|
| 168 |
|
public: |
| 169 |
|
|
| 172 |
|
|
| 173 |
|
virtual void integrateStep( int calcPot, int calcStress ){ |
| 174 |
|
calcStress = 1; |
| 175 |
< |
Integrator::integrateStep( calcPot, calcStress ); |
| 175 |
> |
T::integrateStep( calcPot, calcStress ); |
| 176 |
|
} |
| 177 |
|
|
| 178 |
|
void setTauThermostat(double tt) {tauThermostat = tt; have_tau_thermostat=1;} |
| 182 |
|
|
| 183 |
|
protected: |
| 184 |
|
|
| 185 |
< |
virtual void moveA( void ); |
| 185 |
> |
virtual void moveA( void ); |
| 186 |
|
virtual void moveB( void ); |
| 187 |
|
|
| 188 |
|
virtual int readyCheck(); |
| 189 |
|
|
| 190 |
+ |
Molecule* myMolecules; |
| 191 |
+ |
Atom** myAtoms; |
| 192 |
+ |
|
| 193 |
|
// chi and eta are the propagated degrees of freedom |
| 194 |
|
|
| 195 |
|
double chi; |
| 209 |
|
|
| 210 |
|
}; |
| 211 |
|
|
| 212 |
< |
class NPTf : public Integrator{ |
| 212 |
> |
template<typename T> class NPTf : public T{ |
| 213 |
|
|
| 214 |
|
public: |
| 215 |
|
|
| 218 |
|
|
| 219 |
|
virtual void integrateStep( int calcPot, int calcStress ){ |
| 220 |
|
calcStress = 1; |
| 221 |
< |
Integrator::integrateStep( calcPot, calcStress ); |
| 221 |
> |
T::integrateStep( calcPot, calcStress ); |
| 222 |
|
} |
| 223 |
|
|
| 224 |
|
void setTauThermostat(double tt) {tauThermostat = tt; have_tau_thermostat=1;} |
| 252 |
|
|
| 253 |
|
}; |
| 254 |
|
|
| 255 |
< |
class NPTfm : public Integrator{ |
| 255 |
> |
template<typename T> class NPTfm : public T{ |
| 256 |
|
|
| 257 |
|
public: |
| 258 |
|
|
| 261 |
|
|
| 262 |
|
virtual void integrateStep( int calcPot, int calcStress ){ |
| 263 |
|
calcStress = 1; |
| 264 |
< |
Integrator::integrateStep( calcPot, calcStress ); |
| 264 |
> |
T::integrateStep( calcPot, calcStress ); |
| 265 |
|
} |
| 266 |
|
|
| 267 |
|
void setTauThermostat(double tt) {tauThermostat = tt; have_tau_thermostat=1;} |
| 276 |
|
|
| 277 |
|
virtual int readyCheck(); |
| 278 |
|
|
| 279 |
+ |
Molecule* myMolecules; |
| 280 |
+ |
Atom** myAtoms; |
| 281 |
+ |
|
| 282 |
|
// chi and eta are the propagated degrees of freedom |
| 283 |
|
|
| 284 |
|
double chi; |
| 298 |
|
|
| 299 |
|
}; |
| 300 |
|
|
| 301 |
+ |
template<typename T> class ZConstraint : public T { |
| 302 |
+ |
|
| 303 |
+ |
public: |
| 304 |
+ |
|
| 305 |
+ |
ZConstraint( SimInfo *theInfo, ForceFields* the_ff); |
| 306 |
+ |
~ZConstraint(); |
| 307 |
+ |
|
| 308 |
+ |
void setZConsTime(double time) {this->zconsTime = time;} |
| 309 |
+ |
void getZConsTime() {return zconsTime;} |
| 310 |
+ |
|
| 311 |
+ |
void setIndexOfAllZConsMols(vector<int> index) {indexOfAllZConsMols = index;} |
| 312 |
+ |
void getIndexOfAllZConsMols() {return indexOfAllZConsMols;} |
| 313 |
+ |
|
| 314 |
+ |
void setZConsOutput(const char * fileName) {zconsOutput = fileName;} |
| 315 |
+ |
string getZConsOutput() {return zconsOutput;} |
| 316 |
+ |
|
| 317 |
+ |
virtual void integrate(); |
| 318 |
+ |
|
| 319 |
+ |
|
| 320 |
+ |
#ifdef IS_MPI |
| 321 |
+ |
virtual void update(); //which is called to indicate the molecules' migration |
| 322 |
|
#endif |
| 323 |
+ |
|
| 324 |
+ |
protected: |
| 325 |
+ |
|
| 326 |
+ |
enum ZConsState {zcsMoving, zcsFixed}; |
| 327 |
+ |
|
| 328 |
+ |
|
| 329 |
+ |
|
| 330 |
+ |
virtual void calcForce( int calcPot, int calcStress ); |
| 331 |
+ |
virtual void thermalize(void); |
| 332 |
+ |
|
| 333 |
+ |
void zeroOutVel(); |
| 334 |
+ |
void doZconstraintForce(); |
| 335 |
+ |
bool checkZConsState(); |
| 336 |
+ |
|
| 337 |
+ |
bool haveFixedZMols(); |
| 338 |
+ |
bool haveMovingZMols(); |
| 339 |
+ |
|
| 340 |
+ |
double calcZSys(); |
| 341 |
+ |
|
| 342 |
+ |
int isZConstraintMol(Molecule* mol); |
| 343 |
+ |
|
| 344 |
+ |
|
| 345 |
+ |
double zconsTime; |
| 346 |
+ |
double ztol; |
| 347 |
+ |
|
| 348 |
+ |
vector<Molecule*> zconsMols; |
| 349 |
+ |
vector<double> massOfZConsMols; |
| 350 |
+ |
vector<double> zconsPos; |
| 351 |
+ |
vector<double> kz; |
| 352 |
+ |
vector<ZConsState> states; |
| 353 |
+ |
vector<double> ZPos; |
| 354 |
+ |
|
| 355 |
+ |
|
| 356 |
+ |
vector<Molecule*> unconsMols; |
| 357 |
+ |
vector<double> massOfUnconsMols; |
| 358 |
+ |
double totalMassOfUncons; |
| 359 |
+ |
|
| 360 |
+ |
vector<int> indexOfAllZConsMols; //index of All Z-Constraint Molecuels |
| 361 |
+ |
|
| 362 |
+ |
int* indexOfZConsMols; //index of local Z-Constraint Molecules |
| 363 |
+ |
double* fz; |
| 364 |
+ |
|
| 365 |
+ |
int totNumOfUnconsAtoms; |
| 366 |
+ |
|
| 367 |
+ |
int whichDirection; //constraint direction |
| 368 |
+ |
|
| 369 |
+ |
private: |
| 370 |
+ |
|
| 371 |
+ |
string zconsOutput; |
| 372 |
+ |
ZConsWriter* fzOut; |
| 373 |
+ |
|
| 374 |
+ |
|
| 375 |
+ |
}; |
| 376 |
+ |
|
| 377 |
+ |
#endif |