--- trunk/OOPSE/libmdtools/SimSetup.cpp 2003/07/16 21:30:56 626 +++ trunk/OOPSE/libmdtools/SimSetup.cpp 2003/08/11 19:40:06 676 @@ -1,6 +1,8 @@ +#include #include #include #include +#include #include "SimSetup.hpp" #include "parse_me.h" @@ -14,22 +16,28 @@ // some defines for ensemble and Forcefield cases -#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 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 +#define FF_EAM 2 +using namespace std; SimSetup::SimSetup(){ + + isInfoArray = 0; + nInfo = 1; + stamps = new MakeStamps(); globals = new Globals(); + #ifdef IS_MPI strcpy( checkPointMsg, "SimSetup creation successful" ); MPIcheckPoint(); @@ -41,6 +49,13 @@ void SimSetup::parseFile( char* fileName ){ delete globals; } +void SimSetup::setSimInfo( SimInfo* the_info, int theNinfo ) { + info = the_info; + nInfo = theNinfo; + isInfoArray = 1; +} + + void SimSetup::parseFile( char* fileName ){ #ifdef IS_MPI @@ -76,7 +91,7 @@ void SimSetup::createSim( void ){ #endif // is_mpi -void SimSetup::createSim( void ){ +void SimSetup::createSim(void){ int i, j, k, globalAtomIndex; @@ -94,8 +109,7 @@ void SimSetup::createSim( void ){ // initialize the system coordinates - initSystemCoords(); - + if( !isInfoArray ) initSystemCoords(); // make the output filenames @@ -120,6 +134,7 @@ void SimSetup::makeMolecules( void ){ void SimSetup::makeMolecules( void ){ + int k,l; int i, j, exI, exJ, tempEx, stampID, atomOffset, excludeOffset; molInit molInfo; DirectionalAtom* dAtom; @@ -144,239 +159,247 @@ void SimSetup::makeMolecules( void ){ double ux, uy, uz, u, uSqr; - atomOffset = 0; - excludeOffset = 0; - for(i=0; in_mol; i++){ + for(k=0; ksetSimInfo( &(info[k]) ); - molInfo.nAtoms = comp_stamps[stampID]->getNAtoms(); - molInfo.nBonds = comp_stamps[stampID]->getNBonds(); - molInfo.nBends = comp_stamps[stampID]->getNBends(); - molInfo.nTorsions = comp_stamps[stampID]->getNTorsions(); - molInfo.nExcludes = molInfo.nBonds + molInfo.nBends + molInfo.nTorsions; + atomOffset = 0; + excludeOffset = 0; + for(i=0; igetNAtoms(); + molInfo.nBonds = comp_stamps[stampID]->getNBonds(); + molInfo.nBends = comp_stamps[stampID]->getNBends(); + molInfo.nTorsions = comp_stamps[stampID]->getNTorsions(); + molInfo.nExcludes = molInfo.nBonds + molInfo.nBends + molInfo.nTorsions; + + molInfo.myAtoms = &(info[k].atoms[atomOffset]); + molInfo.myExcludes = &(info[k].excludes[excludeOffset]); + molInfo.myBonds = new Bond*[molInfo.nBonds]; + molInfo.myBends = new Bend*[molInfo.nBends]; + molInfo.myTorsions = new Torsion*[molInfo.nTorsions]; - theBonds = new bond_pair[molInfo.nBonds]; - theBends = new bend_set[molInfo.nBends]; - theTorsions = new torsion_set[molInfo.nTorsions]; + theBonds = new bond_pair[molInfo.nBonds]; + theBends = new bend_set[molInfo.nBends]; + theTorsions = new torsion_set[molInfo.nTorsions]; - // make the Atoms + // make the Atoms - for(j=0; jgetAtom( j ); - if( currentAtom->haveOrientation() ){ + for(j=0; jn_oriented++; - molInfo.myAtoms[j] = dAtom; - - ux = currentAtom->getOrntX(); - uy = currentAtom->getOrntY(); - uz = currentAtom->getOrntZ(); - - uSqr = (ux * ux) + (uy * uy) + (uz * uz); - - u = sqrt( uSqr ); - ux = ux / u; - uy = uy / u; - uz = uz / u; - - dAtom->setSUx( ux ); - dAtom->setSUy( uy ); - dAtom->setSUz( uz ); - } - else{ - molInfo.myAtoms[j] = new GeneralAtom(j + atomOffset); - } - molInfo.myAtoms[j]->setType( currentAtom->getType() ); + currentAtom = comp_stamps[stampID]->getAtom( j ); + if( currentAtom->haveOrientation() ){ + + dAtom = new DirectionalAtom( (j + atomOffset), + info[k].getConfiguration() ); + info[k].n_oriented++; + molInfo.myAtoms[j] = dAtom; + + ux = currentAtom->getOrntX(); + uy = currentAtom->getOrntY(); + uz = currentAtom->getOrntZ(); + + uSqr = (ux * ux) + (uy * uy) + (uz * uz); + + u = sqrt( uSqr ); + ux = ux / u; + uy = uy / u; + uz = uz / u; + + dAtom->setSUx( ux ); + dAtom->setSUy( uy ); + dAtom->setSUz( uz ); + } + else{ + molInfo.myAtoms[j] = new GeneralAtom( (j + atomOffset), + info[k].getConfiguration() ); + } + molInfo.myAtoms[j]->setType( currentAtom->getType() ); #ifdef IS_MPI - molInfo.myAtoms[j]->setGlobalIndex( globalIndex[j+atomOffset] ); + molInfo.myAtoms[j]->setGlobalIndex( globalIndex[j+atomOffset] ); #endif // is_mpi - } + } // make the bonds - for(j=0; jgetBond( j ); - theBonds[j].a = currentBond->getA() + atomOffset; - theBonds[j].b = currentBond->getB() + atomOffset; - - exI = theBonds[j].a; - exJ = theBonds[j].b; - - // exclude_I must always be the smaller of the pair - if( exI > exJ ){ - tempEx = exI; - exI = exJ; - exJ = tempEx; - } + currentBond = comp_stamps[stampID]->getBond( j ); + theBonds[j].a = currentBond->getA() + atomOffset; + theBonds[j].b = currentBond->getB() + atomOffset; + + exI = theBonds[j].a; + exJ = theBonds[j].b; + + // exclude_I must always be the smaller of the pair + if( exI > exJ ){ + tempEx = exI; + exI = exJ; + exJ = tempEx; + } #ifdef IS_MPI - tempEx = exI; - exI = the_atoms[tempEx]->getGlobalIndex() + 1; - tempEx = exJ; - exJ = the_atoms[tempEx]->getGlobalIndex() + 1; - - the_excludes[j+excludeOffset]->setPair( exI, exJ ); + tempEx = exI; + exI = info[k].atoms[tempEx]->getGlobalIndex() + 1; + tempEx = exJ; + exJ = info[k].atoms[tempEx]->getGlobalIndex() + 1; + + info[k].excludes[j+excludeOffset]->setPair( exI, exJ ); #else // isn't MPI - - the_excludes[j+excludeOffset]->setPair( (exI+1), (exJ+1) ); + + info[k].excludes[j+excludeOffset]->setPair( (exI+1), (exJ+1) ); #endif //is_mpi - } - excludeOffset += molInfo.nBonds; - - //make the bends - for(j=0; jgetBend( j ); - theBends[j].a = currentBend->getA() + atomOffset; - theBends[j].b = currentBend->getB() + atomOffset; - theBends[j].c = currentBend->getC() + atomOffset; + //make the bends + for(j=0; jgetBend( j ); + theBends[j].a = currentBend->getA() + atomOffset; + theBends[j].b = currentBend->getB() + atomOffset; + theBends[j].c = currentBend->getC() + atomOffset; + + if( currentBend->haveExtras() ){ - if( currentBend->haveExtras() ){ - - extras = currentBend->getExtras(); - current_extra = extras; - - while( current_extra != NULL ){ - if( !strcmp( current_extra->getlhs(), "ghostVectorSource" )){ - - switch( current_extra->getType() ){ + extras = currentBend->getExtras(); + current_extra = extras; + + while( current_extra != NULL ){ + if( !strcmp( current_extra->getlhs(), "ghostVectorSource" )){ - case 0: - theBends[j].ghost = - current_extra->getInt() + atomOffset; - theBends[j].isGhost = 1; - break; - - case 1: - theBends[j].ghost = - (int)current_extra->getDouble() + atomOffset; - theBends[j].isGhost = 1; - break; - - default: + switch( current_extra->getType() ){ + + case 0: + theBends[j].ghost = + current_extra->getInt() + atomOffset; + theBends[j].isGhost = 1; + break; + + case 1: + theBends[j].ghost = + (int)current_extra->getDouble() + atomOffset; + theBends[j].isGhost = 1; + break; + + default: + sprintf( painCave.errMsg, + "SimSetup Error: ghostVectorSource was neither a " + "double nor an int.\n" + "-->Bend[%d] in %s\n", + j, comp_stamps[stampID]->getID() ); + painCave.isFatal = 1; + simError(); + } + } + + else{ + sprintf( painCave.errMsg, - "SimSetup Error: ghostVectorSource was neither a " - "double nor an int.\n" - "-->Bend[%d] in %s\n", + "SimSetup Error: unhandled bend assignment:\n" + " -->%s in Bend[%d] in %s\n", + current_extra->getlhs(), j, comp_stamps[stampID]->getID() ); painCave.isFatal = 1; simError(); } - } - - else{ - sprintf( painCave.errMsg, - "SimSetup Error: unhandled bend assignment:\n" - " -->%s in Bend[%d] in %s\n", - current_extra->getlhs(), - j, comp_stamps[stampID]->getID() ); - painCave.isFatal = 1; - simError(); + current_extra = current_extra->getNext(); } + } + + if( !theBends[j].isGhost ){ - current_extra = current_extra->getNext(); + exI = theBends[j].a; + exJ = theBends[j].c; } - } + else{ - if( !theBends[j].isGhost ){ - - exI = theBends[j].a; - exJ = theBends[j].c; - } - else{ + exI = theBends[j].a; + exJ = theBends[j].b; + } - exI = theBends[j].a; - exJ = theBends[j].b; - } - - // exclude_I must always be the smaller of the pair - if( exI > exJ ){ + // exclude_I must always be the smaller of the pair + if( exI > exJ ){ + tempEx = exI; + exI = exJ; + exJ = tempEx; + } +#ifdef IS_MPI tempEx = exI; - exI = exJ; - exJ = tempEx; + exI = info[k].atoms[tempEx]->getGlobalIndex() + 1; + tempEx = exJ; + exJ = info[k].atoms[tempEx]->getGlobalIndex() + 1; + + info[k].excludes[j+excludeOffset]->setPair( exI, exJ ); +#else // isn't MPI + info[k].excludes[j+excludeOffset]->setPair( (exI+1), (exJ+1) ); +#endif //is_mpi } -#ifdef IS_MPI - tempEx = exI; - exI = the_atoms[tempEx]->getGlobalIndex() + 1; - tempEx = exJ; - exJ = the_atoms[tempEx]->getGlobalIndex() + 1; + excludeOffset += molInfo.nBends; - the_excludes[j+excludeOffset]->setPair( exI, exJ ); + for(j=0; jgetTorsion( j ); + theTorsions[j].a = currentTorsion->getA() + atomOffset; + theTorsions[j].b = currentTorsion->getB() + atomOffset; + theTorsions[j].c = currentTorsion->getC() + atomOffset; + theTorsions[j].d = currentTorsion->getD() + atomOffset; + + exI = theTorsions[j].a; + exJ = theTorsions[j].d; + + // exclude_I must always be the smaller of the pair + if( exI > exJ ){ + tempEx = exI; + exI = exJ; + exJ = tempEx; + } +#ifdef IS_MPI + tempEx = exI; + exI = info[k].atoms[tempEx]->getGlobalIndex() + 1; + tempEx = exJ; + exJ = info[k].atoms[tempEx]->getGlobalIndex() + 1; + + info[k].excludes[j+excludeOffset]->setPair( exI, exJ ); #else // isn't MPI - the_excludes[j+excludeOffset]->setPair( (exI+1), (exJ+1) ); + info[k].excludes[j+excludeOffset]->setPair( (exI+1), (exJ+1) ); #endif //is_mpi - } - excludeOffset += molInfo.nBends; - - for(j=0; jgetTorsion( j ); - theTorsions[j].a = currentTorsion->getA() + atomOffset; - theTorsions[j].b = currentTorsion->getB() + atomOffset; - theTorsions[j].c = currentTorsion->getC() + atomOffset; - theTorsions[j].d = currentTorsion->getD() + atomOffset; - exI = theTorsions[j].a; - exJ = theTorsions[j].d; + // send the arrays off to the forceField for init. + + the_ff->initializeAtoms( molInfo.nAtoms, molInfo.myAtoms ); + the_ff->initializeBonds( molInfo.nBonds, molInfo.myBonds, theBonds ); + the_ff->initializeBends( molInfo.nBends, molInfo.myBends, theBends ); + the_ff->initializeTorsions( molInfo.nTorsions, molInfo.myTorsions, theTorsions ); + + + info[k].molecules[i].initialize( molInfo ); - // exclude_I must always be the smaller of the pair - if( exI > exJ ){ - tempEx = exI; - exI = exJ; - exJ = tempEx; - } -#ifdef IS_MPI - tempEx = exI; - exI = the_atoms[tempEx]->getGlobalIndex() + 1; - tempEx = exJ; - exJ = the_atoms[tempEx]->getGlobalIndex() + 1; - the_excludes[j+excludeOffset]->setPair( exI, exJ ); -#else // isn't MPI - the_excludes[j+excludeOffset]->setPair( (exI+1), (exJ+1) ); -#endif //is_mpi + atomOffset += molInfo.nAtoms; + delete[] theBonds; + delete[] theBends; + delete[] theTorsions; } - excludeOffset += molInfo.nTorsions; - - - // send the arrays off to the forceField for init. - - the_ff->initializeAtoms( molInfo.nAtoms, molInfo.myAtoms ); - the_ff->initializeBonds( molInfo.nBonds, molInfo.myBonds, theBonds ); - the_ff->initializeBends( molInfo.nBends, molInfo.myBends, theBends ); - the_ff->initializeTorsions( molInfo.nTorsions, molInfo.myTorsions, theTorsions ); - - - the_molecules[i].initialize( molInfo ); - - - atomOffset += molInfo.nAtoms; - delete[] theBonds; - delete[] theBends; - delete[] theTorsions; } - + #ifdef IS_MPI sprintf( checkPointMsg, "all molecules initialized succesfully" ); MPIcheckPoint(); #endif // is_mpi - + // clean up the forcefield + the_ff->calcRcut(); the_ff->cleanMe(); - + } void SimSetup::initFromBass( void ){ @@ -389,6 +412,11 @@ void SimSetup::initFromBass( void ){ int n_extra; int have_extra, done; + double vel[3]; + vel[0] = 0.0; + vel[1] = 0.0; + vel[2] = 0.0; + temp1 = (double)tot_nmol / 4.0; temp2 = pow( temp1, ( 1.0 / 3.0 ) ); temp3 = ceil( temp2 ); @@ -398,9 +426,9 @@ void SimSetup::initFromBass( void ){ have_extra =1; n_cells = (int)temp3 - 1; - cellx = info->boxL[0] / temp3; - celly = info->boxL[1] / temp3; - cellz = info->boxL[2] / temp3; + cellx = info[0].boxL[0] / temp3; + celly = info[0].boxL[1] / temp3; + cellz = info[0].boxL[2] / 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 ); @@ -415,9 +443,9 @@ void SimSetup::initFromBass( void ){ } else{ n_cells = (int)temp3; - cellx = info->boxL[0] / temp3; - celly = info->boxL[1] / temp3; - cellz = info->boxL[2] / temp3; + cellx = info[0].boxL[0] / temp3; + celly = info[0].boxL[1] / temp3; + cellz = info[0].boxL[2] / temp3; } current_mol = 0; @@ -496,11 +524,8 @@ void SimSetup::initFromBass( void ){ } } - - for( i=0; in_atoms; i++ ){ - info->atoms[i]->set_vx( 0.0 ); - info->atoms[i]->set_vy( 0.0 ); - info->atoms[i]->set_vz( 0.0 ); + for( i=0; isetVel( vel ); } } @@ -510,6 +535,7 @@ void SimSetup::makeElement( double x, double y, double AtomStamp* current_atom; DirectionalAtom* dAtom; double rotMat[3][3]; + double pos[3]; for( k=0; kgetNAtoms(); k++ ){ @@ -525,15 +551,17 @@ void SimSetup::makeElement( double x, double y, double painCave.isFatal = 1; simError(); } + + pos[0] = x + current_atom->getPosX(); + pos[1] = y + current_atom->getPosY(); + pos[2] = z + current_atom->getPosZ(); + + info[0].atoms[current_atom_ndx]->setPos( pos ); - the_atoms[current_atom_ndx]->setX( x + current_atom->getPosX() ); - the_atoms[current_atom_ndx]->setY( y + current_atom->getPosY() ); - the_atoms[current_atom_ndx]->setZ( z + current_atom->getPosZ() ); + if( info[0].atoms[current_atom_ndx]->isDirectional() ){ - if( the_atoms[current_atom_ndx]->isDirectional() ){ + dAtom = (DirectionalAtom *)info[0].atoms[current_atom_ndx]; - dAtom = (DirectionalAtom *)the_atoms[current_atom_ndx]; - rotMat[0][0] = 1.0; rotMat[0][1] = 0.0; rotMat[0][2] = 0.0; @@ -569,14 +597,13 @@ void SimSetup::gatherInfo( void ){ ensembleCase = -1; ffCase = -1; - // get the stamps and globals; - stamps = stamps; - globals = globals; - // set the easy ones first - info->target_temp = globals->getTargetTemp(); - info->dt = globals->getDt(); - info->run_time = globals->getRunTime(); + + for( i=0; igetTargetTemp(); + info[i].dt = globals->getDt(); + info[i].run_time = globals->getRunTime(); + } n_components = globals->getNComponents(); @@ -586,6 +613,7 @@ void SimSetup::gatherInfo( void ){ if( !strcasecmp( force_field, "DUFF" )) ffCase = FF_DUFF; else if( !strcasecmp( force_field, "LJ" )) ffCase = FF_LJ; + else if( !strcasecmp( force_field, "EAM" )) ffCase = FF_EAM; else{ sprintf( painCave.errMsg, "SimSetup Error. Unrecognized force field -> %s\n", @@ -615,13 +643,16 @@ void SimSetup::gatherInfo( void ){ strcpy( ensemble, "NVE" ); ensembleCase = NVE_ENS; } - strcpy( info->ensemble, ensemble ); + + for(i=0; imixingRule, globals->getMixingRule() ); - info->usePBC = globals->getPBC(); - + strcpy( info[i].mixingRule, globals->getMixingRule() ); + info[i].usePBC = globals->getPBC(); + } // get the components and calculate the tot_nMol and indvidual n_mol @@ -662,78 +693,80 @@ void SimSetup::gatherInfo( void ){ // set the status, sample, and thermal kick times - if( globals->haveSampleTime() ){ - info->sampleTime = globals->getSampleTime(); - info->statusTime = info->sampleTime; - info->thermalTime = info->sampleTime; - } - else{ - info->sampleTime = globals->getRunTime(); - info->statusTime = info->sampleTime; - info->thermalTime = info->sampleTime; - } + for(i=0; ihaveStatusTime() ){ - info->statusTime = globals->getStatusTime(); - } + if( globals->haveSampleTime() ){ + info[i].sampleTime = globals->getSampleTime(); + info[i].statusTime = info[i].sampleTime; + info[i].thermalTime = info[i].sampleTime; + } + else{ + info[i].sampleTime = globals->getRunTime(); + info[i].statusTime = info[i].sampleTime; + info[i].thermalTime = info[i].sampleTime; + } + + if( globals->haveStatusTime() ){ + info[i].statusTime = globals->getStatusTime(); + } + + if( globals->haveThermalTime() ){ + info[i].thermalTime = globals->getThermalTime(); + } - if( globals->haveThermalTime() ){ - info->thermalTime = globals->getThermalTime(); - } + // check for the temperature set flag - // check for the temperature set flag - - if( globals->haveTempSet() ) info->setTemp = globals->getTempSet(); - - // get some of the tricky things that may still be in the globals - - double boxVector[3]; - if( globals->haveBox() ){ - boxVector[0] = globals->getBox(); - boxVector[1] = globals->getBox(); - boxVector[2] = globals->getBox(); + if( globals->haveTempSet() ) info[i].setTemp = globals->getTempSet(); - info->setBox( boxVector ); + // get some of the tricky things that may still be in the globals + + double boxVector[3]; + if( globals->haveBox() ){ + boxVector[0] = globals->getBox(); + boxVector[1] = globals->getBox(); + boxVector[2] = globals->getBox(); + + info[i].setBox( boxVector ); + } + else if( globals->haveDensity() ){ + + double vol; + vol = (double)tot_nmol / globals->getDensity(); + boxVector[0] = pow( vol, ( 1.0 / 3.0 ) ); + boxVector[1] = boxVector[0]; + boxVector[2] = boxVector[0]; + + info[i].setBox( boxVector ); } - else if( globals->haveDensity() ){ - - double vol; - vol = (double)tot_nmol / globals->getDensity(); - boxVector[0] = pow( vol, ( 1.0 / 3.0 ) ); - boxVector[1] = boxVector[0]; - boxVector[2] = boxVector[0]; - - info->setBox( boxVector ); - } - else{ - if( !globals->haveBoxX() ){ - sprintf( painCave.errMsg, - "SimSetup error, no periodic BoxX size given.\n" ); - painCave.isFatal = 1; - simError(); + else{ + if( !globals->haveBoxX() ){ + sprintf( painCave.errMsg, + "SimSetup error, no periodic BoxX size given.\n" ); + painCave.isFatal = 1; + simError(); + } + boxVector[0] = globals->getBoxX(); + + if( !globals->haveBoxY() ){ + sprintf( painCave.errMsg, + "SimSetup error, no periodic BoxY size given.\n" ); + painCave.isFatal = 1; + simError(); + } + boxVector[1] = globals->getBoxY(); + + if( !globals->haveBoxZ() ){ + sprintf( painCave.errMsg, + "SimSetup error, no periodic BoxZ size given.\n" ); + painCave.isFatal = 1; + simError(); + } + boxVector[2] = globals->getBoxZ(); + + info[i].setBox( boxVector ); } - boxVector[0] = globals->getBoxX(); - if( !globals->haveBoxY() ){ - sprintf( painCave.errMsg, - "SimSetup error, no periodic BoxY size given.\n" ); - painCave.isFatal = 1; - simError(); - } - boxVector[1] = globals->getBoxY(); - - if( !globals->haveBoxZ() ){ - sprintf( painCave.errMsg, - "SimSetup error, no periodic BoxZ size given.\n" ); - painCave.isFatal = 1; - simError(); - } - boxVector[2] = globals->getBoxZ(); - - info->setBox( boxVector ); } - - #ifdef IS_MPI strcpy( checkPointMsg, "Succesfully gathered all information from Bass\n" ); @@ -746,69 +779,27 @@ void SimSetup::finalInfoCheck( void ){ void SimSetup::finalInfoCheck( void ){ int index; int usesDipoles; - + int i; - // check electrostatic parameters - - index = 0; - usesDipoles = 0; - while( (index < info->n_atoms) && !usesDipoles ){ - usesDipoles = ((info->atoms)[index])->hasDipole(); - index++; - } - -#ifdef IS_MPI - int myUse = usesDipoles; - MPI_Allreduce( &myUse, &usesDipoles, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD ); -#endif //is_mpi - - double theEcr, theEst; - - if (globals->getUseRF() ) { - info->useReactionField = 1; + for(i=0; ihaveECR() ){ - sprintf( painCave.errMsg, - "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; - simError(); - double smallest; - smallest = info->boxL[0]; - if (info->boxL[1] <= smallest) smallest = info->boxL[1]; - if (info->boxL[2] <= smallest) smallest = info->boxL[2]; - theEcr = 0.5 * smallest; - } else { - theEcr = globals->getECR(); + index = 0; + usesDipoles = 0; + while( (index < info[i].n_atoms) && !usesDipoles ){ + usesDipoles = (info[i].atoms[index])->hasDipole(); + index++; } - - if( !globals->haveEST() ){ - sprintf( painCave.errMsg, - "SimSetup Warning: using default value of 0.05 * the " - "electrostaticCutoffRadius for the electrostaticSkinThickness\n" - ); - painCave.isFatal = 0; - simError(); - theEst = 0.05 * theEcr; - } else { - theEst= globals->getEST(); - } - - info->setEcr( theEcr, theEst ); - if(!globals->haveDielectric() ){ - sprintf( painCave.errMsg, - "SimSetup Error: You are trying to use Reaction Field without" - "setting a dielectric constant!\n" - ); - painCave.isFatal = 1; - simError(); - } - info->dielectric = globals->getDielectric(); - } - else { - if (usesDipoles) { +#ifdef IS_MPI + int myUse = usesDipoles; + MPI_Allreduce( &myUse, &usesDipoles, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD ); +#endif //is_mpi + + double theEcr, theEst; + + if (globals->getUseRF() ) { + info[i].useReactionField = 1; if( !globals->haveECR() ){ sprintf( painCave.errMsg, @@ -818,9 +809,9 @@ void SimSetup::finalInfoCheck( void ){ painCave.isFatal = 0; simError(); double smallest; - smallest = info->boxL[0]; - if (info->boxL[1] <= smallest) smallest = info->boxL[1]; - if (info->boxL[2] <= smallest) smallest = info->boxL[2]; + smallest = info[i].boxL[0]; + if (info[i].boxL[1] <= smallest) smallest = info[i].boxL[1]; + if (info[i].boxL[2] <= smallest) smallest = info[i].boxL[2]; theEcr = 0.5 * smallest; } else { theEcr = globals->getECR(); @@ -829,8 +820,7 @@ void SimSetup::finalInfoCheck( void ){ if( !globals->haveEST() ){ sprintf( painCave.errMsg, "SimSetup Warning: using default value of 0.05 * the " - "electrostaticCutoffRadius for the " - "electrostaticSkinThickness\n" + "electrostaticCutoffRadius for the electrostaticSkinThickness\n" ); painCave.isFatal = 0; simError(); @@ -838,11 +828,56 @@ void SimSetup::finalInfoCheck( void ){ } else { theEst= globals->getEST(); } + + info[i].setEcr( theEcr, theEst ); + + if(!globals->haveDielectric() ){ + sprintf( painCave.errMsg, + "SimSetup Error: You are trying to use Reaction Field without" + "setting a dielectric constant!\n" + ); + painCave.isFatal = 1; + simError(); + } + info[i].dielectric = globals->getDielectric(); + } + else { + if (usesDipoles) { + + if( !globals->haveECR() ){ + sprintf( painCave.errMsg, + "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; + simError(); + double smallest; + smallest = info[i].boxL[0]; + if (info[i].boxL[1] <= smallest) smallest = info[i].boxL[1]; + if (info[i].boxL[2] <= smallest) smallest = info[i].boxL[2]; + theEcr = 0.5 * smallest; + } else { + theEcr = globals->getECR(); + } + + if( !globals->haveEST() ){ + sprintf( painCave.errMsg, + "SimSetup Warning: using default value of 0.05 * the " + "electrostaticCutoffRadius for the " + "electrostaticSkinThickness\n" + ); + painCave.isFatal = 0; + simError(); + theEst = 0.05 * theEcr; + } else { + theEst= globals->getEST(); + } + + info[i].setEcr( theEcr, theEst ); + } + } + } - info->setEcr( theEcr, theEst ); - } - } - #ifdef IS_MPI strcpy( checkPointMsg, "post processing checks out" ); MPIcheckPoint(); @@ -851,142 +886,154 @@ void SimSetup::initSystemCoords( void ){ } void SimSetup::initSystemCoords( void ){ + int i; + + std::cerr << "Setting atom Coords\n"; - if( globals->haveInitialConfig() ){ - - InitializeFromFile* fileInit; + (info[0].getConfiguration())->createArrays( info[0].n_atoms ); + + for(i=0; isetCoords(); + + if( globals->haveInitialConfig() ){ + + InitializeFromFile* fileInit; #ifdef IS_MPI // is_mpi - if( worldRank == 0 ){ + if( worldRank == 0 ){ #endif //is_mpi - fileInit = new InitializeFromFile( globals->getInitialConfig() ); + fileInit = new InitializeFromFile( globals->getInitialConfig() ); #ifdef IS_MPI - }else fileInit = new InitializeFromFile( NULL ); + }else fileInit = new InitializeFromFile( NULL ); #endif - fileInit->read_xyz( info ); // default velocities on - - delete fileInit; - } - else{ - + fileInit->readInit( info ); // default velocities on + + delete fileInit; + } + else{ + #ifdef IS_MPI - - // no init from bass - - sprintf( painCave.errMsg, - "Cannot intialize a parallel simulation without an initial configuration file.\n" ); - painCave.isFatal; - simError(); - + + // no init from bass + + sprintf( painCave.errMsg, + "Cannot intialize a parallel simulation without an initial configuration file.\n" ); + painCave.isFatal; + simError(); + #else - - initFromBass(); - - + + initFromBass(); + + #endif - } - + } + #ifdef IS_MPI strcpy( checkPointMsg, "Successfully read in the initial configuration" ); MPIcheckPoint(); #endif // is_mpi - + } void SimSetup::makeOutNames( void ){ + + int k; + + for(k=0; khaveFinalConfig() ){ - strcpy( info->finalName, globals->getFinalConfig() ); - } - else{ - strcpy( info->finalName, inFileName ); - char* endTest; - int nameLength = strlen( info->finalName ); - endTest = &(info->finalName[nameLength - 5]); - if( !strcmp( endTest, ".bass" ) ){ - strcpy( endTest, ".eor" ); + + if( globals->haveFinalConfig() ){ + strcpy( info[k].finalName, globals->getFinalConfig() ); } - else if( !strcmp( endTest, ".BASS" ) ){ - strcpy( endTest, ".eor" ); - } else{ - endTest = &(info->finalName[nameLength - 4]); - if( !strcmp( endTest, ".bss" ) ){ + strcpy( info[k].finalName, inFileName ); + char* endTest; + int nameLength = strlen( info[k].finalName ); + endTest = &(info[k].finalName[nameLength - 5]); + if( !strcmp( endTest, ".bass" ) ){ strcpy( endTest, ".eor" ); } - else if( !strcmp( endTest, ".mdl" ) ){ + else if( !strcmp( endTest, ".BASS" ) ){ strcpy( endTest, ".eor" ); } else{ - strcat( info->finalName, ".eor" ); + endTest = &(info[k].finalName[nameLength - 4]); + if( !strcmp( endTest, ".bss" ) ){ + strcpy( endTest, ".eor" ); + } + else if( !strcmp( endTest, ".mdl" ) ){ + strcpy( endTest, ".eor" ); + } + else{ + strcat( info[k].finalName, ".eor" ); + } } } - } - - // make the sample and status out names - - strcpy( info->sampleName, inFileName ); - char* endTest; - int nameLength = strlen( info->sampleName ); - endTest = &(info->sampleName[nameLength - 5]); - if( !strcmp( endTest, ".bass" ) ){ - strcpy( endTest, ".dump" ); - } - else if( !strcmp( endTest, ".BASS" ) ){ - strcpy( endTest, ".dump" ); - } - else{ - endTest = &(info->sampleName[nameLength - 4]); - if( !strcmp( endTest, ".bss" ) ){ + + // make the sample and status out names + + strcpy( info[k].sampleName, inFileName ); + char* endTest; + int nameLength = strlen( info[k].sampleName ); + endTest = &(info[k].sampleName[nameLength - 5]); + if( !strcmp( endTest, ".bass" ) ){ strcpy( endTest, ".dump" ); } - else if( !strcmp( endTest, ".mdl" ) ){ + else if( !strcmp( endTest, ".BASS" ) ){ strcpy( endTest, ".dump" ); } else{ - strcat( info->sampleName, ".dump" ); + endTest = &(info[k].sampleName[nameLength - 4]); + if( !strcmp( endTest, ".bss" ) ){ + strcpy( endTest, ".dump" ); + } + else if( !strcmp( endTest, ".mdl" ) ){ + strcpy( endTest, ".dump" ); + } + else{ + strcat( info[k].sampleName, ".dump" ); + } } - } - - strcpy( info->statusName, inFileName ); - nameLength = strlen( info->statusName ); - endTest = &(info->statusName[nameLength - 5]); - if( !strcmp( endTest, ".bass" ) ){ - strcpy( endTest, ".stat" ); - } - else if( !strcmp( endTest, ".BASS" ) ){ - strcpy( endTest, ".stat" ); - } - else{ - endTest = &(info->statusName[nameLength - 4]); - if( !strcmp( endTest, ".bss" ) ){ + + strcpy( info[k].statusName, inFileName ); + nameLength = strlen( info[k].statusName ); + endTest = &(info[k].statusName[nameLength - 5]); + if( !strcmp( endTest, ".bass" ) ){ strcpy( endTest, ".stat" ); } - else if( !strcmp( endTest, ".mdl" ) ){ + else if( !strcmp( endTest, ".BASS" ) ){ strcpy( endTest, ".stat" ); } else{ - strcat( info->statusName, ".stat" ); + endTest = &(info[k].statusName[nameLength - 4]); + if( !strcmp( endTest, ".bss" ) ){ + strcpy( endTest, ".stat" ); + } + else if( !strcmp( endTest, ".mdl" ) ){ + strcpy( endTest, ".stat" ); + } + else{ + strcat( info[k].statusName, ".stat" ); + } } - } - + #ifdef IS_MPI - } + } #endif // is_mpi - + } } void SimSetup::sysObjectsCreation( void ){ - - int i; - + + int i,k; + // create the forceField - + createFF(); // extract componentList @@ -1010,13 +1057,13 @@ void SimSetup::sysObjectsCreation( void ){ // make and initialize the molecules (all but atomic coordinates) makeMolecules(); - info->identArray = new int[info->n_atoms]; - for(i=0; in_atoms; i++){ - info->identArray[i] = the_atoms[i]->getIdent(); - } - - + for(k=0; kgetIdent(); + } + } } @@ -1032,6 +1079,10 @@ void SimSetup::createFF( void ){ the_ff = new LJFF(); break; + case FF_EAM: + the_ff = new EAM_FF(); + break; + default: sprintf( painCave.errMsg, "SimSetup Error. Unrecognized force field in case statement.\n"); @@ -1050,20 +1101,22 @@ void SimSetup::compList( void ){ void SimSetup::compList( void ){ int i; - + char* id; + LinkedMolStamp* headStamp = new LinkedMolStamp(); + LinkedMolStamp* currentStamp = NULL; comp_stamps = new MoleculeStamp*[n_components]; - + // make an array of molecule stamps that match the components used. // also extract the used stamps out into a separate linked list - - info->nComponents = n_components; - info->componentsNmol = components_nmol; - info->compStamps = comp_stamps; - info->headStamp = new LinkedMolStamp(); - char* id; - LinkedMolStamp* headStamp = info->headStamp; - LinkedMolStamp* currentStamp = NULL; + for(i=0; igetType(); @@ -1101,8 +1154,9 @@ void SimSetup::calcSysValues( void ){ void SimSetup::calcSysValues( void ){ int i, j, k; - - + + int *molMembershipArray; + tot_atoms = 0; tot_bonds = 0; tot_bends = 0; @@ -1114,20 +1168,22 @@ void SimSetup::calcSysValues( void ){ tot_bends += components_nmol[i] * comp_stamps[i]->getNBends(); tot_torsions += components_nmol[i] * comp_stamps[i]->getNTorsions(); } - + tot_SRI = tot_bonds + tot_bends + tot_torsions; - - info->n_atoms = tot_atoms; - info->n_bonds = tot_bonds; - info->n_bends = tot_bends; - info->n_torsions = tot_torsions; - info->n_SRI = tot_SRI; - info->n_mol = tot_nmol; + molMembershipArray = new int[tot_atoms]; - info->molMembershipArray = new int[tot_atoms]; + for(i=0; igetNAtoms(); k++) { - info->molMembershipArray[globalAtomIndex] = allMol; + info[0].molMembershipArray[globalAtomIndex] = allMol; globalAtomIndex++; } @@ -1176,302 +1232,350 @@ void SimSetup::mpiMolDivide( void ){ } local_SRI = local_bonds + local_bends + local_torsions; - info->n_atoms = mpiSim->getMyNlocal(); + info[0].n_atoms = mpiSim->getMyNlocal(); - if( local_atoms != info->n_atoms ){ + if( local_atoms != info[0].n_atoms ){ sprintf( painCave.errMsg, "SimSetup error: mpiSim's localAtom (%d) and SimSetup's" " localAtom (%d) are not equal.\n", - info->n_atoms, + info[0].n_atoms, local_atoms ); painCave.isFatal = 1; simError(); } - info->n_bonds = local_bonds; - info->n_bends = local_bends; - info->n_torsions = local_torsions; - info->n_SRI = local_SRI; - info->n_mol = localMol; + info[0].n_bonds = local_bonds; + info[0].n_bends = local_bends; + info[0].n_torsions = local_torsions; + info[0].n_SRI = local_SRI; + info[0].n_mol = localMol; strcpy( checkPointMsg, "Passed nlocal consistency check." ); MPIcheckPoint(); } - + #endif // is_mpi void SimSetup::makeSysArrays( void ){ - int i, j, k; + int i, j, k, l; + Atom** the_atoms; + Molecule* the_molecules; + Exclude** the_excludes; - // create the atom and short range interaction arrays - - Atom::createArrays(info->n_atoms); - the_atoms = new Atom*[info->n_atoms]; - the_molecules = new Molecule[info->n_mol]; - int molIndex; - - // initialize the molecule's stampID's - -#ifdef IS_MPI + for(l=0; lgetTotNmol(); i++){ + // initialize the molecule's stampID's - if(mol2proc[i] == worldRank ){ - the_molecules[molIndex].setStampID( molCompType[i] ); - the_molecules[molIndex].setMyIndex( molIndex ); - the_molecules[molIndex].setGlobalIndex( i ); - molIndex++; +#ifdef IS_MPI + + + molIndex = 0; + for(i=0; igetTotNmol(); i++){ + + if(mol2proc[i] == worldRank ){ + the_molecules[molIndex].setStampID( molCompType[i] ); + the_molecules[molIndex].setMyIndex( molIndex ); + the_molecules[molIndex].setGlobalIndex( i ); + molIndex++; + } } - } - + #else // is_mpi - - molIndex = 0; - globalAtomIndex = 0; - for(i=0; igetNAtoms(); k++) { - info->molMembershipArray[globalAtomIndex] = molIndex; - globalAtomIndex++; + + molIndex = 0; + globalAtomIndex = 0; + for(i=0; igetNAtoms(); k++) { + info[l].molMembershipArray[globalAtomIndex] = molIndex; + globalAtomIndex++; + } + molIndex++; } - molIndex++; } - } - + #endif // is_mpi - if( info->n_SRI ){ + if( info[l].n_SRI ){ - Exclude::createArray(info->n_SRI); - the_excludes = new Exclude*[info->n_SRI]; - for( int ex=0; exn_SRI; ex++) the_excludes[ex] = new Exclude(ex); - info->globalExcludes = new int; - info->n_exclude = info->n_SRI; - } - else{ + Exclude::createArray(info[l].n_SRI); + the_excludes = new Exclude*[info[l].n_SRI]; + for( int ex=0; exsetPair( 0,0 ); - info->globalExcludes = new int; - info->globalExcludes[0] = 0; - info->n_exclude = 0; - } + Exclude::createArray( 1 ); + the_excludes = new Exclude*; + the_excludes[0] = new Exclude(0); + the_excludes[0]->setPair( 0,0 ); + info[l].globalExcludes = new int; + info[l].globalExcludes[0] = 0; + info[l].n_exclude = 0; + } - // set the arrays into the SimInfo object + // set the arrays into the SimInfo object - info->atoms = the_atoms; - info->molecules = the_molecules; - info->nGlobalExcludes = 0; - info->excludes = the_excludes; + info[l].atoms = the_atoms; + info[l].molecules = the_molecules; + info[l].nGlobalExcludes = 0; + info[l].excludes = the_excludes; - the_ff->setSimInfo( info ); - + the_ff->setSimInfo( info ); + + } } void SimSetup::makeIntegrator( void ){ - NVT* myNVT = NULL; - NPTi* myNPTi = NULL; - NPTf* myNPTf = NULL; - NPTim* myNPTim = NULL; - NPTfm* myNPTfm = NULL; + int k; - switch( ensembleCase ){ + NVT* myNVT = NULL; + NPTi* myNPTi = NULL; + NPTf* myNPTf = NULL; + NPTim* myNPTim = NULL; + NPTfm* myNPTfm = NULL; + + for(k=0; k >( &(info[k]), the_ff ); + } - case NVE_ENS: - new NVE( info, the_ff ); - break; + else + new NVE( &(info[k]), the_ff ); + break; + + case NVT_ENS: + if (haveZConstraint){ + setupZConstraint(); + myNVT = new ZConstraint >( &(info[k]), the_ff ); + } + else + myNVT = new NVT( &(info[k]), the_ff ); - case NVT_ENS: - myNVT = new NVT( info, 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(); - } - break; - - case NPTi_ENS: - myNPTi = new NPTi( info, the_ff ); - myNPTi->setTargetTemp( globals->getTargetTemp() ); + 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(); + } + break; + + case NPTi_ENS: + if (haveZConstraint){ + setupZConstraint(); + myNPTi = new ZConstraint >( &(info[k]), the_ff ); + } + else + myNPTi = new NPTi( &(info[k]), the_ff ); - 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(); - } + 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(); + } + break; + + case NPTf_ENS: + if (haveZConstraint){ + setupZConstraint(); + myNPTf = new ZConstraint >( &(info[k]), the_ff ); + } + else + myNPTf = new NPTf( &(info[k]), the_ff ); - 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(); - } - break; - - case NPTf_ENS: - myNPTf = new NPTf( info, 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" + 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(); - } + 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(); + } + break; + + case NPTim_ENS: + if (haveZConstraint){ + setupZConstraint(); + myNPTim = new ZConstraint >( &(info[k]), the_ff ); + } + else + myNPTim = new NPTim( &(info[k]), the_ff ); - if( globals->haveTauBarostat() ) - myNPTf->setTauBarostat( globals->getTauBarostat() ); - else{ + myNPTim->setTargetTemp( globals->getTargetTemp()); + + if (globals->haveTargetPressure()) + myNPTim->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() ) + myNPTim->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() ) + myNPTim->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(); - } - break; - - case NPTim_ENS: - myNPTim = new NPTim( info, the_ff ); - myNPTim->setTargetTemp( globals->getTargetTemp()); + } + break; + + case NPTfm_ENS: + if (haveZConstraint){ + setupZConstraint(); + myNPTfm = new ZConstraint >( &(info[k]), the_ff ); + } + else + myNPTfm = new NPTfm( &(info[k]), the_ff ); - if (globals->haveTargetPressure()) - myNPTim->setTargetPressure(globals->getTargetPressure()); - else { + myNPTfm->setTargetTemp( globals->getTargetTemp()); + + if (globals->haveTargetPressure()) + myNPTfm->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() ) + myNPTfm->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() ) + myNPTfm->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(); + } + break; + + default: sprintf( painCave.errMsg, - "SimSetup error: If you use a constant pressure\n" - " ensemble, you must set targetPressure in the BASS file.\n"); + "SimSetup Error. Unrecognized ensemble in case statement.\n"); painCave.isFatal = 1; simError(); } - - if( globals->haveTauThermostat() ) - myNPTim->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() ) - myNPTim->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(); - } - break; - - case NPTfm_ENS: - myNPTfm = new NPTfm( info, the_ff ); - myNPTfm->setTargetTemp( globals->getTargetTemp()); - - if (globals->haveTargetPressure()) - myNPTfm->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() ) - myNPTfm->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() ) - myNPTfm->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(); - } - break; - - default: - sprintf( painCave.errMsg, - "SimSetup Error. Unrecognized ensemble in case statement.\n"); - painCave.isFatal = 1; - simError(); } - } void SimSetup::initFortran( void ){ - info->refreshSim(); + info[0].refreshSim(); - if( !strcmp( info->mixingRule, "standard") ){ + if( !strcmp( info[0].mixingRule, "standard") ){ the_ff->initForceField( LB_MIXING_RULE ); } - else if( !strcmp( info->mixingRule, "explicit") ){ + else if( !strcmp( info[0].mixingRule, "explicit") ){ the_ff->initForceField( EXPLICIT_MIXING_RULE ); } else{ sprintf( painCave.errMsg, "SimSetup Error: unknown mixing rule -> \"%s\"\n", - info->mixingRule ); + info[0].mixingRule ); painCave.isFatal = 1; simError(); } @@ -1484,3 +1588,63 @@ void SimSetup::initFortran( void ){ #endif // is_mpi } + +void SimSetup::setupZConstraint() +{ + int k; + + for(k=0; khaveZConsTime()){ + + //add sample time of z-constraint into SimInfo's property list + DoubleData* zconsTimeProp = new DoubleData(); + zconsTimeProp->setID("zconstime"); + zconsTimeProp->setData(globals->getZConsTime()); + info[k].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->haveIndexOfAllZConsMols()){ + + //add index of z-constraint molecules into SimInfo's property list + vector tempIndex = globals->getIndexOfAllZConsMols(); + + //sort the index + sort(tempIndex.begin(), tempIndex.end()); + + IndexData* zconsIndex = new IndexData(); + zconsIndex->setID("zconsindex"); + zconsIndex->setIndexData(tempIndex); + info[k].addProperty(zconsIndex); + } + else{ + sprintf( painCave.errMsg, + "SimSetup error: If you use an ZConstraint\n" + " , you must set index of z-constraint molecules.\n"); + painCave.isFatal = 1; + simError(); + + } + + //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(info[k].finalName); + + zconsOutput = zconsOutput.substr(0, zconsOutput.rfind(".")) + ".fz"; + + StringData* zconsFilename = new StringData(); + zconsFilename->setID("zconsfilename"); + zconsFilename->setData(zconsOutput); + + info[k].addProperty(zconsFilename); + } +}