--- trunk/OOPSE/libmdtools/Integrator.hpp 2003/04/07 14:30:36 466 +++ trunk/OOPSE/libmdtools/Integrator.hpp 2003/06/20 20:29:36 561 @@ -6,77 +6,159 @@ #include "AbstractClasses.hpp" #include "SimInfo.hpp" #include "ForceFields.hpp" -#include "ExtendedSystem.hpp" +#include "Thermo.hpp" +#include "ReadWrite.hpp" -class Verlet : public Integrator { +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 int maxIteration = 300; +const double tol = 1.0e-6; +class Integrator : public BaseIntegrator { + public: - Verlet( SimInfo &info, ForceFields* the_ff, ExtendedSystem* the_es ); - ~Verlet(); + Integrator( SimInfo *theInfo, ForceFields* the_ff ); + virtual ~Integrator(); void integrate( void ); -private: + +protected: - void move_a( double dt ); - void move_b( double dt ); + virtual void integrateStep( int calcPot, int calcStress ); + virtual void preMove( void ); + virtual void moveA( void ); + virtual void moveB( void ); + virtual void constrainA( void ); + virtual void constrainB( void ); + virtual int readyCheck( void ) { return 1; } + + void checkConstraints( void ); + void rotate( int axes1, int axes2, double angle, double j[3], + double A[9] ); + ForceFields* myFF; - ExtendedSystem* myES; - SimInfo *entry_plug; // all the info we'll ever need - int c_natoms; /* the number of atoms */ - Atom **c_atoms; /* array of atom pointers */ + SimInfo *info; // all the info we'll ever need + int nAtoms; /* the number of atoms */ + int oldAtoms; + Atom **atoms; /* array of atom pointers */ Molecule* molecules; int nMols; - int c_is_constrained; /*boolean to know whether the systems contains - constraints. */ - int c_n_constrained; /*counter for number of constraints */ - int *c_constrained_i; /* the i of a constraint pair */ - int *c_constrained_j; /* the j of a constraint pair */ - double *c_constrained_dsqr; /* the square of the constraint distance */ - double *c_mass; /* the array of masses */ - short is_first; /*boolean for the first time integrate is called */ - double c_box_x; - double c_box_y; - double c_box_z; -}; + int isConstrained; // boolean to know whether the systems contains + // constraints. + int nConstrained; // counter for number of constraints + int *constrainedA; // the i of a constraint pair + int *constrainedB; // the j of a constraint pair + double *constrainedDsqr; // the square of the constraint distance + + int* moving; // tells whether we are moving atom i + int* moved; // tells whether we have moved atom i + double* oldPos; // pre constrained positions -class Symplectic : public Integrator { + short isFirst; /*boolean for the first time integrate is called */ + double dt; + double dt2; + + double* pos; + double* vel; + double* frc; + double* trq; + double* Amat; + + Thermo *tStats; + StatWriter* statOut; + DumpWriter* dumpOut; + +}; + +class NVE : public Integrator{ + public: - Symplectic( SimInfo* the_entry_plug, - ForceFields* the_ff, - ExtendedSystem* the_es); - ~Symplectic(); + NVE ( SimInfo *theInfo, ForceFields* the_ff ): + Integrator( theInfo, the_ff ){} + virtual ~NVE(){} + - void integrate( void ); -private: +}; - void rotate( int axes1, int axes2, double angle, double j[3], - double A[3][3] ); +class NVT : public Integrator{ - SimInfo* entry_plug; - ForceFields* myFF; - ExtendedSystem* myES; +public: - Molecule* molecules; - int nMols; + NVT ( SimInfo *theInfo, ForceFields* the_ff); + virtual ~NVT() {} - int is_constrained; /*boolean to know whether the systems contains - constraints. */ - int n_constrained; /*counter for number of constraints */ - int *constrained_i; /* the i of a constraint pair */ - int *constrained_j; /* the j of a constraint pair */ - double *constrained_dsqr; /* the square of the constraint distance */ - double *mass; /* the array of masses */ + void setQmass(double q) {qmass = q; have_qmass = 1;} + void setTauThermostat(double tt) {tauThermostat = tt; have_tau_thermostat=1;} + void setTargetTemp(double tt) {targetTemp = tt; have_target_temp = 1;} - short int isFirst; +protected: - SRI **srInteractions; /* array of SRI pointers */ - int nSRI; /* the number of short range interactions */ + virtual void moveA( void ); + virtual void moveB( void ); + + virtual int readyCheck(); + + // zeta is a propagated degree of freedom. + + double zeta; + + // targetTemp must be set. One of qmass or tauThermostat must be set; + + double qmass; + double targetTemp; + double tauThermostat; + + double NkBT; + short int have_tau_thermostat, have_target_temp, have_qmass; + }; + +class NPT : public Integrator{ + +public: + + NPT ( SimInfo *theInfo, ForceFields* the_ff); + virtual ~NPT(); + + void setQmass(double q) {qmass = q; have_qmass = 1;} + 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(); + + Atom** atoms; + + // zeta and epsilonDot are the propagated degrees of freedom. + + double zeta; + double epsilonDot; + + // targetTemp, targetPressure, and tauBarostat must be set. + // One of qmass or tauThermostat must be set; + + double qmass; + double targetTemp; + double targetPressure; + double tauThermostat; + double tauBarostat; + + short int have_tau_thermostat, have_tau_barostat, have_target_temp; + short int have_target_pressure, have_qmass; + +}; + #endif