2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2014,2015,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.
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", "-bin", "0.05",
88 // Use selection that names a group in the index file
90 // Use selections that name groups in the index file
91 "-sel", "name_OW", "not_name_OW" };
92 // Note not supplying a topology file to -s
93 setTrajectory("spc216.gro");
94 setInputFile("-n", "index.ndx");
95 setOutputFile("-o", ".xvg", NoTextMatch());
96 excludeDataset("pairdist");
97 runTest(CommandLine(cmdline));
100 TEST_F(RdfModuleTest, SelectionsFromBothTopologyFileAndIndexFileWork)
102 const char* const cmdline[] = { "rdf", "-bin", "0.05",
103 // Use selection whose parsing requires topology file
105 // Use selections that name groups in the index file
106 "-sel", "name_OW", "not_name_OW" };
107 // Note supplying a topology file to -s
108 setTopology("spc216.gro");
109 setInputFile("-n", "index.ndx");
110 setOutputFile("-o", ".xvg", NoTextMatch());
111 excludeDataset("pairdist");
112 runTest(CommandLine(cmdline));
115 TEST_F(RdfModuleTest, CalculatesSurf)
117 const char* const cmdline[] = { "rdf",
123 "within 0.5 of (resnr 1 and name OW)",
127 setTopology("spc216.gro");
128 setOutputFile("-o", ".xvg", NoTextMatch());
129 excludeDataset("pairdist");
130 runTest(CommandLine(cmdline));
133 TEST_F(RdfModuleTest, CalculatesXY)
135 const char* const cmdline[] = { "rdf", "-bin", "0.05", "-xy", "-ref",
136 "name OW", "-sel", "name OW", "not name OW" };
137 setTopology("spc216.gro");
138 setOutputFile("-o", ".xvg", NoTextMatch());
139 excludeDataset("pairdist");
140 // TODO: Consider if it is possible to get a more reproducible result
141 // and/or a stricter tolerance (e.g., by checking that the sum of
142 // neighboring values still stays constant).
143 setDatasetTolerance("paircount", gmx::test::absoluteTolerance(2.5));
144 runTest(CommandLine(cmdline));