--- trunk/OOPSE/libmdtools/Integrator.hpp 2003/09/05 21:28:52 747 +++ trunk/OOPSE/libmdtools/Integrator.hpp 2003/09/19 20:00:27 778 @@ -27,10 +27,10 @@ template class Integrator Integrator( SimInfo *theInfo, ForceFields* the_ff ); virtual ~Integrator(); void integrate( void ); + virtual double getConservedQuantity(void); - protected: - + virtual void integrateStep( int calcPot, int calcStress ); virtual void preMove( void ); virtual void moveA( void ); @@ -40,10 +40,12 @@ template class Integrator virtual int readyCheck( void ) { return 1; } virtual void resetIntegrator( void ) { } - + virtual void calcForce( int calcPot, int calcStress ); virtual void thermalize(); + virtual void rotationPropagation( DirectionalAtom* dAtom, double ji[3] ); + void checkConstraints( void ); void rotate( int axes1, int axes2, double angle, double j[3], double A[3][3] ); @@ -95,10 +97,12 @@ template class NVT : public T { (public) public: NVT ( SimInfo *theInfo, ForceFields* the_ff); - virtual ~NVT() {} + virtual ~NVT(); void setTauThermostat(double tt) {tauThermostat = tt; have_tau_thermostat=1;} void setTargetTemp(double tt) {targetTemp = tt; have_target_temp = 1;} + void setChiTolerance(double tol) {chiTolerance = tol;} + virtual double getConservedQuantity(void); protected: @@ -113,6 +117,9 @@ template class NVT : public T { (public) double chi; + //integral of chi(t)dt + double integralOfChidt; + // targetTemp must be set. tauThermostat must also be set; double targetTemp; @@ -120,26 +127,37 @@ template class NVT : public T { (public) short int have_tau_thermostat, have_target_temp; + double *oldVel; + double *oldJi; + + double chiTolerance; + short int have_chi_tolerance; + }; -template class NPTi : public T{ +template class NPT : public T{ public: - NPTi ( SimInfo *theInfo, ForceFields* the_ff); - virtual ~NPTi() {}; - + NPT ( SimInfo *theInfo, ForceFields* the_ff); + virtual ~NPT(); + virtual void integrateStep( int calcPot, int calcStress ){ calcStress = 1; T::integrateStep( calcPot, calcStress ); } + virtual double getConservedQuantity(void) = 0; + 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;} + void setChiTolerance(double tol) {chiTolerance = tol; have_chi_tolerance = 1;} + void setPosIterTolerance(double tol) {posIterTolerance = tol; have_pos_iter_tolerance = 1;} + void setEtaTolerance(double tol) {etaTolerance = tol; have_eta_tolerance = 1;} protected: @@ -150,12 +168,38 @@ template class NPTi : public T{ (protected virtual void resetIntegrator( void ); + virtual void getVelScaleA( double sc[3], double vel[3] ) = 0; + virtual void getVelScaleB( double sc[3], int index ) = 0; + virtual void getPosScale(double pos[3], double COM[3], + int index, double sc[3]) = 0; + + virtual bool chiConverged( void ); + virtual bool etaConverged( void ) = 0; + + virtual void evolveChiA( void ); + virtual void evolveEtaA( void ) = 0; + virtual void evolveChiB( void ); + virtual void evolveEtaB( void ) = 0; + + virtual void scaleSimBox( void ) = 0; + + void accIntegralOfChidt(void) { integralOfChidt += dt * chi;} + // chi and eta are the propagated degrees of freedom + double oldChi; + double prevChi; double chi; - double eta; double NkBT; + double fkBT; + double tt2, tb2; + double instaTemp, instaPress, instaVol; + + int Nparticles; + + double integralOfChidt; + // targetTemp, targetPressure, and tauBarostat must be set. // One of qmass or tauThermostat must be set; @@ -166,25 +210,70 @@ template class NPTi : public T{ (protected short int have_tau_thermostat, have_tau_barostat, have_target_temp; short int have_target_pressure; + + double *oldPos; + double *oldVel; + double *oldJi; + double chiTolerance; + short int have_chi_tolerance; + double posIterTolerance; + short int have_pos_iter_tolerance; + double etaTolerance; + short int have_eta_tolerance; + }; +template class NPTi : public T{ + +public: + NPTi( SimInfo *theInfo, ForceFields* the_ff); + ~NPTi(); + + virtual double getConservedQuantity(void); + virtual void resetIntegrator(void); + +protected: + + + + virtual void evolveEtaA(void); + virtual void evolveEtaB(void); + + virtual bool etaConverged( void ); + + virtual void scaleSimBox( void ); + + virtual void getVelScaleA( double sc[3], double vel[3] ); + virtual void getVelScaleB( double sc[3], int index ); + virtual void getPosScale(double pos[3], double COM[3], + int index, double sc[3]); + + double eta, oldEta, prevEta; +}; + + template class NPTim : public T{ public: NPTim ( SimInfo *theInfo, ForceFields* the_ff); - virtual ~NPTim() {}; + virtual ~NPTim() {} virtual void integrateStep( int calcPot, int calcStress ){ calcStress = 1; T::integrateStep( calcPot, calcStress ); + accIntegralOfChidt(); } + virtual double getConservedQuantity(void); + 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;} + void setChiTolerance(double tol) {chiTolerance = tol;} + void setPosIterTolerance(double tol) {posIterTolerance = tol;} protected: @@ -195,6 +284,8 @@ template class NPTim : public T{ (protecte virtual void resetIntegrator( void ); + void accIntegralOfChidt(void) { integralOfChidt += dt * chi;} + Molecule* myMolecules; Atom** myAtoms; @@ -203,6 +294,7 @@ template class NPTim : public T{ (protecte double chi; double eta; double NkBT; + double integralOfChidt; // targetTemp, targetPressure, and tauBarostat must be set. // One of qmass or tauThermostat must be set; @@ -214,25 +306,82 @@ template class NPTim : public T{ (protecte short int have_tau_thermostat, have_tau_barostat, have_target_temp; short int have_target_pressure; + double chiTolerance; + short int have_chi_tolerance; + double posIterTolerance; + short int have_pos_iter_tolerance; }; +template class NPTzm : public T{ + +public: + + NPTzm ( SimInfo *theInfo, ForceFields* the_ff); + virtual ~NPTzm() {}; + + 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(); + + virtual void resetIntegrator( void ); + + Molecule* myMolecules; + Atom** myAtoms; + + // chi and eta are the propagated degrees of freedom + + double chi; + double eta; + double etaZ; + 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 NPTf : public T{ public: NPTf ( SimInfo *theInfo, ForceFields* the_ff); - virtual ~NPTf() {}; + virtual ~NPTf(); virtual void integrateStep( int calcPot, int calcStress ){ calcStress = 1; T::integrateStep( calcPot, calcStress ); } + + virtual double getConservedQuantity(void); 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;} + void setChiTolerance(double tol) {chiTolerance = tol;} + void setPosIterTolerance(double tol) {posIterTolerance = tol;} protected: @@ -243,10 +392,75 @@ template class NPTf : public T{ (protected virtual int readyCheck(); + // chi and eta are the propagated degrees of freedom double chi; double eta[3][3]; + double NkBT; + double fkBT; + + int Nparticles; + + double *oldPos; + double *oldVel; + double *oldJi; + + double integralOfChidt; + + // 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; + double chiTolerance; + short int have_chi_tolerance; + double posIterTolerance; + short int have_pos_iter_tolerance; + double etaTolerance; + short int have_eta_tolerance; +}; + +template class NPTxym : public T{ + +public: + + NPTxym ( SimInfo *theInfo, ForceFields* the_ff); + virtual ~NPTxym() {}; + + 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(); + + virtual void resetIntegrator( void ); + + Molecule* myMolecules; + Atom** myAtoms; + + // chi and eta are the propagated degrees of freedom + + double chi; + double eta; + double etaX; + double etaY; double NkBT; // targetTemp, targetPressure, and tauBarostat must be set. @@ -262,6 +476,7 @@ template class NPTfm : public T{ }; + template class NPTfm : public T{ public: @@ -272,12 +487,17 @@ template class NPTfm : public T{ (public) virtual void integrateStep( int calcPot, int calcStress ){ calcStress = 1; T::integrateStep( calcPot, calcStress ); + accIntegralOfChidt(); } + virtual double getConservedQuantity(void); + 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;} + void setChiTolerance(double tol) {chiTolerance = tol;} + void setPosIterTolerance(double tol) {posIterTolerance = tol;} protected: @@ -288,6 +508,8 @@ template class NPTfm : public T{ (public) virtual int readyCheck(); + void accIntegralOfChidt(void) { integralOfChidt += dt * chi;} + Molecule* myMolecules; Atom** myAtoms; @@ -296,6 +518,7 @@ template class NPTfm : public T{ (public) double chi; double eta[3][3]; double NkBT; + double integralOfChidt; // targetTemp, targetPressure, and tauBarostat must be set. // One of qmass or tauThermostat must be set; @@ -307,6 +530,10 @@ template class NPTfm : public T{ (public) short int have_tau_thermostat, have_tau_barostat, have_target_temp; short int have_target_pressure; + double chiTolerance; + short int have_chi_tolerance; + double posIterTolerance; + short int have_pos_iter_tolerance; }; @@ -327,6 +554,8 @@ template class NPTpr : public T{ (public) 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;} + void setChiTolerance(double tol) {chiTolerance = tol;} + void setPosIterTolerance(double tol) {posIterTolerance = tol;} protected: @@ -353,6 +582,10 @@ template class NPTpr : public T{ (public) short int have_tau_thermostat, have_tau_barostat, have_target_temp; short int have_target_pressure; + double chiTolerance; + short int have_chi_tolerance; + double posIterTolerance; + short int have_pos_iter_tolerance; }; @@ -385,7 +618,7 @@ template class ZConstraint : public T { virtual double getHFOfUnconsMols(Atom* atom, double totalForce); private: - int totNumOfMovingAtoms; + int totNumOfMovingAtoms; }; class PolicyByMass : public ForceSubtractionPolicy{