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

**URL:** <https://gromacs.bioexcel.eu/t/does-the-ewald3d-c-long-range-correction-include-a-virial-contribution/13708>\
**Category:** User discussions\
**Created:** [September 4, 2026, 1:37am UTC](https://gromacs.bioexcel.eu/t/does-the-ewald3d-c-long-range-correction-include-a-virial-contribution/13708 "2026-09-04T01:37:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yihao-Zhao](https://avatars.discourse-cdn.com/v4/letter/y/8e7dd6/32.png) [@Yihao-Zhao](https://gromacs.bioexcel.eu/u/Yihao-Zhao)\
**Post date:** [September 4, 2026, 1:37am UTC](https://gromacs.bioexcel.eu/t/does-the-ewald3d-c-long-range-correction-include-a-virial-contribution/13708/1 "2026-09-04T01:37:56Z")

</div>

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.

---

<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:** [September 4, 2026, 7:56am UTC](https://gromacs.bioexcel.eu/t/does-the-ewald3d-c-long-range-correction-include-a-virial-contribution/13708/2 "2026-09-04T07:56:00Z")

</div>

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.

---

<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:** [September 4, 2026, 12:47pm UTC](https://gromacs.bioexcel.eu/t/does-the-ewald3d-c-long-range-correction-include-a-virial-contribution/13708/3 "2026-09-04T12:47:50Z")

</div>

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:

> **[The 3DC Ewald correction does not have a virial contribution (#5694) · Issues...](https://gitlab.com/gromacs/gromacs/-/work_items/5694)**
>
> Also the surface correction is lacking the virial contribution. These virial contributions are very small. This is likely was this was never noticed.

> **[Add virial contribution for Ewald 3DC and epsilon surface (!6192) · Merge...](https://gitlab.com/gromacs/gromacs/-/merge_requests/6192)**
>
> Closes #5694

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