From 9c157facb7c0afca926deaf57f96b07a619f41d5 Mon Sep 17 00:00:00 2001 From: Magnus Lundborg Date: Thu, 15 Oct 2020 12:17:03 +0200 Subject: [PATCH] When loading AWH user data do not convolve the bias along FEP dims. Fixes: #3736. --- src/gromacs/applied_forces/awh/biasstate.cpp | 22 ++++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/gromacs/applied_forces/awh/biasstate.cpp b/src/gromacs/applied_forces/awh/biasstate.cpp index a64e8e6038..c248699916 100644 --- a/src/gromacs/applied_forces/awh/biasstate.cpp +++ b/src/gromacs/applied_forces/awh/biasstate.cpp @@ -314,15 +314,19 @@ void BiasState::calcConvolvedPmf(const std::vector& dimParams, const GridPoint& point = grid.point(m); for (auto& neighbor : point.neighbor) { - /* The negative PMF is a positive bias. */ - double biasNeighbor = -pmf[neighbor]; - - /* Add the convolved PMF weights for the neighbors of this point. - Note that this function only adds point within the target > 0 region. - Sum weights, take the logarithm last to get the free energy. */ - double logWeight = biasedLogWeightFromPoint(dimParams, points_, grid, neighbor, - biasNeighbor, point.coordValue, {}, m); - freeEnergyWeights += std::exp(logWeight); + /* Do not convolve the bias along a lambda axis - only use the pmf from the current point */ + if (!pointsHaveDifferentLambda(grid, m, neighbor)) + { + /* The negative PMF is a positive bias. */ + double biasNeighbor = -pmf[neighbor]; + + /* Add the convolved PMF weights for the neighbors of this point. + Note that this function only adds point within the target > 0 region. + Sum weights, take the logarithm last to get the free energy. */ + double logWeight = biasedLogWeightFromPoint(dimParams, points_, grid, neighbor, + biasNeighbor, point.coordValue, {}, m); + freeEnergyWeights += std::exp(logWeight); + } } GMX_RELEASE_ASSERT(freeEnergyWeights > 0, -- 2.22.0