--- trunk/OOPSE/libmdtools/SimSetup.cpp 2003/08/28 21:09:47 736 +++ trunk/OOPSE/libmdtools/SimSetup.cpp 2003/11/06 22:01:37 855 @@ -1,10 +1,9 @@ #include -#include +#include #include -#include +#include #include #include - #include "SimSetup.hpp" #include "ReadWrite.hpp" #include "parse_me.h" @@ -22,9 +21,9 @@ #define NVT_ENS 1 #define NPTi_ENS 2 #define NPTf_ENS 3 -#define NPTim_ENS 4 -#define NPTfm_ENS 5 +#define NPTxyz_ENS 4 + #define FF_DUFF 0 #define FF_LJ 1 #define FF_EAM 2 @@ -32,6 +31,8 @@ SimSetup::SimSetup(){ using namespace std; SimSetup::SimSetup(){ + + initSuspend = false; isInfoArray = 0; nInfo = 1; @@ -54,6 +55,7 @@ void SimSetup::setSimInfo(SimInfo* the_info, int theNi info = the_info; nInfo = theNinfo; isInfoArray = 1; + initSuspend = true; } @@ -92,7 +94,6 @@ void SimSetup::createSim(void){ #endif // is_mpi void SimSetup::createSim(void){ - int i, j, k, globalAtomIndex; // gather all of the information from the Bass file @@ -102,16 +103,19 @@ void SimSetup::createSim(void){ sysObjectsCreation(); - // check on the post processing info - - finalInfoCheck(); - // initialize the system coordinates - if (!isInfoArray){ + if ( !initSuspend ){ initSystemCoords(); + + if( !(globals->getUseInitTime()) ) + info[0].currentTime = 0.0; } + // check on the post processing info + + finalInfoCheck(); + // make the output filenames makeOutNames(); @@ -131,7 +135,7 @@ void SimSetup::makeMolecules(void){ void SimSetup::makeMolecules(void){ - int k, l; + int k; int i, j, exI, exJ, tempEx, stampID, atomOffset, excludeOffset; molInit molInfo; DirectionalAtom* dAtom; @@ -553,7 +557,7 @@ void SimSetup::gatherInfo(void){ void SimSetup::gatherInfo(void){ - int i, j, k; + int i; ensembleCase = -1; ffCase = -1; @@ -603,12 +607,9 @@ void SimSetup::gatherInfo(void){ } else if (!strcasecmp(ensemble, "NPTf")){ ensembleCase = NPTf_ENS; - } - else if (!strcasecmp(ensemble, "NPTim")){ - ensembleCase = NPTim_ENS; } - else if (!strcasecmp(ensemble, "NPTfm")){ - ensembleCase = NPTfm_ENS; + else if (!strcasecmp(ensemble, "NPTxyz")){ + ensembleCase = NPTxyz_ENS; } else{ sprintf(painCave.errMsg, @@ -688,59 +689,24 @@ void SimSetup::gatherInfo(void){ info[i].thermalTime = globals->getThermalTime(); } - // check for the temperature set flag + info[i].resetIntegrator = 0; + if( globals->haveResetTime() ){ + info[i].resetTime = globals->getResetTime(); + info[i].resetIntegrator = 1; + } + // check for the temperature set flag + if (globals->haveTempSet()) info[i].setTemp = globals->getTempSet(); - // get some of the tricky things that may still be in the globals + // check for the extended State init - double boxVector[3]; - if (globals->haveBox()){ - boxVector[0] = globals->getBox(); - boxVector[1] = globals->getBox(); - boxVector[2] = globals->getBox(); - - info[i].setBox(boxVector); - } - else if (globals->haveDensity()){ - double vol; - vol = (double) tot_nmol / globals->getDensity(); - boxVector[0] = pow(vol, (1.0 / 3.0)); - boxVector[1] = boxVector[0]; - boxVector[2] = boxVector[0]; - - info[i].setBox(boxVector); - } - else{ - if (!globals->haveBoxX()){ - sprintf(painCave.errMsg, - "SimSetup error, no periodic BoxX size given.\n"); - painCave.isFatal = 1; - simError(); - } - boxVector[0] = globals->getBoxX(); - - if (!globals->haveBoxY()){ - sprintf(painCave.errMsg, - "SimSetup error, no periodic BoxY size given.\n"); - painCave.isFatal = 1; - simError(); - } - boxVector[1] = globals->getBoxY(); - - if (!globals->haveBoxZ()){ - sprintf(painCave.errMsg, - "SimSetup error, no periodic BoxZ size given.\n"); - painCave.isFatal = 1; - simError(); - } - boxVector[2] = globals->getBoxZ(); - - info[i].setBox(boxVector); - } + info[i].useInitXSstate = globals->getUseInitXSstate(); + info[i].orthoTolerance = globals->getOrthoBoxTolerance(); + } - + //setup seed for random number generator int seedValue; @@ -844,7 +810,7 @@ void SimSetup::finalInfoCheck(void){ theEst = globals->getEST(); } - info[i].setEcr(theEcr, theEst); + info[i].setDefaultEcr(theEcr, theEst); if (!globals->haveDielectric()){ sprintf(painCave.errMsg, @@ -889,9 +855,12 @@ void SimSetup::finalInfoCheck(void){ theEst = globals->getEST(); } - info[i].setEcr(theEcr, theEst); + info[i].setDefaultEcr(theEcr, theEst); } } + + if( !initSuspend ) + info[i].checkCutOffs(); } #ifdef IS_MPI @@ -916,7 +885,6 @@ void SimSetup::initSystemCoords(void){ if (worldRank == 0){ #endif //is_mpi inName = globals->getInitialConfig(); - double* tempDouble = new double[1000000]; fileInit = new InitializeFromFile(inName); #ifdef IS_MPI } @@ -934,7 +902,7 @@ void SimSetup::initSystemCoords(void){ sprintf(painCave.errMsg, "Cannot intialize a parallel simulation without an initial configuration file.\n"); - painCave.isFatal; + painCave.isFatal = 1;; simError(); #else @@ -1160,7 +1128,7 @@ void SimSetup::calcSysValues(void){ } void SimSetup::calcSysValues(void){ - int i, j, k; + int i; int* molMembershipArray; @@ -1259,7 +1227,11 @@ void SimSetup::makeSysArrays(void){ void SimSetup::makeSysArrays(void){ - int i, j, k, l; + +#ifndef IS_MPI + int k, j; +#endif // is_mpi + int i, l; Atom** the_atoms; Molecule* the_molecules; @@ -1342,21 +1314,24 @@ void SimSetup::makeIntegrator(void){ void SimSetup::makeIntegrator(void){ int k; + NVE* myNVE = NULL; NVT* myNVT = NULL; - NPTi* myNPTi = NULL; - NPTf* myNPTf = NULL; - NPTim* myNPTim = NULL; - NPTfm* myNPTfm = NULL; + NPTi >* myNPTi = NULL; + NPTf >* myNPTf = NULL; + NPTxyz >* myNPTxyz = NULL; for (k = 0; k < nInfo; k++){ switch (ensembleCase){ case NVE_ENS: if (globals->haveZconstraints()){ setupZConstraint(info[k]); - new ZConstraint >(&(info[k]), the_ff); + myNVE = new ZConstraint >(&(info[k]), the_ff); } - else - new NVE(&(info[k]), the_ff); + else{ + myNVE = new NVE(&(info[k]), the_ff); + } + + info->the_integrator = myNVE; break; case NVT_ENS: @@ -1378,15 +1353,17 @@ void SimSetup::makeIntegrator(void){ painCave.isFatal = 1; simError(); } + + info->the_integrator = myNVT; break; case NPTi_ENS: if (globals->haveZconstraints()){ setupZConstraint(info[k]); - myNPTi = new ZConstraint >(&(info[k]), the_ff); + myNPTi = new ZConstraint > >(&(info[k]), the_ff); } else - myNPTi = new NPTi(&(info[k]), the_ff); + myNPTi = new NPTi >(&(info[k]), the_ff); myNPTi->setTargetTemp(globals->getTargetTemp()); @@ -1419,15 +1396,17 @@ void SimSetup::makeIntegrator(void){ painCave.isFatal = 1; simError(); } + + info->the_integrator = myNPTi; break; case NPTf_ENS: if (globals->haveZconstraints()){ setupZConstraint(info[k]); - myNPTf = new ZConstraint >(&(info[k]), the_ff); + myNPTf = new ZConstraint > >(&(info[k]), the_ff); } else - myNPTf = new NPTf(&(info[k]), the_ff); + myNPTf = new NPTf >(&(info[k]), the_ff); myNPTf->setTargetTemp(globals->getTargetTemp()); @@ -1443,6 +1422,7 @@ void SimSetup::makeIntegrator(void){ if (globals->haveTauThermostat()) myNPTf->setTauThermostat(globals->getTauThermostat()); + else{ sprintf(painCave.errMsg, "SimSetup error: If you use an NPT\n" @@ -1453,6 +1433,7 @@ void SimSetup::makeIntegrator(void){ if (globals->haveTauBarostat()) myNPTf->setTauBarostat(globals->getTauBarostat()); + else{ sprintf(painCave.errMsg, "SimSetup error: If you use an NPT\n" @@ -1460,30 +1441,32 @@ void SimSetup::makeIntegrator(void){ painCave.isFatal = 1; simError(); } + + info->the_integrator = myNPTf; break; - case NPTim_ENS: + case NPTxyz_ENS: if (globals->haveZconstraints()){ setupZConstraint(info[k]); - myNPTim = new ZConstraint >(&(info[k]), the_ff); + myNPTxyz = new ZConstraint > >(&(info[k]), the_ff); } else - myNPTim = new NPTim(&(info[k]), the_ff); + myNPTxyz = new NPTxyz >(&(info[k]), the_ff); - myNPTim->setTargetTemp(globals->getTargetTemp()); + myNPTxyz->setTargetTemp(globals->getTargetTemp()); if (globals->haveTargetPressure()) - myNPTim->setTargetPressure(globals->getTargetPressure()); + myNPTxyz->setTargetPressure(globals->getTargetPressure()); else{ sprintf(painCave.errMsg, "SimSetup error: If you use a constant pressure\n" " ensemble, you must set targetPressure in the BASS file.\n"); painCave.isFatal = 1; simError(); - } + } if (globals->haveTauThermostat()) - myNPTim->setTauThermostat(globals->getTauThermostat()); + myNPTxyz->setTauThermostat(globals->getTauThermostat()); else{ sprintf(painCave.errMsg, "SimSetup error: If you use an NPT\n" @@ -1493,7 +1476,7 @@ void SimSetup::makeIntegrator(void){ } if (globals->haveTauBarostat()) - myNPTim->setTauBarostat(globals->getTauBarostat()); + myNPTxyz->setTauBarostat(globals->getTauBarostat()); else{ sprintf(painCave.errMsg, "SimSetup error: If you use an NPT\n" @@ -1501,47 +1484,8 @@ void SimSetup::makeIntegrator(void){ painCave.isFatal = 1; simError(); } - break; - case NPTfm_ENS: - if (globals->haveZconstraints()){ - setupZConstraint(info[k]); - myNPTfm = new ZConstraint >(&(info[k]), the_ff); - } - else - myNPTfm = new NPTfm(&(info[k]), the_ff); - - myNPTfm->setTargetTemp(globals->getTargetTemp()); - - if (globals->haveTargetPressure()) - myNPTfm->setTargetPressure(globals->getTargetPressure()); - else{ - sprintf(painCave.errMsg, - "SimSetup error: If you use a constant pressure\n" - " ensemble, you must set targetPressure in the BASS file.\n"); - painCave.isFatal = 1; - simError(); - } - - if (globals->haveTauThermostat()) - myNPTfm->setTauThermostat(globals->getTauThermostat()); - else{ - sprintf(painCave.errMsg, - "SimSetup error: If you use an NPT\n" - " ensemble, you must set tauThermostat.\n"); - painCave.isFatal = 1; - simError(); - } - - if (globals->haveTauBarostat()) - myNPTfm->setTauBarostat(globals->getTauBarostat()); - else{ - sprintf(painCave.errMsg, - "SimSetup error: If you use an NPT\n" - " ensemble, you must set tauBarostat.\n"); - painCave.isFatal = 1; - simError(); - } + info->the_integrator = myNPTxyz; break; default: @@ -1615,7 +1559,7 @@ void SimSetup::setupZConstraint(SimInfo& theInfo){ } theInfo.addProperty(zconsTol); - //set Force Substraction Policy + //set Force Subtraction Policy StringData* zconsForcePolicy = new StringData(); zconsForcePolicy->setID(ZCONSFORCEPOLICY_ID); @@ -1624,7 +1568,7 @@ void SimSetup::setupZConstraint(SimInfo& theInfo){ } else{ sprintf(painCave.errMsg, - "ZConstraint Warning: User does not set force substraction policy, " + "ZConstraint Warning: User does not set force Subtraction policy, " "PolicyByMass is used\n"); painCave.isFatal = 0; simError();