source: src/Parser/unittests/ParserPcpUnitTest.cpp@ e0f8c8

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 v1.1.4
Last change on this file since e0f8c8 was 255829, checked in by Frederik Heber <heber@…>, 14 years ago

Removed Helpers.hpp, deleted Helpers.cpp and libMoleCuilderHelpers.la is history.

  • defs.cpp is now compiled into libmolecuilder.la.
  • ShapeUnitTest alone needs defs.cpp.
  • Most changes are removal of Helpers/helpers.hpp.
  • performCriticalExit() now inline function in Helpers/helpers.hpp.
  • also inclusion possible where performCriticalExit() is needed.
  • Helpers/helpers.hpp does not include defs.hpp anymore and this causes lots of missing Helpers/defs.hpp, CodePatterns/Log.hpp and alikes.
  • removed src/Helpers from configure.ac.
  • Property mode set to 100644
File size: 6.0 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 * ParserPcpUnitTest.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 "ParserPcpUnitTest.hpp"
21
22#include <cppunit/CompilerOutputter.h>
23#include <cppunit/extensions/TestFactoryRegistry.h>
24#include <cppunit/ui/text/TestRunner.h>
25
26#include "Parser/PcpParser.hpp"
27#include "World.hpp"
28#include "atom.hpp"
29#include "element.hpp"
30#include "periodentafel.hpp"
31#include "CodePatterns/Log.hpp"
32#include "Descriptors/AtomTypeDescriptor.hpp"
33
34#ifdef HAVE_TESTRUNNER
35#include "UnitTestMain.hpp"
36#endif /*HAVE_TESTRUNNER*/
37
38using namespace std;
39
40// Registers the fixture into the 'registry'
41CPPUNIT_TEST_SUITE_REGISTRATION( ParserPcpUnitTest );
42
43static string waterPcp = "# ParallelCarParinello - main configuration file - created with molecuilder\n\
44\n\
45mainname\tpcp\t# programm name (for runtime files)\n\
46defaultpath\not specified\t# where to put files during runtime\n\
47pseudopotpath\not specified\t# where to find pseudopotentials\n\
48\n\
49ProcPEGamma\t8\t# for parallel computing: share constants\n\
50ProcPEPsi\t1\t# for parallel computing: share wave functions\n\
51DoOutVis\t0\t# Output data for OpenDX\n\
52DoOutMes\t1\t# Output data for measurements\n\
53DoOutOrbitals\t0\t# Output all Orbitals\n\
54DoOutCurr\t0\t# Ouput current density for OpenDx\n\
55DoOutNICS\t0\t# Output Nucleus independent current shieldings\n\
56DoPerturbation\t0\t# Do perturbation calculate and determine susceptibility and shielding\n\
57DoFullCurrent\t0\t# Do full perturbation\n\
58DoConstrainedMD\t0\t# Do perform a constrained (>0, relating to current MD step) instead of unconstrained (0) MD\n\
59Thermostat\tBerendsen\t2.5\t# Which Thermostat and its parameters to use in MD case.\n\
60PcpWannier\t0\t# Put virtual centers at indivual orbits, all common, merged by variance, to grid point, to cell center\n\
61SawtoothStart\t0.01\t# Absolute value for smooth transition at cell border \n\
62VectorPlane\t0\t# Cut plane axis (x, y or z: 0,1,2) for two-dim current vector plot\n\
63VectorCut\t0\t# Cut plane axis value\n\
64AddGramSch\t1\t# Additional GramSchmidtOrtogonalization to be safe\n\
65Seed\t1\t# initial value for random seed for Psi coefficients\n\
66\n\
67MaxOuterStep\t0\t# number of MolecularDynamics/Structure optimization steps\n\
68Deltat\t0.01\t# time per MD step\n\
69OutVisStep\t10\t# Output visual data every ...th step\n\
70OutSrcStep\t5\t# Output \"restart\" data every ..th step\n\
71TargetTemp\t0.000950045\t# Target temperature\n\
72MaxPsiStep\t3\t# number of Minimisation steps per state (0 - default)\n\
73EpsWannier\t1e-07\t# tolerance value for spread minimisation of orbitals\n\
74# Values specifying when to stop\n\
75MaxMinStep\t100\t# Maximum number of steps\n\
76RelEpsTotalE\t1e-07\t# relative change in total energy\n\
77RelEpsKineticE\t1e-05\t# relative change in kinetic energy\n\
78MaxMinStopStep\t2\t# check every ..th steps\n\
79MaxMinGapStopStep\t1\t# check every ..th steps\n\
80\n\
81# Values specifying when to stop for INIT, otherwise same as above\n\
82MaxInitMinStep\t100\t# Maximum number of steps\n\
83InitRelEpsTotalE\t1e-05\t# relative change in total energy\n\
84InitRelEpsKineticE\t0.0001\t# relative change in kinetic energy\n\
85InitMaxMinStopStep\t2\t# check every ..th steps\n\
86InitMaxMinGapStopStep\t1\t# check every ..th steps\n\
87\n\
88BoxLength\t# (Length of a unit cell)\n\
8920\n\
900\t20\n\
910\t0\t20\n\
92\n\
93ECut\t128\t# energy cutoff for discretization in Hartrees\n\
94MaxLevel\t5\t# number of different levels in the code, >=2\n\
95Level0Factor\t2\t# factor by which node number increases from S to 0 level\n\
96RiemannTensor\t0\t# (Use metric)\n\
97PsiType\t0\t# 0 - doubly occupied, 1 - SpinUp,SpinDown\n\
98MaxPsiDouble\t2\t# here: specifying both maximum number of SpinUp- and -Down-states\n\
99PsiMaxNoUp\t2\t# here: specifying maximum number of SpinUp-states\n\
100PsiMaxNoDown\t2\t# here: specifying maximum number of SpinDown-states\n\
101AddPsis\t0\t# Additional unoccupied Psis for bandgap determination\n\
102\n\
103RCut\t20\t# R-cut for the ewald summation\n\
104StructOpt\t0\t# Do structure optimization beforehand\n\
105IsAngstroem\t1\t# 0 - Bohr, 1 - Angstroem\n\
106RelativeCoord\t0\t# whether ion coordinates are relative (1) or absolute (0)\n\
107MaxTypes\t2\t# maximum number of different ion types\n\
108\n\
109# Ion type data (PP = PseudoPotential, Z = atomic number)\n\
110#Ion_TypeNr.\tAmount\tZ\tRGauss\tL_Max(PP)L_Loc(PP)IonMass\t# chemical name, symbol\n\
111Ion_Type1\t2\t1\t1.0\t3\t3\t1.008\tHydrogen\tH\n\
112Ion_Type2\t1\t8\t1.0\t3\t3\t15.999\tOxygen\tO\n\
113#Ion_TypeNr._Nr.R[0]\tR[1]\tR[2]\tMoveType (0 MoveIon, 1 FixedIon)\n\
114Ion_Type2_1\t1.000000000\t0.000000000\t0.000000000\t0 # molecule nr 0\n\
115Ion_Type1_1\t0.758602\t0.000000000\t0.504284\t0 # molecule nr 1\n\
116Ion_Type1_2\t0.758602\t0.000000000\t-0.504284\t0 # molecule nr 2\n";
117
118void ParserPcpUnitTest::setUp() {
119 World::getInstance();
120
121 setVerbosity(2);
122
123 // we need hydrogens and oxygens in the following tests
124 CPPUNIT_ASSERT(World::getInstance().getPeriode()->FindElement(1) != NULL);
125 CPPUNIT_ASSERT(World::getInstance().getPeriode()->FindElement(8) != NULL);
126}
127
128void ParserPcpUnitTest::tearDown() {
129 ChangeTracker::purgeInstance();
130 World::purgeInstance();
131}
132
133/************************************ tests ***********************************/
134
135void ParserPcpUnitTest::readwritePcpTest() {
136 stringstream input(waterPcp);
137 PcpParser* testParser = new PcpParser();
138 testParser->load(&input);
139 input.clear();
140
141 CPPUNIT_ASSERT_EQUAL(3, World::getInstance().numAtoms());
142
143 // check that equality function is ok
144 CPPUNIT_ASSERT(*testParser == *testParser);
145
146 stringstream output;
147 std::vector<atom *> atoms = World::getInstance().getAllAtoms();
148 testParser->save(&output, atoms);
149
150 input << output.str();
151 PcpParser* testParser2 = new PcpParser();
152 testParser2->load(&input);
153
154 CPPUNIT_ASSERT_EQUAL(6, World::getInstance().numAtoms());
155
156 CPPUNIT_ASSERT(*testParser == *testParser2);
157}
Note: See TracBrowser for help on using the repository browser.