[lammps-users] internal virial

Hi Lammps users & developers,

I want to compute the instantaneous internal virial W from a trajectory for which I have dumped the atoms positions and forces, r_i and f_i for each frame.

I computed the internal virial by W = -1/3 * sum_i r_i . f_i

and knowing that pV = NRT + W , i checked whether i got the right result, as I also have p, V, N and T.

But I do not obtain the same . I have done the simulations in the NVE ensemble with periodic boundary conditions. I tried molecular systems first, and finally restore to a simple atomistic LJ and the results are still not the same.

First I thought it may be an issue of using in-cell vs uncorrected (real) coordinates, but no option gives the right result.

Any feedback on what may be wrong in my calculations and how to obtain the internal virial from a lammps simulation will be appreciated,
thanks!
vale

Hi Vale. It sounds like you're on the right track. Are
you doing the units conversions correctly? Make sure
you know the correct units of r, f, p, etc., and that
you include any required conversion factors, which
vary depending on whether you're using real or LJ or
other units. Other than that, you might look at the
LAMMPS source code to get clues on why you're seeing
the disagreement. -Paul

Try putting two or a few atoms in a simple data file
and running for 0 steps. See if you get the same pressure
via LAMMPS as you expect by your own calculation.

The values LAMMPS uses are in pressure.cpp if you
want to print them out.

Steve