Inconsistence in result of pressure and stress/atom

Dear lammps users,

I am simulating an all-atom model of a polymer composite under NPT ensemble using fix deform command. I want to calculate the Young’s modulus of the system. I have done this in two different ways.

compute newT all temp
compute press1 all pressure newT

compute peratom all stress/atom NULL
compute p all reduce sum c_peratom[1] c_peratom[2] c_peratom[3]
variable strx equal -c_p[1]/vol
etc…

For each of the diagonal components, I observe a difference of
{ pxx pyy pzz
-577.14688 959.23879 779.16382
1360.0821 -81.16043 43.83924
1979.5383 507.0162 1777.9576
1092.6076 385.68412 -2001.5068
-2188.5087 -363.71055 -2862.8444
-1539.617 693.65343 2.58046
}

{ strx stry strz # these are components from stress/atom

313.86507 1850.2507 1670.1758
2246.1962 804.95368 929.95336
2865.6528 1393.1307 2664.0721
1981.1298 1274.2063 -1112.9846}
as mention in the manual that the -(c_p[1]+c_p[2]+c_p[3])/3/vol) will be equal to v_press
but in my case, the values are different
-(c_p[1]+c_p[2]+c_p[3])/3/vol) v_press
1278.0972 387.08524
1327.0344 440.92031
2307.6185 1421.504
714.11721 -174.40501
-919.56401

I am attaching a portion of my script and data file. I am currently using the LAMMPS version August 29, 2024
thank you so much
I also noticed that when I added a negative sign to c_p[1]…, the stress values became more negative. This is opposite to what is mentioned in the manual

300knpt.data (3.4 MB)
run1.in (3.4 KB)
log.lammps (19.1 KB)

As noted here: compute stress/atom command — LAMMPS documentation, LJ tail corrections are not included in compute stress/atom. If you comment those out then everything matches as expected.

“The per-atom stress does not include any Lennard-Jones tail corrections to the pressure added by the pair_modify tail yes command, since those are contributions to the global system pressure.”

1 Like

Thank you so much, Dear @stamoor, for your reply. Yes, you are right. I read this note in the manual, and then I commented the tail yes in the pair_modify command, but still, the v_press and stress are inconsistent.

Works for me using latest LAMMPS, unless I’m missing something:

   Step          Temp       c_press1[1]        Pxx           v_strx      c_press1[2]        Pyy           v_stry      c_press1[3]        Pzz           v_strz      c_press1[4]        Pxy          v_strxy      c_press1[5]        Pxz          v_strxz      c_press1[6]        Pyz          v_stryz       v_st_total       Press     
         0   297.61476      762.55175      762.55175      762.55175      2225.1076      2225.1076      2225.1076      1260.2083      1260.2083      1260.2083     -267.90732     -267.90732     -267.90732     -1353.9005     -1353.9005     -1353.9005      954.19989      954.19989      954.19989      1415.9559      1415.9559    
       500   298.64459     -1402.2207     -1402.2207     -1402.2207     -1834.4377     -1834.4377     -1834.4377      66.761709      66.761709      66.761709      1836.2299      1836.2299      1836.2299      534.08028      534.08028      534.08028      369.5889       369.5889       369.5889      -1056.6322     -1056.6322    
      1000   294.50188     -1484.6583     -1484.6583     -1484.6583     -1087.3392     -1087.3392     -1087.3392      1741.9215      1741.9215      1741.9215     -426.11956     -426.11956     -426.11956     -1106.4921     -1106.4921     -1106.4921      1047.6155      1047.6155      1047.6155     -276.69201     -276.69201 

got it Dear @stamoor thank you so much for your help
i have last question.
In calculating stress, do we need to add a negative sign to the stress/atom components (e.g., -p1[1]), or is the negative sign only necessary when converting stress into pressure?

The negative sign is discussed in the docs: compute stress/atom command — LAMMPS documentation.

Dear @stamoor, I have read the manual, but I still have some doubts. However, I will go through it more thoroughly to gain a deeper understanding
thank you so much for your time.