Changes in / [ee7e25:b5c2d7]


Ignore:
Location:
src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/molecule_graph.cpp

    ree7e25 rb5c2d7  
    149149        for (LC->n[2] = 0; LC->n[2] < LC->N[2]; LC->n[2]++) {
    150150          const LinkedCell::LinkedNodes *List = LC->GetCurrentCell();
    151 //          Log() << Verbose(2) << "Current cell is " << LC->n[0] << ", " << LC->n[1] << ", " << LC->n[2] << " with No. " << LC->index << " containing " << List->size() << " points." << endl;
     151          //Log() << Verbose(2) << "Current cell is " << LC->n[0] << ", " << LC->n[1] << ", " << LC->n[2] << " with No. " << LC->index << " containing " << List->size() << " points." << endl;
    152152          if (List != NULL) {
    153153            for (LinkedCell::LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) {
    154154              Walker = AtomMap[(*Runner)->nr];
    155 //              Log() << Verbose(0) << "Current Atom is " << *Walker << "." << endl;
     155              //Log() << Verbose(0) << "Current Atom is " << *Walker << "." << endl;
    156156              // 3c. check for possible bond between each atom in this and every one in the 27 cells
    157157              for (n[0] = -1; n[0] <= 1; n[0]++)
     
    159159                  for (n[2] = -1; n[2] <= 1; n[2]++) {
    160160                    const LinkedCell::LinkedNodes *OtherList = LC->GetRelativeToCurrentCell(n);
    161 //                    Log() << Verbose(2) << "Current relative cell is " << LC->n[0] << ", " << LC->n[1] << ", " << LC->n[2] << " with No. " << LC->index << " containing " << List->size() << " points." << endl;
     161                    //Log() << Verbose(2) << "Current relative cell is " << LC->n[0] << ", " << LC->n[1] << ", " << LC->n[2] << " with No. " << LC->index << " containing " << List->size() << " points." << endl;
    162162                    if (OtherList != NULL) {
    163163                      for (LinkedCell::LinkedNodes::const_iterator OtherRunner = OtherList->begin(); OtherRunner != OtherList->end(); OtherRunner++) {
    164164                        if ((*OtherRunner)->nr > Walker->nr) {
    165165                          OtherWalker = AtomMap[(*OtherRunner)->nr];
    166 //                          Log() << Verbose(0) << "Current other Atom is " << *OtherWalker << "." << endl;
     166                          //Log() << Verbose(1) << "Checking distance " << OtherWalker->x.PeriodicDistanceSquared(&(Walker->x), cell_size) << " against typical bond length of " << bonddistance*bonddistance << "." << endl;
     167                          (BG->*minmaxdistance)(Walker, OtherWalker, MinDistance, MaxDistance, IsAngstroem);
    167168                          const double distance = OtherWalker->x.PeriodicDistanceSquared(&(Walker->x), cell_size);
    168 //                          Log() << Verbose(1) << "Checking distance " << distance << " against typical bond length of " << bonddistance*bonddistance << "." << endl;
    169                           (BG->*minmaxdistance)(Walker, OtherWalker, MinDistance, MaxDistance, IsAngstroem);
    170169                          const bool status = (distance <= MaxDistance * MaxDistance) && (distance >= MinDistance * MinDistance);
    171 //                          Log() << Verbose(1) << "MinDistance is " << MinDistance << " and MaxDistance is " << MaxDistance << "." << endl;
    172                           if (OtherWalker->father->nr > Walker->father->nr) {
    173                             if (status) { // create bond if distance is smaller
    174 //                              Log() << Verbose(1) << "Adding Bond between " << *Walker << " and " << *OtherWalker << " in distance " << sqrt(distance) << "." << endl;
    175                               AddBond(Walker->father, OtherWalker->father, 1); // also increases molecule::BondCount
    176                             } else {
    177 //                              Log() << Verbose(1) << "Not Adding: distance too great." << endl;
    178                             }
     170                          if ((OtherWalker->father->nr > Walker->father->nr) && (status)) { // create bond if distance is smaller
     171                            //Log() << Verbose(1) << "Adding Bond between " << *Walker << " and " << *OtherWalker << " in distance " << sqrt(distance) << "." << endl;
     172                            AddBond(Walker->father, OtherWalker->father, 1); // also increases molecule::BondCount
    179173                          } else {
    180 //                            Log() << Verbose(1) << "Not Adding: Wrong order of labels." << endl;
     174                            //Log() << Verbose(1) << "Not Adding: Wrong label order or distance too great." << endl;
    181175                          }
    182176                        }
  • src/unittests/bondgraphunittest.cpp

    ree7e25 rb5c2d7  
    2020#include "bondgraph.hpp"
    2121#include "element.hpp"
    22 #include "log.hpp"
    2322#include "molecule.hpp"
    2423#include "periodentafel.hpp"
     
    4342  hydrogen = new element;
    4443  hydrogen->Z = 1;
    45   hydrogen->CovalentRadius = 0.23;
    46   hydrogen->VanDerWaalsRadius = 1.09;
    4744  strcpy(hydrogen->name, "hydrogen");
    4845  strcpy(hydrogen->symbol, "H");
    4946  carbon = new element;
    50   carbon->Z = 2;
    51   carbon->CovalentRadius = 0.68;
    52   carbon->VanDerWaalsRadius = 1.7;
     47  carbon->Z = 1;
    5348  strcpy(carbon->name, "carbon");
    5449  strcpy(carbon->symbol, "C");
     
    6358  TestMolecule = new molecule(tafel);
    6459  Walker = new atom();
    65   Walker->type = carbon;
     60  Walker->type = hydrogen;
    6661  Walker->node->Init(1., 0., 1. );
    6762  TestMolecule->AddAtom(Walker);
    6863  Walker = new atom();
    69   Walker->type = carbon;
     64  Walker->type = hydrogen;
    7065  Walker->node->Init(0., 1., 1. );
    7166  TestMolecule->AddAtom(Walker);
    7267  Walker = new atom();
    73   Walker->type = carbon;
     68  Walker->type = hydrogen;
    7469  Walker->node->Init(1., 1., 0. );
    7570  TestMolecule->AddAtom(Walker);
    7671  Walker = new atom();
    77   Walker->type = carbon;
     72  Walker->type = hydrogen;
    7873  Walker->node->Init(0., 0., 0. );
    7974  TestMolecule->AddAtom(Walker);
     
    8378
    8479  // create a small file with table
    85   dummyname = new string("dummy.dat");
    8680  filename = new string("test.dat");
    8781  ofstream test(filename->c_str());
     
    9993  remove(filename->c_str());
    10094  delete(filename);
    101   delete(dummyname);
    10295  delete(BG);
    10396
     
    121114/** UnitTest for BondGraphTest::ConstructBondGraph().
    122115 */
    123 void BondGraphTest::ConstructGraphFromTableTest()
     116void BondGraphTest::ConstructGraphTest()
    124117{
    125118  atom *Walker = TestMolecule->start->next;
     
    127120  CPPUNIT_ASSERT( TestMolecule->end != Walker );
    128121  CPPUNIT_ASSERT_EQUAL( true , BG->LoadBondLengthTable(*filename) );
    129   CPPUNIT_ASSERT_EQUAL( true , BG->ConstructBondGraph(TestMolecule) );
    130   CPPUNIT_ASSERT_EQUAL( true , Walker->IsBondedTo(Runner) );
    131 };
    132 
    133 /** UnitTest for BondGraphTest::ConstructBondGraph().
    134  */
    135 void BondGraphTest::ConstructGraphFromCovalentRadiiTest()
    136 {
    137   atom *Walker = TestMolecule->start->next;
    138   atom *Runner = TestMolecule->end->previous;
    139   CPPUNIT_ASSERT( TestMolecule->end != Walker );
    140   CPPUNIT_ASSERT_EQUAL( false , BG->LoadBondLengthTable(*dummyname) );
    141122  CPPUNIT_ASSERT_EQUAL( true , BG->ConstructBondGraph(TestMolecule) );
    142123  CPPUNIT_ASSERT_EQUAL( true , Walker->IsBondedTo(Runner) );
  • src/unittests/bondgraphunittest.hpp

    ree7e25 rb5c2d7  
    2323    CPPUNIT_TEST_SUITE( BondGraphTest) ;
    2424    CPPUNIT_TEST ( LoadTableTest );
    25     CPPUNIT_TEST ( ConstructGraphFromTableTest );
    26     CPPUNIT_TEST ( ConstructGraphFromCovalentRadiiTest );
     25    CPPUNIT_TEST ( ConstructGraphTest );
    2726    CPPUNIT_TEST_SUITE_END();
    2827
     
    3130      void tearDown();
    3231      void LoadTableTest();
    33       void ConstructGraphFromTableTest();
    34       void ConstructGraphFromCovalentRadiiTest();
     32      void ConstructGraphTest();
    3533
    3634private:
     
    4341      BondGraph *BG;
    4442      string *filename;
    45       string *dummyname;
    4643};
    4744
Note: See TracChangeset for help on using the changeset viewer.