Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/unittests/AnalysisCorrelationToSurfaceUnitTest.cpp

    rc4d4df r7ea9e6  
    3333
    3434  // init private all pointers to zero
     35  TestList = NULL;
    3536  TestMolecule = NULL;
    3637  hydrogen = NULL;
     
    4142  LC = NULL;
    4243
    43 
    4444  // construct element
    4545  hydrogen = new element;
    4646  hydrogen->Z = 1;
    4747  strcpy(hydrogen->name, "hydrogen");
    48   hydrogen->symbol[0] = 'H';
     48  strcpy(hydrogen->symbol, "H");
     49  carbon = new element;
     50  carbon->Z = 6;
     51  strcpy(carbon->name, "carbon");
     52  strcpy(carbon->symbol, "C");
    4953
    5054  // construct periodentafel
    5155  tafel = new periodentafel;
    5256  tafel->AddElement(hydrogen);
    53 
    54   // construct molecule (tetraeder of hydrogens)
     57  tafel->AddElement(carbon);
     58
     59  // construct molecule (tetraeder of hydrogens) base
    5560  TestMolecule = new molecule(tafel);
    5661  Walker = new atom();
     
    7479  CPPUNIT_ASSERT_EQUAL( TestMolecule->AtomCount, 4 );
    7580
     81  TestList = new MoleculeListClass;
     82  TestMolecule->ActiveFlag = true;
     83  TestList->insert(TestMolecule);
     84
    7685  // init tesselation and linked cell
    7786  Surface = new Tesselation;
    78   TestMolecule->TesselStruct = Surface;
    79   FindNonConvexBorder((ofstream *)&cout, TestMolecule, LC, 2.5, NULL);
     87  FindNonConvexBorder((ofstream *)&cerr, TestMolecule, Surface, (const LinkedCell *&)LC, 2.5, NULL);
    8088  LC = new LinkedCell(TestMolecule, 5.);
    8189  CPPUNIT_ASSERT_EQUAL( (size_t)4, Surface->PointsOnBoundary.size() );
     
    8391  CPPUNIT_ASSERT_EQUAL( (size_t)4, Surface->TrianglesOnBoundary.size() );
    8492
     93  // add outer atoms
     94  Walker = new atom();
     95  Walker->type = carbon;
     96  Walker->node->Init(4., 0., 4. );
     97  TestMolecule->AddAtom(Walker);
     98  Walker = new atom();
     99  Walker->type = carbon;
     100  Walker->node->Init(0., 4., 4. );
     101  TestMolecule->AddAtom(Walker);
     102  Walker = new atom();
     103  Walker->type = carbon;
     104  Walker->node->Init(4., 4., 0. );
     105  TestMolecule->AddAtom(Walker);
     106  // add inner atoms
     107  Walker = new atom();
     108  Walker->type = carbon;
     109  Walker->node->Init(0.5, 0.5, 0.5 );
     110  TestMolecule->AddAtom(Walker);
     111
    85112  // init maps
    86   surfacemap = CorrelationToSurface( (ofstream *)&cout, TestMolecule, hydrogen, Surface, LC );
     113  surfacemap = NULL;
    87114  binmap = NULL;
    88115
     
    98125
    99126  // remove
    100   delete(TestMolecule);
    101   // note that Surface and all the atoms are cleaned by TestMolecule
     127  delete(TestList);
     128  delete(Surface);
     129  // note that all the atoms are cleaned by TestMolecule
    102130  delete(LC);
    103131  delete(tafel);
     
    109137{
    110138  // do the pair correlation
     139  surfacemap = CorrelationToSurface( (ofstream *)&cout, TestList, hydrogen, Surface, LC );
    111140  CPPUNIT_ASSERT( surfacemap != NULL );
    112141  CPPUNIT_ASSERT_EQUAL( (size_t)4, surfacemap->size() );
    113142};
    114143
    115 void AnalysisCorrelationToSurfaceUnitTest::CorrelationToSurfaceBinNoRangeTest()
    116 {
    117   BinPairMap::iterator tester;
     144void AnalysisCorrelationToSurfaceUnitTest::CorrelationToSurfaceHydrogenBinNoRangeTest()
     145{
     146  BinPairMap::iterator tester;
     147  surfacemap = CorrelationToSurface( (ofstream *)&cout, TestList, hydrogen, Surface, LC );
    118148  // put pair correlation into bins and check with no range
    119149  binmap = BinData( (ofstream *)&cout, surfacemap, 0.5, 0., 0. );
     
    126156};
    127157
    128 void AnalysisCorrelationToSurfaceUnitTest::CorrelationToSurfaceBinRangeTest()
    129 {
    130   BinPairMap::iterator tester;
     158void AnalysisCorrelationToSurfaceUnitTest::CorrelationToSurfaceHydrogenBinRangeTest()
     159{
     160  BinPairMap::iterator tester;
     161  surfacemap = CorrelationToSurface( (ofstream *)&cout, TestList, hydrogen, Surface, LC );
    131162  // ... and check with [0., 2.] range
    132163  binmap = BinData( (ofstream *)&cout, surfacemap, 0.5, 0., 2. );
     
    142173};
    143174
     175void AnalysisCorrelationToSurfaceUnitTest::CorrelationToSurfaceCarbonBinNoRangeTest()
     176{
     177  BinPairMap::iterator tester;
     178  surfacemap = CorrelationToSurface( (ofstream *)&cout, TestList, carbon, Surface, LC );
     179  // put pair correlation into bins and check with no range
     180  binmap = BinData( (ofstream *)&cout, surfacemap, 0.5, 0., 0. );
     181  CPPUNIT_ASSERT_EQUAL( (size_t)2, binmap->size() );
     182  OutputCorrelation ( (ofstream *)&cout, binmap );
     183  // inside point is first and must have negative value
     184  tester = binmap->lower_bound(2.95); // start depends on the min value and
     185  CPPUNIT_ASSERT( tester != binmap->end() );
     186  CPPUNIT_ASSERT_EQUAL( 3, tester->second );
     187  // inner point
     188  tester = binmap->lower_bound(-0.5);
     189  CPPUNIT_ASSERT( tester != binmap->end() );
     190  CPPUNIT_ASSERT_EQUAL( 1, tester->second );
     191};
     192
     193void AnalysisCorrelationToSurfaceUnitTest::CorrelationToSurfaceCarbonBinRangeTest()
     194{
     195  BinPairMap::iterator tester;
     196  surfacemap = CorrelationToSurface( (ofstream *)&cout, TestList, carbon, Surface, LC );
     197  // ... and check with [0., 2.] range
     198  binmap = BinData( (ofstream *)&cout, surfacemap, 0.5, -2., 4. );
     199  CPPUNIT_ASSERT_EQUAL( (size_t)13, binmap->size() );
     200  OutputCorrelation ( (ofstream *)&cout, binmap );
     201  // three outside points
     202  tester = binmap->lower_bound(3.);
     203  CPPUNIT_ASSERT( tester != binmap->end() );
     204  CPPUNIT_ASSERT_EQUAL( 3, tester->second );
     205  // inner point
     206  tester = binmap->lower_bound(-0.5);
     207  CPPUNIT_ASSERT( tester != binmap->end() );
     208  CPPUNIT_ASSERT_EQUAL( 1, tester->second );
     209
     210};
     211
    144212/********************************************** Main routine **************************************/
    145213
Note: See TracChangeset for help on using the changeset viewer.