Changes in / [ee7e25:b5c2d7]
- Location:
- src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/molecule_graph.cpp
ree7e25 rb5c2d7 149 149 for (LC->n[2] = 0; LC->n[2] < LC->N[2]; LC->n[2]++) { 150 150 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; 152 152 if (List != NULL) { 153 153 for (LinkedCell::LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) { 154 154 Walker = AtomMap[(*Runner)->nr]; 155 //Log() << Verbose(0) << "Current Atom is " << *Walker << "." << endl;155 //Log() << Verbose(0) << "Current Atom is " << *Walker << "." << endl; 156 156 // 3c. check for possible bond between each atom in this and every one in the 27 cells 157 157 for (n[0] = -1; n[0] <= 1; n[0]++) … … 159 159 for (n[2] = -1; n[2] <= 1; n[2]++) { 160 160 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; 162 162 if (OtherList != NULL) { 163 163 for (LinkedCell::LinkedNodes::const_iterator OtherRunner = OtherList->begin(); OtherRunner != OtherList->end(); OtherRunner++) { 164 164 if ((*OtherRunner)->nr > Walker->nr) { 165 165 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); 167 168 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);170 169 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 179 173 } 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; 181 175 } 182 176 } -
src/unittests/bondgraphunittest.cpp
ree7e25 rb5c2d7 20 20 #include "bondgraph.hpp" 21 21 #include "element.hpp" 22 #include "log.hpp"23 22 #include "molecule.hpp" 24 23 #include "periodentafel.hpp" … … 43 42 hydrogen = new element; 44 43 hydrogen->Z = 1; 45 hydrogen->CovalentRadius = 0.23;46 hydrogen->VanDerWaalsRadius = 1.09;47 44 strcpy(hydrogen->name, "hydrogen"); 48 45 strcpy(hydrogen->symbol, "H"); 49 46 carbon = new element; 50 carbon->Z = 2; 51 carbon->CovalentRadius = 0.68; 52 carbon->VanDerWaalsRadius = 1.7; 47 carbon->Z = 1; 53 48 strcpy(carbon->name, "carbon"); 54 49 strcpy(carbon->symbol, "C"); … … 63 58 TestMolecule = new molecule(tafel); 64 59 Walker = new atom(); 65 Walker->type = carbon;60 Walker->type = hydrogen; 66 61 Walker->node->Init(1., 0., 1. ); 67 62 TestMolecule->AddAtom(Walker); 68 63 Walker = new atom(); 69 Walker->type = carbon;64 Walker->type = hydrogen; 70 65 Walker->node->Init(0., 1., 1. ); 71 66 TestMolecule->AddAtom(Walker); 72 67 Walker = new atom(); 73 Walker->type = carbon;68 Walker->type = hydrogen; 74 69 Walker->node->Init(1., 1., 0. ); 75 70 TestMolecule->AddAtom(Walker); 76 71 Walker = new atom(); 77 Walker->type = carbon;72 Walker->type = hydrogen; 78 73 Walker->node->Init(0., 0., 0. ); 79 74 TestMolecule->AddAtom(Walker); … … 83 78 84 79 // create a small file with table 85 dummyname = new string("dummy.dat");86 80 filename = new string("test.dat"); 87 81 ofstream test(filename->c_str()); … … 99 93 remove(filename->c_str()); 100 94 delete(filename); 101 delete(dummyname);102 95 delete(BG); 103 96 … … 121 114 /** UnitTest for BondGraphTest::ConstructBondGraph(). 122 115 */ 123 void BondGraphTest::ConstructGraph FromTableTest()116 void BondGraphTest::ConstructGraphTest() 124 117 { 125 118 atom *Walker = TestMolecule->start->next; … … 127 120 CPPUNIT_ASSERT( TestMolecule->end != Walker ); 128 121 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) );141 122 CPPUNIT_ASSERT_EQUAL( true , BG->ConstructBondGraph(TestMolecule) ); 142 123 CPPUNIT_ASSERT_EQUAL( true , Walker->IsBondedTo(Runner) ); -
src/unittests/bondgraphunittest.hpp
ree7e25 rb5c2d7 23 23 CPPUNIT_TEST_SUITE( BondGraphTest) ; 24 24 CPPUNIT_TEST ( LoadTableTest ); 25 CPPUNIT_TEST ( ConstructGraphFromTableTest ); 26 CPPUNIT_TEST ( ConstructGraphFromCovalentRadiiTest ); 25 CPPUNIT_TEST ( ConstructGraphTest ); 27 26 CPPUNIT_TEST_SUITE_END(); 28 27 … … 31 30 void tearDown(); 32 31 void LoadTableTest(); 33 void ConstructGraphFromTableTest(); 34 void ConstructGraphFromCovalentRadiiTest(); 32 void ConstructGraphTest(); 35 33 36 34 private: … … 43 41 BondGraph *BG; 44 42 string *filename; 45 string *dummyname;46 43 }; 47 44
Note:
See TracChangeset
for help on using the changeset viewer.