Does the Ewald3D-C long-range correction include a virial contribution?

GROMACS version: gromacs-2025.1.Install
GROMACS modification: Yes/No
Here post your question Dear GROMACS developers and community,

I am using Ewald3D-C for simulations of interfacial systems and would like to know whether the long-range correction term for Ewald3D-C includes a virial contribution.

I have searched through the following source files:

  • ewald/long_range_correction.cpp — the ewald_LRcorrection function computes forces and energies (Vcorr_q, dvdl), but does not take any virial tensor as an argument.

  • mdlib/force.cpp — the ewald_LRcorrection function is called in CpuPpLongRangeNonbondeds::calculate, and I see that ewald_charge_correction (which does compute virial) is called separately, but no virial contribution from ewald_LRcorrection is added to forceWithVirial.

  • ewald/ewald.cpp — the ewald_charge_correction function includes virial contributions, but this appears to be for the net charge correction only, not for the Ewald3D-C dipole surface correction.

Based on my reading of the code, it appears that the Ewald3D-C dipole surface correction computes forces and energies but does not compute the corresponding virial contribution. Could you please confirm:

  1. Is there a virial contribution from the Ewald3D-C correction that I have missed in another part of the code?

  2. If not, is this omission intentional (e.g., because the virial contribution is negligible or not needed for certain applications), or is it a missing feature?

Thank you for your time and help.

Good catch! I see no virial contribution either. This is an accidental omission. I will add the virial contribution.

But I wonder how many practical setups there are where the pressure is relevant. The only case I can think of is determining the surface tension of a liquid-vapor interface using a slab geometry.

I think that the missing contribution is very small in nearly all cases.

I created an issue and uploaded a fix to the main branch, so this will go into the 2027 release:

If we think this is more critical, we could target the 2026.4 release instead.