510 |
|
|
511 |
|
#ifdef IS_MPI |
512 |
|
void SimCreator::divideMolecules(SimInfo *info) { |
513 |
– |
RealType numerator; |
514 |
– |
RealType denominator; |
515 |
– |
RealType precast; |
516 |
– |
RealType x; |
517 |
– |
RealType y; |
513 |
|
RealType a; |
514 |
|
int nProcessors; |
515 |
|
std::vector<int> atomsPerProc; |
551 |
|
atomsPerProc.insert(atomsPerProc.end(), nProcessors, 0); |
552 |
|
|
553 |
|
if (worldRank == 0) { |
554 |
< |
numerator = info->getNGlobalAtoms(); |
555 |
< |
denominator = nProcessors; |
556 |
< |
precast = numerator / denominator; |
554 |
> |
RealType numerator = info->getNGlobalAtoms(); |
555 |
> |
RealType denominator = nProcessors; |
556 |
> |
RealType precast = numerator / denominator; |
557 |
|
int nTarget = (int)(precast + 0.5); |
558 |
|
|
559 |
|
for(int i = 0; i < nGlobalMols; i++) { |
619 |
|
// Pacc(x) = exp(- a * x) |
620 |
|
// where a = penalty / (average atoms per molecule) |
621 |
|
|
622 |
< |
x = (RealType)(new_atoms - nTarget); |
623 |
< |
y = myRandom->rand(); |
622 |
> |
RealType x = (RealType)(new_atoms - nTarget); |
623 |
> |
RealType y = myRandom->rand(); |
624 |
|
|
625 |
|
if (y < exp(- a * x)) { |
626 |
|
molToProcMap[i] = which_proc; |