Introduce a check (in grompp) that AWH FEP sampling is OK
authorMagnus Lundborg <magnus.lundborg@scilifelab.se>
Fri, 19 Feb 2021 17:23:19 +0000 (18:23 +0100)
committerMark Abraham <mark.j.abraham@gmail.com>
Fri, 26 Feb 2021 08:48:24 +0000 (08:48 +0000)
Ensure that awh-nstsample is a multiple of nstcalcenergy when
sampling an FEP dimension.

Fixes #3922

docs/release-notes/2021/2021.1.rst
src/gromacs/applied_forces/awh/read_params.cpp

index 9eb10dae2c77d6be894e25fd730cd5919173cec5..0b2eca9ac9b3ab0a54298882f7d4c03852a27332 100644 (file)
@@ -47,6 +47,15 @@ POSIX and not by C++ was also worked around.
 
 :issue:`3890`
 
+Improve grompp checks of AWH settings when sampling an FEP dimension
+""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+
+Ensure that the AWH sampling interval is compatible with nstcalcenergy
+when sampling an FEP dimension using AWH. This avoids crashes in the
+first AWH sampling step (step > 0) if the settings were not correct.
+
+:issue:`3922`
+
 Miscellaneous
 ^^^^^^^^^^^^^
 * Updated |Gromacs| logos
index 5654d57af433467a7c01085b4b1dd099b0fffdd6..92eca4c25edb42afaed635ef40af9321d4e1d1cc 100644 (file)
@@ -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,2021, 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.
@@ -827,10 +827,30 @@ void checkAwhParams(const AwhParams* awhParams, const t_inputrec* ir, warninp_t
         warning_error(wi, opt + " needs to be an integer > 0");
     }
 
+    bool haveFepLambdaDim = false;
     for (int k = 0; k < awhParams->numBias; k++)
     {
         std::string prefixawh = formatString("awh%d", k + 1);
         checkBiasParams(&awhParams->awhBiasParams[k], prefixawh, ir, wi);
+        /* Check if there is a FEP lambda dimension. */
+        for (int l = 0; l < awhParams->awhBiasParams[k].ndim; l++)
+        {
+            if (awhParams->awhBiasParams[k].dimParams[l].eCoordProvider == eawhcoordproviderFREE_ENERGY_LAMBDA)
+            {
+                haveFepLambdaDim = true;
+                break;
+            }
+        }
+    }
+
+    if (haveFepLambdaDim && awhParams->nstSampleCoord % ir->nstcalcenergy != 0)
+    {
+        opt          = "awh-nstsample";
+        auto message = formatString(
+                "%s (%d) should be a multiple of nstcalcenergy (%d) when using AWH for sampling an "
+                "FEP lambda dimension",
+                opt.c_str(), awhParams->nstSampleCoord, ir->nstcalcenergy);
+        warning_error(wi, message);
     }
 
     /* Do a final consistency check before returning */