# [lammps-users] How to apply pressure?

Dear all,

I would like to know how to apply a pressure difference to a group of atoms?

Suppose I have a water slab which is periodic in x and y dimension, now I’d
like to apply, say, 2 atm pressure to the slab along z axis in the positive direction,
while apply, 1 atm pressure to the slab along z axis in the negative direction.

I’m now using addforce to the atom to mimic a net pressure difference,
but forces applied to each atoms are the same which seemed not consistent with
what should be in the real case.

Any suggestion is highly appreciated~

Chen Chen

Dear Chen,
You could create a artificial horizontal wall and then apply the total force on the wall. Just a shot in the dark, if that helps.

Using fix addforce on all atoms (in a group if you like) is
equivalent to applying a pressure gradient across a system.
I think that's what you want.

Steve

Dear Vikas and Steve,

Since fix addforce add the same force to all the atoms in the group,
if the number of atoms in the surface is a constant, the water slab
would experience a constant pressure, and the value of which can
be calculated out accordingly.

But actually the number of atom is varying all the time, so the slab
may feel quite different pressure during the simulation. What I want
is a constant net pressure to the left of the slab and push it forward.

Furthermore, I’m not sure whether a outer pressure is equivalent to
applying the same force to all the atom in the surface and in the bulk.
It is hard to imagine that every atom in the system experience the
same force due to pressure outside~

Vikas’ suggestion may be a good idea, fix wall/lj126 wall/lj93 wall/reflect
can set up a wall and make is move in some certain velocity,
but can not be applied force on. Maybe I should create a one-layer wall
and apply force on all the atoms belong to it~

Chen Chen

Furthermore, I'm not sure whether a outer pressure is equivalent to
applying the same force to all the atom in the surface and in the bulk.
It is hard to imagine that every atom in the system experience the
same force due to pressure outside~

If you apply addforce to all atoms in your box it is equivalent
to them being in a system where Phi is applied on one side
and Plo on the other, and there is thus a pressure gradient
of Phi-Plo / distance applied. I don't believe surface versus volume
is relevant, the gradient applies to every atom. Think of a fluid