--- trunk/OOPSE/libmdtools/SimSetup.cpp 2003/08/11 19:40:06 676 +++ trunk/OOPSE/libmdtools/SimSetup.cpp 2003/08/13 19:21:53 693 @@ -5,6 +5,7 @@ #include #include "SimSetup.hpp" +#include "ReadWrite.hpp" #include "parse_me.h" #include "Integrator.hpp" #include "simError.h" @@ -96,7 +97,7 @@ void SimSetup::createSim(void){ int i, j, k, globalAtomIndex; // gather all of the information from the Bass file - + gatherInfo(); // creation of complex system objects @@ -104,7 +105,7 @@ void SimSetup::createSim(void){ sysObjectsCreation(); // check on the post processing info - + finalInfoCheck(); // initialize the system coordinates @@ -888,8 +889,9 @@ void SimSetup::initSystemCoords( void ){ void SimSetup::initSystemCoords( void ){ int i; - std::cerr << "Setting atom Coords\n"; + char* inName; + (info[0].getConfiguration())->createArrays( info[0].n_atoms ); for(i=0; isetCoords(); @@ -900,7 +902,9 @@ void SimSetup::initSystemCoords( void ){ #ifdef IS_MPI // is_mpi if( worldRank == 0 ){ #endif //is_mpi - fileInit = new InitializeFromFile( globals->getInitialConfig() ); + inName = globals->getInitialConfig(); + double* tempDouble = new double[1000000]; + fileInit = new InitializeFromFile( inName ); #ifdef IS_MPI }else fileInit = new InitializeFromFile( NULL ); #endif @@ -1033,7 +1037,7 @@ void SimSetup::sysObjectsCreation( void ){ int i,k; // create the forceField - + createFF(); // extract componentList @@ -1051,11 +1055,11 @@ void SimSetup::sysObjectsCreation( void ){ #endif //is_mpi // create the atom and SRI arrays. Also initialize Molecule Stamp ID's - + makeSysArrays(); // make and initialize the molecules (all but atomic coordinates) - + makeMolecules(); for(k=0; khaveZconstraints()){ + setupZConstraint(info[k]); new ZConstraint >( &(info[k]), the_ff ); } @@ -1368,8 +1372,8 @@ void SimSetup::makeIntegrator( void ){ break; case NVT_ENS: - if (haveZConstraint){ - setupZConstraint(); + if (globals->haveZconstraints()){ + setupZConstraint(info[k]); myNVT = new ZConstraint >( &(info[k]), the_ff ); } else @@ -1390,8 +1394,8 @@ void SimSetup::makeIntegrator( void ){ break; case NPTi_ENS: - if (haveZConstraint){ - setupZConstraint(); + if (globals->haveZconstraints()){ + setupZConstraint(info[k]); myNPTi = new ZConstraint >( &(info[k]), the_ff ); } else @@ -1431,8 +1435,8 @@ void SimSetup::makeIntegrator( void ){ break; case NPTf_ENS: - if (haveZConstraint){ - setupZConstraint(); + if (globals->haveZconstraints()){ + setupZConstraint(info[k]); myNPTf = new ZConstraint >( &(info[k]), the_ff ); } else @@ -1472,8 +1476,8 @@ void SimSetup::makeIntegrator( void ){ break; case NPTim_ENS: - if (haveZConstraint){ - setupZConstraint(); + if (globals->haveZconstraints()){ + setupZConstraint(info[k]); myNPTim = new ZConstraint >( &(info[k]), the_ff ); } else @@ -1513,8 +1517,8 @@ void SimSetup::makeIntegrator( void ){ break; case NPTfm_ENS: - if (haveZConstraint){ - setupZConstraint(); + if (globals->haveZconstraints()){ + setupZConstraint(info[k]); myNPTfm = new ZConstraint >( &(info[k]), the_ff ); } else @@ -1589,19 +1593,18 @@ void SimSetup::initFortran( void ){ } -void SimSetup::setupZConstraint() +void SimSetup::setupZConstraint(SimInfo& theInfo) { - int k; - - for(k=0; khaveZConsTime()){ + int nZConstraints; + ZconStamp** zconStamp; + + if(globals->haveZconstraintTime()){ //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); + zconsTimeProp->setID(ZCONSTIME_ID); + zconsTimeProp->setData(globals->getZconsTime()); + theInfo.addProperty(zconsTimeProp); } else{ sprintf( painCave.errMsg, @@ -1610,41 +1613,62 @@ void SimSetup::setupZConstraint() 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); + + // + nZConstraints = globals->getNzConstraints(); + theInfo.nZconstraints = nZConstraints; + + zconStamp = globals->getZconStamp(); + ZConsParaItem tempParaItem; + + ZConsParaData* zconsParaData = new ZConsParaData(); + zconsParaData->setID(ZCONSPARADATA_ID); + + for(int i = 0; i < nZConstraints; i++){ + tempParaItem.havingZPos = zconStamp[i]->haveZpos(); + tempParaItem.zPos = zconStamp[i]->getZpos(); + tempParaItem.zconsIndex = zconStamp[i]->getMolIndex(); + tempParaItem.kRatio = zconStamp[i]->getKratio(); + + zconsParaData->addItem(tempParaItem); } - 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(); - + + //sort the parameters by index of molecules + zconsParaData->sortByIndex(); + + //push data into siminfo, therefore, we can retrieve later + theInfo.addProperty(zconsParaData); + + //push zconsTol into siminfo, if user does not specify + //value for zconsTol, a default value will be used + DoubleData* zconsTol = new DoubleData(); + zconsTol->setID(ZCONSTOL_ID); + if(globals->haveZconsTol()){ + zconsTol->setData(globals->getZconsTol()); } - + else{ + double defaultZConsTol = 1E-6; + sprintf( painCave.errMsg, + "ZConstraint Waring: Tolerance for z-constraint methodl is not specified\n" + " , default value %f is used.\n", defaultZConsTol); + painCave.isFatal = 0; + simError(); + + zconsTol->setData(defaultZConsTol); + } + theInfo.addProperty(zconsTol); + //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); + string zconsOutput(theInfo.finalName); zconsOutput = zconsOutput.substr(0, zconsOutput.rfind(".")) + ".fz"; StringData* zconsFilename = new StringData(); - zconsFilename->setID("zconsfilename"); + zconsFilename->setID(ZCONSFILENAME_ID); zconsFilename->setData(zconsOutput); - info[k].addProperty(zconsFilename); - } + theInfo.addProperty(zconsFilename); }