Rerun does not calculate reciprocal energies
A student in our group found that using rerun in GROMACS 2019, neither the Coulomb nor the LJ reciprocal terms are recalculated. These energies are 0, and consequently, the potential energy is missing these terms and is off compared to the original run.
The bug can be retraced to #1868, where rerun was split off and restricted to explicitly only calculate forces and potential energies, omitting kinetic energies, virial, pressure, constraints, etc. Consequently, within do_rerun, do_force did not get the
GMX_FORCE_VIRIAL flag anymore. In
gmx_pme_do, called from the lower level functions within do_force, the reciprocal terms are however only calculated if
GMX_FORCE_VIRIAL was originally passed. I don't see a compelling reason why reciprocal energy terms and virial should be intimately linked, but maybe I'm overlooking a detail here.
Note that due to #2649, the
GMX_FORCE_VIRIAL flag was reintroduced if GROMACS was compiled with GPU support, so GPU enabled builds are not affected by this bug.
The easy solution to fix this bug is to pass
GMX_FORCE_VIRIAL in all cases. Moving forward, we should check whether these options can be disentangled.
#6 Updated by Pascal Merz about 1 month ago
Note that the reason this was not caught by our tests is that they use the test simulation database, which only tests coulomb & vdw with straight cut-off (see src/testutils/simulationdatabase.cpp). It's worth considering - for the rerun tests, but also for other tests using this database - if we shouldn't also cover other cut-off treatments, or use PME as default.