[lammps-users] fix press/berendsen possible bug

Dear LAMMPS users,

I think I found a bug in fix press/berendsen. I am doing a similar test as with a bug found in April, and I have the test case in a tar file if the developers would like to see it.

I'm not exactly sure where the bug is in the code, but allow me to describe the test. I have a simple system, 216 water molecules, I run nve with fix press/berendsen for one step and print a restart file. Then I read the restart file, and I get a different pressure and energy than the previous run. If you comment out fix press/berendsen the problem goes away.

Harold Hatch

I wouldn't call this a bug - it is due to the way press/berendsen
is implemented within a velocity Verlet timestep.

Fix npt (Nose/Hoover) and fix press/berendsen both adjust
the pressure by changing the volume of the box. Fix npt
does this change at the beginning of the timestep b/c
it is part of the altered eqs of motion. When the forces/energies
are computed in the middle of the timestep, the box has
already been changed, so the energy/pressure you
see printed at the end of the timestep are consistent.

But press/berendsen is more ad-hoc. It just corrects the
box volume at the end of the timestep, after forces/energies
were already computed with the old box volume. Thus
what is printed at the end of the timestep doesn't reflect
the box change that just took place. I.e. that energy/pressure
is slightly out of date.

When you do a restart you are seeing the energy/pressure
for the latest box size, which will be slightly different.

So the fact that printed energy/pressure is slightly off
may be annoying, but isn't affecting the dynamics.

I'd have to think if there is a way to make the output
consistent with the latest box size change. Maybe there
is another valid location during the timestep to make
the volume change, i.e. before forces/energies are calculated.