Dear LAMMPS developers,

I’m reading the fix_gcmc.h and fix_gcmc.cpp file, and got a couple of questions.

There are two variables: random_equal that is a random number generator, same for all procs, and random_unequal that is a random number generator, not the same for all procs.

My first question is, how does LAMMPS set the random_equal to be the same for all procs, while random_unequal to not be the same for all procs? I didn’t find the corresponding code related to the different sets.

My second question is: in the attempt_atomic_deletion() function, the random_unequal is used: “if (random_unequal->uniform() < ngas*exp(beta*deletion_energy)/(zz*volume))", while in the attempt_atomic_deletion_full() function the random_equal is used: "if (random_equal->uniform() < ngas*exp(beta*(energy_before - energy_after))/(zz*volume))”. Why is there such a difference?

Thank you so much!

Jibao

My first question is, how does LAMMPS set the random_equal to be the same for all procs, while >random_unequal to not be the same for all procs? I didn’t find the corresponding code related to the different >sets.

It’s how they are used. If the equal is used by all procs, every time it is invoked,

then all procs use the same random number. The unequal is used differently

by different procs so its random numbers are unique to different procs.

Aidan will have to answer the other Q.

Steve

Good question. As Steve said, the only difference between these two

PRNG objects is how they are used. equal is used for numbers that are

generated on all processors, unequal for numbers that are generated on

only one processor. When using full energy, all procs perform the

acceptance test, hence the equal variant is used, whereas without full

energy, only the processor that owns the atom performs the test, so

unequal is used.

This is a rather fragile construct, easy to get wrong, and I found two

cases where velocities are computed by all procs using unequal (now

fixed). This made the velocities dependent on the processor count.

Aidan

Hi Steve and Aidan,

Thank you for your answers. I appreciate it!

Aidan, could you please briefly explain why only the processor that owns the atom performs the acceptance test without using full energy, while all procs perform the test when using full energy?

Thanks,

Jibao

Hi Steve and Aidan,

Thank you for your answers. I appreciate it!

Aidan, could you please briefly explain why only the processor that owns the

atom performs the acceptance test without using full energy, while all procs

perform the test when using full energy?

It could be done either way. This is just how Paul chose to do it.