Skip to content

Commit

Permalink
Add missing Ewald charge term with PME on GPU
Browse files Browse the repository at this point in the history
With PME on GPU and a system with net charge, the net charge energy
contribution was missing.

This is a backport of 55231153a622f83f053da0b24cd0f2e8c9752962
(MR !3350).

Fixes #4668
  • Loading branch information
al42and authored and mabraham committed Dec 6, 2022
1 parent 2d86fb2 commit 54bfe6f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
12 changes: 12 additions & 0 deletions docs/release-notes/2021/2021.7.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,18 @@ in the :ref:`release-notes`.
Fixes where mdrun could behave incorrectly
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Add missing net charge term when running PME on a GPU
"""""""""""""""""""""""""""""""""""""""""""""""""""""

When PME was running on a GPU, the term due to a net charge of the system was missing.
In normal runs this only changed the potential energy by a constant, which is usually
not relevant. In free-energy calculations where the net charge of the systen changes,
the would lead to incorrect dV/dlambda and Delta lambda values (but one should anyhow
avoid changing the net charge of a system with free-energy calculations).

:issue:`4668`


Fixes for ``gmx`` tools
^^^^^^^^^^^^^^^^^^^^^^^

Expand Down
5 changes: 3 additions & 2 deletions src/gromacs/mdlib/force.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2004, The GROMACS development team.
* Copyright (c) 2013,2014,2015,2016,2017 by the GROMACS development team.
* Copyright (c) 2018,2019,2020, by the GROMACS development team, led by
* Copyright (c) 2018,2019,2020,2022, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
Expand Down Expand Up @@ -122,7 +122,8 @@ void calculateLongRangeNonbondeds(t_forcerec* fr,
/* Do long-range electrostatics and/or LJ-PME
* and compute PME surface terms when necessary.
*/
if ((computePmeOnCpu || fr->ic->eeltype == eelEWALD || haveEwaldSurfaceTerm)
if ((computePmeOnCpu || fr->ic->eeltype == eelEWALD || haveEwaldSurfaceTerm || fr->qsum[0] != 0
|| fr->qsum[1] != 0)
&& stepWork.computeNonbondedForces)
{
int status = 0;
Expand Down

0 comments on commit 54bfe6f

Please sign in to comment.