Interpreting pressure Data in .edr with gmx energy as compared to Excel

GROMACS version: 2022
GROMACS modification: No
Dear Gromacs community,

I’m having problems with a simple pressure calculation and I’m hoping someone will shine a bit of light on it for me, because I truly do not see where I’m going wrong.

I’ve done a 20 ns simulation and saved 4000 points of data in an .edr file. As I’m interested in pressure behavior (NPT simulation phase), I’ve used gmx energy to output the data on total pressure along with the diagonal elements of the pressure tensor, XX, YY, ZZ, which should relate to the total pressure as 1/3*(trace). Upon completing, gmx energy gave me a read of average value, error, rmsd and drift.
For reference, the average values given were Ptot = 1.25261 bar, Pxx = -0.763273 bar, Pyy = 1.63529 bar, Pzz = 2.88581 bar

I took the data set output from the above gmx energy run and went to Microsoft Excel with it. I averaged the data in each column over the 4000 point set and got the following values. Ptot = 5.241004 bar, Pxx = -5.73842 bar, Pyy = 10.21691 bar, Pzz = 11.24464 bar.

Is there a correction I need to be making in order for these values to agree? It doesn’t seem to be a simple scalar: for the gmx energy output the ratio is Pxx/Pyy = -0.467, while for Excel the same ratio is Pxx/Pyy = -0.562.

(One additional possibly relevant point: I have a local copy of gromacs-2022 on my computer and just this morning compiled a copy of gromacs-2022 onto our cluster. The simulation was performed on our cluster, and then I processed the .edr file on my local computer; compilation was achieved with gcc in both cases, but the cluster needed mpi and cuda libraries. There were a couple oddities during compilation this morning and I didn’t run make check; I should’ve. I may try to recompile if the program is simply not quite right. But, it still doesn’t make sense that the data output quoted above is all strictly from the same version of gmx energy on my PC.)

Please help! Is there something else I may be missing?

Greg Smith
University of Colorado, Department of Physics

.edr files contain complete energy history, so you will never get the same values from an external tool as you will from gmx energy, which provides the real statistics over the course of the entire simulation, not just the values in the frames you chose to save.

Thanks, that makes sense! Is the weighting difference nstcalcenergy vs. nstenergy? About a factor of 50 difference here it looks like.

One additional question then; can I switch the number of frames I save if the entire history is still present in the .edr? The determination for saved frames was made in the .mdp before the simulation was run, but if the .edr still has it, can it be accessed?

Thank you!

Yep, there is a relationship, as noted in the manual in the nstenergy entry:

Note that the exact sums and fluctuations over all MD steps modulo nstcalcenergy are stored in the energy file, so gmx energy can report exact energy averages and fluctuations also when nstenergy > 1

I’m not sure I understand the question. The energy history is there, but there is no interpolation of frames, so you can’t access a value if you didn’t tell mdrun to write it to the file.

I think I understand; that does answer my question. Thank you!