Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/unittests/AnalysisCorrelationToSurfaceUnitTest.cpp

    rc6394d r8db598  
    6060
    6161  // construct molecule (tetraeder of hydrogens) base
     62  TestSurfaceMolecule = new molecule(tafel);
     63  Walker = new atom();
     64  Walker->type = hydrogen;
     65  Walker->node->Init(1., 0., 1. );
     66  TestSurfaceMolecule->AddAtom(Walker);
     67  Walker = new atom();
     68  Walker->type = hydrogen;
     69  Walker->node->Init(0., 1., 1. );
     70  TestSurfaceMolecule->AddAtom(Walker);
     71  Walker = new atom();
     72  Walker->type = hydrogen;
     73  Walker->node->Init(1., 1., 0. );
     74  TestSurfaceMolecule->AddAtom(Walker);
     75  Walker = new atom();
     76  Walker->type = hydrogen;
     77  Walker->node->Init(0., 0., 0. );
     78  TestSurfaceMolecule->AddAtom(Walker);
     79
     80  // check that TestMolecule was correctly constructed
     81  CPPUNIT_ASSERT_EQUAL( TestSurfaceMolecule->AtomCount, 4 );
     82
     83  TestList = new MoleculeListClass;
     84  TestSurfaceMolecule->ActiveFlag = true;
     85  TestList->insert(TestSurfaceMolecule);
     86
     87  // init tesselation and linked cell
     88  Surface = new Tesselation;
     89  LC = new LinkedCell(TestSurfaceMolecule, 5.);
     90  FindNonConvexBorder(TestSurfaceMolecule, Surface, (const LinkedCell *&)LC, 2.5, NULL);
     91
     92  // add outer atoms
    6293  TestMolecule = new molecule(tafel);
    6394  Walker = new atom();
    64   Walker->type = hydrogen;
    65   Walker->node->Init(1., 0., 1. );
    66   TestMolecule->AddAtom(Walker);
    67   Walker = new atom();
    68   Walker->type = hydrogen;
    69   Walker->node->Init(0., 1., 1. );
    70   TestMolecule->AddAtom(Walker);
    71   Walker = new atom();
    72   Walker->type = hydrogen;
    73   Walker->node->Init(1., 1., 0. );
    74   TestMolecule->AddAtom(Walker);
    75   Walker = new atom();
    76   Walker->type = hydrogen;
    77   Walker->node->Init(0., 0., 0. );
    78   TestMolecule->AddAtom(Walker);
    79 
    80   // check that TestMolecule was correctly constructed
    81   CPPUNIT_ASSERT_EQUAL( TestMolecule->AtomCount, 4 );
    82 
    83   TestList = new MoleculeListClass;
     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);
    84111  TestMolecule->ActiveFlag = true;
    85112  TestList->insert(TestMolecule);
    86 
    87   // init tesselation and linked cell
    88   Surface = new Tesselation;
    89   FindNonConvexBorder(TestMolecule, Surface, (const LinkedCell *&)LC, 2.5, NULL);
    90   LC = new LinkedCell(TestMolecule, 5.);
    91   CPPUNIT_ASSERT_EQUAL( (size_t)4, Surface->PointsOnBoundary.size() );
    92   CPPUNIT_ASSERT_EQUAL( (size_t)6, Surface->LinesOnBoundary.size() );
    93   CPPUNIT_ASSERT_EQUAL( (size_t)4, Surface->TrianglesOnBoundary.size() );
    94 
    95   // add outer atoms
    96   Walker = new atom();
    97   Walker->type = carbon;
    98   Walker->node->Init(4., 0., 4. );
    99   TestMolecule->AddAtom(Walker);
    100   Walker = new atom();
    101   Walker->type = carbon;
    102   Walker->node->Init(0., 4., 4. );
    103   TestMolecule->AddAtom(Walker);
    104   Walker = new atom();
    105   Walker->type = carbon;
    106   Walker->node->Init(4., 4., 0. );
    107   TestMolecule->AddAtom(Walker);
    108   // add inner atoms
    109   Walker = new atom();
    110   Walker->type = carbon;
    111   Walker->node->Init(0.5, 0.5, 0.5 );
    112   TestMolecule->AddAtom(Walker);
    113113
    114114  // init maps
     
    136136
    137137
     138/** Checks whether setup() does the right thing.
     139 */
     140void AnalysisCorrelationToSurfaceUnitTest::SurfaceTest()
     141{
     142  CPPUNIT_ASSERT_EQUAL( 4, TestSurfaceMolecule->AtomCount );
     143  CPPUNIT_ASSERT_EQUAL( 4, TestMolecule->AtomCount );
     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
    138150void AnalysisCorrelationToSurfaceUnitTest::CorrelationToSurfaceTest()
    139151{
    140152  // do the pair correlation
    141153  surfacemap = CorrelationToSurface( TestList, hydrogen, Surface, LC );
     154//  OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap );
    142155  CPPUNIT_ASSERT( surfacemap != NULL );
    143156  CPPUNIT_ASSERT_EQUAL( (size_t)4, surfacemap->size() );
     
    149162  surfacemap = CorrelationToSurface( TestList, hydrogen, Surface, LC );
    150163  // put pair correlation into bins and check with no range
     164//  OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap );
    151165  binmap = BinData( surfacemap, 0.5, 0., 0. );
    152166  CPPUNIT_ASSERT_EQUAL( (size_t)1, binmap->size() );
    153   //OutputCorrelation ( binmap );
     167  OutputCorrelation ( (ofstream *)&cout, binmap );
    154168  tester = binmap->begin();
    155169  CPPUNIT_ASSERT_EQUAL( 0., tester->first );
     
    162176  BinPairMap::iterator tester;
    163177  surfacemap = CorrelationToSurface( TestList, hydrogen, Surface, LC );
     178//  OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap );
    164179  // ... and check with [0., 2.] range
    165180  binmap = BinData( surfacemap, 0.5, 0., 2. );
    166181  CPPUNIT_ASSERT_EQUAL( (size_t)5, binmap->size() );
    167   //OutputCorrelation ( binmap );
     182//  OutputCorrelation ( (ofstream *)&cout, binmap );
    168183  tester = binmap->begin();
    169184  CPPUNIT_ASSERT_EQUAL( 0., tester->first );
     
    179194  BinPairMap::iterator tester;
    180195  surfacemap = CorrelationToSurface( TestList, carbon, Surface, LC );
     196//  OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap );
    181197  // put pair correlation into bins and check with no range
    182198  binmap = BinData( surfacemap, 0.5, 0., 0. );
     199  CPPUNIT_ASSERT_EQUAL( (size_t)2, binmap->size() );
    183200  OutputCorrelation ( (ofstream *)&cout, binmap );
    184   CPPUNIT_ASSERT_EQUAL( (size_t)9, binmap->size() );
    185201  // inside point is first and must have negative value
    186   tester = binmap->lower_bound(2.95); // start depends on the min value and
     202  tester = binmap->lower_bound(4.25-0.5); // start depends on the min value and
    187203  CPPUNIT_ASSERT( tester != binmap->end() );
    188204  CPPUNIT_ASSERT_EQUAL( 3, tester->second );
    189205  // inner point
    190   tester = binmap->lower_bound(-0.5);
     206  tester = binmap->lower_bound(0.);
    191207  CPPUNIT_ASSERT( tester != binmap->end() );
    192208  CPPUNIT_ASSERT_EQUAL( 1, tester->second );
     
    197213  BinPairMap::iterator tester;
    198214  surfacemap = CorrelationToSurface( TestList, carbon, Surface, LC );
     215//  OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap );
    199216  // ... and check with [0., 2.] range
    200217  binmap = BinData( surfacemap, 0.5, -2., 4. );
    201   OutputCorrelation ( (ofstream *)&cout, binmap );
    202218  CPPUNIT_ASSERT_EQUAL( (size_t)13, binmap->size() );
     219//  OutputCorrelation ( (ofstream *)&cout, binmap );
    203220  // three outside points
    204   tester = binmap->lower_bound(3.);
     221  tester = binmap->lower_bound(4.25-0.5);
    205222  CPPUNIT_ASSERT( tester != binmap->end() );
    206223  CPPUNIT_ASSERT_EQUAL( 3, tester->second );
    207224  // inner point
    208   tester = binmap->lower_bound(-0.5);
     225  tester = binmap->lower_bound(0.);
    209226  CPPUNIT_ASSERT( tester != binmap->end() );
    210227  CPPUNIT_ASSERT_EQUAL( 1, tester->second );
    211 
    212228};
    213229
Note: See TracChangeset for help on using the changeset viewer.