--- trunk/OOPSE/libmdtools/mpiSimulation.cpp 2003/03/27 23:33:40 432 +++ trunk/OOPSE/libmdtools/mpiSimulation.cpp 2003/03/28 19:30:59 434 @@ -85,7 +85,7 @@ int* mpiSimulation::divideLabor( void ){ myRandom = new randomSPRNG( baseSeed ); - a = (double)mpiPlug->nMolGlobal / (double)mpiPlug->nAtomsGlobal; + a = 3.0 * (double)mpiPlug->nMolGlobal / (double)mpiPlug->nAtomsGlobal; // Initialize things that we'll send out later: for (i = 0; i < mpiPlug->numberProcessors; i++ ) { @@ -136,9 +136,6 @@ int* mpiSimulation::divideLabor( void ){ add_atoms = compStamps[MolComponentType[i]]->getNAtoms(); new_atoms = old_atoms + add_atoms; - // If the processor already had too many atoms, just skip this - // processor and try again. - // If we've been through this loop too many times, we need // to just give up and assign the molecule to this processor // and be done with it. @@ -161,8 +158,6 @@ int* mpiSimulation::divideLabor( void ){ done = 1; continue; } - - if (old_atoms >= nTarget) continue; // If we can add this molecule to this processor without sending // it above nTarget, then go ahead and do it: @@ -179,18 +174,18 @@ int* mpiSimulation::divideLabor( void ){ } - // The only situation left is where old_atoms < nTarget, but - // new_atoms > nTarget. We want to accept this with some - // probability that dies off the farther we are from nTarget + // The only situation left is when new_atoms > nTarget. We + // want to accept this with some probability that dies off the + // farther we are from nTarget // roughly: x = new_atoms - nTarget // Pacc(x) = exp(- a * x) - // where a = 1 / (average atoms per molecule) + // where a = penalty / (average atoms per molecule) x = (double) (new_atoms - nTarget); y = myRandom->getRandom(); - - if (exp(- a * x) > y) { + + if (y < exp(- a * x)) { MolToProcMap[i] = which_proc; AtomsPerProc[which_proc] += add_atoms; for (j = 0 ; j < add_atoms; j++ ) { @@ -255,8 +250,6 @@ int* mpiSimulation::divideLabor( void ){ } } - std::cerr << "proc = " << mpiPlug->myNode << " atoms = " << natoms_local << "\n"; - MPI::COMM_WORLD.Allreduce(&nmol_local,&nmol_global,1,MPI_INT,MPI_SUM); MPI::COMM_WORLD.Allreduce(&natoms_local,&natoms_global,1,MPI_INT,MPI_SUM);