source: src/Parser/unittests/ParserMpqcUnitTest.cpp@ f31edc

Action_Thermostats Add_AtomRandomPerturbation Add_FitFragmentPartialChargesAction Add_RotateAroundBondAction Add_SelectAtomByNameAction Added_ParseSaveFragmentResults AddingActions_SaveParseParticleParameters Adding_Graph_to_ChangeBondActions Adding_MD_integration_tests Adding_ParticleName_to_Atom Adding_StructOpt_integration_tests AtomFragments Automaking_mpqc_open AutomationFragmentation_failures Candidate_v1.5.4 Candidate_v1.6.0 Candidate_v1.6.1 ChangeBugEmailaddress ChangingTestPorts ChemicalSpaceEvaluator CombiningParticlePotentialParsing Combining_Subpackages Debian_Package_split Debian_package_split_molecuildergui_only Disabling_MemDebug Docu_Python_wait EmpiricalPotential_contain_HomologyGraph EmpiricalPotential_contain_HomologyGraph_documentation Enable_parallel_make_install Enhance_userguide Enhanced_StructuralOptimization Enhanced_StructuralOptimization_continued Example_ManyWaysToTranslateAtom Exclude_Hydrogens_annealWithBondGraph FitPartialCharges_GlobalError Fix_BoundInBox_CenterInBox_MoleculeActions Fix_ChargeSampling_PBC Fix_ChronosMutex Fix_FitPartialCharges Fix_FitPotential_needs_atomicnumbers Fix_ForceAnnealing Fix_IndependentFragmentGrids Fix_ParseParticles Fix_ParseParticles_split_forward_backward_Actions Fix_PopActions Fix_QtFragmentList_sorted_selection Fix_Restrictedkeyset_FragmentMolecule Fix_StatusMsg Fix_StepWorldTime_single_argument Fix_Verbose_Codepatterns Fix_fitting_potentials Fixes ForceAnnealing_goodresults ForceAnnealing_oldresults ForceAnnealing_tocheck ForceAnnealing_with_BondGraph ForceAnnealing_with_BondGraph_continued ForceAnnealing_with_BondGraph_continued_betteresults ForceAnnealing_with_BondGraph_contraction-expansion FragmentAction_writes_AtomFragments FragmentMolecule_checks_bonddegrees GeometryObjects Gui_Fixes Gui_displays_atomic_force_velocity ImplicitCharges IndependentFragmentGrids IndependentFragmentGrids_IndividualZeroInstances IndependentFragmentGrids_IntegrationTest IndependentFragmentGrids_Sole_NN_Calculation JobMarket_RobustOnKillsSegFaults JobMarket_StableWorkerPool JobMarket_unresolvable_hostname_fix MoreRobust_FragmentAutomation ODR_violation_mpqc_open PartialCharges_OrthogonalSummation PdbParser_setsAtomName PythonUI_with_named_parameters QtGui_reactivate_TimeChanged_changes Recreated_GuiChecks Rewrite_FitPartialCharges RotateToPrincipalAxisSystem_UndoRedo SaturateAtoms_findBestMatching SaturateAtoms_singleDegree StoppableMakroAction Subpackage_CodePatterns Subpackage_JobMarket Subpackage_LinearAlgebra Subpackage_levmar Subpackage_mpqc_open Subpackage_vmg Switchable_LogView ThirdParty_MPQC_rebuilt_buildsystem TrajectoryDependenant_MaxOrder TremoloParser_IncreasedPrecision TremoloParser_MultipleTimesteps TremoloParser_setsAtomName Ubuntu_1604_changes stable
Last change on this file since f31edc was f31edc, checked in by Frederik Heber <heber@…>, 14 years ago

Extended MpqcParser to write config files for all possible theory levels: CLHF, CLKS, MBPT2, MBPT2_R12.

  • ParserMpqcUnitTest tests all four cases now and each contained string with the config file has been tested to work with mpqc-3.0.0-alpha.
  • Property mode set to 100644
File size: 6.3 KB
Line 
1/*
2 * Project: MoleCuilder
3 * Description: creates and alters molecular systems
4 * Copyright (C) 2010 University of Bonn. All rights reserved.
5 * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
6 */
7
8/*
9 * ParserMpqcUnitTest.cpp
10 *
11 * Created on: Mar 3, 2010
12 * Author: metzler
13 */
14
15// include config.h
16#ifdef HAVE_CONFIG_H
17#include <config.h>
18#endif
19
20#include "ParserMpqcUnitTest.hpp"
21
22#include <cppunit/CompilerOutputter.h>
23#include <cppunit/extensions/TestFactoryRegistry.h>
24#include <cppunit/ui/text/TestRunner.h>
25
26#include "Parser/MpqcParser.hpp"
27#include "World.hpp"
28#include "atom.hpp"
29#include "element.hpp"
30#include "periodentafel.hpp"
31#include "Descriptors/AtomTypeDescriptor.hpp"
32
33#ifdef HAVE_TESTRUNNER
34#include "UnitTestMain.hpp"
35#endif /*HAVE_TESTRUNNER*/
36
37using namespace std;
38
39// Registers the fixture into the 'registry'
40CPPUNIT_TEST_SUITE_REGISTRATION( ParserMpqcUnitTest );
41
42static string waterMpqc_CLHF ="% Created by MoleCuilder\n\
43mpqc: (\n\
44\tsavestate = no\n\
45\tdo_gradient = yes\n\
46\tmole<CLHF>: (\n\
47\t\tmolecule = $:molecule\n\
48\t\tbasis = $:basis\n\
49\t\tmemory = 16000000\n\
50\t)\n\
51)\n\
52molecule<Molecule>: (\n\
53\tunit = angstrom\n\
54\t{ atoms geometry } = {\n\
55\t\tO [ -0.505735\t0\t0 ]\n\
56\t\tH [ 0.252867\t0\t0.504284 ]\n\
57\t\tH [ 0.252867\t0\t-0.504284 ]\n\
58\t}\n\
59)\n\
60basis<GaussianBasisSet>: (\n\
61\tname = \"3-21G\"\n\
62\tmolecule = $:molecule\n\
63)\n"; // tested with mpqc 3.0.0-alpha
64static string waterMpqc_CLKS ="% Created by MoleCuilder\n\
65mpqc: (\n\
66\tsavestate = no\n\
67\tdo_gradient = yes\n\
68\tmole<CLKS>: (\n\
69\t\tfunctional<StdDenFunctional>:(name=B3LYP)\n\
70\t\tmolecule = $:molecule\n\
71\t\tbasis = $:basis\n\
72\t\tmemory = 16000000\n\
73\t)\n\
74)\n\
75molecule<Molecule>: (\n\
76\tunit = angstrom\n\
77\t{ atoms geometry } = {\n\
78\t\tO [ -0.505735\t0\t0 ]\n\
79\t\tH [ 0.252867\t0\t0.504284 ]\n\
80\t\tH [ 0.252867\t0\t-0.504284 ]\n\
81\t}\n\
82)\n\
83basis<GaussianBasisSet>: (\n\
84\tname = \"3-21G\"\n\
85\tmolecule = $:molecule\n\
86)\n"; // tested with mpqc 3.0.0-alpha
87static string waterMpqc_MBPT2 ="% Created by MoleCuilder\n\
88mpqc: (\n\
89\tsavestate = no\n\
90\tdo_gradient = yes\n\
91\tmole<MBPT2>: (\n\
92\t\tbasis = $:basis\n\
93\t\tmolecule = $:molecule\n\
94\t\treference<CLHF>: (\n\
95\t\t\tmaxiter = 1000\n\
96\t\t\tbasis = $:basis\n\
97\t\t\tmolecule = $:molecule\n\
98\t\t)\n\
99\t)\n\
100)\n\
101molecule<Molecule>: (\n\
102\tunit = angstrom\n\
103\t{ atoms geometry } = {\n\
104\t\tO [ -0.505735\t0\t0 ]\n\
105\t\tH [ 0.252867\t0\t0.504284 ]\n\
106\t\tH [ 0.252867\t0\t-0.504284 ]\n\
107\t}\n\
108)\n\
109basis<GaussianBasisSet>: (\n\
110\tname = \"3-21G\"\n\
111\tmolecule = $:molecule\n\
112)\n"; // tested with mpqc 3.0.0-alpha
113static string waterMpqc_MBPT2_R12 ="% Created by MoleCuilder\n\
114mpqc: (\n\
115\tsavestate = no\n\
116\tdo_gradient = yes\n\
117\tmole<MBPT2_R12>: (\n\
118\t\tmolecule = $:molecule\n\
119\t\tbasis = $:basis\n\
120\t\taux_basis = $:abasis\n\
121\t\tstdapprox = \"A'\"\n\
122\t\tnfzc = 1\n\
123\t\tmemory = 16000000\n\
124\t\tintegrals<IntegralCints>:()\n\
125\t\treference<CLHF>: (\n\
126\t\t\tmolecule = $:molecule\n\
127\t\t\tbasis = $:basis\n\
128\t\t\tmaxiter = 1000\n\
129\t\t\tmemory = 16000000\n\
130\t\t\tintegrals<IntegralCints>:()\n\
131\t\t)\n\
132\t)\n\
133)\n\
134molecule<Molecule>: (\n\
135\tunit = angstrom\n\
136\t{ atoms geometry } = {\n\
137\t\tO [ -0.505735\t0\t0 ]\n\
138\t\tH [ 0.252867\t0\t0.504284 ]\n\
139\t\tH [ 0.252867\t0\t-0.504284 ]\n\
140\t}\n\
141)\n\
142basis<GaussianBasisSet>: (\n\
143\tname = \"3-21G\"\n\
144\tmolecule = $:molecule\n\
145)\n\
146% auxiliary basis set specification\n\
147\tabasis<GaussianBasisSet>: (\n\
148\tname = \"aug-cc-pVDZ\"\n\
149\tmolecule = $:molecule\n\
150)\n"; // basically tested with mpqc 3.0.0-alpha (no parse errors but did not calculate due to missing code)
151
152void ParserMpqcUnitTest::setUp() {
153 World::getInstance();
154
155 setVerbosity(2);
156
157 // we need hydrogens and oxygens in the following tests
158 CPPUNIT_ASSERT(World::getInstance().getPeriode()->FindElement(1) != NULL);
159 CPPUNIT_ASSERT(World::getInstance().getPeriode()->FindElement(8) != NULL);
160}
161
162void ParserMpqcUnitTest::tearDown() {
163 ChangeTracker::purgeInstance();
164 World::purgeInstance();
165}
166
167/************************************ tests ***********************************/
168
169void ParserMpqcUnitTest::writeMpqcTest() {
170 // build up water molecule
171 string first;
172 string second;
173 atom *Walker = NULL;
174 Walker = World::getInstance().createAtom();
175 Walker->setType(8);
176 Walker->setPosition(Vector(0,0,0));
177 Walker = World::getInstance().createAtom();
178 Walker->setType(1);
179 Walker->setPosition(Vector(0.758602,0,0.504284));
180 Walker = World::getInstance().createAtom();
181 Walker->setType(1);
182 Walker->setPosition(Vector(0.758602,0,-0.504284));
183 CPPUNIT_ASSERT_EQUAL(3, World::getInstance().numAtoms());
184
185 // create two stringstreams, one stored, one created
186
187 MpqcParser* testParser = new MpqcParser();
188 std::vector<atom *> atoms = World::getInstance().getAllAtoms();
189 {
190 // compare both configs for CLHF
191 stringstream output;
192 testParser->setTheory(MpqcParser::CLHF);
193 testParser->save(&output, atoms);
194 stringstream input(waterMpqc_CLHF);
195 for (; std::getline(input, first) && std::getline(output, second); ) {
196 //std::cout << "Comparing '" << first << "' to '" << second << "'" << std::endl;
197 CPPUNIT_ASSERT(first == second);
198 }
199 }
200 {
201 // compare both configs for CLKS
202 stringstream output;
203 testParser->setTheory(MpqcParser::CLKS);
204 testParser->save(&output, atoms);
205 stringstream input(waterMpqc_CLKS);
206 for (; std::getline(input, first) && std::getline(output, second); ) {
207 //std::cout << "Comparing '" << first << "' to '" << second << "'" << std::endl;
208 CPPUNIT_ASSERT(first == second);
209 }
210 }
211 {
212 // compare both configs for MBPT2
213 stringstream output;
214 testParser->setTheory(MpqcParser::MBPT2);
215 testParser->save(&output, atoms);
216 stringstream input(waterMpqc_MBPT2);
217 for (; std::getline(input, first) && std::getline(output, second); ) {
218 //std::cout << "Comparing '" << first << "' to '" << second << "'" << std::endl;
219 CPPUNIT_ASSERT(first == second);
220 }
221 }
222 {
223 // compare both configs for MBPT2_R12
224 stringstream output;
225 testParser->setTheory(MpqcParser::MBPT2_R12);
226 testParser->save(&output, atoms);
227 stringstream input(waterMpqc_MBPT2_R12);
228 for (; std::getline(input, first) && std::getline(output, second); ) {
229 //std::cout << "Comparing '" << first << "' to '" << second << "'" << std::endl;
230 CPPUNIT_ASSERT(first == second);
231 }
232 }
233}
Note: See TracBrowser for help on using the repository browser.