- Timestamp:
- Apr 26, 2010, 3:42:45 PM (15 years ago)
- Branches:
- Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Added_ParseSaveFragmentResults, AddingActions_SaveParseParticleParameters, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_ParticleName_to_Atom, Adding_StructOpt_integration_tests, AtomFragments, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.5.4, Candidate_v1.6.0, Candidate_v1.6.1, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, CombiningParticlePotentialParsing, Combining_Subpackages, Debian_Package_split, Debian_package_split_molecuildergui_only, Disabling_MemDebug, Docu_Python_wait, EmpiricalPotential_contain_HomologyGraph, EmpiricalPotential_contain_HomologyGraph_documentation, Enable_parallel_make_install, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, FitPartialCharges_GlobalError, Fix_BoundInBox_CenterInBox_MoleculeActions, Fix_ChargeSampling_PBC, Fix_ChronosMutex, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ForceAnnealing, Fix_IndependentFragmentGrids, Fix_ParseParticles, Fix_ParseParticles_split_forward_backward_Actions, Fix_PopActions, Fix_QtFragmentList_sorted_selection, Fix_Restrictedkeyset_FragmentMolecule, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, Fix_fitting_potentials, Fixes, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, FragmentAction_writes_AtomFragments, FragmentMolecule_checks_bonddegrees, GeometryObjects, Gui_Fixes, Gui_displays_atomic_force_velocity, ImplicitCharges, IndependentFragmentGrids, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, MoreRobust_FragmentAutomation, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PdbParser_setsAtomName, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, Rewrite_FitPartialCharges, RotateToPrincipalAxisSystem_UndoRedo, SaturateAtoms_findBestMatching, SaturateAtoms_singleDegree, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, Switchable_LogView, ThirdParty_MPQC_rebuilt_buildsystem, TrajectoryDependenant_MaxOrder, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, TremoloParser_setsAtomName, Ubuntu_1604_changes, stable
- Children:
- ee7e25
- Parents:
- e138de
- Location:
- src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/molecule_graph.cpp
re138de re5ad5c 147 147 for (LC->n[2] = 0; LC->n[2] < LC->N[2]; LC->n[2]++) { 148 148 const LinkedNodes *List = LC->GetCurrentCell(); 149 //Log() << Verbose(2) << "Current cell is " << LC->n[0] << ", " << LC->n[1] << ", " << LC->n[2] << " with No. " << LC->index << " containing " << List->size() << " points." << endl;149 // Log() << Verbose(2) << "Current cell is " << LC->n[0] << ", " << LC->n[1] << ", " << LC->n[2] << " with No. " << LC->index << " containing " << List->size() << " points." << endl; 150 150 if (List != NULL) { 151 151 for (LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) { 152 152 Walker = AtomMap[(*Runner)->nr]; 153 //Log() << Verbose(0) << "Current Atom is " << *Walker << "." << endl;153 // Log() << Verbose(0) << "Current Atom is " << *Walker << "." << endl; 154 154 // 3c. check for possible bond between each atom in this and every one in the 27 cells 155 155 for (n[0] = -1; n[0] <= 1; n[0]++) … … 157 157 for (n[2] = -1; n[2] <= 1; n[2]++) { 158 158 const LinkedNodes *OtherList = LC->GetRelativeToCurrentCell(n); 159 //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;159 // 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; 160 160 if (OtherList != NULL) { 161 161 for (LinkedNodes::const_iterator OtherRunner = OtherList->begin(); OtherRunner != OtherList->end(); OtherRunner++) { 162 162 if ((*OtherRunner)->nr > Walker->nr) { 163 163 OtherWalker = AtomMap[(*OtherRunner)->nr]; 164 //Log() << Verbose(1) << "Checking distance " << OtherWalker->x.PeriodicDistanceSquared(&(Walker->x), cell_size) << " against typical bond length of " << bonddistance*bonddistance << "." << endl; 164 // Log() << Verbose(0) << "Current other Atom is " << *OtherWalker << "." << endl; 165 const double distance = OtherWalker->x.PeriodicDistanceSquared(&(Walker->x), cell_size); 166 // Log() << Verbose(1) << "Checking distance " << distance << " against typical bond length of " << bonddistance*bonddistance << "." << endl; 165 167 (BG->*minmaxdistance)(Walker, OtherWalker, MinDistance, MaxDistance, IsAngstroem); 166 const double distance = OtherWalker->x.PeriodicDistanceSquared(&(Walker->x), cell_size);167 168 const bool status = (distance <= MaxDistance * MaxDistance) && (distance >= MinDistance * MinDistance); 168 if ((OtherWalker->father->nr > Walker->father->nr) && (status)) { // create bond if distance is smaller 169 //Log() << Verbose(1) << "Adding Bond between " << *Walker << " and " << *OtherWalker << " in distance " << sqrt(distance) << "." << endl; 170 AddBond(Walker->father, OtherWalker->father, 1); // also increases molecule::BondCount 169 // Log() << Verbose(1) << "MinDistance is " << MinDistance << " and MaxDistance is " << MaxDistance << "." << endl; 170 if (OtherWalker->father->nr > Walker->father->nr) { 171 if (status) { // create bond if distance is smaller 172 // Log() << Verbose(1) << "Adding Bond between " << *Walker << " and " << *OtherWalker << " in distance " << sqrt(distance) << "." << endl; 173 AddBond(Walker->father, OtherWalker->father, 1); // also increases molecule::BondCount 174 } else { 175 // Log() << Verbose(1) << "Not Adding: distance too great." << endl; 176 } 171 177 } else { 172 //Log() << Verbose(1) << "Not Adding: Wrong label order or distance too great." << endl;178 // Log() << Verbose(1) << "Not Adding: Wrong order of labels." << endl; 173 179 } 174 180 } -
src/unittests/bondgraphunittest.cpp
re138de re5ad5c 19 19 #include "bondgraph.hpp" 20 20 #include "element.hpp" 21 #include "log.hpp" 21 22 #include "molecule.hpp" 22 23 #include "periodentafel.hpp" … … 41 42 hydrogen = new element; 42 43 hydrogen->Z = 1; 44 hydrogen->CovalentRadius = 0.23; 45 hydrogen->VanDerWaalsRadius = 1.09; 43 46 strcpy(hydrogen->name, "hydrogen"); 44 47 strcpy(hydrogen->symbol, "H"); 45 48 carbon = new element; 46 carbon->Z = 1; 49 carbon->Z = 2; 50 carbon->CovalentRadius = 0.68; 51 carbon->VanDerWaalsRadius = 1.7; 47 52 strcpy(carbon->name, "carbon"); 48 53 strcpy(carbon->symbol, "C"); … … 57 62 TestMolecule = new molecule(tafel); 58 63 Walker = new atom(); 59 Walker->type = hydrogen;64 Walker->type = carbon; 60 65 Walker->node->Init(1., 0., 1. ); 61 66 TestMolecule->AddAtom(Walker); 62 67 Walker = new atom(); 63 Walker->type = hydrogen;68 Walker->type = carbon; 64 69 Walker->node->Init(0., 1., 1. ); 65 70 TestMolecule->AddAtom(Walker); 66 71 Walker = new atom(); 67 Walker->type = hydrogen;72 Walker->type = carbon; 68 73 Walker->node->Init(1., 1., 0. ); 69 74 TestMolecule->AddAtom(Walker); 70 75 Walker = new atom(); 71 Walker->type = hydrogen;76 Walker->type = carbon; 72 77 Walker->node->Init(0., 0., 0. ); 73 78 TestMolecule->AddAtom(Walker); … … 77 82 78 83 // create a small file with table 84 dummyname = new string("dummy.dat"); 79 85 filename = new string("test.dat"); 80 86 ofstream test(filename->c_str()); … … 91 97 remove(filename->c_str()); 92 98 delete(filename); 99 delete(dummyname); 93 100 delete(BG); 94 101 … … 112 119 /** UnitTest for BondGraphTest::ConstructBondGraph(). 113 120 */ 114 void BondGraphTest::ConstructGraph Test()121 void BondGraphTest::ConstructGraphFromTableTest() 115 122 { 116 123 atom *Walker = TestMolecule->start->next; … … 118 125 CPPUNIT_ASSERT( TestMolecule->end != Walker ); 119 126 CPPUNIT_ASSERT_EQUAL( true , BG->LoadBondLengthTable(*filename) ); 127 CPPUNIT_ASSERT_EQUAL( true , BG->ConstructBondGraph(TestMolecule) ); 128 CPPUNIT_ASSERT_EQUAL( true , Walker->IsBondedTo(Runner) ); 129 }; 130 131 /** UnitTest for BondGraphTest::ConstructBondGraph(). 132 */ 133 void BondGraphTest::ConstructGraphFromCovalentRadiiTest() 134 { 135 atom *Walker = TestMolecule->start->next; 136 atom *Runner = TestMolecule->end->previous; 137 CPPUNIT_ASSERT( TestMolecule->end != Walker ); 138 CPPUNIT_ASSERT_EQUAL( false , BG->LoadBondLengthTable(*dummyname) ); 120 139 CPPUNIT_ASSERT_EQUAL( true , BG->ConstructBondGraph(TestMolecule) ); 121 140 CPPUNIT_ASSERT_EQUAL( true , Walker->IsBondedTo(Runner) ); -
src/unittests/bondgraphunittest.hpp
re138de re5ad5c 23 23 CPPUNIT_TEST_SUITE( BondGraphTest) ; 24 24 CPPUNIT_TEST ( LoadTableTest ); 25 CPPUNIT_TEST ( ConstructGraphTest ); 25 CPPUNIT_TEST ( ConstructGraphFromTableTest ); 26 CPPUNIT_TEST ( ConstructGraphFromCovalentRadiiTest ); 26 27 CPPUNIT_TEST_SUITE_END(); 27 28 … … 30 31 void tearDown(); 31 32 void LoadTableTest(); 32 void ConstructGraphTest(); 33 void ConstructGraphFromTableTest(); 34 void ConstructGraphFromCovalentRadiiTest(); 33 35 34 36 private: … … 41 43 BondGraph *BG; 42 44 string *filename; 45 string *dummyname; 43 46 }; 44 47
Note:
See TracChangeset
for help on using the changeset viewer.