--- trunk/OOPSE/libmdtools/SimSetup.cpp 2003/06/19 19:11:53 557 +++ trunk/OOPSE/libmdtools/SimSetup.cpp 2003/07/02 21:26:55 572 @@ -97,7 +97,7 @@ void SimSetup::createSim( void ){ n_components = the_globals->getNComponents(); strcpy( force_field, the_globals->getForceField() ); - if( !strcasecmp( force_field, "DUFF" )) ffCase = FF_DUFF; + if( !strcasecmp( force_field, "DUFF" )) ffCase = FF_DUFF; else if( !strcasecmp( force_field, "LJ" )) ffCase = FF_LJ; else{ sprintf( painCave.errMsg, @@ -110,9 +110,9 @@ void SimSetup::createSim( void ){ // get the ensemble: strcpy( ensemble, the_globals->getEnsemble() ); - if( !strcasecmp( ensemble, "NVE" )) ffCase = NVE_ENS; - else if( !strcasecmp( ensemble, "NVT" )) ffCase = NVT_ENS; - else if( !strcasecmp( ensemble, "NPT" )) ffCase = NPT_ENS; + if( !strcasecmp( ensemble, "NVE" )) ensembleCase = NVE_ENS; + else if( !strcasecmp( ensemble, "NVT" )) ensembleCase = NVT_ENS; + else if( !strcasecmp( ensemble, "NPT" )) ensembleCase = NPT_ENS; else{ sprintf( painCave.errMsg, "SimSetup Warning. Unrecognized Ensemble -> %s, " @@ -193,7 +193,7 @@ void SimSetup::createSim( void ){ break; case FF_LJ: - the_ff = LJFF(); + the_ff = new LJFF(); break; default: @@ -479,19 +479,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 +504,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 +512,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 +520,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 +552,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 +592,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(); @@ -768,15 +774,41 @@ void SimSetup::createSim( void ){ // make the integrator + + + NVT* myNVT = NULL; + switch( ensembleCase ){ + case NVE_ENS: + new NVE( simnfo, the_ff ); + break; - if( !strcmp( ensemble, "TraPPE_Ex" ) ){ - new Symplectic(simnfo, the_ff, the_extendedsystem); - } - else if( !strcmp( force_field, "LJ" ) ){ - new Verlet( *simnfo, the_ff, the_extendedsystem ); + case NVT_ENS: + myNVT = new NVT( simnfo, the_ff ); + myNVT->setTargetTemp(the_globals->getTargetTemp()); + + 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"); + painCave.isFatal = 1; + simError(); + } + break; + + default: + sprintf( painCave.errMsg, + "SimSetup Error. Unrecognized ensemble in case statement.\n"); + painCave.isFatal = 1; + simError(); } + #ifdef IS_MPI mpiSim->mpiRefresh(); #endif @@ -1089,9 +1121,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 ); @@ -1106,9 +1138,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;