2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2013,2014,2015,2016,2018 by the GROMACS development team.
5 * Copyright (c) 2019,2020, by the GROMACS development team, led by
6 * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
7 * and including many others, as listed in the AUTHORS file in the
8 * top-level source directory and at http://www.gromacs.org.
10 * GROMACS is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public License
12 * as published by the Free Software Foundation; either version 2.1
13 * of the License, or (at your option) any later version.
15 * GROMACS is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with GROMACS; if not, see
22 * http://www.gnu.org/licenses, or write to the Free Software Foundation,
23 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 * If you want to redistribute modifications to GROMACS, please
26 * consider that scientific software is very special. Version
27 * control is crucial - bugs must be traceable. We will be happy to
28 * consider code for inclusion in the official distribution, but
29 * derived work must not be called official GROMACS. Details are found
30 * in the README & COPYING files - if they are missing, get the
31 * official version at http://www.gromacs.org.
33 * To help us fund GROMACS development, we humbly ask that you cite
34 * the research papers on the package. Check out http://www.gromacs.org.
39 * Tests for the .mdp nst*out functionality
41 * \author Mark Abraham <mark.j.abraham@gmail.com>
42 * \ingroup module_mdrun_integration_tests
48 #include <gtest/gtest.h>
50 #include "gromacs/options/filenameoption.h"
51 #include "gromacs/utility/stringutil.h"
53 #include "moduletest.h"
58 // TODO configure these tests so they test all formats for mdrun trajectory writing
61 //! Test fixture for mdrun trajectory writing
62 class TrajectoryWritingTest :
63 public gmx::test::MdrunTestFixture,
64 public ::testing::WithParamInterface<const char*>
67 //! The file name of the MDP file
68 std::string theMdpFile;
70 //! Execute the trajectory writing test
73 runner_.useStringAsMdpFile(theMdpFile);
74 runner_.useTopGroAndNdxFromDatabase("spc-and-methanol");
75 EXPECT_EQ(0, runner_.callGrompp());
77 runner_.fullPrecisionTrajectoryFileName_ =
78 fileManager_.getTemporaryFilePath("spc-and-methanol.tng");
79 runner_.reducedPrecisionTrajectoryFileName_ =
80 fileManager_.getTemporaryFilePath("spc-and-methanol-reduced.tng");
81 ASSERT_EQ(0, runner_.callMdrun());
82 // TODO When there is a way to sense something like the
83 // output of gmx check, compare the result with that from
84 // writing .trr and .xtc and assert the behaviour is
85 // correct. Note that TNG will always write the box, even
86 // when constant - this will be a source of
87 // trajectory-file differences.
91 //! Helper typedef for naming test cases like sentences
92 typedef TrajectoryWritingTest Trajectories;
94 /* This test ensures mdrun can write various quantities at various
96 TEST_P(Trajectories, ThatDifferInNstxout)
98 theMdpFile = gmx::formatString(
104 "nstxout-compressed = 5\n"
105 "tcoupl = v-rescale\n"
109 "compressed-x-grps = Sol\n",
114 //! Helper typedef for naming test cases like sentences
115 typedef TrajectoryWritingTest NptTrajectories;
117 /* This test ensures mdrun can write trajectories in TNG format from NPT ensembles. */
118 TEST_P(NptTrajectories, WithDifferentPcoupl)
120 theMdpFile = gmx::formatString(
128 "compressibility = 4.5e-5\n"
129 "tcoupl = v-rescale\n"
137 // TODO Consider spamming more of the parameter space when we don't
138 // have to write .mdp and .tpr files to do it.
139 INSTANTIATE_TEST_CASE_P(MdrunCanWrite, Trajectories, ::testing::Values("1", "2", "3"));
141 INSTANTIATE_TEST_CASE_P(MdrunCanWrite,
143 ::testing::Values("no", "Berendsen", "Parrinello-Rahman"));