2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2018,2019,2020,2021, by the GROMACS development team, led by
5 * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
6 * and including many others, as listed in the AUTHORS file in the
7 * top-level source directory and at http://www.gromacs.org.
9 * GROMACS is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public License
11 * as published by the Free Software Foundation; either version 2.1
12 * of the License, or (at your option) any later version.
14 * GROMACS is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with GROMACS; if not, see
21 * http://www.gnu.org/licenses, or write to the Free Software Foundation,
22 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 * If you want to redistribute modifications to GROMACS, please
25 * consider that scientific software is very special. Version
26 * control is crucial - bugs must be traceable. We will be happy to
27 * consider code for inclusion in the official distribution, but
28 * derived work must not be called official GROMACS. Details are found
29 * in the README & COPYING files - if they are missing, get the
30 * official version at http://www.gromacs.org.
32 * To help us fund GROMACS development, we humbly ask that you cite
33 * the research papers on the package. Check out http://www.gromacs.org.
36 #ifndef GROMACS_TESTINGCONFIGURATION_H
37 #define GROMACS_TESTINGCONFIGURATION_H
46 #include "gromacs/gmxpreprocess/grompp.h"
47 #include "gromacs/math/vec.h"
48 #include "gromacs/utility/stringutil.h"
49 #include "gromacs/utility/textwriter.h"
51 #include "programs/mdrun/tests/moduletest.h"
52 #include "testutils/cmdlinetest.h"
53 #include "testutils/testfilemanager.h"
61 #if GMX_OPENMP || defined(DOXYGEN)
62 //! Number of OpenMP threads for child mdrun call.
63 static constexpr int g_numOpenMPThreads = 2;
66 /*! \brief Helper function to get step size as floating point number.
68 * A step size of 0.002ps is suitable for the simulation.
69 * We prefer to guarantee that the testing tools easily anticipate TPR time step size
70 * and time value in trajectory outputs, so we explicitly choose a time step that is
71 * exactly representable in binary. 2^-9 is just smaller than 0.002 and requires very
72 * little floating point precision (mantissa == 0). This means that sums and multiples
73 * of the timestep are also exactly representable, and thus particularly convenient for tests."
75 * For human readability we use the decimal representation, 1.0 x 2^-9 = 0.001953125.
77 * \returns Step size for tests.
79 inline real getTestStepSize()
84 //! Provide command-line infrastructure for gmxapi tests.
85 class GmxApiTest : public gmx::test::MdrunTestFixture
91 * Prepare a tpr to run the test with.
93 * Sets up the TPR to run a test of the GMXAPI with a set number of \p steps
94 * defined in the test.
96 * \param[in] steps Number of steps for test to run.
98 void makeTprFile(int steps)
100 runner_.useTopGroAndNdxFromDatabase("spc_and_methane");
101 runner_.useStringAsMdpFile(
102 gmx::formatString("integrator = md\n"
103 "cutoff-scheme = Verlet\n"
109 "nstxout-compressed = 5\n"
110 "tcoupl = v-rescale\n"
114 "compressed-x-grps = Sol\n",
118 EXPECT_EQ(0, runner_.callGromppOnThisRank());
121 //! Make the md arguments to work with
122 std::vector<std::string> makeMdArgs() const
124 std::vector<std::string> mdArgs;
126 mdArgs.emplace_back("-o");
127 mdArgs.emplace_back(runner_.fullPrecisionTrajectoryFileName_);
128 mdArgs.emplace_back("-x");
129 mdArgs.emplace_back(runner_.reducedPrecisionTrajectoryFileName_);
130 mdArgs.emplace_back("-c");
131 mdArgs.emplace_back(runner_.groOutputFileName_);
132 mdArgs.emplace_back("-g");
133 mdArgs.emplace_back(runner_.logFileName_);
134 mdArgs.emplace_back("-e");
135 mdArgs.emplace_back(runner_.edrFileName_);
136 mdArgs.emplace_back("-cpo");
137 mdArgs.emplace_back(runner_.cptFileName_);
139 /* This should be handled through the actual API we have for getting
140 * ranks, but currently this leads to data races right now */
141 mdArgs.emplace_back("-ntmpi");
142 mdArgs.emplace_back("1");
146 mdArgs.emplace_back("-ntomp");
147 mdArgs.emplace_back(std::to_string(g_numOpenMPThreads));
154 } // namespace testing
156 } // end namespace gmxapi
159 #endif // GROMACS_TESTINGCONFIGURATION_H