--- branches/new-templateless/OOPSE/libmdtools/SimSetup.cpp 2003/10/31 18:28:53 848 +++ branches/new-templateless/OOPSE/libmdtools/SimSetup.cpp 2003/11/03 22:07:17 850 @@ -4,6 +4,7 @@ #include #include #include + #include "SimSetup.hpp" #include "ReadWrite.hpp" #include "parse_me.h" @@ -1307,185 +1308,201 @@ void SimSetup::makeIntegrator(void){ void SimSetup::makeIntegrator(void){ int k; - NVE* myNVE = NULL; - NVT* myNVT = NULL; - NPTi >* myNPTi = NULL; - NPTf >* myNPTf = NULL; - NPTxyz >* myNPTxyz = NULL; + NVE* myNVE = NULL; + NVT* myNVT = 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]); - myNVE = new ZConstraint >(&(info[k]), the_ff); - } - else{ - myNVE = new NVE(&(info[k]), the_ff); - } + case NVE_ENS: + if (globals->haveZconstraints()){ - info->the_integrator = myNVE; - break; - - case NVT_ENS: - if (globals->haveZconstraints()){ - setupZConstraint(info[k]); - myNVT = new ZConstraint >(&(info[k]), the_ff); - } - else - myNVT = new NVT(&(info[k]), the_ff); - - myNVT->setTargetTemp(globals->getTargetTemp()); - - if (globals->haveTauThermostat()) - myNVT->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(); - } - - info->the_integrator = myNVT; - break; - - case NPTi_ENS: - if (globals->haveZconstraints()){ - setupZConstraint(info[k]); - myNPTi = new ZConstraint > >(&(info[k]), the_ff); - } - else - myNPTi = new NPTi >(&(info[k]), the_ff); + std::cerr << "ZConstraint is temporarily disabled\n"; + + // setupZConstraint(info[k]); + // myNVE = new ZConstraint >(&(info[k]), the_ff); + } + + // else{ + myNVE = new NVE(&(info[k]), the_ff); + // } + + info->the_integrator = myNVE; + break; + + case NVT_ENS: + if (globals->haveZconstraints()){ + + std::cerr << "ZConstraint is temporarily disabled\n"; + + // setupZConstraint(info[k]); + // myNVT = new ZConstraint >(&(info[k]), the_ff); + } + // else + myNVT = new NVT(&(info[k]), the_ff); + + myNVT->setTargetTemp(globals->getTargetTemp()); + + if (globals->haveTauThermostat()) + myNVT->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(); + } + + info->the_integrator = myNVT; + break; + + case NPTi_ENS: + if (globals->haveZconstraints()){ + + std::cerr << "ZConstraint is temporarily disabled\n"; + + // setupZConstraint(info[k]); + // myNPTi = new ZConstraint > >(&(info[k]), the_ff); + } + // else + myNPTi = new NPTi(&(info[k]), the_ff); + + myNPTi->setTargetTemp(globals->getTargetTemp()); + + if (globals->haveTargetPressure()) + myNPTi->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()) + myNPTi->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()) + myNPTi->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 = myNPTi; + break; + + case NPTf_ENS: + if (globals->haveZconstraints()){ - myNPTi->setTargetTemp(globals->getTargetTemp()); + std::cerr << "ZConstraint is temporarily disabled\n"; - if (globals->haveTargetPressure()) - myNPTi->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()) - myNPTi->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()) - myNPTi->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 = myNPTi; - break; - - case NPTf_ENS: - if (globals->haveZconstraints()){ - setupZConstraint(info[k]); - myNPTf = new ZConstraint > >(&(info[k]), the_ff); - } - else - myNPTf = new NPTf >(&(info[k]), the_ff); - - myNPTf->setTargetTemp(globals->getTargetTemp()); - - if (globals->haveTargetPressure()) - myNPTf->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()) - myNPTf->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()) - myNPTf->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 = 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; +// setupZConstraint(info[k]); +// myNPTf = new ZConstraint > >(&(info[k]), the_ff); + } +// else + myNPTf = new NPTf(&(info[k]), the_ff); + + myNPTf->setTargetTemp(globals->getTargetTemp()); + + if (globals->haveTargetPressure()) + myNPTf->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()) + myNPTf->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()) + myNPTf->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 = myNPTf; + break; + + case NPTxyz_ENS: + if (globals->haveZconstraints()){ + + std::cerr << "ZConstraint is temporarily disabled\n"; + + // setupZConstraint(info[k]); + // myNPTxyz = new ZConstraint > >(&(info[k]), the_ff); + } +// else + myNPTxyz = new NPTxyz(&(info[k]), the_ff); - default: - sprintf(painCave.errMsg, - "SimSetup Error. Unrecognized ensemble in case statement.\n"); - painCave.isFatal = 1; - simError(); + 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"); + painCave.isFatal = 1; + simError(); } } } @@ -1513,107 +1530,107 @@ void SimSetup::initFortran(void){ #endif // is_mpi } -void SimSetup::setupZConstraint(SimInfo& theInfo){ - int nZConstraints; - ZconStamp** zconStamp; +// void SimSetup::setupZConstraint(SimInfo& theInfo){ +// int nZConstraints; +// ZconStamp** zconStamp; - if (globals->haveZconstraintTime()){ - //add sample time of z-constraint into SimInfo's property list - DoubleData* zconsTimeProp = new DoubleData(); - zconsTimeProp->setID(ZCONSTIME_ID); - zconsTimeProp->setData(globals->getZconsTime()); - theInfo.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->haveZconstraintTime()){ +// //add sample time of z-constraint into SimInfo's property list +// DoubleData* zconsTimeProp = new DoubleData(); +// zconsTimeProp->setID(ZCONSTIME_ID); +// zconsTimeProp->setData(globals->getZconsTime()); +// theInfo.addProperty(zconsTimeProp); +// } +// else{ +// sprintf(painCave.errMsg, +// "ZConstraint error: If you use an ZConstraint\n" +// " , you must set sample time.\n"); +// painCave.isFatal = 1; +// simError(); +// } - //push zconsTol into siminfo, if user does not specify - //value for zconsTol, a default value will be used - DoubleData* zconsTol = new DoubleData(); - zconsTol->setID(ZCONSTOL_ID); - if (globals->haveZconsTol()){ - zconsTol->setData(globals->getZconsTol()); - } - else{ - double defaultZConsTol = 0.01; - sprintf(painCave.errMsg, - "ZConstraint Waring: Tolerance for z-constraint methodl is not specified\n" - " , default value %f is used.\n", - defaultZConsTol); - painCave.isFatal = 0; - simError(); +// //push zconsTol into siminfo, if user does not specify +// //value for zconsTol, a default value will be used +// DoubleData* zconsTol = new DoubleData(); +// zconsTol->setID(ZCONSTOL_ID); +// if (globals->haveZconsTol()){ +// zconsTol->setData(globals->getZconsTol()); +// } +// else{ +// double defaultZConsTol = 0.01; +// sprintf(painCave.errMsg, +// "ZConstraint Waring: Tolerance for z-constraint methodl is not specified\n" +// " , default value %f is used.\n", +// defaultZConsTol); +// painCave.isFatal = 0; +// simError(); - zconsTol->setData(defaultZConsTol); - } - theInfo.addProperty(zconsTol); +// zconsTol->setData(defaultZConsTol); +// } +// theInfo.addProperty(zconsTol); - //set Force Subtraction Policy - StringData* zconsForcePolicy = new StringData(); - zconsForcePolicy->setID(ZCONSFORCEPOLICY_ID); +// //set Force Subtraction Policy +// StringData* zconsForcePolicy = new StringData(); +// zconsForcePolicy->setID(ZCONSFORCEPOLICY_ID); - if (globals->haveZconsForcePolicy()){ - zconsForcePolicy->setData(globals->getZconsForcePolicy()); - } - else{ - sprintf(painCave.errMsg, - "ZConstraint Warning: User does not set force Subtraction policy, " - "PolicyByMass is used\n"); - painCave.isFatal = 0; - simError(); - zconsForcePolicy->setData("BYMASS"); - } +// if (globals->haveZconsForcePolicy()){ +// zconsForcePolicy->setData(globals->getZconsForcePolicy()); +// } +// else{ +// sprintf(painCave.errMsg, +// "ZConstraint Warning: User does not set force Subtraction policy, " +// "PolicyByMass is used\n"); +// painCave.isFatal = 0; +// simError(); +// zconsForcePolicy->setData("BYMASS"); +// } - theInfo.addProperty(zconsForcePolicy); +// theInfo.addProperty(zconsForcePolicy); - //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 +// //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(theInfo.finalName); +// string zconsOutput(theInfo.finalName); - zconsOutput = zconsOutput.substr(0, zconsOutput.rfind(".")) + ".fz"; +// zconsOutput = zconsOutput.substr(0, zconsOutput.rfind(".")) + ".fz"; - StringData* zconsFilename = new StringData(); - zconsFilename->setID(ZCONSFILENAME_ID); - zconsFilename->setData(zconsOutput); +// StringData* zconsFilename = new StringData(); +// zconsFilename->setID(ZCONSFILENAME_ID); +// zconsFilename->setData(zconsOutput); - theInfo.addProperty(zconsFilename); +// theInfo.addProperty(zconsFilename); - //setup index, pos and other parameters of z-constraint molecules - nZConstraints = globals->getNzConstraints(); - theInfo.nZconstraints = nZConstraints; +// //setup index, pos and other parameters of z-constraint molecules +// nZConstraints = globals->getNzConstraints(); +// theInfo.nZconstraints = nZConstraints; - zconStamp = globals->getZconStamp(); - ZConsParaItem tempParaItem; +// zconStamp = globals->getZconStamp(); +// ZConsParaItem tempParaItem; - ZConsParaData* zconsParaData = new ZConsParaData(); - zconsParaData->setID(ZCONSPARADATA_ID); +// ZConsParaData* zconsParaData = new ZConsParaData(); +// zconsParaData->setID(ZCONSPARADATA_ID); - for (int i = 0; i < nZConstraints; i++){ - tempParaItem.havingZPos = zconStamp[i]->haveZpos(); - tempParaItem.zPos = zconStamp[i]->getZpos(); - tempParaItem.zconsIndex = zconStamp[i]->getMolIndex(); - tempParaItem.kRatio = zconStamp[i]->getKratio(); +// for (int i = 0; i < nZConstraints; i++){ +// tempParaItem.havingZPos = zconStamp[i]->haveZpos(); +// tempParaItem.zPos = zconStamp[i]->getZpos(); +// tempParaItem.zconsIndex = zconStamp[i]->getMolIndex(); +// tempParaItem.kRatio = zconStamp[i]->getKratio(); - zconsParaData->addItem(tempParaItem); - } +// zconsParaData->addItem(tempParaItem); +// } - //check the uniqueness of index - if(!zconsParaData->isIndexUnique()){ - sprintf(painCave.errMsg, - "ZConstraint Error: molIndex is not unique\n"); - painCave.isFatal = 1; - simError(); - } +// //check the uniqueness of index +// if(!zconsParaData->isIndexUnique()){ +// sprintf(painCave.errMsg, +// "ZConstraint Error: molIndex is not unique\n"); +// painCave.isFatal = 1; +// simError(); +// } - //sort the parameters by index of molecules - zconsParaData->sortByIndex(); +// //sort the parameters by index of molecules +// zconsParaData->sortByIndex(); - //push data into siminfo, therefore, we can retrieve later - theInfo.addProperty(zconsParaData); -} +// //push data into siminfo, therefore, we can retrieve later +// theInfo.addProperty(zconsParaData); +// }