source: src/Parser/unittests/ParserPcpUnitTest.cpp@ 97a858

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 97a858 was 94d5ac6, checked in by Frederik Heber <heber@…>, 12 years ago

FIX: As we use GSL internally, we are as of now required to use GPL v2 license.

  • GNU Scientific Library is used at every place in the code, especially the sub-package LinearAlgebra is based on it which in turn is used really everywhere in the remainder of MoleCuilder. Hence, we have to use the GPL license for the whole of MoleCuilder. In effect, GPL's COPYING was present all along and stated the terms of the GPL v2 license.
  • Hence, I added the default GPL v2 disclaimer to every source file and removed the note about a (actually missing) LICENSE file.
  • also, I added a help-redistribute action which again gives the disclaimer of the GPL v2.
  • also, I changed in the disclaimer that is printed at every program start in builder_init.cpp.
  • TEST: Added check on GPL statement present in every module to test CodeChecks project-disclaimer.
  • Property mode set to 100644
File size: 6.8 KB
Line 
1/*
2 * Project: MoleCuilder
3 * Description: creates and alters molecular systems
4 * Copyright (C) 2010-2012 University of Bonn. All rights reserved.
5 *
6 *
7 * This file is part of MoleCuilder.
8 *
9 * MoleCuilder is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation, either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * MoleCuilder 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
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with MoleCuilder. If not, see <http://www.gnu.org/licenses/>.
21 */
22
23/*
24 * ParserPcpUnitTest.cpp
25 *
26 * Created on: Mar 3, 2010
27 * Author: metzler
28 */
29
30// include config.h
31#ifdef HAVE_CONFIG_H
32#include <config.h>
33#endif
34
35#include "ParserPcpUnitTest.hpp"
36
37#include <cppunit/CompilerOutputter.h>
38#include <cppunit/extensions/TestFactoryRegistry.h>
39#include <cppunit/ui/text/TestRunner.h>
40
41#include "Atom/atom.hpp"
42#include "Atom/AtomObserver.hpp"
43#include "CodePatterns/Log.hpp"
44#include "Descriptors/AtomTypeDescriptor.hpp"
45#include "Element/element.hpp"
46#include "Element/periodentafel.hpp"
47#include "Parser/ChangeTracker.hpp"
48#include "Parser/PcpParser.hpp"
49#include "World.hpp"
50
51#ifdef HAVE_TESTRUNNER
52#include "UnitTestMain.hpp"
53#endif /*HAVE_TESTRUNNER*/
54
55using namespace std;
56
57// Registers the fixture into the 'registry'
58CPPUNIT_TEST_SUITE_REGISTRATION( ParserPcpUnitTest );
59
60static string waterPcp = "# ParallelCarParinello - main configuration file - created with molecuilder\n\
61\n\
62mainname\tpcp\t# programm name (for runtime files)\n\
63defaultpath\not specified\t# where to put files during runtime\n\
64pseudopotpath\not specified\t# where to find pseudopotentials\n\
65\n\
66ProcPEGamma\t8\t# for parallel computing: share constants\n\
67ProcPEPsi\t1\t# for parallel computing: share wave functions\n\
68DoOutVis\t0\t# Output data for OpenDX\n\
69DoOutMes\t1\t# Output data for measurements\n\
70DoOutOrbitals\t0\t# Output all Orbitals\n\
71DoOutCurr\t0\t# Ouput current density for OpenDx\n\
72DoOutNICS\t0\t# Output Nucleus independent current shieldings\n\
73DoPerturbation\t0\t# Do perturbation calculate and determine susceptibility and shielding\n\
74DoFullCurrent\t0\t# Do full perturbation\n\
75DoConstrainedMD\t0\t# Do perform a constrained (>0, relating to current MD step) instead of unconstrained (0) MD\n\
76Thermostat\tBerendsen\t2.5\t# Which Thermostat and its parameters to use in MD case.\n\
77PcpWannier\t0\t# Put virtual centers at indivual orbits, all common, merged by variance, to grid point, to cell center\n\
78SawtoothStart\t0.01\t# Absolute value for smooth transition at cell border \n\
79VectorPlane\t0\t# Cut plane axis (x, y or z: 0,1,2) for two-dim current vector plot\n\
80VectorCut\t0\t# Cut plane axis value\n\
81AddGramSch\t1\t# Additional GramSchmidtOrtogonalization to be safe\n\
82Seed\t1\t# initial value for random seed for Psi coefficients\n\
83\n\
84MaxOuterStep\t0\t# number of MolecularDynamics/Structure optimization steps\n\
85Deltat\t0.01\t# time per MD step\n\
86OutVisStep\t10\t# Output visual data every ...th step\n\
87OutSrcStep\t5\t# Output \"restart\" data every ..th step\n\
88TargetTemp\t0.000950045\t# Target temperature\n\
89MaxPsiStep\t3\t# number of Minimisation steps per state (0 - default)\n\
90EpsWannier\t1e-07\t# tolerance value for spread minimisation of orbitals\n\
91# Values specifying when to stop\n\
92MaxMinStep\t100\t# Maximum number of steps\n\
93RelEpsTotalE\t1e-07\t# relative change in total energy\n\
94RelEpsKineticE\t1e-05\t# relative change in kinetic energy\n\
95MaxMinStopStep\t2\t# check every ..th steps\n\
96MaxMinGapStopStep\t1\t# check every ..th steps\n\
97\n\
98# Values specifying when to stop for INIT, otherwise same as above\n\
99MaxInitMinStep\t100\t# Maximum number of steps\n\
100InitRelEpsTotalE\t1e-05\t# relative change in total energy\n\
101InitRelEpsKineticE\t0.0001\t# relative change in kinetic energy\n\
102InitMaxMinStopStep\t2\t# check every ..th steps\n\
103InitMaxMinGapStopStep\t1\t# check every ..th steps\n\
104\n\
105BoxLength\t# (Length of a unit cell)\n\
10620\n\
1070\t20\n\
1080\t0\t20\n\
109\n\
110ECut\t128\t# energy cutoff for discretization in Hartrees\n\
111MaxLevel\t5\t# number of different levels in the code, >=2\n\
112Level0Factor\t2\t# factor by which node number increases from S to 0 level\n\
113RiemannTensor\t0\t# (Use metric)\n\
114PsiType\t0\t# 0 - doubly occupied, 1 - SpinUp,SpinDown\n\
115MaxPsiDouble\t2\t# here: specifying both maximum number of SpinUp- and -Down-states\n\
116PsiMaxNoUp\t2\t# here: specifying maximum number of SpinUp-states\n\
117PsiMaxNoDown\t2\t# here: specifying maximum number of SpinDown-states\n\
118AddPsis\t0\t# Additional unoccupied Psis for bandgap determination\n\
119\n\
120RCut\t20\t# R-cut for the ewald summation\n\
121StructOpt\t0\t# Do structure optimization beforehand\n\
122IsAngstroem\t1\t# 0 - Bohr, 1 - Angstroem\n\
123RelativeCoord\t0\t# whether ion coordinates are relative (1) or absolute (0)\n\
124MaxTypes\t2\t# maximum number of different ion types\n\
125\n\
126# Ion type data (PP = PseudoPotential, Z = atomic number)\n\
127#Ion_TypeNr.\tAmount\tZ\tRGauss\tL_Max(PP)L_Loc(PP)IonMass\t# chemical name, symbol\n\
128Ion_Type1\t2\t1\t1.0\t3\t3\t1.008\tHydrogen\tH\n\
129Ion_Type2\t1\t8\t1.0\t3\t3\t15.999\tOxygen\tO\n\
130#Ion_TypeNr._Nr.R[0]\tR[1]\tR[2]\tMoveType (0 MoveIon, 1 FixedIon)\n\
131Ion_Type2_1\t1.000000000\t0.000000000\t0.000000000\t0 # molecule nr 0\n\
132Ion_Type1_1\t0.758602\t0.000000000\t0.504284\t0 # molecule nr 1\n\
133Ion_Type1_2\t0.758602\t0.000000000\t-0.504284\t0 # molecule nr 2\n";
134
135void ParserPcpUnitTest::setUp() {
136 World::getInstance();
137
138 parser = new FormatParser<pcp>();
139
140 setVerbosity(2);
141
142 // we need hydrogens and oxygens in the following tests
143 CPPUNIT_ASSERT(World::getInstance().getPeriode()->FindElement(1) != NULL);
144 CPPUNIT_ASSERT(World::getInstance().getPeriode()->FindElement(8) != NULL);
145}
146
147void ParserPcpUnitTest::tearDown()
148{
149 delete parser;
150 ChangeTracker::purgeInstance();
151 AtomObserver::purgeInstance();
152 World::purgeInstance();
153}
154
155/************************************ tests ***********************************/
156
157void ParserPcpUnitTest::readwritePcpTest() {
158 stringstream input(waterPcp);
159 parser->load(&input);
160 input.clear();
161
162 CPPUNIT_ASSERT_EQUAL(3, World::getInstance().numAtoms());
163
164 // check that equality function is ok
165 CPPUNIT_ASSERT(*parser == *parser);
166
167 stringstream output;
168 std::vector<atom *> atoms = World::getInstance().getAllAtoms();
169 parser->save(&output, atoms);
170
171 input << output.str();
172 FormatParser<pcp>* parser2 = new FormatParser<pcp>();
173 parser2->load(&input);
174
175 CPPUNIT_ASSERT_EQUAL(6, World::getInstance().numAtoms());
176
177 CPPUNIT_ASSERT(*parser == *parser2);
178
179 delete parser2;
180}
Note: See TracBrowser for help on using the repository browser.