--- trunk/OOPSE-1.0/libmdtools/SimSetup.cpp 2004/07/16 18:58:03 1334 +++ trunk/OOPSE-1.0/libmdtools/SimSetup.cpp 2004/07/26 17:50:57 1415 @@ -824,10 +824,19 @@ void SimSetup::gatherInfo(void){ // set the easy ones first for (i = 0; i < nInfo; i++){ - info[i].target_temp = globals->getTargetTemp(); - info[i].dt = globals->getDt(); - info[i].run_time = globals->getRunTime(); - } + if (globals->haveTargetTemp()) { + info[i].target_temp = globals->getTargetTemp(); + info[i].have_target_temp = 1; + } else { + info[i].have_target_temp = 0; + } + if (globals->haveDt()) { + info[i].dt = globals->getDt(); + } + if (globals->haveRunTime()) { + info[i].run_time = globals->getRunTime(); + } + } n_components = globals->getNComponents(); @@ -860,49 +869,199 @@ void SimSetup::gatherInfo(void){ // get the ensemble - strcpy(ensemble, globals->getEnsemble()); - if (!strcasecmp(ensemble, "NVE")){ - ensembleCase = NVE_ENS; - } - else if (!strcasecmp(ensemble, "NVT")){ - ensembleCase = NVT_ENS; - } - else if (!strcasecmp(ensemble, "NPTi") || !strcasecmp(ensemble, "NPT")){ - ensembleCase = NPTi_ENS; - } - 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 \n" - "\treverting to NVE for this simulation.\n", - ensemble); - painCave.isFatal = 0; - simError(); - strcpy(ensemble, "NVE"); - ensembleCase = NVE_ENS; - } - - for (i = 0; i < nInfo; i++){ - strcpy(info[i].ensemble, ensemble); + if (globals->haveEnsemble()) { + + strcpy(ensemble, globals->getEnsemble()); + + if (!strcasecmp(ensemble, "NVE")){ + ensembleCase = NVE_ENS; + } + else if (!strcasecmp(ensemble, "NVT")){ + ensembleCase = NVT_ENS; + } + else if (!strcasecmp(ensemble, "NPTi") || !strcasecmp(ensemble, "NPT")){ + ensembleCase = NPTi_ENS; + } + 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 \n" + "\treverting to NVE for this simulation.\n", + ensemble); + painCave.isFatal = 0; + simError(); + strcpy(ensemble, "NVE"); + ensembleCase = NVE_ENS; + } + + for (i = 0; i < nInfo; i++) + strcpy(info[i].ensemble, ensemble); + + + //check whether sample time, status time, thermal time and reset time are divisble by dt + if (globals->haveSampleTime() && !isDivisible(globals->getSampleTime(), globals->getDt())){ + sprintf(painCave.errMsg, + "Sample time is not divisible by dt.\n" + "\tThis will result in samples that are not uniformly\n" + "\tdistributed in time. If this is a problem, change\n" + "\tyour sampleTime variable.\n"); + painCave.isFatal = 0; + simError(); + } + + if (globals->haveStatusTime() && !isDivisible(globals->getStatusTime(), globals->getDt())){ + sprintf(painCave.errMsg, + "Status time is not divisible by dt.\n" + "\tThis will result in status reports that are not uniformly\n" + "\tdistributed in time. If this is a problem, change \n" + "\tyour statusTime variable.\n"); + painCave.isFatal = 0; + simError(); + } + + if (globals->haveThermalTime() && !isDivisible(globals->getThermalTime(), globals->getDt())){ + sprintf(painCave.errMsg, + "Thermal time is not divisible by dt.\n" + "\tThis will result in thermalizations that are not uniformly\n" + "\tdistributed in time. If this is a problem, change \n" + "\tyour thermalTime variable.\n"); + painCave.isFatal = 0; + simError(); + } + + if (globals->haveResetTime() && !isDivisible(globals->getResetTime(), globals->getDt())){ + sprintf(painCave.errMsg, + "Reset time is not divisible by dt.\n" + "\tThis will result in integrator resets that are not uniformly\n" + "\tdistributed in time. If this is a problem, change\n" + "\tyour resetTime variable.\n"); + painCave.isFatal = 0; + simError(); + } + + // set the status, sample, and thermal kick times + + for (i = 0; i < nInfo; i++){ + if (globals->haveSampleTime()){ + info[i].sampleTime = globals->getSampleTime(); + info[i].statusTime = info[i].sampleTime; + } + else{ + info[i].sampleTime = globals->getRunTime(); + info[i].statusTime = info[i].sampleTime; + } + + if (globals->haveStatusTime()){ + info[i].statusTime = globals->getStatusTime(); + } + + if (globals->haveThermalTime()){ + info[i].thermalTime = globals->getThermalTime(); + } else { + info[i].thermalTime = globals->getRunTime(); + } + + info[i].resetIntegrator = 0; + if( globals->haveResetTime() ){ + info[i].resetTime = globals->getResetTime(); + info[i].resetIntegrator = 1; + } + } + + for (i=0; i < nInfo; i++) { + + // check for the temperature set flag + + if (globals->haveTempSet()) + info[i].setTemp = globals->getTempSet(); + + // check for the extended State init + + info[i].useInitXSstate = globals->getUseInitXSstate(); + info[i].orthoTolerance = globals->getOrthoBoxTolerance(); + + // check for thermodynamic integration + if (globals->getUseSolidThermInt() && !globals->getUseLiquidThermInt()) { + if (globals->haveThermIntLambda() && globals->haveThermIntK()) { + info[i].useSolidThermInt = globals->getUseSolidThermInt(); + info[i].thermIntLambda = globals->getThermIntLambda(); + info[i].thermIntK = globals->getThermIntK(); + + Restraints *myRestraint = new Restraints(tot_nmol, info[i].thermIntLambda, info[i].thermIntK); + info[i].restraint = myRestraint; + } + else { + sprintf(painCave.errMsg, + "SimSetup Error:\n" + "\tKeyword useSolidThermInt was set to 'true' but\n" + "\tthermodynamicIntegrationLambda (and/or\n" + "\tthermodynamicIntegrationK) was not specified.\n" + "\tPlease provide a lambda value and k value in your .bass file.\n"); + painCave.isFatal = 1; + simError(); + } + } + else if(globals->getUseLiquidThermInt()) { + if (globals->getUseSolidThermInt()) { + sprintf( painCave.errMsg, + "SimSetup Warning: It appears that you have both solid and\n" + "\tliquid thermodynamic integration activated in your .bass\n" + "\tfile. To avoid confusion, specify only one technique in\n" + "\tyour .bass file. Liquid-state thermodynamic integration\n" + "\twill be assumed for the current simulation. If this is not\n" + "\twhat you desire, set useSolidThermInt to 'true' and\n" + "\tuseLiquidThermInt to 'false' in your .bass file.\n"); + painCave.isFatal = 0; + simError(); + } + if (globals->haveThermIntLambda() && globals->haveThermIntK()) { + info[i].useLiquidThermInt = globals->getUseLiquidThermInt(); + info[i].thermIntLambda = globals->getThermIntLambda(); + info[i].thermIntK = globals->getThermIntK(); + } + else { + sprintf(painCave.errMsg, + "SimSetup Error:\n" + "\tKeyword useLiquidThermInt was set to 'true' but\n" + "\tthermodynamicIntegrationLambda (and/or\n" + "\tthermodynamicIntegrationK) was not specified.\n" + "\tPlease provide a lambda value and k value in your .bass file.\n"); + painCave.isFatal = 1; + simError(); + } + } + else if(globals->haveThermIntLambda() || globals->haveThermIntK()){ + sprintf(painCave.errMsg, + "SimSetup Warning: If you want to use Thermodynamic\n" + "\tIntegration, set useSolidThermInt or useLiquidThermInt to\n" + "\t'true' in your .bass file. These keywords are set to\n" + "\t'false' by default, so your lambda and/or k values are\n" + "\tbeing ignored.\n"); + painCave.isFatal = 0; + simError(); + } + } + } + + for (i = 0; i < nInfo; i++) { // get the mixing rule - + strcpy(info[i].mixingRule, globals->getMixingRule()); info[i].usePBC = globals->getPBC(); } - + // get the components and calculate the tot_nMol and indvidual n_mol - + the_components = globals->getComponents(); components_nmol = new int[n_components]; - - + if (!globals->haveNMol()){ // we don't have the total number of molecules, so we assume it is // given in each component @@ -932,147 +1091,9 @@ void SimSetup::gatherInfo(void){ painCave.isFatal = 1; simError(); } + - //check whether sample time, status time, thermal time and reset time are divisble by dt - if (globals->haveSampleTime() && !isDivisible(globals->getSampleTime(), globals->getDt())){ - sprintf(painCave.errMsg, - "Sample time is not divisible by dt.\n" - "\tThis will result in samples that are not uniformly\n" - "\tdistributed in time. If this is a problem, change\n" - "\tyour sampleTime variable.\n"); - painCave.isFatal = 0; - simError(); - } - - if (globals->haveStatusTime() && !isDivisible(globals->getStatusTime(), globals->getDt())){ - sprintf(painCave.errMsg, - "Status time is not divisible by dt.\n" - "\tThis will result in status reports that are not uniformly\n" - "\tdistributed in time. If this is a problem, change \n" - "\tyour statusTime variable.\n"); - painCave.isFatal = 0; - simError(); - } - - if (globals->haveThermalTime() && !isDivisible(globals->getThermalTime(), globals->getDt())){ - sprintf(painCave.errMsg, - "Thermal time is not divisible by dt.\n" - "\tThis will result in thermalizations that are not uniformly\n" - "\tdistributed in time. If this is a problem, change \n" - "\tyour thermalTime variable.\n"); - painCave.isFatal = 0; - simError(); - } - - if (globals->haveResetTime() && !isDivisible(globals->getResetTime(), globals->getDt())){ - sprintf(painCave.errMsg, - "Reset time is not divisible by dt.\n" - "\tThis will result in integrator resets that are not uniformly\n" - "\tdistributed in time. If this is a problem, change\n" - "\tyour resetTime variable.\n"); - painCave.isFatal = 0; - simError(); - } - - // set the status, sample, and thermal kick times - - for (i = 0; i < nInfo; i++){ - if (globals->haveSampleTime()){ - info[i].sampleTime = globals->getSampleTime(); - info[i].statusTime = info[i].sampleTime; - } - else{ - info[i].sampleTime = globals->getRunTime(); - info[i].statusTime = info[i].sampleTime; - } - - if (globals->haveStatusTime()){ - info[i].statusTime = globals->getStatusTime(); - } - - if (globals->haveThermalTime()){ - info[i].thermalTime = globals->getThermalTime(); - } else { - info[i].thermalTime = globals->getRunTime(); - } - - 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(); - - // check for the extended State init - - info[i].useInitXSstate = globals->getUseInitXSstate(); - info[i].orthoTolerance = globals->getOrthoBoxTolerance(); - // check for thermodynamic integration - if (globals->getUseSolidThermInt() && !globals->getUseLiquidThermInt()) { - if (globals->haveThermIntLambda() && globals->haveThermIntK()) { - info[i].useSolidThermInt = globals->getUseSolidThermInt(); - info[i].thermIntLambda = globals->getThermIntLambda(); - info[i].thermIntK = globals->getThermIntK(); - - Restraints *myRestraint = new Restraints(tot_nmol, info[i].thermIntLambda, info[i].thermIntK); - info[i].restraint = myRestraint; - } - else { - sprintf(painCave.errMsg, - "SimSetup Error:\n" - "\tKeyword useSolidThermInt was set to 'true' but\n" - "\tthermodynamicIntegrationLambda (and/or\n" - "\tthermodynamicIntegrationK) was not specified.\n" - "\tPlease provide a lambda value and k value in your .bass file.\n"); - painCave.isFatal = 1; - simError(); - } - } - else if(globals->getUseLiquidThermInt()) { - if (globals->getUseSolidThermInt()) { - sprintf( painCave.errMsg, - "SimSetup Warning: It appears that you have both solid and\n" - "\tliquid thermodynamic integration activated in your .bass\n" - "\tfile. To avoid confusion, specify only one technique in\n" - "\tyour .bass file. Liquid-state thermodynamic integration\n" - "\twill be assumed for the current simulation. If this is not\n" - "\twhat you desire, set useSolidThermInt to 'true' and\n" - "\tuseLiquidThermInt to 'false' in your .bass file.\n"); - painCave.isFatal = 0; - simError(); - } - if (globals->haveThermIntLambda() && globals->haveThermIntK()) { - info[i].useLiquidThermInt = globals->getUseLiquidThermInt(); - info[i].thermIntLambda = globals->getThermIntLambda(); - info[i].thermIntK = globals->getThermIntK(); - } - else { - sprintf(painCave.errMsg, - "SimSetup Error:\n" - "\tKeyword useLiquidThermInt was set to 'true' but\n" - "\tthermodynamicIntegrationLambda (and/or\n" - "\tthermodynamicIntegrationK) was not specified.\n" - "\tPlease provide a lambda value and k value in your .bass file.\n"); - painCave.isFatal = 1; - simError(); - } - } - else if(globals->haveThermIntLambda() || globals->haveThermIntK()){ - sprintf(painCave.errMsg, - "SimSetup Warning: If you want to use Thermodynamic\n" - "\tIntegration, set useSolidThermInt or useLiquidThermInt to\n" - "\t'true' in your .bass file. These keywords are set to\n" - "\t'false' by default, so your lambda and/or k values are\n" - "\tbeing ignored.\n"); - painCave.isFatal = 0; - simError(); - } - } //setup seed for random number generator int seedValue; @@ -1785,7 +1806,16 @@ void SimSetup::makeIntegrator(void){ else myNVT = new NVT(&(info[k]), the_ff); - myNVT->setTargetTemp(globals->getTargetTemp()); + + if (globals->haveTargetTemp()) + myNVT->setTargetTemp(globals->getTargetTemp()); + else{ + sprintf(painCave.errMsg, + "SimSetup error: If you use the NVT\n" + "\tensemble, you must set targetTemp.\n"); + painCave.isFatal = 1; + simError(); + } if (globals->haveTauThermostat()) myNVT->setTauThermostat(globals->getTauThermostat()); @@ -1808,7 +1838,15 @@ void SimSetup::makeIntegrator(void){ else myNPTi = new NPTi >(&(info[k]), the_ff); - myNPTi->setTargetTemp(globals->getTargetTemp()); + if (globals->haveTargetTemp()) + myNPTi->setTargetTemp(globals->getTargetTemp()); + else{ + sprintf(painCave.errMsg, + "SimSetup error: If you use a constant pressure\n" + "\tensemble, you must set targetTemp.\n"); + painCave.isFatal = 1; + simError(); + } if (globals->haveTargetPressure()) myNPTi->setTargetPressure(globals->getTargetPressure()); @@ -1851,7 +1889,15 @@ void SimSetup::makeIntegrator(void){ else myNPTf = new NPTf >(&(info[k]), the_ff); - myNPTf->setTargetTemp(globals->getTargetTemp()); + if (globals->haveTargetTemp()) + myNPTf->setTargetTemp(globals->getTargetTemp()); + else{ + sprintf(painCave.errMsg, + "SimSetup error: If you use a constant pressure\n" + "\tensemble, you must set targetTemp.\n"); + painCave.isFatal = 1; + simError(); + } if (globals->haveTargetPressure()) myNPTf->setTargetPressure(globals->getTargetPressure()); @@ -1896,7 +1942,15 @@ void SimSetup::makeIntegrator(void){ else myNPTxyz = new NPTxyz >(&(info[k]), the_ff); - myNPTxyz->setTargetTemp(globals->getTargetTemp()); + if (globals->haveTargetTemp()) + myNPTxyz->setTargetTemp(globals->getTargetTemp()); + else{ + sprintf(painCave.errMsg, + "SimSetup error: If you use a constant pressure\n" + "\tensemble, you must set targetTemp.\n"); + painCave.isFatal = 1; + simError(); + } if (globals->haveTargetPressure()) myNPTxyz->setTargetPressure(globals->getTargetPressure());