- Timestamp:
- Apr 27, 2010, 2:25:42 PM (16 years ago)
- Children:
- 90c4460
- Parents:
- 1561e2 (diff), 2bc713 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
molecuilder/src/unittests/AnalysisCorrelationToSurfaceUnitTest.cpp
r1561e2 r075729 70 70 71 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 72 103 TestMolecule = World::getInstance().createMolecule(); 73 104 Walker = World::getInstance().createAtom(); 74 Walker->type = hydrogen; 75 Walker->node->Init(1., 0., 1. ); 76 TestMolecule->AddAtom(Walker); 77 Walker = World::getInstance().createAtom(); 78 Walker->type = hydrogen; 79 Walker->node->Init(0., 1., 1. ); 80 TestMolecule->AddAtom(Walker); 81 Walker = World::getInstance().createAtom(); 82 Walker->type = hydrogen; 83 Walker->node->Init(1., 1., 0. ); 84 TestMolecule->AddAtom(Walker); 85 Walker = World::getInstance().createAtom(); 86 Walker->type = hydrogen; 87 Walker->node->Init(0., 0., 0. ); 88 TestMolecule->AddAtom(Walker); 89 90 // check that TestMolecule was correctly constructed 91 CPPUNIT_ASSERT_EQUAL( TestMolecule->AtomCount, 4 ); 92 93 TestList = World::getInstance().getMolecules(); 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); 94 121 TestMolecule->ActiveFlag = true; 95 122 TestList->insert(TestMolecule); 96 97 // init tesselation and linked cell98 Surface = new Tesselation;99 FindNonConvexBorder(TestMolecule, Surface, (const LinkedCell *&)LC, 2.5, NULL);100 LC = new LinkedCell(TestMolecule, 5.);101 CPPUNIT_ASSERT_EQUAL( (size_t)4, Surface->PointsOnBoundary.size() );102 CPPUNIT_ASSERT_EQUAL( (size_t)6, Surface->LinesOnBoundary.size() );103 CPPUNIT_ASSERT_EQUAL( (size_t)4, Surface->TrianglesOnBoundary.size() );104 105 // add outer atoms106 Walker = World::getInstance().createAtom();107 Walker->type = carbon;108 Walker->node->Init(4., 0., 4. );109 TestMolecule->AddAtom(Walker);110 Walker = World::getInstance().createAtom();111 Walker->type = carbon;112 Walker->node->Init(0., 4., 4. );113 TestMolecule->AddAtom(Walker);114 Walker = World::getInstance().createAtom();115 Walker->type = carbon;116 Walker->node->Init(4., 4., 0. );117 TestMolecule->AddAtom(Walker);118 // add inner atoms119 Walker = World::getInstance().createAtom();120 Walker->type = carbon;121 Walker->node->Init(0.5, 0.5, 0.5 );122 TestMolecule->AddAtom(Walker);123 123 124 124 // init maps … … 145 145 146 146 147 /** Checks whether setup() does the right thing. 148 */ 149 void 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 147 159 void AnalysisCorrelationToSurfaceUnitTest::CorrelationToSurfaceTest() 148 160 { 149 161 // do the pair correlation 150 162 surfacemap = CorrelationToSurface( TestList, hydrogen, Surface, LC ); 163 // OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap ); 151 164 CPPUNIT_ASSERT( surfacemap != NULL ); 152 165 CPPUNIT_ASSERT_EQUAL( (size_t)4, surfacemap->size() ); … … 158 171 surfacemap = CorrelationToSurface( TestList, hydrogen, Surface, LC ); 159 172 // put pair correlation into bins and check with no range 173 // OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap ); 160 174 binmap = BinData( surfacemap, 0.5, 0., 0. ); 161 175 CPPUNIT_ASSERT_EQUAL( (size_t)1, binmap->size() ); 162 //OutputCorrelation (binmap );176 OutputCorrelation ( (ofstream *)&cout, binmap ); 163 177 tester = binmap->begin(); 164 178 CPPUNIT_ASSERT_EQUAL( 0., tester->first ); … … 171 185 BinPairMap::iterator tester; 172 186 surfacemap = CorrelationToSurface( TestList, hydrogen, Surface, LC ); 187 // OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap ); 173 188 // ... and check with [0., 2.] range 174 189 binmap = BinData( surfacemap, 0.5, 0., 2. ); 175 190 CPPUNIT_ASSERT_EQUAL( (size_t)5, binmap->size() ); 176 //OutputCorrelation (binmap );191 // OutputCorrelation ( (ofstream *)&cout, binmap ); 177 192 tester = binmap->begin(); 178 193 CPPUNIT_ASSERT_EQUAL( 0., tester->first ); … … 188 203 BinPairMap::iterator tester; 189 204 surfacemap = CorrelationToSurface( TestList, carbon, Surface, LC ); 205 // OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap ); 190 206 // put pair correlation into bins and check with no range 191 207 binmap = BinData( surfacemap, 0.5, 0., 0. ); 192 CPPUNIT_ASSERT_EQUAL( (size_t)2, binmap->size());193 OutputCorrelation ( (ofstream *)&cout, binmap);208 //OutputCorrelation ( (ofstream *)&cout, binmap ); 209 CPPUNIT_ASSERT_EQUAL( (size_t)9, binmap->size() ); 194 210 // inside point is first and must have negative value 195 tester = binmap->lower_bound( 2.95); // start depends on the min value and211 tester = binmap->lower_bound(4.25-0.5); // start depends on the min value and 196 212 CPPUNIT_ASSERT( tester != binmap->end() ); 197 213 CPPUNIT_ASSERT_EQUAL( 3, tester->second ); 198 214 // inner point 199 tester = binmap->lower_bound( -0.5);215 tester = binmap->lower_bound(0.); 200 216 CPPUNIT_ASSERT( tester != binmap->end() ); 201 217 CPPUNIT_ASSERT_EQUAL( 1, tester->second ); … … 206 222 BinPairMap::iterator tester; 207 223 surfacemap = CorrelationToSurface( TestList, carbon, Surface, LC ); 224 // OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap ); 208 225 // ... and check with [0., 2.] range 209 226 binmap = BinData( surfacemap, 0.5, -2., 4. ); 227 //OutputCorrelation ( (ofstream *)&cout, binmap ); 210 228 CPPUNIT_ASSERT_EQUAL( (size_t)13, binmap->size() ); 211 OutputCorrelation ( (ofstream *)&cout, binmap );212 229 // three outside points 213 tester = binmap->lower_bound( 3.);230 tester = binmap->lower_bound(4.25-0.5); 214 231 CPPUNIT_ASSERT( tester != binmap->end() ); 215 232 CPPUNIT_ASSERT_EQUAL( 3, tester->second ); 216 233 // inner point 217 tester = binmap->lower_bound( -0.5);234 tester = binmap->lower_bound(0.); 218 235 CPPUNIT_ASSERT( tester != binmap->end() ); 219 236 CPPUNIT_ASSERT_EQUAL( 1, tester->second ); 220 221 }; 237 };
Note:
See TracChangeset
for help on using the changeset viewer.
