From: Magnus Lundborg Date: Fri, 19 Feb 2021 17:23:19 +0000 (+0100) Subject: Introduce a check (in grompp) that AWH FEP sampling is OK X-Git-Url: http://biod.pnpi.spb.ru/gitweb/?a=commitdiff_plain;h=feca1cf51566b2373342c810369284026b8e5a3e;p=alexxy%2Fgromacs.git Introduce a check (in grompp) that AWH FEP sampling is OK Ensure that awh-nstsample is a multiple of nstcalcenergy when sampling an FEP dimension. Fixes #3922 --- diff --git a/docs/release-notes/2021/2021.1.rst b/docs/release-notes/2021/2021.1.rst index 9eb10dae2c..0b2eca9ac9 100644 --- a/docs/release-notes/2021/2021.1.rst +++ b/docs/release-notes/2021/2021.1.rst @@ -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 diff --git a/src/gromacs/applied_forces/awh/read_params.cpp b/src/gromacs/applied_forces/awh/read_params.cpp index 5654d57af4..92eca4c25e 100644 --- a/src/gromacs/applied_forces/awh/read_params.cpp +++ b/src/gromacs/applied_forces/awh/read_params.cpp @@ -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 */