Fix mdp parameter handling in mdrun tests
authorejjordan <e.jjordan12@gmail.com>
Thu, 7 Nov 2019 15:10:34 +0000 (16:10 +0100)
committerPaul Bauer <paul.bauer.q@gmail.com>
Sat, 9 Nov 2019 09:55:06 +0000 (10:55 +0100)
Some mdp options that we intended to be set were in fact not being set.
In the two cases where mdp options were not in fact being set the default
option was desired, so this patch does not change any behavior. A note is
added to the mdp options handling code. A better long term solution might
look like popping options off the parameter map and throw if there are
options left after all defaults have been printed. This however may not
be worth the effort as the mdp options handling could change significantly
in the short term.

Change-Id: Ied6580683c91938e577861be43841e7dc3dcd8cd

src/programs/mdrun/tests/normalmodes.cpp
src/programs/mdrun/tests/simple_mdrun.cpp
src/testutils/simulationdatabase.cpp

index b24d75883906784a4ede6dd13fe147c29639e2eb..09108fb45a7c27507c5ed0a90ed7b1a74661d0da 100644 (file)
@@ -76,9 +76,6 @@ namespace test
 namespace
 {
 
-//! Helper type
-using MdpField = MdpFieldValues::value_type;
-
 /*! \brief Test fixture base for normal mode analysis
  *
  * This test ensures mdrun can run a normal mode analysis, reaching
@@ -116,8 +113,8 @@ TEST_P(NormalModesTest, WithinTolerances)
     mdpFieldValues["rlist"]       = "5.6";
     mdpFieldValues["rvdw"]        = "5.6";
     mdpFieldValues["constraints"] = "none";
-    mdpFieldValues.insert(MdpField("coulombtype", "Cut-off"));
-    mdpFieldValues.insert(MdpField("vdwtype", "Cut-off"));
+    mdpFieldValues["coulombtype"] = "Cut-off";
+    mdpFieldValues["vdwtype"]     = "Cut-off";
 
     // prepare the .tpr file
     {
index 3eb08d53ba199fa5a5799a8f95b80b58c2e84aa3..7e84a109a37f3097f6b812770d43d2ca4c775126 100644 (file)
@@ -127,8 +127,8 @@ TEST_P(SimpleMdrunTest, WithinTolerances)
     mdpFieldValues["nstfout"]       = "4";
     mdpFieldValues["constraints"]   = "none";
     mdpFieldValues["nstcalcenergy"] = "4";
-    mdpFieldValues.insert(MdpField("coulombtype", "Cut-off"));
-    mdpFieldValues.insert(MdpField("vdwtype", "Cut-off"));
+    mdpFieldValues["coulombtype"]   = "Cut-off";
+    mdpFieldValues["vdwtype"]       = "Cut-off";
 
     // Prepare the .tpr file
     {
index d628e2b7ab07ad848d204f13b22b26f851ff677d..b8edf036824a120219559e9e2d0e56fb2cd85f1b 100644 (file)
@@ -157,7 +157,10 @@ const MdpFileValues mdpFileValueDatabase_g{
  * bit of a jungle until we transition to using IMdpOptions more.
  *
  * \throws  std::bad_alloc     if out of memory
- *          std::out_of_range  if \c simulationName is not in the database */
+ *          std::out_of_range  if \c simulationName is not in the database
+ *
+ * Note: Any mdp options that are not added here cannot be used
+ */
 MdpFieldValues prepareDefaultMdpFieldValues(const std::string& simulationName)
 {
     using MdpField = MdpFieldValues::value_type;
@@ -179,7 +182,9 @@ MdpFieldValues prepareDefaultMdpFieldValues(const std::string& simulationName)
     mdpFieldValues.insert(MdpField("compressibility", "5e-5"));
     mdpFieldValues.insert(MdpField("constraints", "none"));
     mdpFieldValues.insert(MdpField("other", ""));
+    mdpFieldValues.insert(MdpField("coulombtype", "Cut-off"));
     mdpFieldValues.insert(MdpField("rcoulomb", "0.7"));
+    mdpFieldValues.insert(MdpField("vdwtype", "Cut-off"));
     mdpFieldValues.insert(MdpField("rvdw", "0.7"));
     mdpFieldValues.insert(MdpField("nstcalcenergy", "100"));
 
@@ -243,9 +248,13 @@ std::string prepareMdpFileContents(const MdpFieldValues& mdpFieldValues)
      * currently have a good way to compare forces at steps where
      * energies were not computed with those from rerun on the same
      * coordinates.
+     *
+     * Note: Any mdp options that are not printed here cannot be used
      */
     return formatString(
-            R"(rcoulomb                = %s
+            R"(coulombtype             = %s
+                           rcoulomb                = %s
+                           vdwtype                 = %s
                            rvdw                    = %s
                            rlist                   = -1
                            bd-fric                 = 1000
@@ -279,7 +288,8 @@ std::string prepareMdpFileContents(const MdpFieldValues& mdpFieldValues)
                            comm-mode               = %s
                            nstcomm                 = %s
                            %s)",
-            mdpFieldValues.at("rcoulomb").c_str(), mdpFieldValues.at("rvdw").c_str(),
+            mdpFieldValues.at("coulombtype").c_str(), mdpFieldValues.at("rcoulomb").c_str(),
+            mdpFieldValues.at("vdwtype").c_str(), mdpFieldValues.at("rvdw").c_str(),
             mdpFieldValues.at("nsteps").c_str(), mdpFieldValues.at("nstenergy").c_str(),
             mdpFieldValues.at("nstxout").c_str(), mdpFieldValues.at("nstvout").c_str(),
             mdpFieldValues.at("nstfout").c_str(), mdpFieldValues.at("nstxout-compressed").c_str(),