Modernize AWH enumerations
authorPaul Bauer <paul.bauer.q@gmail.com>
Thu, 4 Mar 2021 08:39:30 +0000 (09:39 +0100)
committerPaul Bauer <paul.bauer.q@gmail.com>
Thu, 4 Mar 2021 08:39:30 +0000 (09:39 +0100)
Changed enums to enum classes.
Use EnumerationArray for strings.

14 files changed:
src/gromacs/applied_forces/awh/awh.cpp
src/gromacs/applied_forces/awh/biasgrid.cpp
src/gromacs/applied_forces/awh/biasparams.cpp
src/gromacs/applied_forces/awh/biasparams.h
src/gromacs/applied_forces/awh/biasstate.cpp
src/gromacs/applied_forces/awh/histogramsize.cpp
src/gromacs/applied_forces/awh/pointstate.h
src/gromacs/applied_forces/awh/read_params.cpp
src/gromacs/applied_forces/awh/tests/bias.cpp
src/gromacs/applied_forces/awh/tests/bias_fep_lambda_state.cpp
src/gromacs/applied_forces/awh/tests/biasstate.cpp
src/gromacs/fileio/tpxio.cpp
src/gromacs/mdtypes/awh_params.h
src/gromacs/mdtypes/inputrec.cpp

index a772d31a34345daf5d6129a893d13d4548f0f7ec..8c80087391383c18879a6134af4c0e4c12532f1b 100644 (file)
@@ -117,7 +117,7 @@ static bool anyDimUsesPull(const AwhBiasParams& awhBiasParams)
     for (int d = 0; d < awhBiasParams.ndim; d++)
     {
         const AwhDimParams& awhDimParams = awhBiasParams.dimParams[d];
-        if (awhDimParams.eCoordProvider == eawhcoordproviderPULL)
+        if (awhDimParams.eCoordProvider == AwhCoordinateProviderType::Pull)
         {
             return true;
         }
@@ -225,14 +225,14 @@ Awh::Awh(FILE*                 fplog,
         for (int d = 0; d < awhBiasParams.ndim; d++)
         {
             const AwhDimParams& awhDimParams = awhBiasParams.dimParams[d];
-            if (awhDimParams.eCoordProvider != eawhcoordproviderPULL
-                && awhDimParams.eCoordProvider != eawhcoordproviderFREE_ENERGY_LAMBDA)
+            if (awhDimParams.eCoordProvider != AwhCoordinateProviderType::Pull
+                && awhDimParams.eCoordProvider != AwhCoordinateProviderType::FreeEnergyLambda)
             {
                 GMX_THROW(
                         InvalidInputError("Currently only the pull code and lambda are supported "
                                           "as coordinate providers"));
             }
-            if (awhDimParams.eCoordProvider == eawhcoordproviderPULL)
+            if (awhDimParams.eCoordProvider == AwhCoordinateProviderType::Pull)
             {
                 const t_pull_coord& pullCoord = inputRecord.pull->coord[awhDimParams.coordIndex];
                 if (pullCoord.eGeom == PullGroupGeometry::DirectionPBC)
@@ -487,7 +487,7 @@ void Awh::registerAwhWithPull(const AwhParams& awhParams, pull_t* pull_work)
 
         for (int d = 0; d < biasParams.ndim; d++)
         {
-            if (biasParams.dimParams[d].eCoordProvider == eawhcoordproviderPULL)
+            if (biasParams.dimParams[d].eCoordProvider == AwhCoordinateProviderType::Pull)
             {
                 register_external_pull_potential(
                         pull_work, biasParams.dimParams[d].coordIndex, Awh::externalPotentialString());
index 16d9d655b6c6d9f437c0737b95afc652db3fa11f..af639fbf6fccc0a4198b5c05d93a35fc0a13923b 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.
@@ -820,7 +820,7 @@ BiasGrid::BiasGrid(const std::vector<DimParams>& dimParams, const AwhDimParams*
     {
         double origin = dimParams[d].scaleUserInputToInternal(awhDimParams[d].origin);
         double end    = dimParams[d].scaleUserInputToInternal(awhDimParams[d].end);
-        if (awhDimParams[d].eCoordProvider == eawhcoordproviderPULL)
+        if (awhDimParams[d].eCoordProvider == AwhCoordinateProviderType::Pull)
         {
             period[d] = dimParams[d].scaleUserInputToInternal(awhDimParams[d].period);
             static_assert(
index 182713007747a0f5f87954939993af84fac69d02..1e66ba164baa4b3c14074fd744ce947f1c039c86 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.
@@ -83,9 +83,9 @@ int64_t calcTargetUpdateInterval(const AwhParams& awhParams, const AwhBiasParams
      */
     switch (awhBiasParams.eTarget)
     {
-        case eawhtargetCONSTANT: numStepsUpdateTarget = 0; break;
-        case eawhtargetCUTOFF:
-        case eawhtargetBOLTZMANN:
+        case AwhTargetType::Constant: numStepsUpdateTarget = 0; break;
+        case AwhTargetType::Cutoff:
+        case AwhTargetType::Boltzmann:
             /* Updating the target generally requires updating the whole grid so to keep the cost
                down we generally update the target less often than the free energy (unless the free
                energy update step is set to > 100 samples). */
@@ -93,7 +93,7 @@ int64_t calcTargetUpdateInterval(const AwhParams& awhParams, const AwhBiasParams
                                             awhParams.numSamplesUpdateFreeEnergy)
                                    * awhParams.nstSampleCoord;
             break;
-        case eawhtargetLOCALBOLTZMANN:
+        case AwhTargetType::LocalBoltzmann:
             /* The target distribution is set equal to the reference histogram which is updated every free energy update.
                So the target has to be updated at the same time. This leads to a global update each time because it is
                assumed that a target distribution update can take any form. This is a bit unfortunate for a "local"
@@ -238,14 +238,14 @@ BiasParams::BiasParams(const AwhParams&              awhParams,
     eTarget(awhBiasParams.eTarget),
     freeEnergyCutoffInKT(beta * awhBiasParams.targetCutoff),
     temperatureScaleFactor(awhBiasParams.targetBetaScaling),
-    idealWeighthistUpdate(eTarget != eawhtargetLOCALBOLTZMANN),
+    idealWeighthistUpdate(eTarget != AwhTargetType::LocalBoltzmann),
     numSharedUpdate(getNumSharedUpdate(awhBiasParams, numSharingSimulations)),
     updateWeight(numSamplesUpdateFreeEnergy_ * numSharedUpdate),
-    localWeightScaling(eTarget == eawhtargetLOCALBOLTZMANN ? temperatureScaleFactor : 1),
+    localWeightScaling(eTarget == AwhTargetType::LocalBoltzmann ? temperatureScaleFactor : 1),
     initialErrorInKT(beta * awhBiasParams.errorInitial),
     initialHistogramSize(
             getInitialHistogramSizeEstimate(awhBiasParams, gridAxis, beta, numStepsSampleCoord_ * mdTimeStep)),
-    convolveForce(awhParams.ePotential == eawhpotentialCONVOLVED),
+    convolveForce(awhParams.ePotential == AwhPotentialType::Convolved),
     biasIndex(biasIndex),
     disableUpdateSkips_(disableUpdateSkips == DisableUpdateSkips::yes)
 {
index 6b24e2bd094444fcab17b68bb444b8ac262f88a7..9fed42fa078aa82c86ddbda242f9b4631da62106 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.
@@ -64,6 +64,7 @@ struct AwhBiasParams;
 struct AwhParams;
 struct DimParams;
 class GridAxis;
+enum class AwhTargetType : int;
 
 /*! \internal \brief Constant parameters for the bias.
  */
@@ -208,10 +209,10 @@ private:
     const int64_t numStepsUpdateTarget_; /**< Number of steps per updating the target distribution. */
     const int64_t numStepsCheckCovering_; /**< Number of steps per checking for covering. */
 public:
-    const int    eTarget;              /**< Type of target distribution. */
-    const double freeEnergyCutoffInKT; /**< Free energy cut-off in kT for cut-off target distribution. */
-    const double temperatureScaleFactor; /**< Temperature scaling factor for temperature scaled targed distributions. */
-    const bool   idealWeighthistUpdate; /**< Update reference weighthistogram using the target distribution? Otherwise use the realized distribution. */
+    const AwhTargetType eTarget;              /**< Type of target distribution. */
+    const double        freeEnergyCutoffInKT; /**< Free energy cut-off in kT for cut-off target distribution. */
+    const double        temperatureScaleFactor; /**< Temperature scaling factor for temperature scaled targed distributions. */
+    const bool          idealWeighthistUpdate; /**< Update reference weighthistogram using the target distribution? Otherwise use the realized distribution. */
     const int    numSharedUpdate; /**< The number of (multi-)simulations sharing the bias update */
     const double updateWeight;    /**< The probability weight accumulated for each update. */
     const double localWeightScaling; /**< Scaling factor applied to a sample before adding it to the reference weight histogram (= 1, usually). */
index b5d68415bcca08d80dd79c748d3986025b2cf442..783cfab1f8a1335421cd098a76a2aca4c0597e70 100644 (file)
@@ -351,7 +351,7 @@ namespace
 void updateTargetDistribution(gmx::ArrayRef<PointState> pointState, const BiasParams& params)
 {
     double freeEnergyCutoff = 0;
-    if (params.eTarget == eawhtargetCUTOFF)
+    if (params.eTarget == AwhTargetType::Cutoff)
     {
         freeEnergyCutoff = freeEnergyMinimumValue(pointState) + params.freeEnergyCutoffInKT;
     }
@@ -996,7 +996,7 @@ bool BiasState::isSamplingRegionCovered(const BiasParams&             params,
     /* Set the free energy cutoff */
     double maxFreeEnergy = GMX_FLOAT_MAX;
 
-    if (params.eTarget == eawhtargetCUTOFF)
+    if (params.eTarget == AwhTargetType::Cutoff)
     {
         maxFreeEnergy = freeEnergyMinimumValue(points_) + params.freeEnergyCutoffInKT;
     }
@@ -1158,7 +1158,7 @@ void BiasState::updateFreeEnergyAndAddSamplesToHistogram(const std::vector<DimPa
 
     /* Update target distribution? */
     bool needToUpdateTargetDistribution =
-            (params.eTarget != eawhtargetCONSTANT && params.isUpdateTargetStep(step));
+            (params.eTarget != AwhTargetType::Constant && params.isUpdateTargetStep(step));
 
     /* In the initial stage, the histogram grows dynamically as a function of the number of coverings. */
     bool detectedCovering = false;
@@ -1838,7 +1838,7 @@ void BiasState::initGridPointState(const AwhBiasParams&          awhBiasParams,
     }
 
     /* The local Boltzmann distribution is special because the target distribution is updated as a function of the reference weighthistogram. */
-    GMX_RELEASE_ASSERT(params.eTarget != eawhtargetLOCALBOLTZMANN || points_[0].weightSumRef() != 0,
+    GMX_RELEASE_ASSERT(params.eTarget != AwhTargetType::LocalBoltzmann || points_[0].weightSumRef() != 0,
                        "AWH reference weight histogram not initialized properly with local "
                        "Boltzmann target distribution.");
 
index a343b4dc8270c570fea69aa3be24c84adf0d1785..f16deed99a720c7c618d37703a7592f6bc6510d5 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.
@@ -67,7 +67,7 @@ namespace gmx
 HistogramSize::HistogramSize(const AwhBiasParams& awhBiasParams, double histogramSizeInitial) :
     numUpdates_(0),
     histogramSize_(histogramSizeInitial),
-    inInitialStage_(awhBiasParams.eGrowth == eawhgrowthEXP_LINEAR),
+    inInitialStage_(awhBiasParams.eGrowth == AwhHistogramGrowthType::ExponentialLinear),
     equilibrateHistogram_(awhBiasParams.equilibrateHistogram),
     logScaledSampleWeight_(0),
     maxLogScaledSampleWeight_(0),
index a893140b6b90249bf24bdf0c9525de2c7b5cf52e..fd4b5e9cb6235951915b85b74c0cf4e9a0a1f8a2 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.
@@ -417,17 +417,18 @@ public:
     {
         switch (params.eTarget)
         {
-            case eawhtargetCONSTANT: target_ = 1; break;
-            case eawhtargetCUTOFF:
+            case AwhTargetType::Constant: target_ = 1; break;
+            case AwhTargetType::Cutoff:
             {
                 double df = freeEnergy_ - freeEnergyCutoff;
                 target_   = 1 / (1 + std::exp(df));
                 break;
             }
-            case eawhtargetBOLTZMANN:
+            case AwhTargetType::Boltzmann:
                 target_ = std::exp(-params.temperatureScaleFactor * freeEnergy_);
                 break;
-            case eawhtargetLOCALBOLTZMANN: target_ = weightSumRef_; break;
+            case AwhTargetType::LocalBoltzmann: target_ = weightSumRef_; break;
+            default: GMX_RELEASE_ASSERT(false, "Unhandled enum");
         }
 
         /* All target types can be modulated by a constant factor. */
index bbdd4f6451388f615536460ba960f36b5dc7e6bf..a889c0e7154275c00d38b308ede85a30899ddfd2 100644 (file)
@@ -55,6 +55,7 @@
 #include "gromacs/random/seed.h"
 #include "gromacs/topology/mtop_util.h"
 #include "gromacs/utility/cstringutil.h"
+#include "gromacs/utility/enumerationhelpers.h"
 #include "gromacs/utility/fatalerror.h"
 #include "gromacs/utility/smalloc.h"
 #include "gromacs/utility/stringutil.h"
 namespace gmx
 {
 
-const char* eawhtarget_names[eawhtargetNR + 1] = { "constant",
-                                                   "cutoff",
-                                                   "boltzmann",
-                                                   "local-boltzmann",
-                                                   nullptr };
+const char* enumValueToString(AwhTargetType enumValue)
+{
+    constexpr gmx::EnumerationArray<AwhTargetType, const char*> awhTargetTypeNames = {
+        "constant", "cutoff", "boltzmann", "local-boltzmann"
+    };
+    return awhTargetTypeNames[enumValue];
+}
 
-const char* eawhgrowth_names[eawhgrowthNR + 1] = { "exp-linear", "linear", nullptr };
+const char* enumValueToString(AwhHistogramGrowthType enumValue)
+{
+    constexpr gmx::EnumerationArray<AwhHistogramGrowthType, const char*> awhHistogramGrowthTypeNames = {
+        "exp-linear", "linear"
+    };
+    return awhHistogramGrowthTypeNames[enumValue];
+}
 
-const char* eawhpotential_names[eawhpotentialNR + 1] = { "convolved", "umbrella", nullptr };
+const char* enumValueToString(AwhPotentialType enumValue)
+{
+    constexpr gmx::EnumerationArray<AwhPotentialType, const char*> awhPotentialTypeNames = {
+        "convolved", "umbrella"
+    };
+    return awhPotentialTypeNames[enumValue];
+}
 
-const char* eawhcoordprovider_names[eawhcoordproviderNR + 1] = { "pull", "fep-lambda", nullptr };
+const char* enumValueToString(AwhCoordinateProviderType enumValue)
+{
+    constexpr gmx::EnumerationArray<AwhCoordinateProviderType, const char*> awhCoordinateProviderTypeNames = {
+        "pull", "fep-lambda"
+    };
+    return awhCoordinateProviderTypeNames[enumValue];
+}
 
 namespace
 {
@@ -104,8 +125,8 @@ void checkMtsConsistency(const t_inputrec& inputrec, warninp_t wi)
         {
             switch (biasParams.dimParams[d].eCoordProvider)
             {
-                case eawhcoordproviderPULL: usesPull = true; break;
-                case eawhcoordproviderFREE_ENERGY_LAMBDA: usesFep = true; break;
+                case AwhCoordinateProviderType::Pull: usesPull = true; break;
+                case AwhCoordinateProviderType::FreeEnergyLambda: usesFep = true; break;
                 default: GMX_RELEASE_ASSERT(false, "Unsupported coord provider");
             }
         }
@@ -371,7 +392,7 @@ void readDimParams(std::vector<t_inpfile>* inp,
                 "currently only 'pull' and 'fep-lambda' (free energy lambda state) is supported");
     }
     opt                       = prefix + "-coord-provider";
-    dimParams->eCoordProvider = get_eeenum(inp, opt, eawhcoordprovider_names, wi);
+    dimParams->eCoordProvider = getEnum<AwhCoordinateProviderType>(inp, opt.c_str(), wi);
 
     if (bComment)
     {
@@ -429,7 +450,7 @@ void readDimParams(std::vector<t_inpfile>* inp,
  */
 void checkDimParams(const std::string& prefix, AwhDimParams* dimParams, const t_inputrec* ir, warninp_t wi)
 {
-    if (dimParams->eCoordProvider == eawhcoordproviderPULL)
+    if (dimParams->eCoordProvider == AwhCoordinateProviderType::Pull)
     {
         if (!ir->bPull)
         {
@@ -439,7 +460,7 @@ void checkDimParams(const std::string& prefix, AwhDimParams* dimParams, const t_
         }
         checkPullDimParams(prefix, dimParams, *ir->pull, wi);
     }
-    else if (dimParams->eCoordProvider == eawhcoordproviderFREE_ENERGY_LAMBDA)
+    else if (dimParams->eCoordProvider == AwhCoordinateProviderType::FreeEnergyLambda)
     {
         if (ir->efep == FreeEnergyPerturbationType::No)
         {
@@ -507,7 +528,7 @@ void readBiasParams(std::vector<t_inpfile>* inp,
                              "size: exp-linear or linear");
     }
     opt                    = prefix + "-growth";
-    awhBiasParams->eGrowth = get_eeenum(inp, opt, eawhgrowth_names, wi);
+    awhBiasParams->eGrowth = getEnum<AwhHistogramGrowthType>(inp, opt.c_str(), wi);
 
     if (bComment)
     {
@@ -524,7 +545,7 @@ void readBiasParams(std::vector<t_inpfile>* inp,
                 inp, "Target distribution type: constant, cutoff, boltzmann or local-boltzmann");
     }
     opt                    = prefix + "-target";
-    awhBiasParams->eTarget = get_eeenum(inp, opt, eawhtarget_names, wi);
+    awhBiasParams->eTarget = getEnum<AwhTargetType>(inp, opt.c_str(), wi);
 
     if (bComment)
     {
@@ -594,40 +615,40 @@ void checkBiasParams(const AwhBiasParams* awhBiasParams, const std::string& pref
     }
 
     opt = prefix + "-equilibrate-histogram";
-    if (awhBiasParams->equilibrateHistogram && awhBiasParams->eGrowth != eawhgrowthEXP_LINEAR)
+    if (awhBiasParams->equilibrateHistogram && awhBiasParams->eGrowth != AwhHistogramGrowthType::ExponentialLinear)
     {
         auto message =
                 formatString("Option %s will only have an effect for histogram growth type '%s'.",
                              opt.c_str(),
-                             EAWHGROWTH(eawhgrowthEXP_LINEAR));
+                             enumValueToString(AwhHistogramGrowthType::ExponentialLinear));
         warning(wi, message);
     }
 
-    if ((awhBiasParams->eTarget == eawhtargetLOCALBOLTZMANN)
-        && (awhBiasParams->eGrowth == eawhgrowthEXP_LINEAR))
+    if ((awhBiasParams->eTarget == AwhTargetType::LocalBoltzmann)
+        && (awhBiasParams->eGrowth == AwhHistogramGrowthType::ExponentialLinear))
     {
         auto message = formatString(
                 "Target type '%s' combined with histogram growth type '%s' is not "
                 "expected to give stable bias updates. You probably want to use growth type "
                 "'%s' instead.",
-                EAWHTARGET(eawhtargetLOCALBOLTZMANN),
-                EAWHGROWTH(eawhgrowthEXP_LINEAR),
-                EAWHGROWTH(eawhgrowthLINEAR));
+                enumValueToString(AwhTargetType::LocalBoltzmann),
+                enumValueToString(AwhHistogramGrowthType::ExponentialLinear),
+                enumValueToString(AwhHistogramGrowthType::Linear));
         warning(wi, message);
     }
 
     opt = prefix + "-target-beta-scaling";
     switch (awhBiasParams->eTarget)
     {
-        case eawhtargetBOLTZMANN:
-        case eawhtargetLOCALBOLTZMANN:
+        case AwhTargetType::Boltzmann:
+        case AwhTargetType::LocalBoltzmann:
             if (awhBiasParams->targetBetaScaling < 0 || awhBiasParams->targetBetaScaling > 1)
             {
                 gmx_fatal(FARGS,
                           "%s = %g is not useful for target type %s.",
                           opt.c_str(),
                           awhBiasParams->targetBetaScaling,
-                          EAWHTARGET(awhBiasParams->eTarget));
+                          enumValueToString(awhBiasParams->eTarget));
             }
             break;
         default:
@@ -638,7 +659,7 @@ void checkBiasParams(const AwhBiasParams* awhBiasParams, const std::string& pref
                         "Value for %s (%g) set explicitly but will not be used for target type %s.",
                         opt.c_str(),
                         awhBiasParams->targetBetaScaling,
-                        EAWHTARGET(awhBiasParams->eTarget));
+                        enumValueToString(awhBiasParams->eTarget));
             }
             break;
     }
@@ -646,14 +667,14 @@ void checkBiasParams(const AwhBiasParams* awhBiasParams, const std::string& pref
     opt = prefix + "-target-cutoff";
     switch (awhBiasParams->eTarget)
     {
-        case eawhtargetCUTOFF:
+        case AwhTargetType::Cutoff:
             if (awhBiasParams->targetCutoff <= 0)
             {
                 gmx_fatal(FARGS,
                           "%s = %g is not useful for target type %s.",
                           opt.c_str(),
                           awhBiasParams->targetCutoff,
-                          EAWHTARGET(awhBiasParams->eTarget));
+                          enumValueToString(awhBiasParams->eTarget));
             }
             break;
         default:
@@ -664,7 +685,7 @@ void checkBiasParams(const AwhBiasParams* awhBiasParams, const std::string& pref
                         "Value for %s (%g) set explicitly but will not be used for target type %s.",
                         opt.c_str(),
                         awhBiasParams->targetCutoff,
-                        EAWHTARGET(awhBiasParams->eTarget));
+                        enumValueToString(awhBiasParams->eTarget));
             }
             break;
     }
@@ -723,7 +744,7 @@ void checkInputConsistencyAwh(const AwhParams& awhParams, warninp_t wi)
         {
             for (int d1 = 0; d1 < awhBiasParams1.ndim; d1++)
             {
-                if (awhBiasParams1.dimParams[d1].eCoordProvider == eawhcoordproviderFREE_ENERGY_LAMBDA)
+                if (awhBiasParams1.dimParams[d1].eCoordProvider == AwhCoordinateProviderType::FreeEnergyLambda)
                 {
                     continue;
                 }
@@ -732,7 +753,7 @@ void checkInputConsistencyAwh(const AwhParams& awhParams, warninp_t wi)
                 /* d1 is the reference dimension of the reference AWH. d2 is the dim index of the AWH to compare with. */
                 for (int d2 = 0; d2 < awhBiasParams2.ndim; d2++)
                 {
-                    if (awhBiasParams2.dimParams[d2].eCoordProvider == eawhcoordproviderFREE_ENERGY_LAMBDA)
+                    if (awhBiasParams2.dimParams[d2].eCoordProvider == AwhCoordinateProviderType::FreeEnergyLambda)
                     {
                         continue;
                     }
@@ -785,7 +806,7 @@ AwhParams* readAwhParams(std::vector<t_inpfile>* inp, warninp_t wi)
 
     printStringNoNewline(inp, "The way to apply the biasing potential: convolved or umbrella");
     opt                   = "awh-potential";
-    awhParams->ePotential = get_eeenum(inp, opt, eawhpotential_names, wi);
+    awhParams->ePotential = getEnum<AwhPotentialType>(inp, opt.c_str(), wi);
 
     printStringNoNewline(inp,
                          "The random seed used for sampling the umbrella center in the case of "
@@ -1168,7 +1189,7 @@ void setStateDependentAwhParams(AwhParams*           awhParams,
         for (int d = 0; d < awhBiasParams->ndim; d++)
         {
             AwhDimParams* dimParams = &awhBiasParams->dimParams[d];
-            if (dimParams->eCoordProvider == eawhcoordproviderPULL)
+            if (dimParams->eCoordProvider == AwhCoordinateProviderType::Pull)
             {
                 setStateDependentAwhPullDimParams(
                         dimParams, k, d, &pull_params, pull_work, pbc, compressibility, wi);
index b64d01123e06c1cd2543d4b7bce2ec1d511db301..5abe89de9dff2c198e63db49e3347497234c4e27 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2017,2018,2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 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.
@@ -86,7 +86,7 @@ struct AwhTestParameters
 };
 
 //! Helper function to set up the C-style AWH parameters for the test
-static AwhTestParameters getAwhTestParameters(int eawhgrowth, int eawhpotential)
+static AwhTestParameters getAwhTestParameters(AwhHistogramGrowthType eawhgrowth, AwhPotentialType eawhpotential)
 {
     AwhTestParameters params;
 
@@ -101,13 +101,13 @@ static AwhTestParameters getAwhTestParameters(int eawhgrowth, int eawhpotential)
     awhDimParams.end            = 1.5;
     awhDimParams.coordValueInit = awhDimParams.origin;
     awhDimParams.coverDiameter  = 0;
-    awhDimParams.eCoordProvider = eawhcoordproviderPULL;
+    awhDimParams.eCoordProvider = AwhCoordinateProviderType::Pull;
 
     AwhBiasParams& awhBiasParams = params.awhBiasParams;
 
     awhBiasParams.ndim                 = 1;
     awhBiasParams.dimParams            = &awhDimParams;
-    awhBiasParams.eTarget              = eawhtargetCONSTANT;
+    awhBiasParams.eTarget              = AwhTargetType::Constant;
     awhBiasParams.targetBetaScaling    = 0;
     awhBiasParams.targetCutoff         = 0;
     awhBiasParams.eGrowth              = eawhgrowth;
@@ -141,7 +141,7 @@ const double g_coords[] = { 0.62, 0.70, 0.68, 0.80, 0.93, 0.87, 1.16, 1.14, 0.95
                             0.86, 0.88, 0.79, 0.75, 0.82, 0.74, 0.70, 0.68, 0.71, 0.73 };
 
 //! Convenience typedef: growth type enum, potential type enum, disable update skips
-typedef std::tuple<int, int, BiasParams::DisableUpdateSkips> BiasTestParameters;
+typedef std::tuple<AwhHistogramGrowthType, AwhPotentialType, BiasParams::DisableUpdateSkips> BiasTestParameters;
 
 /*! \brief Test fixture for testing Bias updates
  */
@@ -173,8 +173,8 @@ public:
          *       and disableUpdateSkips do not affect the point state.
          *       But the reference data will also ensure this.
          */
-        int                            eawhgrowth;
-        int                            eawhpotential;
+        AwhHistogramGrowthType         eawhgrowth;
+        AwhPotentialType               eawhpotential;
         BiasParams::DisableUpdateSkips disableUpdateSkips;
         std::tie(eawhgrowth, eawhpotential, disableUpdateSkips) = GetParam();
 
@@ -287,15 +287,18 @@ TEST_P(BiasTest, ForcesBiasPmf)
  */
 INSTANTIATE_TEST_CASE_P(WithParameters,
                         BiasTest,
-                        ::testing::Combine(::testing::Values(eawhgrowthLINEAR, eawhgrowthEXP_LINEAR),
-                                           ::testing::Values(eawhpotentialUMBRELLA, eawhpotentialCONVOLVED),
+                        ::testing::Combine(::testing::Values(AwhHistogramGrowthType::Linear,
+                                                             AwhHistogramGrowthType::ExponentialLinear),
+                                           ::testing::Values(AwhPotentialType::Umbrella,
+                                                             AwhPotentialType::Convolved),
                                            ::testing::Values(BiasParams::DisableUpdateSkips::yes,
                                                              BiasParams::DisableUpdateSkips::no)));
 
 // Test that we detect coverings and exit the initial stage at the correct step
 TEST(BiasTest, DetectsCovering)
 {
-    const AwhTestParameters params = getAwhTestParameters(eawhgrowthEXP_LINEAR, eawhpotentialCONVOLVED);
+    const AwhTestParameters params = getAwhTestParameters(AwhHistogramGrowthType::ExponentialLinear,
+                                                          AwhPotentialType::Convolved);
     const AwhDimParams&     awhDimParams = params.awhParams.awhBiasParams[0].dimParams[0];
 
     const double mdTimeStep = 0.1;
index de0d6de7c0e2f7bf169d6fb3f458e42eb9f46c54..b53777cfd84f38dc2b9dd3a96445468a56ad247f 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2017,2018,2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 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.
@@ -88,7 +88,8 @@ struct AwhFepLambdaStateTestParameters
 };
 
 //! Helper function to set up the C-style AWH parameters for the test
-static AwhFepLambdaStateTestParameters getAwhFepLambdaTestParameters(int eawhgrowth, int eawhpotential)
+static AwhFepLambdaStateTestParameters getAwhFepLambdaTestParameters(AwhHistogramGrowthType eawhgrowth,
+                                                                     AwhPotentialType eawhpotential)
 {
     AwhFepLambdaStateTestParameters params;
 
@@ -103,13 +104,13 @@ static AwhFepLambdaStateTestParameters getAwhFepLambdaTestParameters(int eawhgro
     awhDimParams.end            = numLambdaStates - 1;
     awhDimParams.coordValueInit = awhDimParams.origin;
     awhDimParams.coverDiameter  = 0;
-    awhDimParams.eCoordProvider = eawhcoordproviderFREE_ENERGY_LAMBDA;
+    awhDimParams.eCoordProvider = AwhCoordinateProviderType::FreeEnergyLambda;
 
     AwhBiasParams& awhBiasParams = params.awhBiasParams;
 
     awhBiasParams.ndim                 = 1;
     awhBiasParams.dimParams            = &awhDimParams;
-    awhBiasParams.eTarget              = eawhtargetCONSTANT;
+    awhBiasParams.eTarget              = AwhTargetType::Constant;
     awhBiasParams.targetBetaScaling    = 0;
     awhBiasParams.targetCutoff         = 0;
     awhBiasParams.eGrowth              = eawhgrowth;
@@ -137,7 +138,7 @@ static AwhFepLambdaStateTestParameters getAwhFepLambdaTestParameters(int eawhgro
 }
 
 //! Convenience typedef: growth type enum, potential type enum, disable update skips
-typedef std::tuple<int, int, BiasParams::DisableUpdateSkips> BiasTestParameters;
+typedef std::tuple<AwhHistogramGrowthType, AwhPotentialType, BiasParams::DisableUpdateSkips> BiasTestParameters;
 
 /*! \brief Test fixture for testing Bias updates
  */
@@ -168,8 +169,8 @@ public:
          *       and disableUpdateSkips do not affect the point state.
          *       But the reference data will also ensure this.
          */
-        int                            eawhgrowth;
-        int                            eawhpotential;
+        AwhHistogramGrowthType         eawhgrowth;
+        AwhPotentialType               eawhpotential;
         BiasParams::DisableUpdateSkips disableUpdateSkips;
         std::tie(eawhgrowth, eawhpotential, disableUpdateSkips) = GetParam();
 
@@ -283,16 +284,18 @@ TEST_P(BiasFepLambdaStateTest, ForcesBiasPmf)
  */
 INSTANTIATE_TEST_CASE_P(WithParameters,
                         BiasFepLambdaStateTest,
-                        ::testing::Combine(::testing::Values(eawhgrowthLINEAR, eawhgrowthEXP_LINEAR),
-                                           ::testing::Values(eawhpotentialUMBRELLA, eawhpotentialCONVOLVED),
+                        ::testing::Combine(::testing::Values(AwhHistogramGrowthType::Linear,
+                                                             AwhHistogramGrowthType::ExponentialLinear),
+                                           ::testing::Values(AwhPotentialType::Umbrella,
+                                                             AwhPotentialType::Convolved),
                                            ::testing::Values(BiasParams::DisableUpdateSkips::yes,
                                                              BiasParams::DisableUpdateSkips::no)));
 
 // Test that we detect coverings and exit the initial stage at the correct step
 TEST(BiasFepLambdaStateTest, DetectsCovering)
 {
-    const AwhFepLambdaStateTestParameters params =
-            getAwhFepLambdaTestParameters(eawhgrowthEXP_LINEAR, eawhpotentialCONVOLVED);
+    const AwhFepLambdaStateTestParameters params = getAwhFepLambdaTestParameters(
+            AwhHistogramGrowthType::ExponentialLinear, AwhPotentialType::Convolved);
 
     const double mdTimeStep = 0.1;
 
index 4349d9b997d2973596064acbc8d408e15afb2b9f..c78d55061a48bf430337fe14c633897b73825fd2 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2017,2018,2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 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.
@@ -92,7 +92,7 @@ static AwhTestParameters getAwhTestParameters()
     awhDimParams0.end            = 1.5;
     awhDimParams0.coordValueInit = awhDimParams0.origin;
     awhDimParams0.coverDiameter  = 0;
-    awhDimParams0.eCoordProvider = eawhcoordproviderPULL;
+    awhDimParams0.eCoordProvider = AwhCoordinateProviderType::Pull;
 
     AwhDimParams& awhDimParams1 = awhBiasParams.dimParams[1];
 
@@ -102,13 +102,13 @@ static AwhTestParameters getAwhTestParameters()
     awhDimParams1.end            = 1.3;
     awhDimParams1.coordValueInit = awhDimParams1.origin;
     awhDimParams1.coverDiameter  = 0;
-    awhDimParams1.eCoordProvider = eawhcoordproviderPULL;
+    awhDimParams1.eCoordProvider = AwhCoordinateProviderType::Pull;
 
     awhBiasParams.ndim                 = 2;
-    awhBiasParams.eTarget              = eawhtargetCONSTANT;
+    awhBiasParams.eTarget              = AwhTargetType::Constant;
     awhBiasParams.targetBetaScaling    = 0;
     awhBiasParams.targetCutoff         = 0;
-    awhBiasParams.eGrowth              = eawhgrowthLINEAR;
+    awhBiasParams.eGrowth              = AwhHistogramGrowthType::Linear;
     awhBiasParams.bUserData            = TRUE;
     awhBiasParams.errorInitial         = 0.5;
     awhBiasParams.shareGroup           = 0;
@@ -119,7 +119,7 @@ static AwhTestParameters getAwhTestParameters()
     awhParams.nstOut                     = 0;
     awhParams.nstSampleCoord             = 1;
     awhParams.numSamplesUpdateFreeEnergy = 10;
-    awhParams.ePotential                 = eawhpotentialCONVOLVED;
+    awhParams.ePotential                 = AwhPotentialType::Convolved;
     awhParams.shareBiasMultisim          = FALSE;
 
     return params;
index 448bb9dd58aef89cf2ee7c09cbf4fc0087bf7821..2336b231ffacd203d9274a1e78676c67abcd3ef4 100644 (file)
@@ -657,10 +657,10 @@ static void do_fepvals(gmx::ISerializer* serializer, t_lambda* fepvals, int file
 
 static void do_awhBias(gmx::ISerializer* serializer, gmx::AwhBiasParams* awhBiasParams, int gmx_unused file_version)
 {
-    serializer->doInt(&awhBiasParams->eTarget);
+    serializer->doEnumAsInt(&awhBiasParams->eTarget);
     serializer->doDouble(&awhBiasParams->targetBetaScaling);
     serializer->doDouble(&awhBiasParams->targetCutoff);
-    serializer->doInt(&awhBiasParams->eGrowth);
+    serializer->doEnumAsInt(&awhBiasParams->eGrowth);
     if (serializer->reading())
     {
         int temp = 0;
@@ -686,7 +686,7 @@ static void do_awhBias(gmx::ISerializer* serializer, gmx::AwhBiasParams* awhBias
     {
         gmx::AwhDimParams* dimParams = &awhBiasParams->dimParams[d];
 
-        serializer->doInt(&dimParams->eCoordProvider);
+        serializer->doEnumAsInt(&dimParams->eCoordProvider);
         serializer->doInt(&dimParams->coordIndex);
         serializer->doDouble(&dimParams->origin);
         serializer->doDouble(&dimParams->end);
@@ -705,7 +705,7 @@ static void do_awh(gmx::ISerializer* serializer, gmx::AwhParams* awhParams, int
     serializer->doInt64(&awhParams->seed);
     serializer->doInt(&awhParams->nstSampleCoord);
     serializer->doInt(&awhParams->numSamplesUpdateFreeEnergy);
-    serializer->doInt(&awhParams->ePotential);
+    serializer->doEnumAsInt(&awhParams->ePotential);
     serializer->doBool(&awhParams->shareBiasMultisim);
 
     if (awhParams->numBias > 0)
index c047978b15bd913e1a65dd249c197d2674270ac6..debbb846728fff2816f39523c2fe3e6b1b26326c 100644 (file)
@@ -58,66 +58,62 @@ namespace gmx
 {
 
 //! Target distribution enum.
-enum
+enum class AwhTargetType : int
 {
-    eawhtargetCONSTANT,
-    eawhtargetCUTOFF,
-    eawhtargetBOLTZMANN,
-    eawhtargetLOCALBOLTZMANN,
-    eawhtargetNR
+    Constant,
+    Cutoff,
+    Boltzmann,
+    LocalBoltzmann,
+    Count,
+    Default = Constant
 };
 //! String for target distribution.
-extern const char* eawhtarget_names[eawhtargetNR + 1];
-//! Macro for target distribution string.
-#define EAWHTARGET(e) enum_name(e, gmx::eawhtargetNR, gmx::eawhtarget_names)
+const char* enumValueToString(AwhTargetType enumValue);
 
 //! Weight histogram growth enum.
-enum
+enum class AwhHistogramGrowthType : int
 {
-    eawhgrowthEXP_LINEAR,
-    eawhgrowthLINEAR,
-    eawhgrowthNR
+    ExponentialLinear,
+    Linear,
+    Count,
+    Default = ExponentialLinear
 };
 //! String for weight histogram growth
-extern const char* eawhgrowth_names[eawhgrowthNR + 1];
-//! Macro for weight histogram growth string.
-#define EAWHGROWTH(e) enum_name(e, gmx::eawhgrowthNR, gmx::eawhgrowth_names)
+const char* enumValueToString(AwhHistogramGrowthType enumValue);
 
 //! AWH potential type enum.
-enum
+enum class AwhPotentialType : int
 {
-    eawhpotentialCONVOLVED,
-    eawhpotentialUMBRELLA,
-    eawhpotentialNR
+    Convolved,
+    Umbrella,
+    Count,
+    Default = Convolved
 };
 //! String for AWH potential type
-extern const char* eawhpotential_names[eawhpotentialNR + 1];
-//! Macro for AWH potential type string.
-#define EAWHPOTENTIAL(e) enum_name(e, gmx::eawhpotentialNR, gmx::eawhpotential_names)
+const char* enumValueToString(AwhPotentialType enumValue);
 
 //! AWH bias reaction coordinate provider
-enum
+enum class AwhCoordinateProviderType : int
 {
-    eawhcoordproviderPULL,
-    eawhcoordproviderFREE_ENERGY_LAMBDA,
-    eawhcoordproviderNR
+    Pull,
+    FreeEnergyLambda,
+    Count,
+    Default = Pull
 };
 //! String for AWH bias reaction coordinate provider.
-extern const char* eawhcoordprovider_names[eawhcoordproviderNR + 1];
-//! Macro for AWH bias reaction coordinate provider.
-#define EAWHCOORDPROVIDER(e) enum_name(e, gmx::eawhcoordproviderNR, gmx::eawhcoordprovider_names)
+const char* enumValueToString(AwhCoordinateProviderType enumValue);
 
 /*! \cond INTERNAL */
 
 //! Parameters for an AWH coordinate dimension.
 struct AwhDimParams
 {
-    int    eCoordProvider; /**< The module providing the reaction coordinate. */
-    int    coordIndex;     /**< Index of reaction coordinate in the provider. */
-    double origin;         /**< Start value of the interval. */
-    double end;            /**< End value of the interval. */
-    double period;         /**< The period of this dimension (= 0 if not periodic). */
-    double forceConstant;  /**< The force constant in kJ/mol/nm^2, kJ/mol/rad^2 */
+    AwhCoordinateProviderType eCoordProvider; /**< The module providing the reaction coordinate. */
+    int                       coordIndex;     /**< Index of reaction coordinate in the provider. */
+    double                    origin;         /**< Start value of the interval. */
+    double                    end;            /**< End value of the interval. */
+    double                    period; /**< The period of this dimension (= 0 if not periodic). */
+    double                    forceConstant; /**< The force constant in kJ/mol/nm^2, kJ/mol/rad^2 */
     double diffusion; /**< Estimated diffusion constant in units of nm^2/ps, rad^2/ps or ps^-1. */
     double coordValueInit; /**< The initial coordinate value. */
     double coverDiameter; /**< The diameter that needs to be sampled around a point before it is considered covered. */
@@ -127,12 +123,12 @@ struct AwhDimParams
 struct AwhBiasParams
 {
     // TODO: Turn dimParams into a std::vector when moved into AWH module
-    int           ndim;         /**< Dimension of the coordinate space. */
-    AwhDimParams* dimParams;    /**< AWH parameters per dimension. */
-    int           eTarget;      /**< Type of target distribution. */
-    double   targetBetaScaling; /**< Beta scaling value for Boltzmann type target distributions. */
-    double   targetCutoff; /**< Free energy cutoff value for cutoff type target distribution in kJ/mol.*/
-    int      eGrowth;      /**< How the biasing histogram grows. */
+    int           ndim;       /**< Dimension of the coordinate space. */
+    AwhDimParams* dimParams;  /**< AWH parameters per dimension. */
+    AwhTargetType eTarget;    /**< Type of target distribution. */
+    double targetBetaScaling; /**< Beta scaling value for Boltzmann type target distributions. */
+    double targetCutoff; /**< Free energy cutoff value for cutoff type target distribution in kJ/mol.*/
+    AwhHistogramGrowthType eGrowth; /**< How the biasing histogram grows. */
     bool     bUserData;    /**< Is there a user-defined initial PMF estimate and target estimate? */
     double   errorInitial; /**< Estimated initial free energy error in kJ/mol. */
     int      shareGroup; /**< When >0, the bias is shared with biases of the same group and across multiple simulations when shareBiasMultisim=true */
@@ -147,10 +143,10 @@ struct AwhParams
     AwhBiasParams* awhBiasParams; /**< AWH bias parameters.*/
     int64_t        seed;          /**< Random seed.*/
     int            nstOut;        /**< Output step interval.*/
-    int      nstSampleCoord; /**< Number of samples per coordinate sample (also used for PMF) */
-    int      numSamplesUpdateFreeEnergy; /**< Number of samples per free energy update. */
-    int      ePotential;                 /**< Type of potential. */
-    gmx_bool shareBiasMultisim; /**< When true, share biases with shareGroup>0 between multi-simulations */
+    int nstSampleCoord; /**< Number of samples per coordinate sample (also used for PMF) */
+    int numSamplesUpdateFreeEnergy; /**< Number of samples per free energy update. */
+    AwhPotentialType ePotential;    /**< Type of potential. */
+    gmx_bool         shareBiasMultisim; /**< When true, share biases with shareGroup>0 between multi-simulations */
 };
 
 /*! \endcond */
index e5abdb4f5e2ebd010b94e6b7c9e19aaf79b48946..b0853f0de3a008b5384e90ef2606e92c303d07eb 100644 (file)
@@ -622,7 +622,7 @@ static void pr_awh_bias_dim(FILE* fp, int indent, gmx::AwhDimParams* awhDimParam
     pr_indent(fp, indent);
     indent++;
     fprintf(fp, "%s:\n", prefix);
-    PS("coord-provider", EAWHCOORDPROVIDER(awhDimParams->eCoordProvider));
+    PS("coord-provider", enumValueToString(awhDimParams->eCoordProvider));
     PI("coord-index", awhDimParams->coordIndex + 1);
     PR("start", awhDimParams->origin);
     PR("end", awhDimParams->end);
@@ -639,9 +639,9 @@ static void pr_awh_bias(FILE* fp, int indent, gmx::AwhBiasParams* awhBiasParams,
     sprintf(opt, "%s-error-init", prefix);
     PR(opt, awhBiasParams->errorInitial);
     sprintf(opt, "%s-growth", prefix);
-    PS(opt, EAWHGROWTH(awhBiasParams->eGrowth));
+    PS(opt, enumValueToString(awhBiasParams->eGrowth));
     sprintf(opt, "%s-target", prefix);
-    PS(opt, EAWHTARGET(awhBiasParams->eTarget));
+    PS(opt, enumValueToString(awhBiasParams->eTarget));
     sprintf(opt, "%s-target-beta-scalng", prefix);
     PR(opt, awhBiasParams->targetBetaScaling);
     sprintf(opt, "%s-target-cutoff", prefix);
@@ -665,7 +665,7 @@ static void pr_awh_bias(FILE* fp, int indent, gmx::AwhBiasParams* awhBiasParams,
 
 static void pr_awh(FILE* fp, int indent, gmx::AwhParams* awhParams)
 {
-    PS("awh-potential", EAWHPOTENTIAL(awhParams->ePotential));
+    PS("awh-potential", enumValueToString(awhParams->ePotential));
     PI("awh-seed", awhParams->seed);
     PI("awh-nstout", awhParams->nstOut);
     PI("awh-nstsample", awhParams->nstSampleCoord);
@@ -1141,7 +1141,7 @@ static void cmp_awhBiasParams(FILE*                     fp,
                               real                      abstol)
 {
     cmp_int(fp, "inputrec->awhParams->ndim", biasIndex, bias1->ndim, bias2->ndim);
-    cmp_int(fp, "inputrec->awhParams->biaseTarget", biasIndex, bias1->eTarget, bias2->eTarget);
+    cmpEnum<gmx::AwhTargetType>(fp, "inputrec->awhParams->biaseTarget", bias1->eTarget, bias2->eTarget);
     cmp_double(fp,
                "inputrec->awhParams->biastargetBetaScaling",
                biasIndex,
@@ -1156,7 +1156,8 @@ static void cmp_awhBiasParams(FILE*                     fp,
                bias2->targetCutoff,
                ftol,
                abstol);
-    cmp_int(fp, "inputrec->awhParams->biaseGrowth", biasIndex, bias1->eGrowth, bias2->eGrowth);
+    cmpEnum<gmx::AwhHistogramGrowthType>(
+            fp, "inputrec->awhParams->biaseGrowth", bias1->eGrowth, bias2->eGrowth);
     cmp_bool(fp, "inputrec->awhParams->biasbUserData", biasIndex, bias1->bUserData, bias2->bUserData);
     cmp_double(fp,
                "inputrec->awhParams->biaserror_initial",
@@ -1184,7 +1185,7 @@ static void cmp_awhParams(FILE* fp, const gmx::AwhParams* awh1, const gmx::AwhPa
             -1,
             awh1->numSamplesUpdateFreeEnergy,
             awh2->numSamplesUpdateFreeEnergy);
-    cmp_int(fp, "inputrec->awhParams->ePotential", -1, awh1->ePotential, awh2->ePotential);
+    cmpEnum<gmx::AwhPotentialType>(fp, "inputrec->awhParams->ePotential", awh1->ePotential, awh2->ePotential);
     cmp_bool(fp, "inputrec->awhParams->shareBiasMultisim", -1, awh1->shareBiasMultisim, awh2->shareBiasMultisim);
 
     if (awh1->numBias == awh2->numBias)