Please find the attached a comment file on manuals.

Best Wishes!

Gang Liu

Scientific Computing Specialist
Centre for Advanced Computing
Queen’s University
Tel: (613) 533-6000 ext.78387
Fax: (613) 533-2015
We’ve changed our name! HPCVL is now the Centre for Advanced Computing. Check out our new look at http://cac.queensu.ca https://ca.linkedin.com/in/liuganglinkedin

I read your comment file, but did not agree with your assertion that the LAMMPS documentation for compute pressure is wrong. We deliberately do not define the meaning of r_i and f_i in the formula for P, because for periodic boundaries and manybody potentials, it is a little complicated. In the absence of periodic boundaries, r_i and f_i are exactly what you might think, and the formula is correct. This is fully explained in our paper, as we state in the doc page:

“Details of how LAMMPS computes the virial efficiently for the entire system, including the effects of periodic boundary conditions is discussed in (Thompson).”

In any case, this is a false controversy. There is only 1 reasonable and correct way of defining the force contribution to the stress tensor for periodic systems, and all widely used MD codes use it.

Thanks for your reading my comment file and replying for item 2!

First of all, I only commented on the current Lammps manual. I earnestly hope the manual itself presents the basic principles the Lammps based on concisely and accurately, since everybody reads it as a starting point.

I believe that the pressure tensor in the Lammps source code was coded based on your paper
A. P. Thompson, S. J. Plimpton, and W. Mattson, J. Chem. Phys. 131, 154107 (2009), doi: 10.1063/1.3245303
then should not be any problem in the source code.

Although the pressure formula as in the attached picture is correct in the absence of periodic boundaries, it is not good for periodic boundaries, which is frequently used. Then I suggest to update it into one for general situations with everything well-defined. I understand the complexity of manybody potentials, which I have ever tried on in https://arxiv.org/pdf/cond-mat/0505251v1.pdf. Then I suggest only consider pair potentials in the manual.

I think it would be better to replace the equations in the attached picture with Equation (31) of your above paper for general purpose.

Best Wishes!

Gang Liu

Scientific Computing Specialist
Centre for Advanced Computing
Queen’s University
Tel: (613) 533-6000 ext.78387
Fax: (613) 533-2015
We’ve changed our name! HPCVL is now the Centre for Advanced Computing. Check out our new look at http://cac.queensu.ca https://ca.linkedin.com/in/liuganglinkedin

I agree that the equation for the pressure on the LAMMPS doc page is incomplete for periodic boundary conditions. Anyone who tries to use it directly will quickly discover the same thing. Your suggestion to write the complete form for the case of pair potentials is not a good one. Then we will have people complaining that it does not work for manybody potentials, which will just create more confusion.

Instead, I will make the following change:

— , and the second term is the virial, computed within LAMMPS for all pairwise as well as 2-body, 3-body, and 4-body, and long-range interactions.
+++ The second term is the virial, -dU/dV, computed within LAMMPS for all pairwise as well as 2-body, 3-body, and 4-body, manybody, and long-range interactions, where r_i and f_i are the position and force vector of atom i, and the big black dot indicates dot product. When periodic boundary conditions are used, the summation includes contributions from periodic images of the atoms in the central box. A detailed description of how partial forces for 2-body and manybody potentials are computed is provided in (Thompson).

If preferable, I like to draw your attention to a concise and general formula of internal virial pressure/stress tensor, Equation (40) in https://arxiv.org/pdf/cond-mat/0209372v16.pdf
where two vectors being put together like AB mean a dyadic or direct tensor product.

In this equation, the summation is over all MD particle position vectors and all box/period vectors, and E_{p,MD} is the total potential energy of the MD cell (including the potentials between the MD cell and other cells). If the pair-potential, three-body potential, four-body potential, ..., till M-body potential are implemented into E_{p,MD}, like Equations (10-11) in https://arxiv.org/pdf/cond-mat/0505251v1.pdf ,
the above virial tensor has all such many-body interactions included.

More details are here. This virial tensor can be written as two parts: the summation over all MD particle position vectors and the summation over all box/period vectors. The former, the first equation in the first line of page 6 and Equations (36-37) in https://arxiv.org/pdf/cond-mat/0505251v1.pdf , has all from 2 to M-body forces individually acting on the MD particles included. The later, Equation (27-31) in https://arxiv.org/pdf/cond-mat/0505251v1.pdf , also has interactions from 2 to M-body superimposed. Playing a key role in periodic systems, the later disappears by itself in non-periodic systems, while the former appears in any system.

Your description sounds a lot like our 2009 paper, which you forgot to cite, but there might be some subtle differences. Certainly there are differences in notation. I think it best if we refer LAMMPS users to our description of our code in our paper.

Hi Gang and Aidan - the doc pages are meant to be a concise summary of
how LAMMPS computes things, not all the gory details. The references
are provided for that. But I agree the current doc page is somewhat
misleading wrt periodic boundary conditions.

I suggest the following as a balance between brevity and accuracy.
Note that the mention of ghost atoms is actually exactly how
LAMMPS does the virial computation. It is implicitly a summation
over periodic box images.