--- trunk/OOPSE/libmdtools/Integrator.hpp 2003/07/15 03:27:24 605 +++ trunk/OOPSE/libmdtools/Integrator.hpp 2003/08/13 19:21:53 693 @@ -1,6 +1,8 @@ #ifndef _INTEGRATOR_H_ #define _INTEGRATOR_H_ +#include +#include #include "Atom.hpp" #include "Molecule.hpp" #include "SRI.hpp" @@ -9,15 +11,18 @@ #include "ForceFields.hpp" #include "Thermo.hpp" #include "ReadWrite.hpp" +#include "ZConsWriter.hpp" +using namespace std; const double kB = 8.31451e-7;// boltzmann constant amu*Ang^2*fs^-2/K const double eConvert = 4.184e-4; // converts kcal/mol -> amu*A^2/fs^2 const double p_convert = 1.63882576e8; //converts amu*fs^-2*Ang^-1 -> atm const int maxIteration = 300; const double tol = 1.0e-6; -class Integrator : public BaseIntegrator { +template class Integrator : public T { + public: Integrator( SimInfo *theInfo, ForceFields* the_ff ); virtual ~Integrator(); @@ -33,12 +38,14 @@ class Integrator : public BaseIntegrator { (protected) virtual void constrainA( void ); virtual void constrainB( void ); virtual int readyCheck( void ) { return 1; } + + virtual void calcForce( int calcPot, int calcStress ); + virtual void thermalize(); void checkConstraints( void ); void rotate( int axes1, int axes2, double angle, double j[3], double A[3][3] ); - - + ForceFields* myFF; SimInfo *info; // all the info we'll ever need @@ -70,19 +77,19 @@ class NVE : public Integrator{ }; -class NVE : public Integrator{ +typedef Integrator RealIntegrator; +template class NVE : public T { + public: NVE ( SimInfo *theInfo, ForceFields* the_ff ): - Integrator( theInfo, the_ff ){} - virtual ~NVE(){} - - - + T( theInfo, the_ff ){} + virtual ~NVE(){} }; -class NVT : public Integrator{ +template class NVT : public T { + public: NVT ( SimInfo *theInfo, ForceFields* the_ff); @@ -112,8 +119,9 @@ class NPTi : public Integrator{ }; -class NPTi : public Integrator{ +template class NPTi : public T{ + public: NPTi ( SimInfo *theInfo, ForceFields* the_ff); @@ -121,7 +129,7 @@ class NPTi : public Integrator{ (public) virtual void integrateStep( int calcPot, int calcStress ){ calcStress = 1; - Integrator::integrateStep( calcPot, calcStress ); + T::integrateStep( calcPot, calcStress ); } void setTauThermostat(double tt) {tauThermostat = tt; have_tau_thermostat=1;} @@ -155,7 +163,7 @@ class NPTim : public Integrator{ }; -class NPTim : public Integrator{ +template class NPTim : public T{ public: @@ -164,7 +172,7 @@ class NPTim : public Integrator{ (public) virtual void integrateStep( int calcPot, int calcStress ){ calcStress = 1; - Integrator::integrateStep( calcPot, calcStress ); + T::integrateStep( calcPot, calcStress ); } void setTauThermostat(double tt) {tauThermostat = tt; have_tau_thermostat=1;} @@ -201,7 +209,7 @@ class NPTf : public Integrator{ }; -class NPTf : public Integrator{ +template class NPTf : public T{ public: @@ -210,7 +218,7 @@ class NPTf : public Integrator{ (public) virtual void integrateStep( int calcPot, int calcStress ){ calcStress = 1; - Integrator::integrateStep( calcPot, calcStress ); + T::integrateStep( calcPot, calcStress ); } void setTauThermostat(double tt) {tauThermostat = tt; have_tau_thermostat=1;} @@ -244,7 +252,7 @@ class NPTfm : public Integrator{ }; -class NPTfm : public Integrator{ +template class NPTfm : public T{ public: @@ -253,7 +261,7 @@ class NPTfm : public Integrator{ (public) virtual void integrateStep( int calcPot, int calcStress ){ calcStress = 1; - Integrator::integrateStep( calcPot, calcStress ); + T::integrateStep( calcPot, calcStress ); } void setTauThermostat(double tt) {tauThermostat = tt; have_tau_thermostat=1;} @@ -290,4 +298,85 @@ class NPTfm : public Integrator{ (public) }; +template class ZConstraint : public T { + +public: + + ZConstraint( SimInfo *theInfo, ForceFields* the_ff); + ~ZConstraint(); + + void setZConsTime(double time) {this->zconsTime = time;} + void getZConsTime() {return zconsTime;} + + void setIndexOfAllZConsMols(vector index) {indexOfAllZConsMols = index;} + void getIndexOfAllZConsMols() {return indexOfAllZConsMols;} + + void setZConsOutput(const char * fileName) {zconsOutput = fileName;} + string getZConsOutput() {return zconsOutput;} + + virtual void integrate(); + + +#ifdef IS_MPI + virtual void update(); //which is called to indicate the molecules' migration #endif + +protected: + + enum ZConsState {zcsMoving, zcsFixed}; + + + + virtual void calcForce( int calcPot, int calcStress ); + virtual void thermalize(void); + + void zeroOutVel(); + void doZconstraintForce(); + void doHarmonic(); + bool checkZConsState(); + + bool haveFixedZMols(); + bool haveMovingZMols(); + + double calcZSys(); + + int isZConstraintMol(Molecule* mol); + + + double zconsTime; + double zconsTol; + double zForceConst; + + vector zconsMols; + vector massOfZConsMols; + vector kz; + vector states; + vector zPos; + + + vector unconsMols; + vector massOfUnconsMols; + double totalMassOfUncons; + + vector* parameters; + + vector indexOfAllZConsMols; //index of All Z-Constraint Molecuels + + int* indexOfZConsMols; //index of local Z-Constraint Molecules + double* fz; + + int totNumOfUnconsAtoms; + + int whichDirection; //constraint direction + +private: + + string zconsOutput; + ZConsWriter* fzOut; + + double calcCOMVel(); + double calcCOMVel2(); + +}; + +#endif