Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/unittests/AnalysisCorrelationToSurfaceUnitTest.cpp

    r8db598 rc6394d  
    6060
    6161  // construct molecule (tetraeder of hydrogens) base
    62   TestSurfaceMolecule = new molecule(tafel);
     62  TestMolecule = new molecule(tafel);
    6363  Walker = new atom();
    6464  Walker->type = hydrogen;
    6565  Walker->node->Init(1., 0., 1. );
    66   TestSurfaceMolecule->AddAtom(Walker);
     66  TestMolecule->AddAtom(Walker);
    6767  Walker = new atom();
    6868  Walker->type = hydrogen;
    6969  Walker->node->Init(0., 1., 1. );
    70   TestSurfaceMolecule->AddAtom(Walker);
     70  TestMolecule->AddAtom(Walker);
    7171  Walker = new atom();
    7272  Walker->type = hydrogen;
    7373  Walker->node->Init(1., 1., 0. );
    74   TestSurfaceMolecule->AddAtom(Walker);
     74  TestMolecule->AddAtom(Walker);
    7575  Walker = new atom();
    7676  Walker->type = hydrogen;
    7777  Walker->node->Init(0., 0., 0. );
    78   TestSurfaceMolecule->AddAtom(Walker);
     78  TestMolecule->AddAtom(Walker);
    7979
    8080  // check that TestMolecule was correctly constructed
    81   CPPUNIT_ASSERT_EQUAL( TestSurfaceMolecule->AtomCount, 4 );
     81  CPPUNIT_ASSERT_EQUAL( TestMolecule->AtomCount, 4 );
    8282
    8383  TestList = new MoleculeListClass;
    84   TestSurfaceMolecule->ActiveFlag = true;
    85   TestList->insert(TestSurfaceMolecule);
     84  TestMolecule->ActiveFlag = true;
     85  TestList->insert(TestMolecule);
    8686
    8787  // init tesselation and linked cell
    8888  Surface = new Tesselation;
    89   LC = new LinkedCell(TestSurfaceMolecule, 5.);
    90   FindNonConvexBorder(TestSurfaceMolecule, Surface, (const LinkedCell *&)LC, 2.5, NULL);
     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() );
    9194
    9295  // add outer atoms
    93   TestMolecule = new molecule(tafel);
    9496  Walker = new atom();
    9597  Walker->type = carbon;
     
    109111  Walker->node->Init(0.5, 0.5, 0.5 );
    110112  TestMolecule->AddAtom(Walker);
    111   TestMolecule->ActiveFlag = true;
    112   TestList->insert(TestMolecule);
    113113
    114114  // init maps
     
    136136
    137137
    138 /** Checks whether setup() does the right thing.
    139  */
    140 void 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 
    150138void AnalysisCorrelationToSurfaceUnitTest::CorrelationToSurfaceTest()
    151139{
    152140  // do the pair correlation
    153141  surfacemap = CorrelationToSurface( TestList, hydrogen, Surface, LC );
    154 //  OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap );
    155142  CPPUNIT_ASSERT( surfacemap != NULL );
    156143  CPPUNIT_ASSERT_EQUAL( (size_t)4, surfacemap->size() );
     
    162149  surfacemap = CorrelationToSurface( TestList, hydrogen, Surface, LC );
    163150  // put pair correlation into bins and check with no range
    164 //  OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap );
    165151  binmap = BinData( surfacemap, 0.5, 0., 0. );
    166152  CPPUNIT_ASSERT_EQUAL( (size_t)1, binmap->size() );
    167   OutputCorrelation ( (ofstream *)&cout, binmap );
     153  //OutputCorrelation ( binmap );
    168154  tester = binmap->begin();
    169155  CPPUNIT_ASSERT_EQUAL( 0., tester->first );
     
    176162  BinPairMap::iterator tester;
    177163  surfacemap = CorrelationToSurface( TestList, hydrogen, Surface, LC );
    178 //  OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap );
    179164  // ... and check with [0., 2.] range
    180165  binmap = BinData( surfacemap, 0.5, 0., 2. );
    181166  CPPUNIT_ASSERT_EQUAL( (size_t)5, binmap->size() );
    182 //  OutputCorrelation ( (ofstream *)&cout, binmap );
     167  //OutputCorrelation ( binmap );
    183168  tester = binmap->begin();
    184169  CPPUNIT_ASSERT_EQUAL( 0., tester->first );
     
    194179  BinPairMap::iterator tester;
    195180  surfacemap = CorrelationToSurface( TestList, carbon, Surface, LC );
    196 //  OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap );
    197181  // put pair correlation into bins and check with no range
    198182  binmap = BinData( surfacemap, 0.5, 0., 0. );
    199   CPPUNIT_ASSERT_EQUAL( (size_t)2, binmap->size() );
    200183  OutputCorrelation ( (ofstream *)&cout, binmap );
     184  CPPUNIT_ASSERT_EQUAL( (size_t)9, binmap->size() );
    201185  // inside point is first and must have negative value
    202   tester = binmap->lower_bound(4.25-0.5); // start depends on the min value and
     186  tester = binmap->lower_bound(2.95); // start depends on the min value and
    203187  CPPUNIT_ASSERT( tester != binmap->end() );
    204188  CPPUNIT_ASSERT_EQUAL( 3, tester->second );
    205189  // inner point
    206   tester = binmap->lower_bound(0.);
     190  tester = binmap->lower_bound(-0.5);
    207191  CPPUNIT_ASSERT( tester != binmap->end() );
    208192  CPPUNIT_ASSERT_EQUAL( 1, tester->second );
     
    213197  BinPairMap::iterator tester;
    214198  surfacemap = CorrelationToSurface( TestList, carbon, Surface, LC );
    215 //  OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap );
    216199  // ... and check with [0., 2.] range
    217200  binmap = BinData( surfacemap, 0.5, -2., 4. );
     201  OutputCorrelation ( (ofstream *)&cout, binmap );
    218202  CPPUNIT_ASSERT_EQUAL( (size_t)13, binmap->size() );
    219 //  OutputCorrelation ( (ofstream *)&cout, binmap );
    220203  // three outside points
    221   tester = binmap->lower_bound(4.25-0.5);
     204  tester = binmap->lower_bound(3.);
    222205  CPPUNIT_ASSERT( tester != binmap->end() );
    223206  CPPUNIT_ASSERT_EQUAL( 3, tester->second );
    224207  // inner point
    225   tester = binmap->lower_bound(0.);
     208  tester = binmap->lower_bound(-0.5);
    226209  CPPUNIT_ASSERT( tester != binmap->end() );
    227210  CPPUNIT_ASSERT_EQUAL( 1, tester->second );
     211
    228212};
    229213
Note: See TracChangeset for help on using the changeset viewer.