Can I Fix and Couple Pressure XYZ Without Deforming X?

I would like to impose the total pressure (i.e., [Pxx+Pyy+Pzz]/3) on my simulation with one of the box lengths fixed.

Theoretically, what I want is something like

fix 3  all press/berendsen y ${targetP} ${targetP} ${pdamp} z ${targetP} ${targetP} ${pdamp} couple xyz

This does not work as it is an illegal pressure configuration.
Another idea was to use:

variable xlo equal xlo
variable xhi equal xhi
fix 3 all npt iso ${targetP} ${targetP} ${pdamp}
fix 4 all deform 1 x final ${xlo} ${xhi} remap v

but as I understand it currently, the fix deform would barely change anything if the following run command has a too large number of time-steps, as it “has plenty of time to fix the box length later”. Also, it fails because of “ERROR: Must not have multiple fixes change box parameter x”.
Is there a way to do this in LAMMPS that I have not thought of yet?

Why must you couple x as well? Why not just couple y and z?

If y and z are the only ways the volume can relax, then it will also eventually relieve excess pressure in x, too. If it cannot due to system setup/geometry, it would be very strange to have a relaxation in y and z only, because then those box dimensions would change without ever having an effect on x.

Why must you couple x as well? Why not just couple y and z?

In my understanding, if I only couple y and z, the pressure that is fixed is computed as (Pyy+Pzz)/2, rather than the overall pressure. If I do not couple at all, only the respective components are respected (i.e. Pyy for y, Pzz for z).

If y and z are the only ways the volume can relax, then it will also eventually relieve excess pressure in x, too. If it cannot due to system setup/geometry, it would be very strange to have a relaxation in y and z only, because then those box dimensions would change without ever having an effect on x.

I guess what I did not note clearly enough is that what I actually care about is that the reference pressure used is the overall pressure, (Pxx+Pyy+Pzz)/3, which is achieved with coupling xyz (at least, maybe this is where you can propose an alternative). I do not really care about coupling the deformation magnitudes.

What I do is to fix the x component of the box in a slightly strained state, and then want to impose a total pressure on this system, having y and z adapt to achieve this total pressure.

The first order approximation to this would be to assume that that pressure in x doesn’t change without deformation and thus to achieve the situation you describe you would have to increase the target pressure for Pyy and Pyy by adding Pxx/2 (using a value averaged from a previous run without any box changes).

This could be improved by using a loop and updating the target pressures based on intermediate results with the assumption that it will converge eventually.

For anything more complex there is the generic fix controller command — LAMMPS documentation
However, I have no idea at the moment how this could be applied to box changes.

1 Like

The calculation proposed is not currently supported. It is unlikely that it makes any physical sense. Note that the barostat does not force the LAMMPS pressure constant, rather it produces a distribution of strain fluctuations that is consistent with embedding the infinite periodic system in an even more infinite elastic medium that is in a state of constant pressure (the target pressure). A side effect of this is that the average pressure reported by LAMMPS will statistically match the target pressure. It is true that behind the scenes, the instantaneous LAMMPS stress tensor components are used to implement barostats, and different components are used depending on the settings specified. If you apply a fixed compression in x and then barostat in y and z with target pressure 0, the behavior you get will also depend on whether you are system is solid or liquid. In the liquid case, the compression in x will be fully compensated by increased expansion in y and z, and so the result will be the same whether LAMMPS is using (Pxx+Pyy+Pzz)/3 or (Pyy+Pzz)/2. If it is a solid, things are more complicated. But if the x compression is fixed, it is hard to see why you would want to include Pxx in the calculation of the pressure used to adjust the volume in y and z. This will result in <Pxx> > 0, <Pyy>, <Pzz> < 0, and <P> ~ 0. If that is really the stress state you want, why not just specify target values for all 3 components.

1 Like

Thank you both for your kind and insightful answers. You are absolutely right, the physicality of the simulation is not given.

Using the approach suggested by @ akohlmey actually works perfectly fine (via loops, a fix ave/time and some variables, re-setting the target pressures). It was an interesting experiment, thanks!