Changeset 1024cb for src/molecule_graph.cpp
- Timestamp:
- May 31, 2010, 5:32:27 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:
- e08c46
- Parents:
- 42af9e (diff), a7b761b (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - git-author:
- Frederik Heber <heber@…> (05/31/10 17:29:30)
- git-committer:
- Frederik Heber <heber@…> (05/31/10 17:32:27)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/molecule_graph.cpp
r42af9e r1024cb 20 20 #include "World.hpp" 21 21 #include "Helpers/fast_functions.hpp" 22 #include "Helpers/Assert.hpp" 23 22 24 23 25 struct BFSAccounting … … 80 82 flip(atom1, atom2); 81 83 Walker = FindAtom(atom1); 84 ASSERT(Walker,"Could not find an atom with the ID given in dbond file"); 82 85 OtherWalker = FindAtom(atom2); 86 ASSERT(OtherWalker,"Could not find an atom with the ID given in dbond file"); 83 87 AddBond(Walker, OtherWalker); //Add the bond between the two atoms with respective indices. 84 88 } … … 109 113 atom *Walker = NULL; 110 114 atom *OtherWalker = NULL; 111 atom **AtomMap = NULL;112 115 int n[NDIM]; 113 116 double MinDistance, MaxDistance; … … 134 137 135 138 // count atoms in molecule = dimension of matrix (also give each unique name and continuous numbering) 136 CountAtoms(); 137 DoLog(1) && (Log() << Verbose(1) << "AtomCount " << AtomCount << " and bonddistance is " << bonddistance << "." << endl); 138 139 if ((AtomCount > 1) && (bonddistance > 1.)) { 139 DoLog(1) && (Log() << Verbose(1) << "AtomCount " << getAtomCount() << " and bonddistance is " << bonddistance << "." << endl); 140 141 if ((getAtomCount() > 1) && (bonddistance > 1.)) { 140 142 DoLog(2) && (Log() << Verbose(2) << "Creating Linked Cell structure ... " << endl); 141 143 LC = new LinkedCell(this, bonddistance); … … 143 145 // create a list to map Tesselpoint::nr to atom * 144 146 DoLog(2) && (Log() << Verbose(2) << "Creating TesselPoint to atom map ... " << endl); 145 AtomMap = new atom *[AtomCount]; 146 for (int i=0;i<AtomCount;i++) 147 AtomMap[i] = NULL; 148 Walker = start; 149 while (Walker->next != end) { 150 Walker = Walker->next; 151 AtomMap[Walker->nr] = Walker; 147 148 // set numbers for atoms that can later be used 149 int i=0; 150 for(internal_iterator iter = atoms.begin();iter!= atoms.end(); ++iter){ 151 (*iter)->nr = i++; 152 152 } 153 153 … … 161 161 if (List != NULL) { 162 162 for (LinkedCell::LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) { 163 Walker = AtomMap[(*Runner)->nr]; 164 // Log() << Verbose(0) << "Current Atom is " << *Walker << "." << endl; 163 Walker = dynamic_cast<atom*>(*Runner); 164 ASSERT(Walker,"Tesselpoint that was not an atom retrieved from LinkedNode"); 165 //Log() << Verbose(0) << "Current Atom is " << *Walker << "." << endl; 165 166 // 3c. check for possible bond between each atom in this and every one in the 27 cells 166 167 for (n[0] = -1; n[0] <= 1; n[0]++) … … 172 173 for (LinkedCell::LinkedNodes::const_iterator OtherRunner = OtherList->begin(); OtherRunner != OtherList->end(); OtherRunner++) { 173 174 if ((*OtherRunner)->nr > Walker->nr) { 174 OtherWalker = AtomMap[(*OtherRunner)->nr]; 175 // Log() << Verbose(0) << "Current other Atom is " << *OtherWalker << "." << endl; 176 const double distance = OtherWalker->x.PeriodicDistanceSquared(Walker->x, cell_size); 177 // Log() << Verbose(1) << "Checking distance " << distance << " against typical bond length of " << bonddistance*bonddistance << "." << endl; 175 OtherWalker = dynamic_cast<atom*>(*OtherRunner); 176 ASSERT(OtherWalker,"TesselPoint that was not an atom retrieved from LinkedNode"); 177 //Log() << Verbose(1) << "Checking distance " << OtherWalker->x.PeriodicDistanceSquared(&(Walker->x), cell_size) << " against typical bond length of " << bonddistance*bonddistance << "." << endl; 178 178 (BG->*minmaxdistance)(Walker, OtherWalker, MinDistance, MaxDistance, IsAngstroem); 179 const double distance = OtherWalker->x.PeriodicDistanceSquared(Walker->x,cell_size); 179 180 const bool status = (distance <= MaxDistance * MaxDistance) && (distance >= MinDistance * MinDistance); 180 181 // Log() << Verbose(1) << "MinDistance is " << MinDistance << " and MaxDistance is " << MaxDistance << "." << endl; … … 196 197 } 197 198 } 198 delete[](AtomMap);199 199 delete (LC); 200 200 DoLog(1) && (Log() << Verbose(1) << "I detected " << BondCount << " bonds in the molecule with distance " << BondDistance << "." << endl); … … 207 207 ActOnAllAtoms( &atom::OutputBondOfAtom ); 208 208 } else 209 DoLog(1) && (Log() << Verbose(1) << "AtomCount is " << AtomCount<< ", thus no bonds, no connections!." << endl);209 DoLog(1) && (Log() << Verbose(1) << "AtomCount is " << getAtomCount() << ", thus no bonds, no connections!." << endl); 210 210 DoLog(0) && (Log() << Verbose(0) << "End of CreateAdjacencyList." << endl); 211 211 if (free_BG) … … 249 249 DoLog(0) && (Log() << Verbose(0) << " done." << endl); 250 250 } else { 251 DoLog(1) && (Log() << Verbose(1) << "BondCount is " << BondCount << ", no bonds between any of the " << AtomCount<< " atoms." << endl);251 DoLog(1) && (Log() << Verbose(1) << "BondCount is " << BondCount << ", no bonds between any of the " << getAtomCount() << " atoms." << endl); 252 252 } 253 253 DoLog(0) && (Log() << Verbose(0) << No << " bonds could not be corrected." << endl); … … 469 469 void DepthFirstSearchAnalysis_Init(struct DFSAccounting &DFS, const molecule * const mol) 470 470 { 471 DFS.AtomStack = new StackClass<atom *> (mol-> AtomCount);471 DFS.AtomStack = new StackClass<atom *> (mol->getAtomCount()); 472 472 DFS.CurrentGraphNr = 0; 473 473 DFS.ComponentNumber = 0; … … 510 510 bond *Binder = NULL; 511 511 512 if ( AtomCount== 0)512 if (getAtomCount() == 0) 513 513 return SubGraphs; 514 514 DoLog(0) && (Log() << Verbose(0) << "Begin of DepthFirstSearchAnalysis" << endl); 515 515 DepthFirstSearchAnalysis_Init(DFS, this); 516 516 517 DFS.Root = start->next;518 while (DFS.Root != end) { // if there any atoms at all517 for (molecule::const_iterator iter = begin(); iter != end();) { 518 DFS.Root = *iter; 519 519 // (1) mark all edges unused, empty stack, set atom->GraphNr = -1 for all 520 520 DFS.AtomStack->ClearStack(); … … 556 556 557 557 // step on to next root 558 while (( DFS.Root != end) && (DFS.Root->GraphNr != -1)) {559 //Log() << Verbose(1) << "Current next subgraph root candidate is " << Root->Name << "." << endl;560 if ( DFS.Root->GraphNr != -1) // if already discovered, step on561 DFS.Root = DFS.Root->next;558 while ((iter != end()) && ((*iter)->GraphNr != -1)) { 559 //Log() << Verbose(1) << "Current next subgraph root candidate is " << (*iter)->Name << "." << endl; 560 if ((*iter)->GraphNr != -1) // if already discovered, step on 561 iter++; 562 562 } 563 563 } … … 864 864 if (MinRingSize != -1) { // if rings are present 865 865 // go over all atoms 866 Root = mol->start; 867 while (Root->next != mol->end) { 868 Root = Root->next; 869 870 if (MinimumRingSize[Root->GetTrueFather()->nr] == mol->AtomCount) { // check whether MinimumRingSize is set, if not BFS to next where it is 866 for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) { 867 Root = *iter; 868 869 if (MinimumRingSize[Root->GetTrueFather()->nr] == mol->getAtomCount()) { // check whether MinimumRingSize is set, if not BFS to next where it is 871 870 Walker = Root; 872 871 873 872 //Log() << Verbose(1) << "---------------------------------------------------------------------------------------------------------" << endl; 874 CyclicStructureAnalysis_BFSToNextCycle(Root, Walker, MinimumRingSize, mol-> AtomCount);873 CyclicStructureAnalysis_BFSToNextCycle(Root, Walker, MinimumRingSize, mol->getAtomCount()); 875 874 876 875 } … … 902 901 int MinRingSize = -1; 903 902 904 InitializeBFSAccounting(BFS, AtomCount);903 InitializeBFSAccounting(BFS, getAtomCount()); 905 904 906 905 //Log() << Verbose(1) << "Back edge list - "; … … 1145 1144 CurrentBondsOfAtom = -1; // we count one too far due to line end 1146 1145 // parse into structure 1147 if ((AtomNr >= 0) && (AtomNr < AtomCount)) {1146 if ((AtomNr >= 0) && (AtomNr < getAtomCount())) { 1148 1147 Walker = ListOfAtoms[AtomNr]; 1149 1148 while (!line.eof()) … … 1324 1323 AddedAtomList[Root->nr] = Mol->AddCopyAtom(Root); 1325 1324 1326 BreadthFirstSearchAdd_Init(BFS, Root, BondOrder, AtomCount, AddedAtomList);1325 BreadthFirstSearchAdd_Init(BFS, Root, BondOrder, getAtomCount(), AddedAtomList); 1327 1326 1328 1327 // and go on ... Queue always contains all lightgray vertices … … 1382 1381 // fill parent list with sons 1383 1382 DoLog(3) && (Log() << Verbose(3) << "Filling Parent List." << endl); 1384 atom *Walker = mol->start; 1385 while (Walker->next != mol->end) { 1386 Walker = Walker->next; 1387 ParentList[Walker->father->nr] = Walker; 1383 for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) { 1384 ParentList[(*iter)->father->nr] = (*iter); 1388 1385 // Outputting List for debugging 1389 DoLog(4) && (Log() << Verbose(4) << "Son[" << Walker->father->nr << "] of " << Walker->father << " is " << ParentList[Walker->father->nr] << "." << endl); 1390 } 1391 1392 } 1393 ; 1386 DoLog(4) && (Log() << Verbose(4) << "Son[" << (*iter)->father->nr << "] of " << (*iter)->father << " is " << ParentList[(*iter)->father->nr] << "." << endl); 1387 } 1388 }; 1394 1389 1395 1390 void BuildInducedSubgraph_Finalize(atom **&ParentList) … … 1402 1397 { 1403 1398 bool status = true; 1404 atom *Walker = NULL;1405 1399 atom *OtherAtom = NULL; 1406 1400 // check each entry of parent list and if ok (one-to-and-onto matching) create bonds 1407 1401 DoLog(3) && (Log() << Verbose(3) << "Creating bonds." << endl); 1408 Walker = Father->start; 1409 while (Walker->next != Father->end) { 1410 Walker = Walker->next; 1411 if (ParentList[Walker->nr] != NULL) { 1412 if (ParentList[Walker->nr]->father != Walker) { 1402 for (molecule::const_iterator iter = Father->begin(); iter != Father->end(); ++iter) { 1403 if (ParentList[(*iter)->nr] != NULL) { 1404 if (ParentList[(*iter)->nr]->father != (*iter)) { 1413 1405 status = false; 1414 1406 } else { 1415 for (BondList::const_iterator Runner = Walker->ListOfBonds.begin(); Runner != Walker->ListOfBonds.end(); (++Runner)) {1416 OtherAtom = (*Runner)->GetOtherAtom( Walker);1407 for (BondList::const_iterator Runner = (*iter)->ListOfBonds.begin(); Runner != (*iter)->ListOfBonds.end(); (++Runner)) { 1408 OtherAtom = (*Runner)->GetOtherAtom((*iter)); 1417 1409 if (ParentList[OtherAtom->nr] != NULL) { // if otheratom is also a father of an atom on this molecule, create the bond 1418 DoLog(4) && (Log() << Verbose(4) << "Endpoints of Bond " << (*Runner) << " are both present: " << ParentList[ Walker->nr]->getName() << " and " << ParentList[OtherAtom->nr]->getName() << "." << endl);1419 mol->AddBond(ParentList[ Walker->nr], ParentList[OtherAtom->nr], (*Runner)->BondDegree);1410 DoLog(4) && (Log() << Verbose(4) << "Endpoints of Bond " << (*Runner) << " are both present: " << ParentList[(*iter)->nr]->getName() << " and " << ParentList[OtherAtom->nr]->getName() << "." << endl); 1411 mol->AddBond(ParentList[(*iter)->nr], ParentList[OtherAtom->nr], (*Runner)->BondDegree); 1420 1412 } 1421 1413 } … … 1440 1432 bool status = true; 1441 1433 atom **ParentList = NULL; 1442 1443 1434 DoLog(2) && (Log() << Verbose(2) << "Begin of BuildInducedSubgraph." << endl); 1444 BuildInducedSubgraph_Init(ParentList, Father-> AtomCount);1435 BuildInducedSubgraph_Init(ParentList, Father->getAtomCount()); 1445 1436 BuildInducedSubgraph_FillParentList(this, Father, ParentList); 1446 1437 status = BuildInducedSubgraph_CreateBondsFromParent(this, Father, ParentList);
Note:
See TracChangeset
for help on using the changeset viewer.