source: src/unittests/AnalysisCorrelationToPointUnitTest.cpp@ c6efc1

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 c6efc1 was 8cbb97, checked in by Tillmann Crueger <crueger@…>, 15 years ago

Merge branch 'VectorRefactoring' into StructureRefactoring

Conflicts:

molecuilder/src/Legacy/oldmenu.cpp
molecuilder/src/Makefile.am
molecuilder/src/analysis_correlation.cpp
molecuilder/src/boundary.cpp
molecuilder/src/builder.cpp
molecuilder/src/config.cpp
molecuilder/src/ellipsoid.cpp
molecuilder/src/linkedcell.cpp
molecuilder/src/molecule.cpp
molecuilder/src/molecule_fragmentation.cpp
molecuilder/src/molecule_geometry.cpp
molecuilder/src/molecule_graph.cpp
molecuilder/src/moleculelist.cpp
molecuilder/src/tesselation.cpp
molecuilder/src/tesselationhelpers.cpp
molecuilder/src/unittests/AnalysisCorrelationToSurfaceUnitTest.cpp
molecuilder/src/unittests/bondgraphunittest.cpp
molecuilder/src/vector.cpp
molecuilder/src/vector.hpp

  • Property mode set to 100644
File size: 3.8 KB
RevLine 
[c4d4df]1/*
2 * AnalysisCorrelationToPointUnitTest.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
[49e1ae]14#include <cstring>
15
[c4d4df]16#include "analysis_correlation.hpp"
17#include "AnalysisCorrelationToPointUnitTest.hpp"
18
[46d958]19#include "World.hpp"
[c4d4df]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"
[e6fdbe]27#include "World.hpp"
[c4d4df]28
[9b6b2f]29#ifdef HAVE_TESTRUNNER
30#include "UnitTestMain.hpp"
31#endif /*HAVE_TESTRUNNER*/
[c4d4df]32
33/********************************************** Test classes **************************************/
34
35// Registers the fixture into the 'registry'
36CPPUNIT_TEST_SUITE_REGISTRATION( AnalysisCorrelationToPointUnitTest );
37
38void AnalysisCorrelationToPointUnitTest::setUp()
39{
40 atom *Walker = NULL;
41
42 // init private all pointers to zero
[a5551b]43 TestList = NULL;
[c4d4df]44 TestMolecule = NULL;
45 hydrogen = NULL;
46 tafel = NULL;
47 pointmap = NULL;
48 binmap = NULL;
49 point = NULL;
50
51 // construct element
52 hydrogen = new element;
53 hydrogen->Z = 1;
54 strcpy(hydrogen->name, "hydrogen");
[bbc338]55 strcpy(hydrogen->symbol, "H");
56
[c4d4df]57
58 // construct periodentafel
[23b547]59 tafel = World::getInstance().getPeriode();
[c4d4df]60 tafel->AddElement(hydrogen);
61
62 // construct molecule (tetraeder of hydrogens)
[23b547]63 TestMolecule = World::getInstance().createMolecule();
64 Walker = World::getInstance().createAtom();
[c4d4df]65 Walker->type = hydrogen;
[1bd79e]66 *Walker->node = Vector(1., 0., 1. );
[c4d4df]67 TestMolecule->AddAtom(Walker);
[23b547]68 Walker = World::getInstance().createAtom();
[c4d4df]69 Walker->type = hydrogen;
[1bd79e]70 *Walker->node = Vector(0., 1., 1. );
[c4d4df]71 TestMolecule->AddAtom(Walker);
[23b547]72 Walker = World::getInstance().createAtom();
[c4d4df]73 Walker->type = hydrogen;
[1bd79e]74 *Walker->node = Vector(1., 1., 0. );
[c4d4df]75 TestMolecule->AddAtom(Walker);
[23b547]76 Walker = World::getInstance().createAtom();
[c4d4df]77 Walker->type = hydrogen;
[1bd79e]78 *Walker->node = Vector(0., 0., 0. );
[c4d4df]79 TestMolecule->AddAtom(Walker);
80
81 // check that TestMolecule was correctly constructed
82 CPPUNIT_ASSERT_EQUAL( TestMolecule->AtomCount, 4 );
83
[23b547]84 TestList = World::getInstance().getMolecules();
[a5551b]85 TestList->insert(TestMolecule);
[5f612ee]86 TestMolecule->ActiveFlag = true;
[a5551b]87
[c4d4df]88 // init point
89 point = new Vector(1.,1.,1.);
90
91 // init maps
[e138de]92 pointmap = CorrelationToPoint( (MoleculeListClass * const)TestList, (const element * const)hydrogen, (const Vector *)point );
[c4d4df]93 binmap = NULL;
94
95};
96
97
98void AnalysisCorrelationToPointUnitTest::tearDown()
99{
100 if (pointmap != NULL)
101 delete(pointmap);
102 if (binmap != NULL)
103 delete(binmap);
104
105 delete(point);
[23b547]106 World::purgeInstance();
[e6fdbe]107 MemoryUsageObserver::purgeInstance();
108 logger::purgeInstance();
[c4d4df]109};
110
111void AnalysisCorrelationToPointUnitTest::CorrelationToPointTest()
112{
113 // do the pair correlation
114 CPPUNIT_ASSERT( pointmap != NULL );
115 CPPUNIT_ASSERT_EQUAL( (size_t)4, pointmap->size() );
116
117};
118
119void AnalysisCorrelationToPointUnitTest::CorrelationToPointBinNoRangeTest()
120{
121 BinPairMap::iterator tester;
122 // put pair correlation into bins and check with no range
[e138de]123 binmap = BinData( pointmap, 0.5, 0., 0. );
[3d9df5]124 OutputCorrelation ( (ofstream *)&cout, binmap );
125 CPPUNIT_ASSERT_EQUAL( (size_t)3, binmap->size() );
[c4d4df]126 tester = binmap->begin();
127 CPPUNIT_ASSERT_EQUAL( 1., tester->first );
128 CPPUNIT_ASSERT_EQUAL( 3, tester->second );
129
130};
131
132void AnalysisCorrelationToPointUnitTest::CorrelationToPointBinRangeTest()
133{
134 BinPairMap::iterator tester;
135 // ... and check with [0., 2.] range
[e138de]136 binmap = BinData( pointmap, 0.5, 0., 2. );
[3d9df5]137 OutputCorrelation ( (ofstream *)&cout, binmap );
[c4d4df]138 CPPUNIT_ASSERT_EQUAL( (size_t)5, binmap->size() );
139 tester = binmap->begin();
140 CPPUNIT_ASSERT_EQUAL( 0., tester->first );
141 tester = binmap->find(1.);
142 CPPUNIT_ASSERT_EQUAL( 1., tester->first );
143 CPPUNIT_ASSERT_EQUAL( 3, tester->second );
144
145};
Note: See TracBrowser for help on using the repository browser.