source: src/unittests/AnalysisCorrelationToSurfaceUnitTest.cpp@ 15b670

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 15b670 was 1024cb, checked in by Frederik Heber <heber@…>, 15 years ago

Merge commit 'jupiter/MoleculeStartEndSwitch' into CommandLineActionMapping

Conflicts:

molecuilder/src/Makefile.am
molecuilder/src/builder.cpp
molecuilder/src/config.cpp
molecuilder/src/helpers.hpp
molecuilder/src/molecule.cpp
molecuilder/src/molecule_dynamics.cpp
molecuilder/src/molecule_fragmentation.cpp
molecuilder/src/molecule_geometry.cpp
molecuilder/src/molecule_graph.cpp
molecuilder/src/moleculelist.cpp
molecuilder/src/unittests/AnalysisCorrelationToPointUnitTest.cpp
molecuilder/src/unittests/listofbondsunittest.cpp

Integration of MoleculeStartEndSwitch had the following consequences:

  • no more AtomCount -> getAtomCount()
  • no more start/end -> begin(), end() and iterator
  • no more decent ordering in atomic ids (hence, Simple_configuration/8 and Domain/5, Domain/6 now check by comparing sorted xyz, not confs)

There is still a huge problem with bonds. One test runs into an endless loop.

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

  • Property mode set to 100644
File size: 7.2 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 "atom.hpp"
20#include "boundary.hpp"
21#include "element.hpp"
22#include "molecule.hpp"
23#include "linkedcell.hpp"
24#include "periodentafel.hpp"
25#include "tesselation.hpp"
26#include "World.hpp"
27#include "Helpers/Assert.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 TestSurfaceMolecule = NULL;
49 surfacemap = NULL;
50 binmap = NULL;
51 Surface = NULL;
52 LC = NULL;
53
54 // construct molecule (tetraeder of hydrogens) base
55 hydrogen = World::getInstance().getPeriode()->FindElement(1);
56 TestSurfaceMolecule = World::getInstance().createMolecule();
57
58 Walker = World::getInstance().createAtom();
59 Walker->type = hydrogen;
60 *Walker->node = Vector(1., 0., 1. );
61 TestSurfaceMolecule->AddAtom(Walker);
62
63 Walker = World::getInstance().createAtom();
64 Walker->type = hydrogen;
65 *Walker->node = Vector(0., 1., 1. );
66 TestSurfaceMolecule->AddAtom(Walker);
67
68 Walker = World::getInstance().createAtom();
69 Walker->type = hydrogen;
70 *Walker->node = Vector(1., 1., 0. );
71 TestSurfaceMolecule->AddAtom(Walker);
72
73 Walker = World::getInstance().createAtom();
74 Walker->type = hydrogen;
75 *Walker->node = Vector(0., 0., 0. );
76 TestSurfaceMolecule->AddAtom(Walker);
77
78 // check that TestMolecule was correctly constructed
79 CPPUNIT_ASSERT_EQUAL( TestSurfaceMolecule->getAtomCount(), 4 );
80
81 TestList = World::getInstance().getMolecules();
82 TestSurfaceMolecule->ActiveFlag = true;
83 TestList->insert(TestSurfaceMolecule);
84
85 // init tesselation and linked cell
86 Surface = new Tesselation;
87 LC = new LinkedCell(TestSurfaceMolecule, 5.);
88 FindNonConvexBorder(TestSurfaceMolecule, Surface, (const LinkedCell *&)LC, 2.5, NULL);
89
90 // add outer atoms
91 carbon = World::getInstance().getPeriode()->FindElement(6);
92 TestSurfaceMolecule = World::getInstance().createMolecule();
93 Walker = World::getInstance().createAtom();
94 Walker->type = carbon;
95 *Walker->node = Vector(4., 0., 4. );
96 TestSurfaceMolecule->AddAtom(Walker);
97
98 Walker = World::getInstance().createAtom();
99 Walker->type = carbon;
100 *Walker->node = Vector(0., 4., 4. );
101 TestSurfaceMolecule->AddAtom(Walker);
102
103 Walker = World::getInstance().createAtom();
104 Walker->type = carbon;
105 *Walker->node = Vector(4., 4., 0. );
106 TestSurfaceMolecule->AddAtom(Walker);
107
108 // add inner atoms
109 Walker = World::getInstance().createAtom();
110 Walker->type = carbon;
111 *Walker->node = Vector(0.5, 0.5, 0.5 );
112 TestSurfaceMolecule->AddAtom(Walker);
113
114 TestSurfaceMolecule->ActiveFlag = true;
115 TestList->insert(TestSurfaceMolecule);
116
117 // init maps
118 surfacemap = NULL;
119 binmap = NULL;
120
121};
122
123
124void AnalysisCorrelationToSurfaceUnitTest::tearDown()
125{
126 if (surfacemap != NULL)
127 delete(surfacemap);
128 if (binmap != NULL)
129 delete(binmap);
130
131 delete(Surface);
132 // note that all the atoms are cleaned by TestMolecule
133 delete(LC);
134 World::purgeInstance();
135 logger::purgeInstance();
136};
137
138
139/** Checks whether setup() does the right thing.
140 */
141void AnalysisCorrelationToSurfaceUnitTest::SurfaceTest()
142{
143 CPPUNIT_ASSERT_EQUAL( 4, TestSurfaceMolecule->getAtomCount() );
144 CPPUNIT_ASSERT_EQUAL( (size_t)2, TestList->ListOfMolecules.size() );
145 CPPUNIT_ASSERT_EQUAL( (size_t)4, Surface->PointsOnBoundary.size() );
146 CPPUNIT_ASSERT_EQUAL( (size_t)6, Surface->LinesOnBoundary.size() );
147 CPPUNIT_ASSERT_EQUAL( (size_t)4, Surface->TrianglesOnBoundary.size() );
148};
149
150void AnalysisCorrelationToSurfaceUnitTest::CorrelationToSurfaceTest()
151{
152 // do the pair correlation
153 surfacemap = CorrelationToSurface( TestList, hydrogen, Surface, LC );
154// OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap );
155 CPPUNIT_ASSERT( surfacemap != NULL );
156 CPPUNIT_ASSERT_EQUAL( (size_t)4, surfacemap->size() );
157};
158
159void AnalysisCorrelationToSurfaceUnitTest::CorrelationToSurfaceHydrogenBinNoRangeTest()
160{
161 BinPairMap::iterator tester;
162 surfacemap = CorrelationToSurface( TestList, hydrogen, Surface, LC );
163 // put pair correlation into bins and check with no range
164// OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap );
165 binmap = BinData( surfacemap, 0.5, 0., 0. );
166 CPPUNIT_ASSERT_EQUAL( (size_t)1, binmap->size() );
167 OutputCorrelation ( (ofstream *)&cout, binmap );
168 tester = binmap->begin();
169 CPPUNIT_ASSERT_EQUAL( 0., tester->first );
170 CPPUNIT_ASSERT_EQUAL( 4, tester->second );
171
172};
173
174void AnalysisCorrelationToSurfaceUnitTest::CorrelationToSurfaceHydrogenBinRangeTest()
175{
176 BinPairMap::iterator tester;
177 surfacemap = CorrelationToSurface( TestList, hydrogen, Surface, LC );
178// OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap );
179 // ... and check with [0., 2.] range
180 binmap = BinData( surfacemap, 0.5, 0., 2. );
181 CPPUNIT_ASSERT_EQUAL( (size_t)5, binmap->size() );
182// OutputCorrelation ( (ofstream *)&cout, binmap );
183 tester = binmap->begin();
184 CPPUNIT_ASSERT_EQUAL( 0., tester->first );
185 CPPUNIT_ASSERT_EQUAL( 4, tester->second );
186 tester = binmap->find(1.);
187 CPPUNIT_ASSERT_EQUAL( 1., tester->first );
188 CPPUNIT_ASSERT_EQUAL( 0, tester->second );
189
190};
191
192void AnalysisCorrelationToSurfaceUnitTest::CorrelationToSurfaceCarbonBinNoRangeTest()
193{
194 BinPairMap::iterator tester;
195 surfacemap = CorrelationToSurface( TestList, carbon, Surface, LC );
196// OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap );
197 // put pair correlation into bins and check with no range
198 binmap = BinData( surfacemap, 0.5, 0., 0. );
199 //OutputCorrelation ( (ofstream *)&cout, binmap );
200 CPPUNIT_ASSERT_EQUAL( (size_t)9, binmap->size() );
201 // inside point is first and must have negative value
202 tester = binmap->lower_bound(4.25-0.5); // start depends on the min value and
203 CPPUNIT_ASSERT( tester != binmap->end() );
204 CPPUNIT_ASSERT_EQUAL( 3, tester->second );
205 // inner point
206 tester = binmap->lower_bound(0.);
207 CPPUNIT_ASSERT( tester != binmap->end() );
208 CPPUNIT_ASSERT_EQUAL( 1, tester->second );
209};
210
211void AnalysisCorrelationToSurfaceUnitTest::CorrelationToSurfaceCarbonBinRangeTest()
212{
213 BinPairMap::iterator tester;
214 surfacemap = CorrelationToSurface( TestList, carbon, Surface, LC );
215// OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap );
216 // ... and check with [0., 2.] range
217 binmap = BinData( surfacemap, 0.5, -2., 4. );
218 //OutputCorrelation ( (ofstream *)&cout, binmap );
219 CPPUNIT_ASSERT_EQUAL( (size_t)13, binmap->size() );
220 // three outside points
221 tester = binmap->lower_bound(4.25-0.5);
222 CPPUNIT_ASSERT( tester != binmap->end() );
223 CPPUNIT_ASSERT_EQUAL( 3, tester->second );
224 // inner point
225 tester = binmap->lower_bound(0.);
226 CPPUNIT_ASSERT( tester != binmap->end() );
227 CPPUNIT_ASSERT_EQUAL( 1, tester->second );
228};
Note: See TracBrowser for help on using the repository browser.