Skip to content

Commit 2de89cf

Browse files
committed
Fix MTS constraint dH/dlambda contribution
With MTS the slow force contributions to dH/dlambda were multiplied by the MTS factor. Fixes #5060
1 parent da9a5f3 commit 2de89cf

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

docs/release-notes/2023/2023.5.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,17 @@ for this in grompp was lost. Now both grompp and mdrun will exit with an error.
6363
:issue:`3775`
6464
:issue:`5053`
6565

66+
Correct dH/dlambda with MTS and perturbed constraints
67+
"""""""""""""""""""""""""""""""""""""""""""""""""""""
68+
69+
When doing free-energy calculations with multiple time stepping and perturbed
70+
constraint lengths, the slow force contributions to dH/dlambda were incorrectly
71+
multiplied by the MTS factor. The effect of this is usually rather small
72+
when only integrating the PME grid part less frequently, but can be substantial
73+
when the non-bonded pair interactions are not integrated at every step.
74+
75+
:issue:`5060`
76+
6677
Fixes for ``gmx`` tools
6778
^^^^^^^^^^^^^^^^^^^^^^^
6879

src/gromacs/mdrun/md.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1588,12 +1588,14 @@ void gmx::LegacySimulator::do_md()
15881588
else
15891589
{
15901590
/* With multiple time stepping we need to do an additional normal
1591-
* update step to obtain the virial, as the actual MTS integration
1591+
* update step to obtain the virial and dH/dl, as the actual MTS integration
15921592
* using an acceleration where the slow forces are multiplied by mtsFactor.
15931593
* Using that acceleration would result in a virial with the slow
15941594
* force contribution would be a factor mtsFactor too large.
15951595
*/
1596-
if (simulationWork.useMts && bCalcVir && constr != nullptr)
1596+
const bool separateVirialConstraining =
1597+
(simulationWork.useMts && (bCalcVir || computeDHDL) && constr != nullptr);
1598+
if (separateVirialConstraining)
15971599
{
15981600
upd.update_for_constraint_virial(*ir,
15991601
md->homenr,
@@ -1643,8 +1645,8 @@ void gmx::LegacySimulator::do_md()
16431645
step,
16441646
state,
16451647
upd.xp()->arrayRefWithPadding(),
1646-
&dvdl_constr,
1647-
bCalcVir && !simulationWork.useMts,
1648+
separateVirialConstraining ? nullptr : &dvdl_constr,
1649+
bCalcVir && !separateVirialConstraining,
16481650
shake_vir);
16491651

16501652
upd.update_sd_second_half(*ir,

0 commit comments

Comments
 (0)