Dear Lammps developers,
I am trying to understand the code of fix-gcmc. To make it easy, I start from a system only Argon atoms (single-atom molecule) are included. I have tested it and it seems everything goes well. But when I artificially modified some Argon atom type from 1 to 2, I found something I can not understand.
According to my understanding, in the code of fix-gcmc, “gas atoms” refers to the atoms of gcmc type, i.e. the atoms to be inserted or deleted. My understanding comes from the following function:
int FixGCMC::pick_random_gas_atom()
{
int i = -1;
int iwhichglobal = static_cast (ngas*random_equal->uniform());
if ((iwhichglobal >= ngas_before) &&
(iwhichglobal < ngas_before + ngas_local)) {
int iwhichlocal = iwhichglobal - ngas_before;
i = local_gas_list[iwhichlocal];
}
return i;
}
By using this function, one atom is chosen for deletion or translation. So, I guess, here “ngas_local” is the number of gcmc type atoms in the current processor. This function is used to choose one of the “ngas_local” atoms.
However, in another function, void FixGCMC::update_gas_atoms_list(), it seems not only the gcmc type atoms are counted as “ngas_local” atoms (the meaning of “groupbit” is not clear to me yet). The related code is as follows:
for (int i = 0; i < nlocal; i++) {
if (mask[i] & groupbit) {
local_gas_list[ngas_local] = i;
ngas_local++;
}
}
In my test run, I modified 20 Argon atom type from 1 to 2. I have found that the value of “atom->nlocal” is the same as that of “ngas_local”. That means, all local atoms (whether they are gcmc type or not) are also local gas atoms, and all local atoms can be chosen for GCMC exchange (in my simulation, atoms of type 1 is set as the gcmc type). I tried many ways but just could not find the origin of my puzzle.
In my test, the value of mask[i] for atoms of type 1 is 1 or 3, for atoms of type 2 is 5. The values for “groupbit” and “groupbitall” are both 1. That is the reason why both atoms of type 1 and 2 are chosen for “ngas_local”. But why they are both included?
Could someone help me? Thanks in advance!
All the best,
Yongbiao