2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2014,2015,2019,2020, 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.
37 * Tests for functionality of the "rdf" trajectory analysis module.
39 * These tests are essentially regression tests for the actual RDF calculation
40 * from very small configurations. Exclusions are not tested (since the input
41 * does not contain any), nor is the effect of -cut of -rmax.
42 * At the moment, they do not test the final normalization, but only the pair
43 * counts calculated for each frame. Tests for the final normalization should
44 * be added once related TODOs in the implementation/framework have been
45 * resolved (currently, the test framework does not see the final output data).
47 * \author Teemu Murtola <teemu.murtola@gmail.com>
48 * \ingroup module_trajectoryanalysis
52 #include "gromacs/trajectoryanalysis/modules/rdf.h"
54 #include <gtest/gtest.h>
56 #include "testutils/cmdlinetest.h"
57 #include "testutils/testasserts.h"
58 #include "testutils/textblockmatchers.h"
60 #include "moduletest.h"
65 using gmx::test::CommandLine;
66 using gmx::test::NoTextMatch;
68 /********************************************************************
69 * Tests for gmx::analysismodules::Rdf.
72 //! Test fixture for the `rdf` analysis module.
73 typedef gmx::test::TrajectoryAnalysisModuleTestFixture<gmx::analysismodules::RdfInfo> RdfModuleTest;
75 TEST_F(RdfModuleTest, BasicTest)
77 const char* const cmdline[] = { "rdf", "-bin", "0.05", "-ref",
78 "name OW", "-sel", "name OW", "not name OW" };
79 setTopology("spc216.gro");
80 setOutputFile("-o", ".xvg", NoTextMatch());
81 excludeDataset("pairdist");
82 runTest(CommandLine(cmdline));
85 TEST_F(RdfModuleTest, SelectionsSolelyFromIndexFileWork)
87 const char* const cmdline[] = { "rdf",
90 // Use selection that names a group in the index file
93 // Use selections that name groups in the index file
97 // Note not supplying a topology file to -s
98 setTrajectory("spc216.gro");
99 setInputFile("-n", "index.ndx");
100 setOutputFile("-o", ".xvg", NoTextMatch());
101 excludeDataset("pairdist");
102 runTest(CommandLine(cmdline));
105 TEST_F(RdfModuleTest, SelectionsFromBothTopologyFileAndIndexFileWork)
107 const char* const cmdline[] = { "rdf",
110 // Use selection whose parsing requires topology file
113 // Use selections that name groups in the index file
117 // Note supplying a topology file to -s
118 setTopology("spc216.gro");
119 setInputFile("-n", "index.ndx");
120 setOutputFile("-o", ".xvg", NoTextMatch());
121 excludeDataset("pairdist");
122 runTest(CommandLine(cmdline));
125 TEST_F(RdfModuleTest, CalculatesSurf)
127 const char* const cmdline[] = { "rdf",
133 "within 0.5 of (resnr 1 and name OW)",
137 setTopology("spc216.gro");
138 setOutputFile("-o", ".xvg", NoTextMatch());
139 excludeDataset("pairdist");
140 runTest(CommandLine(cmdline));
143 TEST_F(RdfModuleTest, CalculatesXY)
145 const char* const cmdline[] = { "rdf", "-bin", "0.05", "-xy", "-ref",
146 "name OW", "-sel", "name OW", "not name OW" };
147 setTopology("spc216.gro");
148 setOutputFile("-o", ".xvg", NoTextMatch());
149 excludeDataset("pairdist");
150 // TODO: Consider if it is possible to get a more reproducible result
151 // and/or a stricter tolerance (e.g., by checking that the sum of
152 // neighboring values still stays constant).
153 setDatasetTolerance("paircount", gmx::test::absoluteTolerance(2.5));
154 runTest(CommandLine(cmdline));