pressure and stress tensor with periodic boundary conditions

Dear all,

I have a possibly naive question about the computation of pressure and
stress tensor in LAMMPS.

I came across a J. Chem. Phys. paper by people involved in LAMMPS [J.
Chem. Phys. 131, 154107 (2009), http://dx.doi.org/10.1063/1.3245303],
on the calculation of pressure and stress tensor under periodic
boundary conditions for arbitrary many-body interaction potentials,
but in LAMMPS documentation (in particular for the compute pressure
command) I found no reference to this article.

I was therefore wondering if the forms derived in this article were in
practice used in LAMMPS? In any case, I think it would be interesting
to add in the documentation a fews words and references on how
periodic boundary conditions are accounted for in the computation of
the virial.

Best regards,
Laurent

Dear all,

aidan can probably elaborate in more detail, but i'll give it a shot
from what i've learned over the years of staring at different pieces
of LAMMPS.

I have a possibly naive question about the computation of pressure and
stress tensor in LAMMPS.

I came across a J. Chem. Phys. paper by people involved in LAMMPS [J.
Chem. Phys. 131, 154107 (2009), http://dx.doi.org/10.1063/1.3245303],
on the calculation of pressure and stress tensor under periodic
boundary conditions for arbitrary many-body interaction potentials,
but in LAMMPS documentation (in particular for the compute pressure
command) I found no reference to this article.

because compute pressure doesn't care where the virial is coming from.
the actual code is in the corresponding many-body potentials and in
the base (pair) class. in general, LAMMPS has two ways to compute the
(global) virial: 1) through F dot r, 2) through computing per atom
virial contributions and summing them across all atoms. for most
pairwise-additive potentials, one can use strategy 1) for as long as
no per atom stress is required. 1) is much faster, since you have only
one loop over all particles rather than having to collect virial
contributions for each pair. the collection of virial data is done (or
not) via the various ev_tally*() functions based on the values of the
member variables vflag_global, vflag_atom and vflag_fdotr as they are
set in Pair::ev_setup()

I was therefore wondering if the forms derived in this article were in
practice used in LAMMPS? In any case, I think it would be interesting

yes, have a look at, e.g. PairSW::compute() and Pair:ev_tally(),
Pair::ev_tally3(). the ev_tally() function is generic for pairwise
additive contributions; ev_tally3() is specifically written for not
pairwise additive contributions. there are other variants for other
manybody potentials or TIP4P (for which you cannot use F dot r
either).

HTH,
    axel.

I added a few lines to the compute pressure and stress/atom
doc pages about this, and cited the paper Laurent suggested.

Thanks,

Steve