--- trunk/OOPSE/libmdtools/SimSetup.cpp 2003/04/07 14:30:36 466 +++ trunk/OOPSE/libmdtools/SimSetup.cpp 2003/04/11 18:46:37 491 @@ -67,7 +67,7 @@ void SimSetup::createSim( void ){ MakeStamps *the_stamps; Globals* the_globals; ExtendedSystem* the_extendedsystem; - int i, j; + int i, j, k, globalAtomIndex; // get the stamps and globals; the_stamps = stamps; @@ -87,10 +87,58 @@ void SimSetup::createSim( void ){ if( !strcasecmp( ensemble, "NPT" ) ) { the_extendedsystem = new ExtendedSystem( simnfo ); the_extendedsystem->setTargetTemp(the_globals->getTargetTemp()); - the_extendedsystem->setTargetPressure(the_globals->getTargetPressure()); + if (the_globals->haveTargetPressure()) + the_extendedsystem->setTargetPressure(the_globals->getTargetPressure()); + else { + sprintf( painCave.errMsg, + "SimSetup error: If you use the constant pressure\n" + " ensemble, you must set targetPressure.\n" + " This was found in the BASS file.\n"); + painCave.isFatal = 1; + simError(); + } + + if (the_globals->haveTauThermostat()) + the_extendedsystem->setTauThermostat(the_globals->getTauThermostat()); + else if (the_globals->haveQmass()) + the_extendedsystem->setQmass(the_globals->getQmass()); + else { + sprintf( painCave.errMsg, + "SimSetup error: If you use one of the constant temperature\n" + " ensembles, you must set either tauThermostat or qMass.\n" + " Neither of these was found in the BASS file.\n"); + painCave.isFatal = 1; + simError(); + } + + if (the_globals->haveTauBarostat()) + the_extendedsystem->setTauBarostat(the_globals->getTauBarostat()); + else { + sprintf( painCave.errMsg, + "SimSetup error: If you use the constant pressure\n" + " ensemble, you must set tauBarostat.\n" + " This was found in the BASS file.\n"); + painCave.isFatal = 1; + simError(); + } + } else if ( !strcasecmp( ensemble, "NVT") ) { the_extendedsystem = new ExtendedSystem( simnfo ); the_extendedsystem->setTargetTemp(the_globals->getTargetTemp()); + + if (the_globals->haveTauThermostat()) + the_extendedsystem->setTauThermostat(the_globals->getTauThermostat()); + else if (the_globals->haveQmass()) + the_extendedsystem->setQmass(the_globals->getQmass()); + else { + sprintf( painCave.errMsg, + "SimSetup error: If you use one of the constant temperature\n" + " ensembles, you must set either tauThermostat or qMass.\n" + " Neither of these was found in the BASS file.\n"); + painCave.isFatal = 1; + simError(); + } + } else if ( !strcasecmp( ensemble, "NVE") ) { } else { sprintf( painCave.errMsg, @@ -106,7 +154,11 @@ void SimSetup::createSim( void ){ strcpy( simnfo->mixingRule, the_globals->getMixingRule() ); simnfo->usePBC = the_globals->getPBC(); - if( !strcmp( force_field, "TraPPE_Ex" ) ) the_ff = new TraPPE_ExFF(); + int usesDipoles = 0; + if( !strcmp( force_field, "TraPPE_Ex" ) ){ + the_ff = new TraPPE_ExFF(); + usesDipoles = 1; + } else if( !strcasecmp( force_field, "LJ" ) ) the_ff = new LJ_FF(); else{ sprintf( painCave.errMsg, @@ -246,16 +298,15 @@ void SimSetup::createSim( void ){ simnfo->n_torsions = tot_torsions; simnfo->n_SRI = tot_SRI; simnfo->n_mol = tot_nmol; - + simnfo->molMembershipArray = new int[tot_atoms]; + #ifdef IS_MPI // divide the molecules among processors here. mpiSim = new mpiSimulation( simnfo ); - - globalIndex = mpiSim->divideLabor(); // set up the local variables @@ -272,11 +323,14 @@ void SimSetup::createSim( void ){ local_bonds = 0; local_bends = 0; local_torsions = 0; + globalAtomIndex = 0; + + for( i=0; igetNAtoms(); local_bonds += comp_stamps[i]->getNBonds(); @@ -284,12 +338,16 @@ void SimSetup::createSim( void ){ local_torsions += comp_stamps[i]->getNTorsions(); localMol++; } - allMol++; + for (k = 0; k < comp_stamps[i]->getNAtoms(); k++) { + simnfo->molMembershipArray[globalAtomIndex] = allMol; + globalAtomIndex++; + } + + allMol++; } } local_SRI = local_bonds + local_bends + local_torsions; - simnfo->n_atoms = mpiSim->getMyNlocal(); if( local_atoms != simnfo->n_atoms ){ @@ -333,6 +391,7 @@ void SimSetup::createSim( void ){ if(mol2proc[i] == worldRank ){ the_molecules[molIndex].setStampID( molCompType[i] ); the_molecules[molIndex].setMyIndex( molIndex ); + the_molecules[molIndex].setGlobalIndex( i ); molIndex++; } } @@ -340,10 +399,16 @@ void SimSetup::createSim( void ){ #else // is_mpi molIndex = 0; + globalAtomIndex = 0; for(i=0; igetNAtoms(); k++) { + simnfo->molMembershipArray[globalAtomIndex] = molIndex; + globalAtomIndex++; + } molIndex++; } } @@ -478,11 +543,11 @@ void SimSetup::createSim( void ){ } simnfo->dielectric = the_globals->getDielectric(); } else { - if (simnfo->n_dipoles) { + if (usesDipoles) { if( !the_globals->haveECR() ){ sprintf( painCave.errMsg, - "SimSetup Warning: using default value of 1/2 the smallest" + "SimSetup Warning: using default value of 1/2 the smallest " "box length for the electrostaticCutoffRadius.\n" "I hope you have a very fast processor!\n"); painCave.isFatal = 0; @@ -498,7 +563,7 @@ void SimSetup::createSim( void ){ if( !the_globals->haveEST() ){ sprintf( painCave.errMsg, - "SimSetup Warning: using default value of 5% of the" + "SimSetup Warning: using default value of 5%% of the " "electrostaticCutoffRadius for the " "electrostaticSkinThickness\n" ); @@ -673,13 +738,17 @@ void SimSetup::createSim( void ){ // new AllLong( simnfo ); - if( !strcmp( force_field, "TraPPE_Ex" ) ) new Symplectic(simnfo, - the_ff, - the_extendedsystem); - if( !strcmp( force_field, "LJ" ) ) new Verlet( *simnfo, - the_ff, - the_extendedsystem ); - + + if( !strcmp( force_field, "TraPPE_Ex" ) ){ + new Symplectic(simnfo, the_ff, the_extendedsystem); + } + else if( !strcmp( force_field, "LJ" ) ){ + new Verlet( *simnfo, the_ff, the_extendedsystem ); + } + else { + std::cerr << "I'm a bug.\n"; + fprintf( stderr, "Ima bug. stderr %s\n", force_field); + } #ifdef IS_MPI mpiSim->mpiRefresh(); #endif