--- trunk/OOPSE/libmdtools/Integrator.hpp 2003/08/13 19:21:53 693 +++ trunk/OOPSE/libmdtools/Integrator.hpp 2003/09/02 14:30:12 738 @@ -44,8 +44,8 @@ template class Integrator void checkConstraints( void ); void rotate( int axes1, int axes2, double angle, double j[3], - double A[3][3] ); - + double A[3][3] ); + ForceFields* myFF; SimInfo *info; // all the info we'll ever need @@ -56,7 +56,7 @@ template class Integrator int nMols; int isConstrained; // boolean to know whether the systems contains - // constraints. + // constraints. int nConstrained; // counter for number of constraints int *constrainedA; // the i of a constraint pair int *constrainedB; // the j of a constraint pair @@ -297,9 +297,96 @@ template class NPTfm : public T{ (protecte short int have_target_pressure; }; + + +template class NPTpr : public T{ + +public: + + NPTpr ( SimInfo *theInfo, ForceFields* the_ff); + virtual ~NPTpr() {}; + + virtual void integrateStep( int calcPot, int calcStress ){ + calcStress = 1; + T::integrateStep( calcPot, calcStress ); + } + + void setTauThermostat(double tt) {tauThermostat = tt; have_tau_thermostat=1;} + void setTauBarostat(double tb) {tauBarostat = tb; have_tau_barostat=1;} + void setTargetTemp(double tt) {targetTemp = tt; have_target_temp = 1;} + void setTargetPressure(double tp) {targetPressure = tp; have_target_pressure = 1;} +protected: + + virtual void moveA( void ); + virtual void moveB( void ); + + virtual int readyCheck(); + + // chi and eta are the propagated degrees of freedom + + double chi; + double eta[3][3]; + double NkBT; + + // targetTemp, targetPressure, and tauBarostat must be set. + // One of qmass or tauThermostat must be set; + + double targetTemp; + double targetPressure; + double tauThermostat; + double tauBarostat; + + short int have_tau_thermostat, have_tau_barostat, have_target_temp; + short int have_target_pressure; + +}; + + template class ZConstraint : public T { + + public: + class ForceSubtractionPolicy{ + public: + ForceSubtractionPolicy(ZConstraint* integrator) {zconsIntegrator = integrator;} + virtual void update() = 0; + virtual double getZFOfFixedZMols(Molecule* mol, Atom* atom, double totalForce) = 0; + virtual double getZFOfMovingMols(Atom* atom, double totalForce) = 0; + virtual double getHFOfFixedZMols(Molecule* mol, Atom* atom, double totalForce) = 0; + virtual double getHFOfUnconsMols(Atom* atom, double totalForce) = 0; + + protected: + ZConstraint* zconsIntegrator;; + }; + + class PolicyByNumber : public ForceSubtractionPolicy{ + public: + PolicyByNumber(ZConstraint* integrator) :ForceSubtractionPolicy(integrator) {} + virtual void update(); + virtual double getZFOfFixedZMols(Molecule* mol, Atom* atom, double totalForce) ; + virtual double getZFOfMovingMols(Atom* atom, double totalForce) ; + virtual double getHFOfFixedZMols(Molecule* mol, Atom* atom, double totalForce); + virtual double getHFOfUnconsMols(Atom* atom, double totalForce); + + private: + int totNumOfMovingAtoms; + }; + + class PolicyByMass : public ForceSubtractionPolicy{ + public: + PolicyByMass(ZConstraint* integrator) :ForceSubtractionPolicy(integrator) {} + + virtual void update(); + virtual double getZFOfFixedZMols(Molecule* mol, Atom* atom, double totalForce) ; + virtual double getZFOfMovingMols(Atom* atom, double totalForce) ; + virtual double getHFOfFixedZMols(Molecule* mol, Atom* atom, double totalForce); + virtual double getHFOfUnconsMols(Atom* atom, double totalForce); + + private: + double totMassOfMovingAtoms; + }; + public: ZConstraint( SimInfo *theInfo, ForceFields* the_ff); @@ -308,24 +395,22 @@ template class ZConstraint : public T { (p void setZConsTime(double time) {this->zconsTime = time;} void getZConsTime() {return zconsTime;} - void setIndexOfAllZConsMols(vector index) {indexOfAllZConsMols = index;} - void getIndexOfAllZConsMols() {return indexOfAllZConsMols;} + void setIndexOfAllZConsMols(vector index) {indexOfAllZConsMols = index;} + void getIndexOfAllZConsMols() {return indexOfAllZConsMols;} - void setZConsOutput(const char * fileName) {zconsOutput = fileName;} + 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 + virtual void update(); //which is called to indicate the molecules' migration #endif protected: - enum ZConsState {zcsMoving, zcsFixed}; - - + enum ZConsState {zcsMoving, zcsFixed}; virtual void calcForce( int calcPot, int calcStress ); virtual void thermalize(void); @@ -343,40 +428,48 @@ template class ZConstraint : public T { (p int isZConstraintMol(Molecule* mol); - double zconsTime; - double zconsTol; - double zForceConst; + double zconsTime; //sample time + double zconsTol; //tolerance of z-contratint + double zForceConst; //base force constant term + //which is estimate by OOPSE - vector zconsMols; - vector massOfZConsMols; - vector kz; - vector states; - vector zPos; + vector zconsMols; //z-constraint molecules array + vector massOfZConsMols; //mass of z-constraint molecule + vector kz; //force constant array + vector states; //state of z-constraint molecules + vector zPos; // - vector unconsMols; - vector massOfUnconsMols; - double totalMassOfUncons; + vector unconsMols; //unconstraint molecules array + vector massOfUnconsMols; //mass array of unconstraint molecules + double totalMassOfUncons; //total mas of unconstraint molecules - vector* parameters; + vector* parameters; // vector indexOfAllZConsMols; //index of All Z-Constraint Molecuels int* indexOfZConsMols; //index of local Z-Constraint Molecules double* fz; + double* curZPos; - int totNumOfUnconsAtoms; + int totNumOfUnconsAtoms; //total number of uncontraint atoms int whichDirection; //constraint direction private: - string zconsOutput; - ZConsWriter* fzOut; + string zconsOutput; //filename of zconstraint output + ZConsWriter* fzOut; //z-constraint writer - double calcCOMVel(); - double calcCOMVel2(); + double curZconsTime; + double calcMovingMolsCOMVel(); + double calcSysCOMVel(); + double calcTotalForce(); + + ForceSubtractionPolicy* forcePolicy; //force substration policy + friend class ForceSubtractionPolicy; + }; #endif