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.
38 * Tests for MiMiC forces computation
40 * \author Viacheslav Bolnykh <v.bolnykh@hpc-leap.eu>
41 * \ingroup module_mdrun_integration_tests
45 #include <gtest/gtest.h>
47 #include "gromacs/topology/ifunc.h"
48 #include "gromacs/trajectory/energyframe.h"
49 #include "gromacs/utility/basenetwork.h"
50 #include "gromacs/utility/stringutil.h"
52 #include "testutils/cmdlinetest.h"
53 #include "testutils/refdata.h"
54 #include "testutils/simulationdatabase.h"
56 #include "energycomparison.h"
57 #include "energyreader.h"
58 #include "moduletest.h"
65 //! Test fixture for bonded interactions
66 class MimicTest
: public gmx::test::MdrunTestFixture
69 //! Execute the trajectory writing test
70 void setupGrompp(const char *index_file
, const char *top_file
, const char *gro_file
)
72 runner_
.topFileName_
= TestFileManager::getInputFilePath(top_file
);
73 runner_
.groFileName_
= TestFileManager::getInputFilePath(gro_file
);
74 runner_
.ndxFileName_
= TestFileManager::getInputFilePath(index_file
);
75 runner_
.useStringAsMdpFile("integrator = mimic\n"
76 "QMMM-grps = QMatoms");
78 //! Prepare an mdrun caller
79 CommandLine
setupRerun()
81 CommandLine rerunCaller
;
82 rerunCaller
.append("mdrun");
83 rerunCaller
.addOption("-rerun", runner_
.groFileName_
);
84 runner_
.edrFileName_
= fileManager_
.getTemporaryFilePath(".edr");
87 //! Check the output of mdrun
90 EnergyTermsToCompare energyTermsToCompare
93 interaction_function
[F_EPOT
].longname
, relativeToleranceAsFloatingPoint(-20.1, 1e-4)
97 TestReferenceData refData
;
98 auto checker
= refData
.rootChecker();
99 checkEnergiesAgainstReferenceData(runner_
.edrFileName_
,
100 energyTermsToCompare
,
105 // This test checks if the energies produced with one quantum molecule are reasonable
106 TEST_F(MimicTest
, OneQuantumMol
)
108 setupGrompp("1quantum.ndx", "4water.top", "4water.gro");
109 ASSERT_EQ(0, runner_
.callGrompp());
111 test::CommandLine rerunCaller
= setupRerun();
113 ASSERT_EQ(0, runner_
.callMdrun(rerunCaller
));
114 if (gmx_node_rank() == 0)
120 // This test checks if the energies produced with all quantum molecules are reasonable (0)
121 TEST_F(MimicTest
, AllQuantumMol
)
123 setupGrompp("allquantum.ndx", "4water.top", "4water.gro");
124 ASSERT_EQ(0, runner_
.callGrompp());
126 test::CommandLine rerunCaller
= setupRerun();
127 ASSERT_EQ(0, runner_
.callMdrun(rerunCaller
));
128 if (gmx_node_rank() == 0)
134 // This test checks if the energies produced with two quantum molecules are reasonable
135 // Needed to check the LJ intermolecular exclusions
136 TEST_F(MimicTest
, TwoQuantumMol
)
138 setupGrompp("2quantum.ndx", "4water.top", "4water.gro");
139 ASSERT_EQ(0, runner_
.callGrompp());
141 test::CommandLine rerunCaller
= setupRerun();
142 ASSERT_EQ(0, runner_
.callMdrun(rerunCaller
));
143 if (gmx_node_rank() == 0)
149 // This test checks if the energies produced with QM/MM boundary cutting the bond are ok
150 TEST_F(MimicTest
, BondCuts
)
152 setupGrompp("ala.ndx", "ala.top", "ala.gro");
153 ASSERT_EQ(0, runner_
.callGrompp());
155 test::CommandLine rerunCaller
= setupRerun();
156 ASSERT_EQ(0, runner_
.callMdrun(rerunCaller
));
157 if (gmx_node_rank() == 0)