--- trunk/OOPSE/libmdtools/SimSetup.cpp 2003/09/23 20:34:31 782 +++ trunk/OOPSE/libmdtools/SimSetup.cpp 2003/11/10 21:50:36 859 @@ -1,10 +1,9 @@ #include -#include +#include #include -#include +#include #include #include - #include "SimSetup.hpp" #include "ReadWrite.hpp" #include "parse_me.h" @@ -22,7 +21,9 @@ #define NVT_ENS 1 #define NPTi_ENS 2 #define NPTf_ENS 3 +#define NPTxyz_ENS 4 + #define FF_DUFF 0 #define FF_LJ 1 #define FF_EAM 2 @@ -30,6 +31,8 @@ SimSetup::SimSetup(){ using namespace std; SimSetup::SimSetup(){ + + initSuspend = false; isInfoArray = 0; nInfo = 1; @@ -52,6 +55,7 @@ void SimSetup::setSimInfo(SimInfo* the_info, int theNi info = the_info; nInfo = theNinfo; isInfoArray = 1; + initSuspend = true; } @@ -90,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 @@ -106,8 +109,11 @@ void SimSetup::createSim(void){ // initialize the system coordinates - if (!isInfoArray){ + if ( !initSuspend ){ initSystemCoords(); + + if( !(globals->getUseInitTime()) ) + info[0].currentTime = 0.0; } // make the output filenames @@ -129,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; @@ -551,7 +557,7 @@ void SimSetup::gatherInfo(void){ void SimSetup::gatherInfo(void){ - int i, j, k; + int i; ensembleCase = -1; ffCase = -1; @@ -602,6 +608,9 @@ void SimSetup::gatherInfo(void){ else if (!strcasecmp(ensemble, "NPTf")){ ensembleCase = NPTf_ENS; } + else if (!strcasecmp(ensemble, "NPTxyz")){ + ensembleCase = NPTxyz_ENS; + } else{ sprintf(painCave.errMsg, "SimSetup Warning. Unrecognized Ensemble -> %s, " @@ -687,58 +696,17 @@ void SimSetup::gatherInfo(void){ } // 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; @@ -813,18 +781,11 @@ void SimSetup::finalInfoCheck(void){ if (!globals->haveECR()){ sprintf(painCave.errMsg, - "SimSetup Warning: using default value of 1/2 the smallest " - "box length for the electrostaticCutoffRadius.\n" - "I hope you have a very fast processor!\n"); + "SimSetup Warning: using default value of 15.0 angstroms" + "box length for the electrostaticCutoffRadius.\n"); painCave.isFatal = 0; simError(); - double smallest; - smallest = info[i].boxL[0]; - if (info[i].boxL[1] <= smallest) - smallest = info[i].boxL[1]; - if (info[i].boxL[2] <= smallest) - smallest = info[i].boxL[2]; - theEcr = 0.5 * smallest; + theEcr = 15.0; } else{ theEcr = globals->getECR(); @@ -842,7 +803,7 @@ void SimSetup::finalInfoCheck(void){ theEst = globals->getEST(); } - info[i].setEcr(theEcr, theEst); + info[i].setDefaultEcr(theEcr, theEst); if (!globals->haveDielectric()){ sprintf(painCave.errMsg, @@ -857,23 +818,16 @@ void SimSetup::finalInfoCheck(void){ if (usesDipoles){ if (!globals->haveECR()){ sprintf(painCave.errMsg, - "SimSetup Warning: using default value of 1/2 the smallest " - "box length for the electrostaticCutoffRadius.\n" - "I hope you have a very fast processor!\n"); - painCave.isFatal = 0; - simError(); - double smallest; - smallest = info[i].boxL[0]; - if (info[i].boxL[1] <= smallest) - smallest = info[i].boxL[1]; - if (info[i].boxL[2] <= smallest) - smallest = info[i].boxL[2]; - theEcr = 0.5 * smallest; + "SimSetup Warning: using default value of 15.0 angstroms" + "box length for the electrostaticCutoffRadius.\n"); + painCave.isFatal = 0; + simError(); + theEcr = 15.0; } else{ theEcr = globals->getECR(); } - + if (!globals->haveEST()){ sprintf(painCave.errMsg, "SimSetup Warning: using default value of 0.05 * the " @@ -886,18 +840,17 @@ void SimSetup::finalInfoCheck(void){ else{ theEst = globals->getEST(); } - - info[i].setEcr(theEcr, theEst); + + info[i].setDefaultEcr(theEcr, theEst); } } } - #ifdef IS_MPI strcpy(checkPointMsg, "post processing checks out"); MPIcheckPoint(); #endif // is_mpi } - + void SimSetup::initSystemCoords(void){ int i; @@ -914,7 +867,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 } @@ -926,21 +878,14 @@ void SimSetup::initSystemCoords(void){ delete fileInit; } else{ -#ifdef IS_MPI - + // no init from bass - + sprintf(painCave.errMsg, - "Cannot intialize a parallel simulation without an initial configuration file.\n"); - painCave.isFatal; + "Cannot intialize a simulation without an initial configuration file.\n"); + painCave.isFatal = 1;; simError(); - -#else - - initFromBass(); - - -#endif + } #ifdef IS_MPI @@ -1158,7 +1103,7 @@ void SimSetup::calcSysValues(void){ } void SimSetup::calcSysValues(void){ - int i, j, k; + int i; int* molMembershipArray; @@ -1257,7 +1202,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; @@ -1344,6 +1293,7 @@ void SimSetup::makeIntegrator(void){ NVT* myNVT = NULL; NPTi >* myNPTi = NULL; NPTf >* myNPTf = NULL; + NPTxyz >* myNPTxyz = NULL; for (k = 0; k < nInfo; k++){ switch (ensembleCase){ @@ -1447,6 +1397,7 @@ void SimSetup::makeIntegrator(void){ if (globals->haveTauThermostat()) myNPTf->setTauThermostat(globals->getTauThermostat()); + else{ sprintf(painCave.errMsg, "SimSetup error: If you use an NPT\n" @@ -1457,6 +1408,7 @@ void SimSetup::makeIntegrator(void){ if (globals->haveTauBarostat()) myNPTf->setTauBarostat(globals->getTauBarostat()); + else{ sprintf(painCave.errMsg, "SimSetup error: If you use an NPT\n" @@ -1468,6 +1420,49 @@ void SimSetup::makeIntegrator(void){ info->the_integrator = myNPTf; break; + case NPTxyz_ENS: + if (globals->haveZconstraints()){ + setupZConstraint(info[k]); + myNPTxyz = new ZConstraint > >(&(info[k]), the_ff); + } + else + myNPTxyz = new NPTxyz >(&(info[k]), the_ff); + + myNPTxyz->setTargetTemp(globals->getTargetTemp()); + + if (globals->haveTargetPressure()) + 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()) + myNPTxyz->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()) + myNPTxyz->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: sprintf(painCave.errMsg, "SimSetup Error. Unrecognized ensemble in case statement.\n");