2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2018,2019, 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
39 #include <gtest/gtest.h>
44 #include "gromacs/gmxpreprocess/grompp.h"
45 #include "gromacs/math/vec.h"
46 #include "gromacs/utility/stringutil.h"
47 #include "gromacs/utility/textwriter.h"
49 #include "testutils/cmdlinetest.h"
50 #include "testutils/testfilemanager.h"
51 #include "programs/mdrun/tests/moduletest.h"
59 /*! \brief Helper function to get step size as floating point number.
61 * A step size of 0.002ps is suitable for the simulation.
62 * We prefer to guarantee that the testing tools easily anticipate TPR time step size
63 * and time value in trajectory outputs, so we explicitly choose a time step that is
64 * exactly representable in binary. 2^-9 is just smaller than 0.002 and requires very
65 * little floating point precision (mantissa == 0). This means that sums and multiples
66 * of the timestep are also exactly representable, and thus particularly convenient for tests."
68 * For human readability we use the decimal representation, 1.0 x 2^-9 = 0.001953125.
70 * \returns Step size for tests.
72 inline real getTestStepSize()
77 //! Provide command-line infrastructure for gmxapi tests.
78 class GmxApiTest : public gmx::test::MdrunTestFixture
84 * Prepare a tpr to run the test with.
86 * Sets up the TPR to run a test of the GMXAPI with a set number of \p steps
87 * defined in the test.
89 * \param[in] steps Number of steps for test to run.
91 void makeTprFile(int steps)
93 runner_.useTopGroAndNdxFromDatabase("spc_and_methane");
94 runner_.useStringAsMdpFile(
95 gmx::formatString("integrator = md\n"
96 "cutoff-scheme = Verlet\n"
102 "nstxout-compressed = 5\n"
103 "tcoupl = v-rescale\n"
107 "compressed-x-grps = Sol\n",
108 steps, getTestStepSize()));
110 EXPECT_EQ(0, runner_.callGromppOnThisRank());
113 //! Make the md arguments to work with
114 std::vector<std::string> makeMdArgs() const
116 std::vector<std::string> mdArgs;
118 mdArgs.emplace_back("-o");
119 mdArgs.emplace_back(runner_.fullPrecisionTrajectoryFileName_);
120 mdArgs.emplace_back("-x");
121 mdArgs.emplace_back(runner_.reducedPrecisionTrajectoryFileName_);
122 mdArgs.emplace_back("-c");
123 mdArgs.emplace_back(runner_.groOutputFileName_);
124 mdArgs.emplace_back("-g");
125 mdArgs.emplace_back(runner_.logFileName_);
126 mdArgs.emplace_back("-e");
127 mdArgs.emplace_back(runner_.edrFileName_);
128 mdArgs.emplace_back("-cpo");
129 mdArgs.emplace_back(runner_.cptFileName_);
135 } // namespace testing
137 } // end namespace gmxapi
140 #endif // GROMACS_TESTINGCONFIGURATION_H