Apply clang-format to source tree
[alexxy/gromacs.git] / src / testutils / simulationdatabase.cpp
index 72152526946b4c1d7dbd3ab61d0cac361bfcfec9..d628e2b7ab07ad848d204f13b22b26f851ff677d 100644 (file)
@@ -69,183 +69,69 @@ struct DatabaseEntry
 using MdpFileValues = std::map<std::string, DatabaseEntry>;
 
 //! Database of .mdp strings that supports prepareDefaultMdpValues()
-const MdpFileValues mdpFileValueDatabase_g
-{
+const MdpFileValues mdpFileValueDatabase_g{
     // Simple system with 12 argon atoms, fairly widely separated
-    {
-        "argon12", { { {
-                           "ref-t", "80"
-                       },
-                       {
-                           "compressibility", "5e-10"
-                       },
-                       {
-                           "tau-p", "1000"
-                       } },
-                     {
-                         1, 2, 3, 4
-                     } }
-    },
+    { "argon12",
+      { { { "ref-t", "80" }, { "compressibility", "5e-10" }, { "tau-p", "1000" } }, { 1, 2, 3, 4 } } },
     // Simple system with 5 water molecules, fairly widely separated
-    {
-        "tip3p5", { { {
-                          "compressibility", "5e-10"
-                      },
-                      {
-                          "tau-p", "1000"
-                      } },
-                    {
-                        1, 2, 3, 4, 5, 6, 8, 9
-                    } }
-    },
+    { "tip3p5", { { { "compressibility", "5e-10" }, { "tau-p", "1000" } }, { 1, 2, 3, 4, 5, 6, 8, 9 } } },
     // Simple system with 5832 argon atoms, suitable for normal pressure coupling
-    {
-        "argon5832", { { {
-                             "ref-t", "80"
-                         } },
-                       {
-                           // TODO This test case is not currently used, so we
-                           // have not tested which rank counts work.
-                           1, 2, 3, 4, 5, 6, 7, 8, 9
-                       } }
-    },
+    { "argon5832",
+      { { { "ref-t", "80" } },
+        { // TODO This test case is not currently used, so we
+          // have not tested which rank counts work.
+          1, 2, 3, 4, 5, 6, 7, 8, 9 } } },
     // Simple system with 2 nearby water molecules
-    {
-        "spc2", { { },
-                  {
-                      // TODO This test case is not currently used, so we
-                      // have not tested which rank counts work.
-                      1, 2, 3, 4, 5, 6, 7, 8, 9
-                  } }
-    },
+    { "spc2",
+      { {},
+        { // TODO This test case is not currently used, so we
+          // have not tested which rank counts work.
+          1, 2, 3, 4, 5, 6, 7, 8, 9 } } },
     // Simple system with 216 water molecules, condensed phase
-    {
-        "spc216", { { },
-                    {
-                        // TODO This test case is not currently used, so we
-                        // have not tested which rank counts work.
-                        1, 2, 3, 4, 5, 6, 7, 8, 9 // TODO tpi test
-                    } }
-    },
+    { "spc216",
+      { {},
+        {
+                // TODO This test case is not currently used, so we
+                // have not tested which rank counts work.
+                1, 2, 3, 4, 5, 6, 7, 8, 9 // TODO tpi test
+        } } },
     // Capped alanine peptide in vacuo with virtual sites
-    {
-        "alanine_vsite_vacuo", { { {
-                                       "constraints", "all-bonds"
-                                   },
-                                   {
-                                       "compressibility", "5e-10"
-                                   },
-                                   {
-                                       "tau-p", "1000"
-                                   } },
-                                 {
-                                     1, 2, 3, 4, 6, 9
-                                 } }
-    },
+    { "alanine_vsite_vacuo",
+      { { { "constraints", "all-bonds" }, { "compressibility", "5e-10" }, { "tau-p", "1000" } },
+        { 1, 2, 3, 4, 6, 9 } } },
     // Capped alanine peptide in aqueous condensed phase, with virtual sites
-    {
-        "alanine_vsite_solvated", { { {
-                                          "constraints", "all-bonds"
-                                      },
-                                      {
-                                          "compressibility", "5e-10"
-                                      },
-                                      {
-                                          "tau-p", "1000"
-                                      } },
-                                    {
-                                        // TODO This test case is not currently used, so we
-                                        // have not tested which rank counts work.
-                                        1, 2, 3, 4, 5, 6, 7, 8, 9
-                                    } }
-    },
+    { "alanine_vsite_solvated",
+      { { { "constraints", "all-bonds" }, { "compressibility", "5e-10" }, { "tau-p", "1000" } },
+        { // TODO This test case is not currently used, so we
+          // have not tested which rank counts work.
+          1, 2, 3, 4, 5, 6, 7, 8, 9 } } },
     // Zwitterionic glycine in vacuo
-    {
-        "glycine_vacuo", { { {
-                                 "constraints", "h-bonds"
-                             } },
-                           {
-                               1, 2, 3, 4, 5, 6, 7, 8, 9
-                           } }
-    },
+    { "glycine_vacuo", { { { "constraints", "h-bonds" } }, { 1, 2, 3, 4, 5, 6, 7, 8, 9 } } },
     // Zwitterionic glycine in vacuo, without constraints
-    {
-        "glycine_no_constraints_vacuo", { { {
-                                                "constraints", "none"
-                                            } },
-                                          {
-                                              1, 2, 3, 4, 5, 6, 7, 8, 9
-                                          } }
-    },
+    { "glycine_no_constraints_vacuo", { { { "constraints", "none" } }, { 1, 2, 3, 4, 5, 6, 7, 8, 9 } } },
     // Simple mdrun tests of energy
-    {
-        "angles1", { { },
-                     {
-                         1, 2
-                     } }
-    },
+    { "angles1", { {}, { 1, 2 } } },
     // Scaled water for NMA
-    {
-        "scaled-water", { { },
-                          {
-                              1, 2, 3, 4, 5, 6
-                          } }
-    },
+    { "scaled-water", { {}, { 1, 2, 3, 4, 5, 6 } } },
     // Villin for NMA
-    {
-        "villin", { { },
-                    {
-                        1, 2, 3, 4, 5, 6
-                    } }
-    },
+    { "villin", { {}, { 1, 2, 3, 4, 5, 6 } } },
     // SPC-Dimer for NMA
-    {
-        "spc-dimer", { { },
-                       {
-                           1, 2, 3, 4, 5, 6
-                       } }
-    },
+    { "spc-dimer", { {}, { 1, 2, 3, 4, 5, 6 } } },
     // SW-Dimer for NMA
-    {
-        "sw-dimer", { { {
-                            "nstcalcenergy", "1"
-                        } },
-                      {
-                          1, 2, 3, 4, 5, 6
-                      } }
-    },
+    { "sw-dimer", { { { "nstcalcenergy", "1" } }, { 1, 2, 3, 4, 5, 6 } } },
     // TIP5P for NMA
-    {
-        "one-tip5p", { { },
-                       {
-                           1, 2, 3, 4, 5, 6
-                       } }
-    },
+    { "one-tip5p", { {}, { 1, 2, 3, 4, 5, 6 } } },
     // ICE-Binding protein for NMA
-    {
-        "ice-binding", { { },
-                         {
-                             1, 2, 3, 4, 5, 6
-                         } }
-    },
+    { "ice-binding", { {}, { 1, 2, 3, 4, 5, 6 } } },
     // Nonanol molecule in vacuo, topology suitable for testing FEP
     // on KE, angles, dihedral restraints, coulomb and vdw
-    {
-        "nonanol_vacuo", { { {
-                                 "nsteps", "16"
-                             },
-                             {
-                                 "compressibility", "5e-10"
-                             },
-                             {
-                                 "tau-p", "1000"
-                             },
-                             {
-                                 "constraints", "h-bonds"
-                             },
-                             {
-                                 "other",
-                                 R"(free-energy         = yes
+    { "nonanol_vacuo",
+      { { { "nsteps", "16" },
+          { "compressibility", "5e-10" },
+          { "tau-p", "1000" },
+          { "constraints", "h-bonds" },
+          { "other",
+            R"(free-energy         = yes
                                   sc-alpha            = 0.5
                                   sc-r-power          = 6
                                   mass-lambdas        = 0.0 0.5 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0
@@ -256,12 +142,8 @@ const MdpFileValues mdpFileValueDatabase_g
                                   ;couple-moltype      = nonanol
                                   ;couple-lambda0      = none
                                   ;couple-lambda1      = vdw-q
-                                  ;couple-intramol     = yes)"
-                             } },
-                           {
-                               1, 2, 3, 4, 5, 6, 8, 9
-                           } }
-    }
+                                  ;couple-intramol     = yes)" } },
+        { 1, 2, 3, 4, 5, 6, 8, 9 } } }
 };
 
 /*! \brief Prepare default .mdp values
@@ -276,7 +158,7 @@ const MdpFileValues mdpFileValueDatabase_g
  *
  * \throws  std::bad_alloc     if out of memory
  *          std::out_of_range  if \c simulationName is not in the database */
-MdpFieldValues prepareDefaultMdpFieldValues(const std::string &simulationName)
+MdpFieldValues prepareDefaultMdpFieldValues(const std::stringsimulationName)
 {
     using MdpField = MdpFieldValues::value_type;
 
@@ -304,30 +186,26 @@ MdpFieldValues prepareDefaultMdpFieldValues(const std::string &simulationName)
     return mdpFieldValues;
 }
 
-}       // namespace
+} // namespace
 
-bool
-isNumberOfPpRanksSupported(const std::string &simulationName,
-                           int                possibleNumberOfPpRanks)
+bool isNumberOfPpRanksSupported(const std::string& simulationName, int possibleNumberOfPpRanks)
 {
-    const auto &possibleNumbers = mdpFileValueDatabase_g.at(simulationName).validPpRankCounts;
-    return (std::find(std::begin(possibleNumbers), std::end(possibleNumbers),
-                      possibleNumberOfPpRanks) != std::end(possibleNumbers));
+    const autopossibleNumbers = mdpFileValueDatabase_g.at(simulationName).validPpRankCounts;
+    return (std::find(std::begin(possibleNumbers), std::end(possibleNumbers), possibleNumberOfPpRanks)
+            != std::end(possibleNumbers));
 }
 
-std::string
-reportNumbersOfPpRanksSupported(const std::string &simulationName)
+std::string reportNumbersOfPpRanksSupported(const std::string& simulationName)
 {
-    const auto &possibleNumbers = mdpFileValueDatabase_g.at(simulationName).validPpRankCounts;
-    return formatAndJoin(std::begin(possibleNumbers), std::end(possibleNumbers),
-                         ",", StringFormatter("%d"));
+    const autopossibleNumbers = mdpFileValueDatabase_g.at(simulationName).validPpRankCounts;
+    return formatAndJoin(std::begin(possibleNumbers), std::end(possibleNumbers), ",",
+                         StringFormatter("%d"));
 }
 
-MdpFieldValues
-prepareMdpFieldValues(const std::string &simulationName,
-                      const std::string &integrator,
-                      const std::string &tcoupl,
-                      const std::string &pcoupl)
+MdpFieldValues prepareMdpFieldValues(const std::string& simulationName,
+                                     const std::string& integrator,
+                                     const std::string& tcoupl,
+                                     const std::string& pcoupl)
 {
     using MdpField = MdpFieldValues::value_type;
 
@@ -338,16 +216,14 @@ prepareMdpFieldValues(const std::string &simulationName,
     return mdpFieldValues;
 }
 
-MdpFieldValues
-prepareMdpFieldValues(const char *simulationName,
-                      const char *integrator,
-                      const char *tcoupl,
-                      const char *pcoupl)
+MdpFieldValues prepareMdpFieldValues(const char* simulationName,
+                                     const char* integrator,
+                                     const char* tcoupl,
+                                     const char* pcoupl)
 {
     return prepareMdpFieldValues(std::string(simulationName), integrator, tcoupl, pcoupl);
 }
-std::string
-prepareMdpFileContents(const MdpFieldValues &mdpFieldValues)
+std::string prepareMdpFileContents(const MdpFieldValues& mdpFieldValues)
 {
     /* Set up an .mdp file that permits a highly reproducible
      * simulation. The format string needs to be configured with
@@ -368,7 +244,8 @@ prepareMdpFileContents(const MdpFieldValues &mdpFieldValues)
      * energies were not computed with those from rerun on the same
      * coordinates.
      */
-    return formatString(R"(rcoulomb                = %s
+    return formatString(
+            R"(rcoulomb                = %s
                            rvdw                    = %s
                            rlist                   = -1
                            bd-fric                 = 1000
@@ -402,28 +279,17 @@ prepareMdpFileContents(const MdpFieldValues &mdpFieldValues)
                            comm-mode               = %s
                            nstcomm                 = %s
                            %s)",
-                        mdpFieldValues.at("rcoulomb").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(),
-                        mdpFieldValues.at("nstdhdl").c_str(),
-                        mdpFieldValues.at("integrator").c_str(),
-                        mdpFieldValues.at("tcoupl").c_str(),
-                        mdpFieldValues.at("nsttcouple").c_str(),
-                        mdpFieldValues.at("ref-t").c_str(),
-                        mdpFieldValues.at("pcoupl").c_str(),
-                        mdpFieldValues.at("nstpcouple").c_str(),
-                        mdpFieldValues.at("tau-p").c_str(),
-                        mdpFieldValues.at("compressibility").c_str(),
-                        mdpFieldValues.at("constraints").c_str(),
-                        mdpFieldValues.at("nstcalcenergy").c_str(),
-                        mdpFieldValues.at("comm-mode").c_str(),
-                        mdpFieldValues.at("nstcomm").c_str(),
-                        mdpFieldValues.at("other").c_str());
+            mdpFieldValues.at("rcoulomb").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(),
+            mdpFieldValues.at("nstdhdl").c_str(), mdpFieldValues.at("integrator").c_str(),
+            mdpFieldValues.at("tcoupl").c_str(), mdpFieldValues.at("nsttcouple").c_str(),
+            mdpFieldValues.at("ref-t").c_str(), mdpFieldValues.at("pcoupl").c_str(),
+            mdpFieldValues.at("nstpcouple").c_str(), mdpFieldValues.at("tau-p").c_str(),
+            mdpFieldValues.at("compressibility").c_str(), mdpFieldValues.at("constraints").c_str(),
+            mdpFieldValues.at("nstcalcenergy").c_str(), mdpFieldValues.at("comm-mode").c_str(),
+            mdpFieldValues.at("nstcomm").c_str(), mdpFieldValues.at("other").c_str());
 }
 
 } // namespace test