odd behavior for set type/frac

this is mostly an fyi since I don’t know how to fix it.

If you set the set type/frac to create one group and then apply the set type/frac to this new group with the same seed you can get odd results e.g. all atoms are set to the last type regardless of the specified fraction (see below for details).

changing the seed gets closer to the expected result but, as the man pages state, a 50% 50% split is not guaranteed. Since I need this for charge neutrality does anyone else have a method in lammps to set exactly half of a group to a new type?


set group FLUID type/fraction 3 0.101 13156
Setting atom values …
194 settings made for type/fraction
group CHARGED type 3
194 atoms in group CHARGED
#set group CHARGED type/fraction 4 0.5 123
set group CHARGED type/fraction 4 0.5 13156
Setting atom values …
194 settings made for type/fraction
group POSITIVE type 3
0 atoms in group POSITIVE
group NEGATIVE type 4
194 atoms in group NEGATIVE

variable cC equal count(CHARGED)
variable cPOS equal count(POSITIVE)
variable cNEG equal count(NEGATIVE)
print “charged {cC} positive {cPOS} negative ${cNEG}”
charged 194 positive 0 negative 194

If you used a different seed in the 2nd command you wouldn't
see this result. The way type/fraction works is to generate
a new seed that is a function of the atom's coords and the
user-input seed. The new seed is used to decide whether
to change the type of the atom (based on the input fraction).

To get exactly half of the atom's changed, a different method
that involves communication across procs would be needed.
The current method lets every proc make its decisions


thanks Steve
   for the confirmation. I'll write the alternate method and give it to you to include or not at some future date.