source: src/unittests/AnalysisCorrelationToSurfaceUnitTest.cpp@ 632bc3

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 632bc3 was 5f612ee, checked in by Frederik Heber <heber@…>, 15 years ago

Merge branch 'Analysis_PairCorrelation' into StructureRefactoring

Conflicts:

molecuilder/src/Makefile.am
molecuilder/src/World.cpp
molecuilder/src/World.hpp
molecuilder/src/boundary.cpp
molecuilder/src/builder.cpp
molecuilder/src/log.cpp
molecuilder/src/moleculelist.cpp
molecuilder/src/periodentafel.cpp
molecuilder/src/tesselation.cpp
molecuilder/src/unittests/AnalysisCorrelationToSurfaceUnitTest.cpp
molecuilder/src/unittests/Makefile.am
molecuilder/src/unittests/bondgraphunittest.cpp
molecuilder/src/unittests/gslvectorunittest.cpp
molecuilder/src/unittests/logunittest.cpp
molecuilder/src/unittests/tesselation_boundarytriangleunittest.hpp
molecuilder/src/vector.cpp
molecuilder/tests/Tesselations/defs.in

Conflicts have been many and too numerous to listen here, just the few general cases

  • new molecule() replaced by World::getInstance().createMolecule()
  • new atom() replaced by World::getInstance().createAtom() where appropriate.
  • Some DoLog()s added interfered with changes to the message produced by Log() << Verbose(.) << ...
  • DoLog() has been erroneously added to TestRunner.cpp as well, there cout is appropriate
  • ...

Additionally, there was a bug in atom::clone(), sort was set to atom::nr of the atom to clone not of the clone itself. This caused a failure of the fragmentation.

This merge has been fully checked from a clean build directory with subsequent configure,make all install and make check.
It configures, compiles and runs all test cases and the test suite without errors.

Signed-off-by: Frederik Heber <heber@…>

  • Property mode set to 100644
File size: 7.4 KB
Line 
1/*
2 * AnalysisCorrelationToSurfaceUnitTest.cpp
3 *
4 * Created on: Oct 13, 2009
5 * Author: heber
6 */
7
8using namespace std;
9
10#include <cppunit/CompilerOutputter.h>
11#include <cppunit/extensions/TestFactoryRegistry.h>
12#include <cppunit/ui/text/TestRunner.h>
13
14#include <cstring>
15
16#include "analysis_correlation.hpp"
17#include "AnalysisCorrelationToSurfaceUnitTest.hpp"
18
19#include "World.hpp"
20#include "atom.hpp"
21#include "boundary.hpp"
22#include "element.hpp"
23#include "molecule.hpp"
24#include "linkedcell.hpp"
25#include "periodentafel.hpp"
26#include "tesselation.hpp"
27#include "World.hpp"
28
29#include "Helpers/Assert.hpp"
30
31#ifdef HAVE_TESTRUNNER
32#include "UnitTestMain.hpp"
33#endif /*HAVE_TESTRUNNER*/
34
35/********************************************** Test classes **************************************/
36
37// Registers the fixture into the 'registry'
38CPPUNIT_TEST_SUITE_REGISTRATION( AnalysisCorrelationToSurfaceUnitTest );
39
40void AnalysisCorrelationToSurfaceUnitTest::setUp()
41{
42 ASSERT_DO(Assert::Throw);
43
44 atom *Walker = NULL;
45
46 // init private all pointers to zero
47 TestList = NULL;
48 TestMolecule = NULL;
49 hydrogen = NULL;
50 tafel = NULL;
51 surfacemap = NULL;
52 binmap = NULL;
53 Surface = NULL;
54 LC = NULL;
55
56 // construct element
57 hydrogen = new element;
58 hydrogen->Z = 1;
59 strcpy(hydrogen->name, "hydrogen");
60 strcpy(hydrogen->symbol, "H");
61 carbon = new element;
62 carbon->Z = 6;
63 strcpy(carbon->name, "carbon");
64 strcpy(carbon->symbol, "C");
65
66 // construct periodentafel
67 tafel = World::getInstance().getPeriode();
68 tafel->AddElement(hydrogen);
69 tafel->AddElement(carbon);
70
71 // construct molecule (tetraeder of hydrogens) base
72 TestSurfaceMolecule = World::getInstance().createMolecule();
73 Walker = World::getInstance().createAtom();
74 Walker->type = hydrogen;
75 Walker->node->Init(1., 0., 1. );
76 TestSurfaceMolecule->AddAtom(Walker);
77 Walker = World::getInstance().createAtom();
78 Walker->type = hydrogen;
79 Walker->node->Init(0., 1., 1. );
80 TestSurfaceMolecule->AddAtom(Walker);
81 Walker = World::getInstance().createAtom();
82 Walker->type = hydrogen;
83 Walker->node->Init(1., 1., 0. );
84 TestSurfaceMolecule->AddAtom(Walker);
85 Walker = World::getInstance().createAtom();
86 Walker->type = hydrogen;
87 Walker->node->Init(0., 0., 0. );
88 TestSurfaceMolecule->AddAtom(Walker);
89
90 // check that TestMolecule was correctly constructed
91 CPPUNIT_ASSERT_EQUAL( TestSurfaceMolecule->AtomCount, 4 );
92
93 TestList = World::getInstance().getMolecules();
94 TestSurfaceMolecule->ActiveFlag = true;
95 TestList->insert(TestSurfaceMolecule);
96
97 // init tesselation and linked cell
98 Surface = new Tesselation;
99 LC = new LinkedCell(TestSurfaceMolecule, 5.);
100 FindNonConvexBorder(TestSurfaceMolecule, Surface, (const LinkedCell *&)LC, 2.5, NULL);
101
102 // add outer atoms
103 TestMolecule = World::getInstance().createMolecule();
104 Walker = World::getInstance().createAtom();
105 Walker->type = carbon;
106 Walker->node->Init(4., 0., 4. );
107 TestMolecule->AddAtom(Walker);
108 Walker = World::getInstance().createAtom();
109 Walker->type = carbon;
110 Walker->node->Init(0., 4., 4. );
111 TestMolecule->AddAtom(Walker);
112 Walker = World::getInstance().createAtom();
113 Walker->type = carbon;
114 Walker->node->Init(4., 4., 0. );
115 TestMolecule->AddAtom(Walker);
116 // add inner atoms
117 Walker = World::getInstance().createAtom();
118 Walker->type = carbon;
119 Walker->node->Init(0.5, 0.5, 0.5 );
120 TestMolecule->AddAtom(Walker);
121 TestMolecule->ActiveFlag = true;
122 TestList->insert(TestMolecule);
123
124 // init maps
125 surfacemap = NULL;
126 binmap = NULL;
127
128};
129
130
131void AnalysisCorrelationToSurfaceUnitTest::tearDown()
132{
133 if (surfacemap != NULL)
134 delete(surfacemap);
135 if (binmap != NULL)
136 delete(binmap);
137
138 delete(Surface);
139 // note that all the atoms are cleaned by TestMolecule
140 delete(LC);
141 World::purgeInstance();
142 MemoryUsageObserver::purgeInstance();
143 logger::purgeInstance();
144};
145
146
147/** Checks whether setup() does the right thing.
148 */
149void AnalysisCorrelationToSurfaceUnitTest::SurfaceTest()
150{
151 CPPUNIT_ASSERT_EQUAL( 4, TestSurfaceMolecule->AtomCount );
152 CPPUNIT_ASSERT_EQUAL( 4, TestMolecule->AtomCount );
153 CPPUNIT_ASSERT_EQUAL( (size_t)2, TestList->ListOfMolecules.size() );
154 CPPUNIT_ASSERT_EQUAL( (size_t)4, Surface->PointsOnBoundary.size() );
155 CPPUNIT_ASSERT_EQUAL( (size_t)6, Surface->LinesOnBoundary.size() );
156 CPPUNIT_ASSERT_EQUAL( (size_t)4, Surface->TrianglesOnBoundary.size() );
157};
158
159void AnalysisCorrelationToSurfaceUnitTest::CorrelationToSurfaceTest()
160{
161 // do the pair correlation
162 surfacemap = CorrelationToSurface( TestList, hydrogen, Surface, LC );
163// OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap );
164 CPPUNIT_ASSERT( surfacemap != NULL );
165 CPPUNIT_ASSERT_EQUAL( (size_t)4, surfacemap->size() );
166};
167
168void AnalysisCorrelationToSurfaceUnitTest::CorrelationToSurfaceHydrogenBinNoRangeTest()
169{
170 BinPairMap::iterator tester;
171 surfacemap = CorrelationToSurface( TestList, hydrogen, Surface, LC );
172 // put pair correlation into bins and check with no range
173// OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap );
174 binmap = BinData( surfacemap, 0.5, 0., 0. );
175 CPPUNIT_ASSERT_EQUAL( (size_t)1, binmap->size() );
176 OutputCorrelation ( (ofstream *)&cout, binmap );
177 tester = binmap->begin();
178 CPPUNIT_ASSERT_EQUAL( 0., tester->first );
179 CPPUNIT_ASSERT_EQUAL( 4, tester->second );
180
181};
182
183void AnalysisCorrelationToSurfaceUnitTest::CorrelationToSurfaceHydrogenBinRangeTest()
184{
185 BinPairMap::iterator tester;
186 surfacemap = CorrelationToSurface( TestList, hydrogen, Surface, LC );
187// OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap );
188 // ... and check with [0., 2.] range
189 binmap = BinData( surfacemap, 0.5, 0., 2. );
190 CPPUNIT_ASSERT_EQUAL( (size_t)5, binmap->size() );
191// OutputCorrelation ( (ofstream *)&cout, binmap );
192 tester = binmap->begin();
193 CPPUNIT_ASSERT_EQUAL( 0., tester->first );
194 CPPUNIT_ASSERT_EQUAL( 4, tester->second );
195 tester = binmap->find(1.);
196 CPPUNIT_ASSERT_EQUAL( 1., tester->first );
197 CPPUNIT_ASSERT_EQUAL( 0, tester->second );
198
199};
200
201void AnalysisCorrelationToSurfaceUnitTest::CorrelationToSurfaceCarbonBinNoRangeTest()
202{
203 BinPairMap::iterator tester;
204 surfacemap = CorrelationToSurface( TestList, carbon, Surface, LC );
205// OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap );
206 // put pair correlation into bins and check with no range
207 binmap = BinData( surfacemap, 0.5, 0., 0. );
208 //OutputCorrelation ( (ofstream *)&cout, binmap );
209 CPPUNIT_ASSERT_EQUAL( (size_t)9, binmap->size() );
210 // inside point is first and must have negative value
211 tester = binmap->lower_bound(4.25-0.5); // start depends on the min value and
212 CPPUNIT_ASSERT( tester != binmap->end() );
213 CPPUNIT_ASSERT_EQUAL( 3, tester->second );
214 // inner point
215 tester = binmap->lower_bound(0.);
216 CPPUNIT_ASSERT( tester != binmap->end() );
217 CPPUNIT_ASSERT_EQUAL( 1, tester->second );
218};
219
220void AnalysisCorrelationToSurfaceUnitTest::CorrelationToSurfaceCarbonBinRangeTest()
221{
222 BinPairMap::iterator tester;
223 surfacemap = CorrelationToSurface( TestList, carbon, Surface, LC );
224// OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap );
225 // ... and check with [0., 2.] range
226 binmap = BinData( surfacemap, 0.5, -2., 4. );
227 //OutputCorrelation ( (ofstream *)&cout, binmap );
228 CPPUNIT_ASSERT_EQUAL( (size_t)13, binmap->size() );
229 // three outside points
230 tester = binmap->lower_bound(4.25-0.5);
231 CPPUNIT_ASSERT( tester != binmap->end() );
232 CPPUNIT_ASSERT_EQUAL( 3, tester->second );
233 // inner point
234 tester = binmap->lower_bound(0.);
235 CPPUNIT_ASSERT( tester != binmap->end() );
236 CPPUNIT_ASSERT_EQUAL( 1, tester->second );
237};
Note: See TracBrowser for help on using the repository browser.