The output average of gmx energy differs from the average of the data stored in .xvg

GROMACS version: 2025.3
GROMACS modification: No

Hi,

I am computing the surface tension of a liquid-liquid system using gmx energy and I am encountering some odd behaviour. When I run gmx energy -f ener.edr -o surftens.xvg -b 2000, I get this:

Energy                      Average   Err.Est.       RMSD  Tot-Drift
-------------------------------------------------------------------------------
#Surf*SurfTen               776.168         56    3942.74   -337.931  (bar nm)

But when I analyze the data in surftens.xvg I get this instead:

surftens_results = np.loadtxt('surftens.xvg',comments=('@','#'))
data = surftens_results[:,1]
print(np.avg(data))
>> 953.241228864068

Is this expected? I doubt the discrepancy could be due to a numerical precision issue. I should also say that given the physics of the problem I trust the output of gmx energy more, maybe something went wrong when writing the .xvg file.

Here are the .edr and the .xvg files: surftens-output-gmx-2025-3 - Google Drive

Should I excalate this to Gitlab? I hope not.

P.S. I realize now that it could actually be a numerical precision issue, given the RMSD. It would be great to have a confirmation anyway.

gmx energy computes averages using sums stored for all nstcalcenergy steps, not just the nstenergy steps that end up the xvg output. Option -aver also prints these averages to xvg.

Ah, I didn’t know that! I thought the sampling to be the same, albeit with different precision. Thanks for the clarification.

I see now that I mixed up the two mdp parameters in my last answer. I’ll fix this.

The help text mentions this extensively (although we should mention nstcalcenergy there).