How to prevent a goupr of atoms rotating

Dear LAMMPS users,

Currently, I am wrestling with preventing a group of molecules rotating.
What I try to do is,

There are two groups of molecules which are defined one is upper layer and the other is lower layer.
I want to constrain the low layer in all direction and the upper layer in x,y-directions.
In summary, only the upper layer allows to translate in z-direction without rotating.
What I did for this job follows,

group doublelayers molecule 1 2
group lowerlayer molecule 1
group upperlayer molecule 2

fix 1 all nve
fix 2 doublelayers rigid molecule
fix 3 upperlayer setforce 0.0 0.0 NULL
fix 4 lowerlayer setforce 0.0 0.0 0.0
fix 5 upperlayer momentum 1 linear 1 1 0 angular
fix 6 lowerlayer momentum 1 linear 1 1 1 angular
fix 7 all temp/rescale 100 300 310 1 1.0

I set the zero set force, linear and angular momentum for lower layer to freeze it.
It seems working since the lower layer does not move or rotate during simulation.
In the same manner, I set the upper layer, and only allow it translate z-direction by fix/momentum linear 1 1 0 angular.
However, the upper layer is rotating during simulation.
Do I miss something or misunderstand the command, fix/setforce and momentum?

Thank you in advance for your help!

Joon

Dear LAMMPS users,

Currently, I am wrestling with preventing a group of molecules rotating.
What I try to do is,

There are two groups of molecules which are defined one is upper layer and
the other is lower layer.
I want to constrain the low layer in all direction and the upper layer in
x,y-directions.

what do you mean by "constrain"?

In summary, only the upper layer allows to translate in z-direction without
rotating.
What I did for this job follows,

group doublelayers molecule 1 2
group lowerlayer molecule 1
group upperlayer molecule 2

fix 1 all nve
fix 2 doublelayers rigid molecule

fix rigid includes a propagator, so
you should not use fix nve on group all.

LAMMPS should have printed a warning about this!!

fix 3 upperlayer setforce 0.0 0.0 NULL
fix 4 lowerlayer setforce 0.0 0.0 0.0
fix 5 upperlayer momentum 1 linear 1 1 0 angular
fix 6 lowerlayer momentum 1 linear 1 1 1 angular

why do you need to use fix momentum, if you are already
setting the forces to zero? just remove any residual
momentum with the velocity command and then you
should be good. ...except for

fix 7 all temp/rescale 100 300 310 1 1.0

this fix applied to _all_ atom will certainly mess up
things. fix temp/rescale is not a good method to use
under these circumstances in the first place, but
applying it to all atoms makes no sense at all.

I set the zero set force, linear and angular momentum for lower layer to
freeze it.
It seems working since the lower layer does not move or rotate during
simulation.
In the same manner, I set the upper layer, and only allow it translate
z-direction by fix/momentum linear 1 1 0 angular.
However, the upper layer is rotating during simulation.
Do I miss something or misunderstand the command, fix/setforce and momentum?

i don't know. likely you are missing something.
your setup looks weird and it is not easy to
figure out what you really want to do.

axel.

I will only add that if you are using
fix rigid to constrain a set of atoms
to move as a rigid body, the command
also has a torque option to turn off
torques on the body, so that it will
not rotate.

Steve