The following set of fixes has worked for me the way you wanted (sort
of). For my case, I had a system confined between 2 layers periodic in X
and Y direction.
#Create a group of atoms of top layer ( name it top)
#Create a group of atoms of bottom layer ( name it bottom)
#Create a group of rest of the atoms ( name it rest)
Fix 1 top setforce 0 0 0
Fix 2 bottom setforce 0 0 0
Fix 3 top rigid single
Fix 4 rest npt 1.0 1.0 0.1 aniso NULL NULL NULL NULL 0.5 0.5 1.0 (In
this case, I wanted my X and Y dimensions fixed.)
This will move top layer up or down according to the desired pressure
keeping the bottom layer fixed. If you want both layers to move only In
Z direction so that you get a particular pressure. Then I think you have
to include "bottom" group in the fix rigid command using its group
I hope this helps.