Dynamically change particles in a group

Submitted by RonMexico on Thu, 08/05/2021 - 19:40

I am trying to change the group particles are assigned to based on their location in the simulation. I can do this as a one time thing, but I want to keep doing it throughout the simulation. Consider just a periodic box with particles randomly moving. If I want to separate particles into different groups based on y location, I can use

variable loc1 atom y
variable loc2 atom "y > 0.5"
variable loc3 atom "y < 0.5"
group top_group variable loc2
group bottom_group variable loc3

However, this seems to only give a one-time assignment since the particle counts in each group don't change throughout the simulation. Is there a way to keep updating the particles to each group through the simulation?

Thanks!

Daniel Queteschiner | Fri, 08/06/2021 - 10:38

The groups in LIGGGHTS-PUBLIC are all static (i.e. atoms are assigned once). You may try to use run every in combination with group delete and group region.
Alternatively, you may want to try our fork at https://github.com/ParticulateFlow/LIGGGHTS-PFM where we have backported the dynamic groups implementation from LAMMPS. However, I must admit that it's not the most thoroughly tested feature in our code base.

RonMexico | Fri, 08/06/2021 - 22:11

Thank you for the great response. The run every in combination with group delete and group region does work as a quick fix.