Potential energy includes dispersion correction term 2 times during minimization
Summary
I run energy minimization of the system using the l-bfgs algorithm with energy dumping every frame. I use long range dispersion corrections for energy and pressure. Then I use gmx energy to get all the energy terms. The sum of the energy terms (bond, angle, ...) doesn't match the full potential energy. It seems that the potential energy includes the dispersion correction term 2 times in the sum. During MD instead of minimization the potential energy matches with the sum of the terms.
GROMACS version
GROMACS version: 2022.4
Precision: mixed
Steps to reproduce
gmx grompp -f min.mdp -c box.gro -p topol.top -o min.tpr -maxwarn 1
gmx mdrun -deffnm min ; run 10-step minimization
gmx energy -f min.edr -o min ; 1 2 3 4 5 6 7 8 9 10 11 0 to get all energy terms and potential energy
import numpy as np
log = np.loadtxt('./min.xvg', comments=['#', '@'])
energy1 = log[:, 1:-1].sum(axis=1) # sum of all energy terms
energy2 = log[:, -1] # potential energy from log
dE = energy2 - energy1 # difference (should be zero)
print(dE, log[:, 8], sep = '\n') # print energy diff and Disp corr term (they match)
What is the current bug behavior?
The potential energy includes dispersion correction term 2 times during minimization.
What did you expect the correct behavior to be?
The potential energy includes dispersion correction term only 1 time.