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

**URL:** <https://gromacs.bioexcel.eu/t/the-output-average-of-gmx-energy-differs-from-the-average-of-the-data-stored-in-xvg/13140>\
**Category:** User discussions\
**Tags:** analysis-tools\
**Created:** [January 22, 2026, 12:35pm UTC](https://gromacs.bioexcel.eu/t/the-output-average-of-gmx-energy-differs-from-the-average-of-the-data-stored-in-xvg/13140 "2026-01-22T12:35:44Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![MichelePellegrino](https://dub1.discourse-cdn.com/flex017/user_avatar/gromacs.bioexcel.eu/michelepellegrino/32/628_2.png) [@MichelePellegrino](https://gromacs.bioexcel.eu/u/MichelePellegrino)\
**Post date:** [January 22, 2026, 12:35pm UTC](https://gromacs.bioexcel.eu/t/the-output-average-of-gmx-energy-differs-from-the-average-of-the-data-stored-in-xvg/13140/1 "2026-01-22T12:35:44Z")

</div>

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:

```auto
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:

```auto
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](https://drive.google.com/drive/folders/1bpqtMtkR2xAsSOc6FWh81ZlfxFIoVhjY?usp=sharing)

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.

---

<div class="post-metadata">

**Author:** ![hess](https://dub1.discourse-cdn.com/flex017/user_avatar/gromacs.bioexcel.eu/hess/32/416_2.png) [@hess](https://gromacs.bioexcel.eu/u/hess)\
**Post date:** [January 22, 2026, 12:44pm UTC](https://gromacs.bioexcel.eu/t/the-output-average-of-gmx-energy-differs-from-the-average-of-the-data-stored-in-xvg/13140/2 "2026-01-22T12:44:03Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![MichelePellegrino](https://dub1.discourse-cdn.com/flex017/user_avatar/gromacs.bioexcel.eu/michelepellegrino/32/628_2.png) [@MichelePellegrino](https://gromacs.bioexcel.eu/u/MichelePellegrino)\
**Post date:** [January 22, 2026, 12:46pm UTC](https://gromacs.bioexcel.eu/t/the-output-average-of-gmx-energy-differs-from-the-average-of-the-data-stored-in-xvg/13140/3 "2026-01-22T12:46:59Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![hess](https://dub1.discourse-cdn.com/flex017/user_avatar/gromacs.bioexcel.eu/hess/32/416_2.png) [@hess](https://gromacs.bioexcel.eu/u/hess)\
**Post date:** [January 22, 2026, 12:48pm UTC](https://gromacs.bioexcel.eu/t/the-output-average-of-gmx-energy-differs-from-the-average-of-the-data-stored-in-xvg/13140/4 "2026-01-22T12:48:21Z")

</div>

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).
