Merge release-4-6 into master
[alexxy/gromacs.git] / src / gromacs / trajectoryanalysis / tests / angle.cpp
1 /*
2  *
3  *                This source code is part of
4  *
5  *                 G   R   O   M   A   C   S
6  *
7  *          GROningen MAchine for Chemical Simulations
8  *
9  * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
10  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
11  * Copyright (c) 2001-2009, The GROMACS development team,
12  * check out http://www.gromacs.org for more information.
13
14  * This program is free software; you can redistribute it and/or
15  * modify it under the terms of the GNU General Public License
16  * as published by the Free Software Foundation; either version 2
17  * of the License, or (at your option) any later version.
18  *
19  * If you want to redistribute modifications, please consider that
20  * scientific software is very special. Version control is crucial -
21  * bugs must be traceable. We will be happy to consider code for
22  * inclusion in the official distribution, but derived work must not
23  * be called official GROMACS. Details are found in the README & COPYING
24  * files - if they are missing, get the official version at www.gromacs.org.
25  *
26  * To help us fund GROMACS development, we humbly ask that you cite
27  * the papers on the package - you can find them in the top README file.
28  *
29  * For more info, check our website at http://www.gromacs.org
30  */
31 /*! \internal \file
32  * \brief
33  * Tests for functionality of the "angle" trajectory analysis module.
34  *
35  * \author Teemu Murtola <teemu.murtola@cbr.su.se>
36  * \ingroup module_trajectoryanalysis
37  */
38 #include <gtest/gtest.h>
39
40 #include "gromacs/trajectoryanalysis/modules/angle.h"
41
42 #include "testutils/cmdlinetest.h"
43
44 #include "moduletest.h"
45
46 namespace
47 {
48
49 using gmx::test::CommandLine;
50
51 /********************************************************************
52  * Tests for gmx::analysismodules::Angle.
53  */
54
55 //! Test fixture for the angle analysis module.
56 typedef gmx::test::TrajectoryAnalysisModuleTestFixture<gmx::analysismodules::Angle>
57         AngleModuleTest;
58
59 TEST_F(AngleModuleTest, ComputesSimpleAngles)
60 {
61     const char *const cmdline[] = {
62         "angle",
63         "-g1", "angle", "-group1", "resname RA1 RA2 and name A1 A2 A3"
64     };
65     setTopology("angle.gro");
66     runTest(CommandLine::create(cmdline));
67 }
68
69 TEST_F(AngleModuleTest, ComputesDihedrals)
70 {
71     const char *const cmdline[] = {
72         "angle",
73         "-g1", "dihedral", "-group1", "resname RD1 RD2 RD3 and name A1 A2 A3 A4"
74     };
75     setTopology("angle.gro");
76     runTest(CommandLine::create(cmdline));
77 }
78
79 TEST_F(AngleModuleTest, ComputesVectorPairAngles)
80 {
81     const char *const cmdline[] = {
82         "angle",
83         "-g1", "vector", "-group1", "resname RV1 RV2 and name A1 A2",
84         "-g2", "vector", "-group2", "resname RV3 RV4 and name A1 A2"
85     };
86     setTopology("angle.gro");
87     runTest(CommandLine::create(cmdline));
88 }
89
90 TEST_F(AngleModuleTest, ComputesVectorPlanePairAngles)
91 {
92     const char *const cmdline[] = {
93         "angle",
94         "-g1", "vector", "-group1", "resname RV1 RV2 and name A1 A2",
95         "-g2", "plane",  "-group2", "resname RP1 RP2 and name A1 A2 A3"
96     };
97     setTopology("angle.gro");
98     runTest(CommandLine::create(cmdline));
99 }
100
101 TEST_F(AngleModuleTest, ComputesPlaneZAxisAngles)
102 {
103     const char *const cmdline[] = {
104         "angle",
105         "-g1", "plane", "-group1", "resname RP1 RP2 and name A1 A2 A3",
106         "-g2", "z"
107     };
108     setTopology("angle.gro");
109     runTest(CommandLine::create(cmdline));
110 }
111
112 TEST_F(AngleModuleTest, ComputesVectorSphereNormalZAxisAngles)
113 {
114     const char *const cmdline[] = {
115         "angle",
116         "-g1", "vector",  "-group1", "resname RV1 RV2 and name A1 A2",
117         "-g2", "sphnorm", "-group2", "cog of resname RS"
118     };
119     setTopology("angle.gro");
120     runTest(CommandLine::create(cmdline));
121 }
122
123 TEST_F(AngleModuleTest, ComputesVectorTimeZeroAngles)
124 {
125     const char *const cmdline[] = {
126         "angle",
127         "-g1", "vector", "-group1", "resname RV1 RV2 RV3 RV4 and name A1 A2",
128         "-g2", "t0"
129     };
130     setTopology("angle.gro");
131     setTrajectory("angle.gro");
132     runTest(CommandLine::create(cmdline));
133 }
134
135 } // namespace