source: src/unittests/AnalysisCorrelationToSurfaceUnitTest.cpp@ a80241

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 Candidate_v1.7.0 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 a80241 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
RevLine 
[c4d4df]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
[49e1ae]14#include <cstring>
15
[c4d4df]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"
[e6fdbe]26#include "World.hpp"
[8d2772]27#include "Helpers/Assert.hpp"
[c4d4df]28
[5be0eb]29#include "Helpers/Assert.hpp"
30
[9b6b2f]31#ifdef HAVE_TESTRUNNER
32#include "UnitTestMain.hpp"
33#endif /*HAVE_TESTRUNNER*/
[c4d4df]34
35/********************************************** Test classes **************************************/
36
37// Registers the fixture into the 'registry'
38CPPUNIT_TEST_SUITE_REGISTRATION( AnalysisCorrelationToSurfaceUnitTest );
39
40void AnalysisCorrelationToSurfaceUnitTest::setUp()
41{
[e0b6fd]42 ASSERT_DO(Assert::Throw);
[5be0eb]43
[c4d4df]44 atom *Walker = NULL;
45
46 // init private all pointers to zero
[a5551b]47 TestList = NULL;
[8cbb97]48 TestSurfaceMolecule = NULL;
[c4d4df]49 surfacemap = NULL;
50 binmap = NULL;
51 Surface = NULL;
52 LC = NULL;
53
[bbc338]54 // construct molecule (tetraeder of hydrogens) base
[4eb4fe]55 hydrogen = World::getInstance().getPeriode()->FindElement(1);
[5f612ee]56 TestSurfaceMolecule = World::getInstance().createMolecule();
[a7b761b]57
[23b547]58 Walker = World::getInstance().createAtom();
[c4d4df]59 Walker->type = hydrogen;
[1bd79e]60 *Walker->node = Vector(1., 0., 1. );
[8db598]61 TestSurfaceMolecule->AddAtom(Walker);
[a7b761b]62
[23b547]63 Walker = World::getInstance().createAtom();
[c4d4df]64 Walker->type = hydrogen;
[1bd79e]65 *Walker->node = Vector(0., 1., 1. );
[8db598]66 TestSurfaceMolecule->AddAtom(Walker);
[a7b761b]67
[23b547]68 Walker = World::getInstance().createAtom();
[c4d4df]69 Walker->type = hydrogen;
[1bd79e]70 *Walker->node = Vector(1., 1., 0. );
[8db598]71 TestSurfaceMolecule->AddAtom(Walker);
[a7b761b]72
[23b547]73 Walker = World::getInstance().createAtom();
[c4d4df]74 Walker->type = hydrogen;
[1bd79e]75 *Walker->node = Vector(0., 0., 0. );
[8db598]76 TestSurfaceMolecule->AddAtom(Walker);
[c4d4df]77
78 // check that TestMolecule was correctly constructed
[a7b761b]79 CPPUNIT_ASSERT_EQUAL( TestSurfaceMolecule->getAtomCount(), 4 );
[c4d4df]80
[23b547]81 TestList = World::getInstance().getMolecules();
[8db598]82 TestSurfaceMolecule->ActiveFlag = true;
83 TestList->insert(TestSurfaceMolecule);
[a5551b]84
[c4d4df]85 // init tesselation and linked cell
86 Surface = new Tesselation;
[8db598]87 LC = new LinkedCell(TestSurfaceMolecule, 5.);
88 FindNonConvexBorder(TestSurfaceMolecule, Surface, (const LinkedCell *&)LC, 2.5, NULL);
[c4d4df]89
[bbc338]90 // add outer atoms
[4eb4fe]91 carbon = World::getInstance().getPeriode()->FindElement(6);
[8cbb97]92 TestSurfaceMolecule = World::getInstance().createMolecule();
[23b547]93 Walker = World::getInstance().createAtom();
[bbc338]94 Walker->type = carbon;
[1bd79e]95 *Walker->node = Vector(4., 0., 4. );
[8cbb97]96 TestSurfaceMolecule->AddAtom(Walker);
[a7b761b]97
[23b547]98 Walker = World::getInstance().createAtom();
[bbc338]99 Walker->type = carbon;
[1bd79e]100 *Walker->node = Vector(0., 4., 4. );
[8cbb97]101 TestSurfaceMolecule->AddAtom(Walker);
[a7b761b]102
[23b547]103 Walker = World::getInstance().createAtom();
[bbc338]104 Walker->type = carbon;
[1bd79e]105 *Walker->node = Vector(4., 4., 0. );
[8cbb97]106 TestSurfaceMolecule->AddAtom(Walker);
[a7b761b]107
[bbc338]108 // add inner atoms
[23b547]109 Walker = World::getInstance().createAtom();
[bbc338]110 Walker->type = carbon;
[1bd79e]111 *Walker->node = Vector(0.5, 0.5, 0.5 );
[8cbb97]112 TestSurfaceMolecule->AddAtom(Walker);
[a7b761b]113
[8cbb97]114 TestSurfaceMolecule->ActiveFlag = true;
115 TestList->insert(TestSurfaceMolecule);
[bbc338]116
[c4d4df]117 // init maps
[bbc338]118 surfacemap = NULL;
[c4d4df]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
[776b64]131 delete(Surface);
132 // note that all the atoms are cleaned by TestMolecule
[c4d4df]133 delete(LC);
[23b547]134 World::purgeInstance();
[e6fdbe]135 logger::purgeInstance();
[c4d4df]136};
137
138
[8db598]139/** Checks whether setup() does the right thing.
140 */
141void AnalysisCorrelationToSurfaceUnitTest::SurfaceTest()
142{
[a7b761b]143 CPPUNIT_ASSERT_EQUAL( 4, TestSurfaceMolecule->getAtomCount() );
[8db598]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
[c4d4df]150void AnalysisCorrelationToSurfaceUnitTest::CorrelationToSurfaceTest()
151{
152 // do the pair correlation
[e138de]153 surfacemap = CorrelationToSurface( TestList, hydrogen, Surface, LC );
[8db598]154// OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap );
[c4d4df]155 CPPUNIT_ASSERT( surfacemap != NULL );
156 CPPUNIT_ASSERT_EQUAL( (size_t)4, surfacemap->size() );
157};
158
[bbc338]159void AnalysisCorrelationToSurfaceUnitTest::CorrelationToSurfaceHydrogenBinNoRangeTest()
[c4d4df]160{
161 BinPairMap::iterator tester;
[e138de]162 surfacemap = CorrelationToSurface( TestList, hydrogen, Surface, LC );
[c4d4df]163 // put pair correlation into bins and check with no range
[8db598]164// OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap );
[e138de]165 binmap = BinData( surfacemap, 0.5, 0., 0. );
[c4d4df]166 CPPUNIT_ASSERT_EQUAL( (size_t)1, binmap->size() );
[8db598]167 OutputCorrelation ( (ofstream *)&cout, binmap );
[c4d4df]168 tester = binmap->begin();
169 CPPUNIT_ASSERT_EQUAL( 0., tester->first );
170 CPPUNIT_ASSERT_EQUAL( 4, tester->second );
171
172};
173
[bbc338]174void AnalysisCorrelationToSurfaceUnitTest::CorrelationToSurfaceHydrogenBinRangeTest()
[c4d4df]175{
176 BinPairMap::iterator tester;
[e138de]177 surfacemap = CorrelationToSurface( TestList, hydrogen, Surface, LC );
[8db598]178// OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap );
[c4d4df]179 // ... and check with [0., 2.] range
[e138de]180 binmap = BinData( surfacemap, 0.5, 0., 2. );
[c4d4df]181 CPPUNIT_ASSERT_EQUAL( (size_t)5, binmap->size() );
[8db598]182// OutputCorrelation ( (ofstream *)&cout, binmap );
[c4d4df]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
[bbc338]192void AnalysisCorrelationToSurfaceUnitTest::CorrelationToSurfaceCarbonBinNoRangeTest()
193{
194 BinPairMap::iterator tester;
[e138de]195 surfacemap = CorrelationToSurface( TestList, carbon, Surface, LC );
[8db598]196// OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap );
[bbc338]197 // put pair correlation into bins and check with no range
[e138de]198 binmap = BinData( surfacemap, 0.5, 0., 0. );
[3b9e34]199 //OutputCorrelation ( (ofstream *)&cout, binmap );
[c6394d]200 CPPUNIT_ASSERT_EQUAL( (size_t)9, binmap->size() );
[bbc338]201 // inside point is first and must have negative value
[8db598]202 tester = binmap->lower_bound(4.25-0.5); // start depends on the min value and
[bbc338]203 CPPUNIT_ASSERT( tester != binmap->end() );
204 CPPUNIT_ASSERT_EQUAL( 3, tester->second );
205 // inner point
[8db598]206 tester = binmap->lower_bound(0.);
[bbc338]207 CPPUNIT_ASSERT( tester != binmap->end() );
208 CPPUNIT_ASSERT_EQUAL( 1, tester->second );
209};
210
211void AnalysisCorrelationToSurfaceUnitTest::CorrelationToSurfaceCarbonBinRangeTest()
212{
213 BinPairMap::iterator tester;
[e138de]214 surfacemap = CorrelationToSurface( TestList, carbon, Surface, LC );
[8db598]215// OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap );
[bbc338]216 // ... and check with [0., 2.] range
[e138de]217 binmap = BinData( surfacemap, 0.5, -2., 4. );
[3b9e34]218 //OutputCorrelation ( (ofstream *)&cout, binmap );
[bbc338]219 CPPUNIT_ASSERT_EQUAL( (size_t)13, binmap->size() );
220 // three outside points
[8db598]221 tester = binmap->lower_bound(4.25-0.5);
[bbc338]222 CPPUNIT_ASSERT( tester != binmap->end() );
223 CPPUNIT_ASSERT_EQUAL( 3, tester->second );
224 // inner point
[8db598]225 tester = binmap->lower_bound(0.);
[bbc338]226 CPPUNIT_ASSERT( tester != binmap->end() );
227 CPPUNIT_ASSERT_EQUAL( 1, tester->second );
228};
Note: See TracBrowser for help on using the repository browser.