# how to fix a group of variable atoms?

Hi, everyone! Can you give me some suggestions about my question? Thanks very much.
My questions as follows:
I want to freeze the atoms which Z values are smaller than 2000 during the whole simulation. So I try it by two ways.

1. I used the variable and group command:

variable freeze atom z<2000
group deposition variable freeze

group free subtract all deposition

fix 1 deposition setforce 0.0 0.0 0.0
fix 2 free nve

1. I used the region and group command:

region freeze block 0 11000 0 11000 0 2000
group deposition region freeze
group free subtract all deposition

fix 1 deposition setforce 0.0 0.0 0.0
fix 2 free nve

But both the results show that only the atoms which initial Z values are smaller than 2000 can be freeze. The atoms which Z values are smaller than 2000 in the following timesteps can not be picked up and frozen. Can you give me some suggestions? Thanks very much.

yours sincerely,

jane

Hi, everyone! Can you give me some suggestions about my question? Thanks
very much.
My questions as follows:
I want to freeze the atoms which Z values are smaller than 2000 during the
whole simulation. So I try it by two ways.
1. I used the variable and group command:

variable freeze atom z<2000
group deposition variable freeze
group free subtract all deposition
.........................................................
fix 1 deposition setforce 0.0 0.0 0.0
fix 2 free nve

2. I used the region and group command:

region freeze block 0 11000 0 11000 0 2000
group deposition region freeze
group free subtract all deposition
..................................................................
fix 1 deposition setforce 0.0 0.0 0.0
fix 2 free nve

But both the results show that only the atoms which initial Z values are
smaller than 2000 can be freeze. The atoms which Z values are smaller than
2000 in the following timesteps can not be picked up and frozen. Can you
give me some suggestions? Thanks very much.

there are two problems:

1) as you observed, group assignments are static, i.e. they are
evaluated immediately when the command is issued and never updated.
you need to define a group as dynamic to have it updated. please see
the documentation of the group command for details

2) setting the force to zero doesn't immobilize atoms by itself. you
also need to set their velocity to zero. so your fix setforce would
not work. what makes it work in your case, is that you are also
changing the group of atoms for which fix nve is applied. so you can
simplify the group definition to directly define the group of mobile
atoms.

so something like the following should work (please note that
redefining a group is a costly operation, so it should be done as
infrequent as possible unless you don't care about the speed of your
simulation).:

region mobile block -INF INF -INF INF 2000 INF
group free dynamic all region mobile every 10
fix 2 free nve

axel.

Or just don’t time integrate the atoms in the static (or dynamic)

group with z < 2000. Then you don’t need to set their

force/vels to 0.0.

Steve

Hi, Axel and Steve, thanks very much for your answers in detail. I have sovled the question by using dynamic group. Thanks again.

Best wishes!

yours sincerely,

jane