--- trunk/OOPSE/libmdtools/SimSetup.cpp 2003/06/20 20:29:36 561 +++ trunk/OOPSE/libmdtools/SimSetup.cpp 2003/07/15 03:27:24 605 @@ -14,10 +14,14 @@ // some defines for ensemble and Forcefield cases -#define NVE_ENS 0 -#define NVT_ENS 1 -#define NPT_ENS 2 +#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 FF_DUFF 0 #define FF_LJ 1 @@ -112,7 +116,11 @@ void SimSetup::createSim( void ){ if( !strcasecmp( ensemble, "NVE" )) ensembleCase = NVE_ENS; else if( !strcasecmp( ensemble, "NVT" )) ensembleCase = NVT_ENS; - else if( !strcasecmp( ensemble, "NPT" )) ensembleCase = NPT_ENS; + else if( !strcasecmp( ensemble, "NPTi" ) || !strcasecmp( ensemble, "NPT") ) + ensembleCase = NPTi_ENS; + 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{ sprintf( painCave.errMsg, "SimSetup Warning. Unrecognized Ensemble -> %s, " @@ -479,19 +487,23 @@ void SimSetup::createSim( void ){ // get some of the tricky things that may still be in the globals - + double boxVector[3]; if( the_globals->haveBox() ){ - simnfo->box_x = the_globals->getBox(); - simnfo->box_y = the_globals->getBox(); - simnfo->box_z = the_globals->getBox(); + boxVector[0] = the_globals->getBox(); + boxVector[1] = the_globals->getBox(); + boxVector[2] = the_globals->getBox(); + + simnfo->setBox( boxVector ); } else if( the_globals->haveDensity() ){ double vol; vol = (double)tot_nmol / the_globals->getDensity(); - simnfo->box_x = pow( vol, ( 1.0 / 3.0 ) ); - simnfo->box_y = simnfo->box_x; - simnfo->box_z = simnfo->box_x; + boxVector[0] = pow( vol, ( 1.0 / 3.0 ) ); + boxVector[1] = boxVector[0]; + boxVector[2] = boxVector[0]; + + simnfo->setBox( boxVector ); } else{ if( !the_globals->haveBoxX() ){ @@ -500,7 +512,7 @@ void SimSetup::createSim( void ){ painCave.isFatal = 1; simError(); } - simnfo->box_x = the_globals->getBoxX(); + boxVector[0] = the_globals->getBoxX(); if( !the_globals->haveBoxY() ){ sprintf( painCave.errMsg, @@ -508,7 +520,7 @@ void SimSetup::createSim( void ){ painCave.isFatal = 1; simError(); } - simnfo->box_y = the_globals->getBoxY(); + boxVector[1] = the_globals->getBoxY(); if( !the_globals->haveBoxZ() ){ sprintf( painCave.errMsg, @@ -516,7 +528,9 @@ void SimSetup::createSim( void ){ painCave.isFatal = 1; simError(); } - simnfo->box_z = the_globals->getBoxZ(); + boxVector[2] = the_globals->getBoxZ(); + + simnfo->setBox( boxVector ); } #ifdef IS_MPI @@ -546,9 +560,9 @@ void SimSetup::createSim( void ){ painCave.isFatal = 0; simError(); double smallest; - smallest = simnfo->box_x; - if (simnfo->box_y <= smallest) smallest = simnfo->box_y; - if (simnfo->box_z <= smallest) smallest = simnfo->box_z; + smallest = simnfo->boxLx; + if (simnfo->boxLy <= smallest) smallest = simnfo->boxLy; + if (simnfo->boxLz <= smallest) smallest = simnfo->boxLz; simnfo->ecr = 0.5 * smallest; } else { simnfo->ecr = the_globals->getECR(); @@ -586,9 +600,9 @@ void SimSetup::createSim( void ){ painCave.isFatal = 0; simError(); double smallest; - smallest = simnfo->box_x; - if (simnfo->box_y <= smallest) smallest = simnfo->box_y; - if (simnfo->box_z <= smallest) smallest = simnfo->box_z; + smallest = simnfo->boxLx; + if (simnfo->boxLy <= smallest) smallest = simnfo->boxLy; + if (simnfo->boxLz <= smallest) smallest = simnfo->boxLz; simnfo->ecr = 0.5 * smallest; } else { simnfo->ecr = the_globals->getECR(); @@ -770,7 +784,12 @@ void SimSetup::createSim( void ){ // make the integrator - NVT* myNVT = NULL; + NVT* myNVT = NULL; + NPTi* myNPTi = NULL; + NPTf* myNPTf = NULL; + NPTim* myNPTim = NULL; + NPTfm* myNPTfm = NULL; + switch( ensembleCase ){ case NVE_ENS: @@ -783,18 +802,156 @@ void SimSetup::createSim( void ){ if (the_globals->haveTauThermostat()) myNVT->setTauThermostat(the_globals->getTauThermostat()); - else if (the_globals->haveQmass()) - myNVT->setQmass(the_globals->getQmass()); + else { sprintf( painCave.errMsg, "SimSetup error: If you use the NVT\n" - " ensemble, you must set either tauThermostat or qMass.\n" - " Neither of these was found in the BASS file.\n"); + " ensemble, you must set tauThermostat.\n"); painCave.isFatal = 1; simError(); } break; + case NPTi_ENS: + myNPTi = new NPTi( simnfo, the_ff ); + myNPTi->setTargetTemp( the_globals->getTargetTemp()); + + if (the_globals->haveTargetPressure()) + myNPTi->setTargetPressure(the_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( the_globals->haveTauThermostat() ) + myNPTi->setTauThermostat( the_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( the_globals->haveTauBarostat() ) + myNPTi->setTauBarostat( the_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 NPTf_ENS: + myNPTf = new NPTf( simnfo, the_ff ); + myNPTf->setTargetTemp( the_globals->getTargetTemp()); + + if (the_globals->haveTargetPressure()) + myNPTf->setTargetPressure(the_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( the_globals->haveTauThermostat() ) + myNPTf->setTauThermostat( the_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( the_globals->haveTauBarostat() ) + myNPTf->setTauBarostat( the_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 NPTim_ENS: + myNPTim = new NPTim( simnfo, the_ff ); + myNPTim->setTargetTemp( the_globals->getTargetTemp()); + + if (the_globals->haveTargetPressure()) + myNPTim->setTargetPressure(the_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( the_globals->haveTauThermostat() ) + myNPTim->setTauThermostat( the_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( the_globals->haveTauBarostat() ) + myNPTim->setTauBarostat( the_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 NPTfm_ENS: + myNPTfm = new NPTfm( simnfo, the_ff ); + myNPTfm->setTargetTemp( the_globals->getTargetTemp()); + + if (the_globals->haveTargetPressure()) + myNPTfm->setTargetPressure(the_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( the_globals->haveTauThermostat() ) + myNPTfm->setTauThermostat( the_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( the_globals->haveTauBarostat() ) + myNPTfm->setTauBarostat( the_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"); @@ -1115,9 +1272,9 @@ void SimSetup::initFromBass( void ){ have_extra =1; n_cells = (int)temp3 - 1; - cellx = simnfo->box_x / temp3; - celly = simnfo->box_y / temp3; - cellz = simnfo->box_z / temp3; + cellx = simnfo->boxLx / temp3; + celly = simnfo->boxLy / temp3; + cellz = simnfo->boxLz / temp3; n_extra = tot_nmol - ( 4 * n_cells * n_cells * n_cells ); temp1 = ((double)n_extra) / ( pow( temp3, 3.0 ) - pow( n_cells, 3.0 ) ); n_per_extra = (int)ceil( temp1 ); @@ -1132,9 +1289,9 @@ void SimSetup::initFromBass( void ){ } else{ n_cells = (int)temp3; - cellx = simnfo->box_x / temp3; - celly = simnfo->box_y / temp3; - cellz = simnfo->box_z / temp3; + cellx = simnfo->boxLx / temp3; + celly = simnfo->boxLy / temp3; + cellz = simnfo->boxLz / temp3; } current_mol = 0;