pressure calculation

Dear LAMMPS developers and users,

Greetings! We are calculating the pressure of a group of water by using the commands “compute pressure” and “compute stress/atom”. Ideally, the two results should be identical. Yet they constantly differ by a factor ~ 340 atm…(the one predicted by compute stress/atom is higher). We also tried to add the compute temp in order to remove the bias, but the temperature output is zero (why?) hence no help to remove the bias. I wonder if we miss anything in the setting? Do we need to care for the DOF calculation (since we are calculating rigid water)? Thank you for the help.

LC Liu

Piece of input script is as follows:

compute allperatom all stress/atom NULL
compute allp all reduce sum c_allperatom[1] c_allperatom[2] c_allperatom[3]
variable allpress equal -(c_allp[1]+c_allp[2]+c_allp[3])/(3*vol)

thermo 10
thermo_style custom v_phytime temp density press v_allpress

Partial thermodynamic output:

phytime Temp Density Press allpress
5002 360.6901 1.1117538 8756.6441 9096.9169
5002.02 358.16763 1.1117538 8801.549 9141.8218
5002.04 362.10777 1.1117538 8718.2698 9058.5426
5002.06 356.90886 1.1117538 8902.2334 9242.5062
5002.08 360.70131 1.1117538 8692.3825 9032.6553
5002.1 361.63099 1.1117538 8678.3567 9018.6295
5002.12 360.88555 1.1117538 9079.0125 9419.2853
5002.14 364.13932 1.1117538 8936.3629 9276.6357
5002.16 366.06058 1.1117538 8711.1414 9051.4142
5002.18 362.52163 1.1117538 8798.8162 9139.0889
5002.2 359.9284 1.1117538 8989.2595 9329.5323
5002.22 367.20256 1.1117538 8633.7426 8974.0154
5002.24 363.85339 1.1117538 8866.2807 9206.5535
5002.26 364.60774 1.1117538 9165.6355 9505.9083
5002.28 362.382 1.1117538 9177.2767 9517.5495
5002.3 366.06607 1.1117538 9193.7156 9533.9884
5002.32 363.91476 1.1117538 9461.0295 9801.3023
5002.34 363.94724 1.1117538 9269.8109 9610.0837
5002.36 365.67752 1.1117538 9050.7309 9391.0037

Dear LAMMPS developers and users,

Greetings! We are calculating the pressure of a group of water by using the
commands "compute pressure" and "compute stress/atom". Ideally, the two
results should be identical. Yet they constantly differ by a factor ~ 340
atm....(the one predicted by compute stress/atom is higher). We also tried
to add the compute temp in order to remove the bias, but the temperature
output is zero (why?) hence no help to remove the bias. I wonder if we miss
anything in the setting? Do we need to care for the DOF calculation (since
we are calculating rigid water)? Thank you for the help.

impossible to say with so little information.

it works fine for me. i just ran three different test cases for rigid
water with fix shake and fix rigid/nvt, respectively, and in all cases
the pressure computation via compute reduce matches the regular global
pressure.

this is with the very latest LAMMPS-ICMS git repository code (last
updated dec 23rd) and the spce and tip4p test cases in the
test-user-omp folder (of LAMMPS-ICMS).

axel.

Hi, Axel,

Sorry that I did not phrase the question with enough information. I used the ICMS version as mentioned in your previous email, but the difference persists.

I am attaching the input script and the partial output for your reference…

Thank you for the help again and happy holiday!

LC Liu

in.tip4p2005 (1.86 KB)

log (35.1 KB)

tip4p2005.data (484 Bytes)

Hi, Axel,

Sorry that I did not phrase the question with enough information. I used the
ICMS version as mentioned in your previous email, but the difference
persists.

well, the difference you see is to be expected, since you are using
pair_modify tail yes. that LJ tail correction contribution to the
pressure is not present when you compute the pressure from the per
atom stress, only when you compute the global (virial) stress (since
this is only computed globally). turn it off and the two numbers agree
as they should.

in short, you get what you are asking for. no bug in LAMMPS as far as
i can tell.

also, i don't see the "zero temperature" that you mentioned in your
initial e-mail. neither in my not your log. file.

axel.