Disable awh-potential=convolved when using AWH with pull and FEP
[alexxy/gromacs.git] / src / gromacs / applied_forces / awh / bias.cpp
index 5abd53402bb187a393970121244fb053d532b1ba..7df5a236f9b3069968ca47b87458e2343b48a0d6 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2015,2016,2017,2018,2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2015,2016,2017,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.
@@ -120,6 +120,10 @@ gmx::ArrayRef<const double> Bias::calcForceAndUpdateBias(const awh_dvec
                 "The step number is negative which is not supported by the AWH code."));
     }
 
+    GMX_RELEASE_ASSERT(!(params_.convolveForce && grid_.hasLambdaAxis()),
+                       "When using AWH to sample an FEP lambda dimension the AWH potential cannot "
+                       "be convolved.");
+
     state_.setCoordValue(grid_, coordValue);
 
     std::vector<double, AlignedAllocator<double>>& probWeightNeighbor = alignedTempWorkSpace_;
@@ -149,12 +153,6 @@ gmx::ArrayRef<const double> Bias::calcForceAndUpdateBias(const awh_dvec
 
             state_.sampleCoordAndPmf(dimParams_, grid_, probWeightNeighbor, convolvedBias);
         }
-        /* Set the umbrella grid point (for the lambda axis) to the
-         * current grid point. */
-        if (params_.convolveForce && grid_.hasLambdaAxis())
-        {
-            state_.setUmbrellaGridpointToGridpoint();
-        }
     }
 
     /* Set the bias force and get the potential contribution from this bias.
@@ -190,11 +188,10 @@ gmx::ArrayRef<const double> Bias::calcForceAndUpdateBias(const awh_dvec
          */
         if (moveUmbrella)
         {
-            const bool onlySampleUmbrellaGridpoint = false;
-            double     newPotential = state_.moveUmbrella(dimParams_, grid_, probWeightNeighbor,
-                                                      neighborLambdaDhdl, biasForce_, step, seed,
-                                                      params_.biasIndex, onlySampleUmbrellaGridpoint);
-            *potentialJump          = newPotential - potential;
+            double newPotential =
+                    state_.moveUmbrella(dimParams_, grid_, probWeightNeighbor, neighborLambdaDhdl,
+                                        biasForce_, step, seed, params_.biasIndex);
+            *potentialJump = newPotential - potential;
         }
     }
 
@@ -211,14 +208,6 @@ gmx::ArrayRef<const double> Bias::calcForceAndUpdateBias(const awh_dvec
             *potentialJump      = newPotential - potential;
         }
     }
-    /* If there is a lambda axis it is still controlled using an umbrella even if the force
-     * is convolved in the other dimensions. */
-    if (moveUmbrella && params_.convolveForce && grid_.hasLambdaAxis())
-    {
-        const bool onlySampleUmbrellaGridpoint = true;
-        state_.moveUmbrella(dimParams_, grid_, probWeightNeighbor, neighborLambdaDhdl, biasForce_,
-                            step, seed, params_.biasIndex, onlySampleUmbrellaGridpoint);
-    }
 
     /* Return the potential. */
     *awhPotential = potential;