--- trunk/OOPSE/libmdtools/SimSetup.cpp 2003/07/31 15:35:07 658 +++ trunk/OOPSE/libmdtools/SimSetup.cpp 2003/07/31 19:59:34 660 @@ -16,14 +16,18 @@ // some defines for ensemble and Forcefield cases -#define NVE_ENS 0 -#define NVT_ENS 1 -#define NPTi_ENS 2 -#define NPTf_ENS 3 -#define NPTim_ENS 4 -#define NPTfm_ENS 5 -#define NVEZCONS_ENS 6 - +#define NVE_ENS 0 +#define NVT_ENS 1 +#define NPTi_ENS 2 +#define NPTf_ENS 3 +#define NPTim_ENS 4 +#define NPTfm_ENS 5 +#define NVEZCONS_ENS 6 +#define NVTZCONS_ENS 7 +#define NPTiZCONS_ENS 8 +#define NPTfZCONS_ENS 9 +#define NPTimZCONS_ENS 10 +#define NPTfmZCONS_ENS 11 #define FF_DUFF 0 #define FF_LJ 1 @@ -623,7 +627,15 @@ 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, "NVEZCONS")) ensembleCase = NVEZCONS_ENS; + else if( !strcasecmp( ensemble, "NVTZCONS")) ensembleCase = NVTZCONS_ENS; + else if( !strcasecmp( ensemble, "NPTiZCONS") || !strcasecmp( ensemble, "NPT")) + ensembleCase = NPTiZCONS_ENS; + else if( !strcasecmp( ensemble, "NPTfCONS")) ensembleCase = NPTfZCONS_ENS; + else if( !strcasecmp( ensemble, "NPTimZCONS")) ensembleCase = NPTimZCONS_ENS; + else if( !strcasecmp( ensemble, "NPTfmCONS")) ensembleCase = NPTfmZCONS_ENS; + else{ sprintf( painCave.errMsg, "SimSetup Warning. Unrecognized Ensemble -> %s, " @@ -1310,6 +1322,11 @@ void SimSetup::makeIntegrator( void ){ NPTim* myNPTim = NULL; NPTfm* myNPTfm = NULL; ZConstraint >* myNVEZCons = NULL; + ZConstraint >* myNVTZCons = NULL; + ZConstraint >* myNPTiZCons = NULL; + ZConstraint >* myNPTfZCons = NULL; + ZConstraint >* myNPTimZCons = NULL; + ZConstraint >* myNPTfmZCons = NULL; cerr << "setting integrator" <haveZConsTime()){ - - //add sample time of z-constraint into SimInfo's property list - DoubleData* zconsTimeProp = new DoubleData(); - zconsTimeProp->setID("zconstime"); - zconsTimeProp->setData(globals->getZConsTime()); - info->addProperty(zconsTimeProp); - } - else{ - sprintf( painCave.errMsg, - "ZConstraint error: If you use an ZConstraint\n" - " , you must set sample time.\n"); - painCave.isFatal = 1; - simError(); - } - - if(globals->haveIndexOfAllZConsMols()){ - - //add index of z-constraint molecules into SimInfo's property list - vector tempIndex = globals->getIndexOfAllZConsMols(); - sort(tempIndex.begin(), tempIndex.end()); - - IndexData* zconsIndex = new IndexData(); - zconsIndex->setID("zconsindex"); - zconsIndex->setIndexData(tempIndex); - info->addProperty(zconsIndex); - } - else{ - sprintf( painCave.errMsg, - "SimSetup error: If you use an ZConstraint\n" - " , you must set index of z-constraint molecules.\n"); - painCave.isFatal = 1; - simError(); - - } - //Determine the name of ouput file and add it into SimInfo's property list - //Be careful, do not use inFileName, since it is a pointer which - //point to a string at master node, and slave nodes do not contain that string - - string zconsOutput(info->finalName); - - zconsOutput = zconsOutput.substr(0, zconsOutput.rfind(".")) + ".fz"; - - StringData* zconsFilename = new StringData(); - zconsFilename->setID("zconsfilename"); - zconsFilename->setData(zconsOutput); + //setup index of z-constraint molecules, z-constraint sampel time + //and z-constraint force output name. These parameter should be known + //before constructing the z-constraint integrator + setupZConstraint(); + + myNVEZCons = new ZConstraint >( info, the_ff ); + + break; + + + case NVTZCONS_ENS: + + setupZConstraint(); + + myNVTZCons = new ZConstraint >( info, the_ff ); + myNVTZCons->setTargetTemp(globals->getTargetTemp()); - info->addProperty(zconsFilename); + if (globals->haveTauThermostat()) + myNVTZCons->setTauThermostat(globals->getTauThermostat()); + + else { + sprintf( painCave.errMsg, + "SimSetup error: If you use the NVT\n" + " ensemble, you must set tauThermostat.\n"); + painCave.isFatal = 1; + simError(); + } + break; + + case NPTiZCONS_ENS: + + setupZConstraint(); + + myNPTiZCons = new ZConstraint >( info, the_ff ); + myNPTiZCons->setTargetTemp( globals->getTargetTemp() ); + + if (globals->haveTargetPressure()) + myNPTiZCons->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() ) + myNPTiZCons->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() ) + myNPTiZCons->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(); + } + + break; + + case NPTfZCONS_ENS: + + setupZConstraint(); + + myNPTfZCons = new ZConstraint >( info, the_ff ); + myNPTfZCons->setTargetTemp( globals->getTargetTemp()); + + if (globals->haveTargetPressure()) + myNPTfZCons->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() ) + myNPTfZCons->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() ) + myNPTfZCons->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(); + } + + break; - myNVEZCons = new ZConstraint >( info, the_ff ); - + case NPTimZCONS_ENS: + + setupZConstraint(); + + myNPTimZCons = new ZConstraint >( info, the_ff ); + myNPTimZCons->setTargetTemp( globals->getTargetTemp()); + + if (globals->haveTargetPressure()) + myNPTimZCons->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() ) + myNPTimZCons->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() ) + myNPTimZCons->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(); + } + break; + + case NPTfmZCONS_ENS: + + setupZConstraint(); + + myNPTfmZCons = new ZConstraint >( info, the_ff ); + myNPTfmZCons->setTargetTemp( globals->getTargetTemp()); + + if (globals->haveTargetPressure()) + myNPTfmZCons->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() ) + myNPTfmZCons->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() ) + myNPTfmZCons->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(); + } + break; + + + default: sprintf( painCave.errMsg, "SimSetup Error. Unrecognized ensemble in case statement.\n"); @@ -1568,3 +1716,59 @@ void SimSetup::initFortran( void ){ #endif // is_mpi } + +void SimSetup::setupZConstraint() +{ + if(globals->haveZConsTime()){ + + //add sample time of z-constraint into SimInfo's property list + DoubleData* zconsTimeProp = new DoubleData(); + zconsTimeProp->setID("zconstime"); + zconsTimeProp->setData(globals->getZConsTime()); + info->addProperty(zconsTimeProp); + } + else{ + sprintf( painCave.errMsg, + "ZConstraint error: If you use an ZConstraint\n" + " , you must set sample time.\n"); + painCave.isFatal = 1; + simError(); + } + + if(globals->haveIndexOfAllZConsMols()){ + + //add index of z-constraint molecules into SimInfo's property list + vector tempIndex = globals->getIndexOfAllZConsMols(); + + //sort the index + sort(tempIndex.begin(), tempIndex.end()); + + IndexData* zconsIndex = new IndexData(); + zconsIndex->setID("zconsindex"); + zconsIndex->setIndexData(tempIndex); + info->addProperty(zconsIndex); + } + else{ + sprintf( painCave.errMsg, + "SimSetup error: If you use an ZConstraint\n" + " , you must set index of z-constraint molecules.\n"); + painCave.isFatal = 1; + simError(); + + } + + //Determine the name of ouput file and add it into SimInfo's property list + //Be careful, do not use inFileName, since it is a pointer which + //point to a string at master node, and slave nodes do not contain that string + + string zconsOutput(info->finalName); + + zconsOutput = zconsOutput.substr(0, zconsOutput.rfind(".")) + ".fz"; + + StringData* zconsFilename = new StringData(); + zconsFilename->setID("zconsfilename"); + zconsFilename->setData(zconsOutput); + + info->addProperty(zconsFilename); + +}