Use MDP database for simulator equivalence tests
authorPascal Merz <pascal.merz@me.com>
Tue, 29 Jun 2021 22:00:20 +0000 (18:00 -0400)
committerPascal Merz <pascal.merz@me.com>
Wed, 30 Jun 2021 14:43:41 +0000 (14:43 +0000)
Changes the simulator equivalence tests to use the additional MDP
database introduced recently. This will allow to test algorithms
requiring additional MDP parameters more cleanly.

This also changes the MDP database behavior to overwrite default
parameters. This does not change any current behavior, as in the
current usage, no parameters are defined in both the default and
the additional parameter sets. Moving forward, it's more likely
that we will want to explicitly overwrite default parameters with
the additional database rather than have parameter redefinitions
silently fail.

src/programs/mdrun/tests/simulator.cpp
src/testutils/simulationdatabase.cpp

index effbce0df6de0b56fd5e7c6b35285ffb2adc8d18..cb0ac652c1f2930e758f988a0add972ae9e6a6d0 100644 (file)
@@ -73,7 +73,7 @@ namespace
  * are equivalent.
  */
 using SimulatorComparisonTestParams =
-        std::tuple<std::tuple<std::string, std::string, std::string, std::string>, std::string>;
+        std::tuple<std::tuple<std::string, std::string, std::string, std::string, MdpParameterDatabase>, std::string>;
 class SimulatorComparisonTest :
     public MdrunTestFixture,
     public ::testing::WithParamInterface<SimulatorComparisonTestParams>
@@ -88,6 +88,7 @@ TEST_P(SimulatorComparisonTest, WithinTolerances)
     const auto& integrator          = std::get<1>(mdpParams);
     const auto& tcoupling           = std::get<2>(mdpParams);
     const auto& pcoupling           = std::get<3>(mdpParams);
+    const auto& additionalParameter = std::get<4>(mdpParams);
     const auto& environmentVariable = std::get<1>(params);
 
     int maxNumWarnings = 0;
@@ -169,7 +170,7 @@ TEST_P(SimulatorComparisonTest, WithinTolerances)
             environmentVariable.c_str()));
 
     auto mdpFieldValues = prepareMdpFieldValues(
-            simulationName.c_str(), integrator.c_str(), tcoupling.c_str(), pcoupling.c_str());
+            simulationName.c_str(), integrator.c_str(), tcoupling.c_str(), pcoupling.c_str(), additionalParameter);
     if (tcoupling == "andersen")
     {
         // Fixes error "nstcomm must be 1, not 4 for Andersen, as velocities of
@@ -281,21 +282,21 @@ TEST_P(SimulatorComparisonTest, WithinTolerances)
 // These tests are very sensitive, so we only run them in double precision.
 // As we change call ordering, they might actually become too strict to be useful.
 #if !GMX_GPU_OPENCL && GMX_DOUBLE
-INSTANTIATE_TEST_CASE_P(SimulatorsAreEquivalentDefaultModular,
-                        SimulatorComparisonTest,
-                        ::testing::Combine(::testing::Combine(::testing::Values("argon12", "tip3p5"),
-                                                              ::testing::Values("md-vv"),
-                                                              ::testing::Values("no",
-                                                                                "v-rescale",
-                                                                                "berendsen",
-                                                                                "nose-hoover",
-                                                                                "andersen-massive",
-                                                                                "andersen"),
-                                                              ::testing::Values("no",
-                                                                                "berendsen",
-                                                                                "c-rescale",
-                                                                                "mttk")),
-                                           ::testing::Values("GMX_DISABLE_MODULAR_SIMULATOR")));
+INSTANTIATE_TEST_CASE_P(
+        SimulatorsAreEquivalentDefaultModular,
+        SimulatorComparisonTest,
+        ::testing::Combine(
+                ::testing::Combine(::testing::Values("argon12", "tip3p5"),
+                                   ::testing::Values("md-vv"),
+                                   ::testing::Values("no",
+                                                     "v-rescale",
+                                                     "berendsen",
+                                                     "nose-hoover",
+                                                     "andersen-massive",
+                                                     "andersen"),
+                                   ::testing::Values("mttk", "no", "berendsen", "c-rescale", "mttk"),
+                                   ::testing::Values(MdpParameterDatabase::Default)),
+                ::testing::Values("GMX_DISABLE_MODULAR_SIMULATOR")));
 INSTANTIATE_TEST_CASE_P(
         SimulatorsAreEquivalentDefaultLegacy,
         SimulatorComparisonTest,
@@ -304,24 +305,25 @@ INSTANTIATE_TEST_CASE_P(
                         ::testing::Values("argon12", "tip3p5"),
                         ::testing::Values("md"),
                         ::testing::Values("no", "v-rescale", "berendsen", "nose-hoover"),
-                        ::testing::Values("no", "Parrinello-Rahman", "berendsen", "c-rescale")),
+                        ::testing::Values("no", "Parrinello-Rahman", "berendsen", "c-rescale"),
+                        ::testing::Values(MdpParameterDatabase::Default)),
                 ::testing::Values("GMX_USE_MODULAR_SIMULATOR")));
 #else
-INSTANTIATE_TEST_CASE_P(DISABLED_SimulatorsAreEquivalentDefaultModular,
-                        SimulatorComparisonTest,
-                        ::testing::Combine(::testing::Combine(::testing::Values("argon12", "tip3p5"),
-                                                              ::testing::Values("md-vv"),
-                                                              ::testing::Values("no",
-                                                                                "v-rescale",
-                                                                                "berendsen",
-                                                                                "andersen-massive",
-                                                                                "andersen",
-                                                                                "nose-hoover"),
-                                                              ::testing::Values("no",
-                                                                                "berendsen",
-                                                                                "c-rescale",
-                                                                                "mttk")),
-                                           ::testing::Values("GMX_DISABLE_MODULAR_SIMULATOR")));
+INSTANTIATE_TEST_CASE_P(
+        DISABLED_SimulatorsAreEquivalentDefaultModular,
+        SimulatorComparisonTest,
+        ::testing::Combine(
+                ::testing::Combine(::testing::Values("argon12", "tip3p5"),
+                                   ::testing::Values("md-vv"),
+                                   ::testing::Values("no",
+                                                     "v-rescale",
+                                                     "berendsen",
+                                                     "andersen-massive",
+                                                     "andersen",
+                                                     "nose-hoover"),
+                                   ::testing::Values("no", "berendsen", "c-rescale", "mttk"),
+                                   ::testing::Values(MdpParameterDatabase::Default)),
+                ::testing::Values("GMX_DISABLE_MODULAR_SIMULATOR")));
 INSTANTIATE_TEST_CASE_P(
         DISABLED_SimulatorsAreEquivalentDefaultLegacy,
         SimulatorComparisonTest,
@@ -330,7 +332,8 @@ INSTANTIATE_TEST_CASE_P(
                         ::testing::Values("argon12", "tip3p5"),
                         ::testing::Values("md"),
                         ::testing::Values("no", "v-rescale", "berendsen", "nose-hoover"),
-                        ::testing::Values("no", "Parrinello-Rahman", "berendsen", "c-rescale")),
+                        ::testing::Values("no", "Parrinello-Rahman", "berendsen", "c-rescale"),
+                        ::testing::Values(MdpParameterDatabase::Default)),
                 ::testing::Values("GMX_USE_MODULAR_SIMULATOR")));
 #endif
 
index 36ac5ad86fdf3ef3f9bc0807b26a737342a6d8b5..ff4e9685fafeeea2e02b800c2eab58b292940989 100644 (file)
@@ -324,7 +324,9 @@ MdpFieldValues prepareMdpFieldValues(const std::string&   simulationName,
     mdpFieldValues.insert(MdpField("pcoupl", pcoupl));
     for (const auto& mdpField : c_additionalMdpOptions.at(additionalMdpParameters))
     {
-        mdpFieldValues.insert(mdpField);
+        // Here, we are overwriting default values - we assume the additional
+        // parameters take precedence over the default parameters
+        mdpFieldValues[mdpField.first] = mdpField.second;
     }
 
     return mdpFieldValues;