# LAMMPS pressure calculations

Dear all,

I’ve spent some time trying to calculate the virial pressure for a Lennard-Jones system in LAMMPS, and realised that there are some subtle issues in the literature. If I understand things correctly, for pairwise forces LAMMPS calculates the virial pressure as the sum

\sum_{i = 1}^{N} f_i \cdot r_i (1)

where f_i is the force acting on particle i, and r_i its position. For a finite system with pairwise additive forces, this is known to reduce to

\sum_{i = 1}^{N-1} \sum_{j > i}^{N} f_{ij} \cdot r_{ij} (2)

where f_{ij} and r_{ij} are now the force and separation vectors between particles i and j. In systems with periodic boundary conditions, however, these two formulations are equivalent. If I’ve understood the literature correctly, Eq. (1) does not hold anymore when using PBCs, although Eq. (2) still remains valid through a lucky coincidence (see Louwerse and Baerens, Chem. Phys. Lett. 421, 138-141 (2006)). The difference between the two formulas is far from negligible: for a test configuration, I got a more than 10-fold difference between the pressures computed using the two approaches. Have I misunderstood the code, or is it actually the case that Eq. (1) is used per default even when using periodic boundary conditions? In that case, this ought to yield significant errors in the pressure calculations. Kind regards, Joakim Stenhammar

Hello,

the calculation of pressure in LAMMPS is described in detail in the paper of Thompson, Plimpton and Mattson (J. Chem. Phys. 2009): https://cfwebprod.sandia.gov/cfdocs/CCIM/docs/JCPSA613115154107_1.pdf

Please check it. It also discusses Louwerse and Baerends work.

Regards,
Oleg

27.11.2013, 23:09, "Joakim Stenhammar" <[email protected]...>:

Dear Oleg,

Thanks a lot for the link, and apologies for not browsing the literature properly before posting!

Kind regards,

Joakim

Oleg Sergeev skrev 2013-11-27 22:07: