ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE/libmdtools/SimSetup.cpp
(Generate patch)

Comparing trunk/OOPSE/libmdtools/SimSetup.cpp (file contents):
Revision 1104 by gezelter, Tue Apr 13 16:26:03 2004 UTC vs.
Revision 1154 by gezelter, Tue May 11 16:00:22 2004 UTC

# Line 147 | Line 147 | void SimSetup::createSim(void){
147    // make the output filenames
148  
149    makeOutNames();
150
151  if (globals->haveMinimizer())
152    // make minimizer
153    makeMinimizer();
154  else
155    // make the integrator
156    makeIntegrator();
150    
151   #ifdef IS_MPI
152    mpiSim->mpiRefresh();
# Line 162 | Line 155 | void SimSetup::createSim(void){
155    // initialize the Fortran
156  
157    initFortran();
158 +
159 +  if (globals->haveMinimizer())
160 +    // make minimizer
161 +    makeMinimizer();
162 +  else
163 +    // make the integrator
164 +    makeIntegrator();
165 +
166   }
167  
168  
# Line 190 | Line 191 | void SimSetup::makeMolecules(void){
191    set<int> skipList;
192  
193    double phi, theta, psi;
194 +  char* molName;
195 +  char rbName[100];
196  
197    //init the forceField paramters
198  
# Line 206 | Line 209 | void SimSetup::makeMolecules(void){
209  
210      for (i = 0; i < info[k].n_mol; i++){
211        stampID = info[k].molecules[i].getStampID();
212 +      molName = comp_stamps[stampID]->getID();
213  
214        molInfo.nAtoms = comp_stamps[stampID]->getNAtoms();
215        molInfo.nBonds = comp_stamps[stampID]->getNBonds();
# Line 259 | Line 263 | void SimSetup::makeMolecules(void){
263          else{
264  
265            molInfo.myAtoms[j] = new Atom((j + atomOffset), info[k].getConfiguration());
266 +
267          }
268  
269          molInfo.myAtoms[j]->setType(currentAtom->getType());
265
270   #ifdef IS_MPI
271  
272 <        molInfo.myAtoms[j]->setGlobalIndex(globalIndex[j + atomOffset]);
272 >        molInfo.myAtoms[j]->setGlobalIndex(globalAtomIndex[j + atomOffset]);
273  
274   #endif // is_mpi
275        }
# Line 406 | Line 410 | void SimSetup::makeMolecules(void){
410          info[k].excludes->addPair(exK, exL);
411        }
412  
413 +      
414 +      molInfo.myRigidBodies.clear();
415 +      
416        for (j = 0; j < molInfo.nRigidBodies; j++){
417  
418          currentRigidBody = comp_stamps[stampID]->getRigidBody(j);
# Line 414 | Line 421 | void SimSetup::makeMolecules(void){
421          // Create the Rigid Body:
422  
423          myRB = new RigidBody();
424 +
425 +        sprintf(rbName,"%s_RB_%d", molName, j);
426 +        myRB->setType(rbName);
427          
428          for (rb1 = 0; rb1 < nMembers; rb1++) {
429  
# Line 454 | Line 464 | void SimSetup::makeMolecules(void){
464              // used for the exclude list:
465              
466   #ifdef IS_MPI
467 <            exI = info[k].atoms[tempI]->getGlobalIndex() + 1;
468 <            exJ = info[k].atoms[tempJ]->getGlobalIndex() + 1;
467 >            exI = molInfo.myAtoms[tempI]->getGlobalIndex() + 1;
468 >            exJ = molInfo.myAtoms[tempJ]->getGlobalIndex() + 1;
469   #else
470 <            exI = tempI + 1;
471 <            exJ = tempJ + 1;
470 >            exI = molInfo.myAtoms[tempI]->getIndex() + 1;
471 >            exJ = molInfo.myAtoms[tempJ]->getIndex() + 1;
472   #endif
473              
474              info[k].excludes->addPair(exI, exJ);
# Line 474 | Line 484 | void SimSetup::makeMolecules(void){
484        // After this is all set up, scan through the atoms to
485        // see if they can be added to the integrableObjects:
486  
487 +      molInfo.myIntegrableObjects.clear();
488 +      
489 +
490        for (j = 0; j < molInfo.nAtoms; j++){
491  
492   #ifdef IS_MPI
# Line 525 | Line 538 | void SimSetup::makeMolecules(void){
538  
539    // clean up the forcefield
540  
541 <  if (!globals->haveLJrcut()){
541 >  if (!globals->haveRcut()){
542  
543      the_ff->calcRcut();
544  
545    } else {
546      
547 <    the_ff->setRcut( globals->getLJrcut() );
547 >    the_ff->setRcut( globals->getRcut() );
548    }
549  
550    the_ff->cleanMe();
# Line 821 | Line 834 | void SimSetup::gatherInfo(void){
834    }
835  
836    //check whether sample time, status time, thermal time and reset time are divisble by dt
837 <  if (!isDivisible(globals->getSampleTime(), globals->getDt())){
837 >  if (globals->haveSampleTime() && !isDivisible(globals->getSampleTime(), globals->getDt())){
838      sprintf(painCave.errMsg,
839              "Sample time is not divisible by dt.\n"
840              "\tThis will result in samples that are not uniformly\n"
# Line 831 | Line 844 | void SimSetup::gatherInfo(void){
844      simError();    
845    }
846  
847 <  if (globals->haveStatusTime() && !isDivisible(globals->getSampleTime(), globals->getDt())){
847 >  if (globals->haveStatusTime() && !isDivisible(globals->getStatusTime(), globals->getDt())){
848      sprintf(painCave.errMsg,
849              "Status time is not divisible by dt.\n"
850              "\tThis will result in status reports that are not uniformly\n"
# Line 867 | Line 880 | void SimSetup::gatherInfo(void){
880      if (globals->haveSampleTime()){
881        info[i].sampleTime = globals->getSampleTime();
882        info[i].statusTime = info[i].sampleTime;
870      info[i].thermalTime = info[i].sampleTime;
883      }
884      else{
885        info[i].sampleTime = globals->getRunTime();
886        info[i].statusTime = info[i].sampleTime;
875      info[i].thermalTime = info[i].sampleTime;
887      }
888  
889      if (globals->haveStatusTime()){
# Line 881 | Line 892 | void SimSetup::gatherInfo(void){
892  
893      if (globals->haveThermalTime()){
894        info[i].thermalTime = globals->getThermalTime();
895 +    } else {
896 +      info[i].thermalTime = globals->getRunTime();
897      }
898  
899      info[i].resetIntegrator = 0;
# Line 951 | Line 964 | void SimSetup::finalInfoCheck(void){
964   void SimSetup::finalInfoCheck(void){
965    int index;
966    int usesDipoles;
967 +  int usesCharges;
968    int i;
969  
970    for (i = 0; i < nInfo; i++){
# Line 962 | Line 976 | void SimSetup::finalInfoCheck(void){
976        usesDipoles = (info[i].atoms[index])->hasDipole();
977        index++;
978      }
979 <
979 >    index = 0;
980 >    usesCharges = 0;
981 >    while ((index < info[i].n_atoms) && !usesCharges){
982 >      usesCharges= (info[i].atoms[index])->hasCharge();
983 >      index++;
984 >    }
985   #ifdef IS_MPI
986      int myUse = usesDipoles;
987      MPI_Allreduce(&myUse, &usesDipoles, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD);
988   #endif //is_mpi
989  
990 <    double theEcr, theEst;
990 >    double theRcut, theRsw;
991  
992      if (globals->getUseRF()){
993        info[i].useReactionField = 1;
994  
995 <      if (!globals->haveECR()){
995 >      if (!globals->haveRcut()){
996          sprintf(painCave.errMsg,
997 <                "SimSetup Warning: No value was set for electrostaticCutoffRadius.\n"
997 >                "SimSetup Warning: No value was set for the cutoffRadius.\n"
998                  "\tOOPSE will use a default value of 15.0 angstroms"
999 <                "\tfor the electrostaticCutoffRadius.\n");
999 >                "\tfor the cutoffRadius.\n");
1000          painCave.isFatal = 0;
1001          simError();
1002 <        theEcr = 15.0;
1002 >        theRcut = 15.0;
1003        }
1004        else{
1005 <        theEcr = globals->getECR();
1005 >        theRcut = globals->getRcut();
1006        }
1007  
1008 <      if (!globals->haveEST()){
1008 >      if (!globals->haveRsw()){
1009          sprintf(painCave.errMsg,
1010 <                "SimSetup Warning: No value was set for electrostaticSkinThickness.\n"
1010 >                "SimSetup Warning: No value was set for switchingRadius.\n"
1011                  "\tOOPSE will use a default value of\n"
1012 <                "\t0.05 * electrostaticCutoffRadius\n"
994 <                "\tfor the electrostaticSkinThickness\n");
1012 >                "\t0.95 * cutoffRadius for the switchingRadius\n");
1013          painCave.isFatal = 0;
1014          simError();
1015 <        theEst = 0.05 * theEcr;
1015 >        theRsw = 0.95 * theRcut;
1016        }
1017        else{
1018 <        theEst = globals->getEST();
1018 >        theRsw = globals->getRsw();
1019        }
1020  
1021 <      info[i].setDefaultEcr(theEcr, theEst);
1021 >      info[i].setDefaultRcut(theRcut, theRsw);
1022  
1023        if (!globals->haveDielectric()){
1024          sprintf(painCave.errMsg,
# Line 1013 | Line 1031 | void SimSetup::finalInfoCheck(void){
1031        info[i].dielectric = globals->getDielectric();
1032      }
1033      else{
1034 <      if (usesDipoles){
1035 <        if (!globals->haveECR()){
1034 >      if (usesDipoles || usesCharges){
1035 >
1036 >        if (!globals->haveRcut()){
1037            sprintf(painCave.errMsg,
1038 <                  "SimSetup Warning: No value was set for electrostaticCutoffRadius.\n"
1038 >                  "SimSetup Warning: No value was set for the cutoffRadius.\n"
1039                    "\tOOPSE will use a default value of 15.0 angstroms"
1040 <                  "\tfor the electrostaticCutoffRadius.\n");
1041 <          painCave.isFatal = 0;
1042 <          simError();
1043 <          theEcr = 15.0;
1044 <        }
1040 >                  "\tfor the cutoffRadius.\n");
1041 >          painCave.isFatal = 0;
1042 >          simError();
1043 >          theRcut = 15.0;
1044 >      }
1045          else{
1046 <          theEcr = globals->getECR();
1046 >          theRcut = globals->getRcut();
1047          }
1048 <        
1049 <        if (!globals->haveEST()){
1048 >        
1049 >        if (!globals->haveRsw()){
1050            sprintf(painCave.errMsg,
1051 <                  "SimSetup Warning: No value was set for electrostaticSkinThickness.\n"
1051 >                  "SimSetup Warning: No value was set for switchingRadius.\n"
1052                    "\tOOPSE will use a default value of\n"
1053 <                  "\t0.05 * electrostaticCutoffRadius\n"
1035 <                  "\tfor the electrostaticSkinThickness\n");
1053 >                  "\t0.95 * cutoffRadius for the switchingRadius\n");
1054            painCave.isFatal = 0;
1055            simError();
1056 <          theEst = 0.05 * theEcr;
1056 >          theRsw = 0.95 * theRcut;
1057          }
1058          else{
1059 <          theEst = globals->getEST();
1059 >          theRsw = globals->getRsw();
1060          }
1061 +        
1062 +        info[i].setDefaultRcut(theRcut, theRsw);
1063          
1044        info[i].setDefaultEcr(theEcr, theEst);
1064        }
1065      }
1066    }
# Line 1346 | Line 1365 | void SimSetup::mpiMolDivide(void){
1365    int localMol, allMol;
1366    int local_atoms, local_bonds, local_bends, local_torsions, local_SRI;
1367    int local_rigid;
1368 +  vector<int> globalMolIndex;
1369  
1370    mpiSim = new mpiSimulation(info);
1371  
1372 <  globalIndex = mpiSim->divideLabor();
1372 >  mpiSim->divideLabor();
1373 >  globalAtomIndex = mpiSim->getGlobalAtomIndex();
1374 >  //globalMolIndex = mpiSim->getGlobalMolIndex();
1375  
1376    // set up the local variables
1377  
# Line 1363 | Line 1385 | void SimSetup::mpiMolDivide(void){
1385    local_bends = 0;
1386    local_torsions = 0;
1387    local_rigid = 0;
1388 <  globalAtomIndex = 0;
1388 >  globalAtomCounter = 0;
1389  
1390    for (i = 0; i < n_components; i++){
1391      for (j = 0; j < components_nmol[i]; j++){
# Line 1376 | Line 1398 | void SimSetup::mpiMolDivide(void){
1398          localMol++;
1399        }      
1400        for (k = 0; k < comp_stamps[i]->getNAtoms(); k++){
1401 <        info[0].molMembershipArray[globalAtomIndex] = allMol;
1402 <        globalAtomIndex++;
1401 >        info[0].molMembershipArray[globalAtomCounter] = allMol;
1402 >        globalAtomCounter++;
1403        }
1404  
1405        allMol++;
# Line 1445 | Line 1467 | void SimSetup::makeSysArrays(void){
1467   #else // is_mpi
1468  
1469      molIndex = 0;
1470 <    globalAtomIndex = 0;
1470 >    globalAtomCounter = 0;
1471      for (i = 0; i < n_components; i++){
1472        for (j = 0; j < components_nmol[i]; j++){
1473          the_molecules[molIndex].setStampID(i);
1474          the_molecules[molIndex].setMyIndex(molIndex);
1475          the_molecules[molIndex].setGlobalIndex(molIndex);
1476          for (k = 0; k < comp_stamps[i]->getNAtoms(); k++){
1477 <          info[l].molMembershipArray[globalAtomIndex] = molIndex;
1478 <          globalAtomIndex++;
1477 >          info[l].molMembershipArray[globalAtomCounter] = molIndex;
1478 >          globalAtomCounter++;
1479          }
1480          molIndex++;
1481        }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines