Changeset 9879f6 for src/molecule_fragmentation.cpp
- Timestamp:
- Mar 5, 2010, 10:16:47 AM (16 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, Candidate_v1.7.0, 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:
- d3347e
- Parents:
- e87acf
- git-author:
- Frederik Heber <heber@…> (03/05/10 10:08:44)
- git-committer:
- Frederik Heber <heber@…> (03/05/10 10:16:47)
- File:
-
- 1 edited
-
src/molecule_fragmentation.cpp (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/molecule_fragmentation.cpp
re87acf r9879f6 38 38 int FragmentCount; 39 39 // get maximum bond degree 40 atom *Walker = start; 41 while (Walker->next != end) { 42 Walker = Walker->next; 43 c = (Walker->ListOfBonds.size() > c) ? Walker->ListOfBonds.size() : c; 40 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) { 41 c = ((*iter)->ListOfBonds.size() > c) ? (*iter)->ListOfBonds.size() : c; 44 42 } 45 43 FragmentCount = NoNonHydrogen*(1 << (c*order)); … … 358 356 map<double, pair<int,int> > * ReMapAdaptiveCriteriaListToValue(map<int, pair<double,int> > *AdaptiveCriteriaList, molecule *mol) 359 357 { 360 atom *Walker = mol->start;358 atom *Walker = NULL; 361 359 map<double, pair<int,int> > *FinalRootCandidates = new map<double, pair<int,int> > ; 362 360 Log() << Verbose(1) << "Root candidate list is: " << endl; … … 390 388 bool MarkUpdateCandidates(bool *AtomMask, map<double, pair<int,int> > &FinalRootCandidates, int Order, molecule *mol) 391 389 { 392 atom *Walker = mol->start;390 atom *Walker = NULL; 393 391 int No = -1; 394 392 bool status = false; … … 434 432 bool molecule::CheckOrderAtSite(bool *AtomMask, Graph *GlobalKeySetList, int Order, int *MinimumRingSize, char *path) 435 433 { 436 atom *Walker = start;437 434 bool status = false; 438 435 … … 456 453 if (AdaptiveCriteriaList->empty()) { 457 454 eLog() << Verbose(2) << "Unable to parse file, incrementing all." << endl; 458 while (Walker->next != end) { 459 Walker = Walker->next; 455 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) { 460 456 #ifdef ADDHYDROGEN 461 if ( Walker->type->Z != 1) // skip hydrogen457 if ((*iter)->type->Z != 1) // skip hydrogen 462 458 #endif 463 459 { 464 AtomMask[ Walker->nr] = true; // include all (non-hydrogen) atoms460 AtomMask[(*iter)->nr] = true; // include all (non-hydrogen) atoms 465 461 status = true; 466 462 } … … 477 473 Free(&FinalRootCandidates); 478 474 } else { // global increase of Bond Order 479 while (Walker->next != end) { 480 Walker = Walker->next; 475 for(molecule::const_iterator iter = begin(); iter != end(); ++iter) { 481 476 #ifdef ADDHYDROGEN 482 if ( Walker->type->Z != 1) // skip hydrogen477 if ((*iter)->type->Z != 1) // skip hydrogen 483 478 #endif 484 479 { 485 AtomMask[ Walker->nr] = true; // include all (non-hydrogen) atoms486 if ((Order != 0) && ( Walker->AdaptiveOrder < Order)) // && (Walker->AdaptiveOrder < MinimumRingSize[Walker->nr]))480 AtomMask[(*iter)->nr] = true; // include all (non-hydrogen) atoms 481 if ((Order != 0) && ((*iter)->AdaptiveOrder < Order)) // && ((*iter)->AdaptiveOrder < MinimumRingSize[(*iter)->nr])) 487 482 status = true; 488 483 } … … 523 518 524 519 return true; 520 }; 521 522 523 524 /** Creates a lookup table for true father's Atom::Nr -> atom ptr. 525 * \param *start begin of list (STL iterator, i.e. first item) 526 * \paran *end end of list (STL iterator, i.e. one past last item) 527 * \param **Lookuptable pointer to return allocated lookup table (should be NULL on start) 528 * \param count optional predetermined size for table (otherwise we set the count to highest true father id) 529 * \return true - success, false - failure 530 */ 531 bool molecule::CreateFatherLookupTable(atom **&LookupTable, int count) 532 { 533 bool status = true; 534 int AtomNo; 535 536 if (LookupTable != NULL) { 537 Log() << Verbose(0) << "Pointer for Lookup table is not NULL! Aborting ..." <<endl; 538 return false; 539 } 540 541 // count them 542 if (count == 0) { 543 for (molecule::iterator iter = begin(); iter != end(); ++iter) { // create a lookup table (Atom::nr -> atom) used as a marker table lateron 544 count = (count < (*iter)->GetTrueFather()->nr) ? (*iter)->GetTrueFather()->nr : count; 545 } 546 } 547 if (count <= 0) { 548 Log() << Verbose(0) << "Count of lookup list is 0 or less." << endl; 549 return false; 550 } 551 552 // allocate and fill 553 LookupTable = Calloc<atom *>(count, "CreateFatherLookupTable - **LookupTable"); 554 if (LookupTable == NULL) { 555 eLog() << Verbose(0) << "LookupTable memory allocation failed!" << endl; 556 performCriticalExit(); 557 status = false; 558 } else { 559 for (molecule::iterator iter = begin(); iter != end(); ++iter) { 560 AtomNo = (*iter)->GetTrueFather()->nr; 561 if ((AtomNo >= 0) && (AtomNo < count)) { 562 //*out << "Setting LookupTable[" << AtomNo << "] to " << *(*iter) << endl; 563 LookupTable[AtomNo] = (*iter); 564 } else { 565 Log() << Verbose(0) << "Walker " << *(*iter) << " exceeded range of nuclear ids [0, " << count << ")." << endl; 566 status = false; 567 break; 568 } 569 } 570 } 571 572 return status; 525 573 }; 526 574 … … 575 623 576 624 // create lookup table for Atom::nr 577 FragmentationToDo = FragmentationToDo && CreateFatherLookupTable( start, end,ListOfAtoms, AtomCount);625 FragmentationToDo = FragmentationToDo && CreateFatherLookupTable(ListOfAtoms, AtomCount); 578 626 579 627 // === compare it with adjacency file === … … 871 919 Leaf->CountAtoms(); 872 920 873 atom *Runner = Leaf->start; 874 while (Runner->next != Leaf->end) { 875 Runner = Runner->next; 921 #ifdef ADDHYDROGEN 922 molecule::const_iterator runner; 923 #endif 924 for (molecule::const_iterator iter = Leaf->begin(); iter != Leaf->end(); ) { 876 925 LonelyFlag = true; 877 FatherOfRunner = Runner->father;926 FatherOfRunner = (*iter)->father; 878 927 if (SonList[FatherOfRunner->nr] != NULL) { // check if this, our father, is present in list 879 928 // create all bonds … … 886 935 // Log() << Verbose(3) << "Adding Bond: "; 887 936 // Log() << Verbose(0) << 888 Leaf->AddBond( Runner, SonList[OtherFather->nr], (*BondRunner)->BondDegree);937 Leaf->AddBond((*iter), SonList[OtherFather->nr], (*BondRunner)->BondDegree); 889 938 // Log() << Verbose(0) << "." << endl; 890 //NumBonds[ Runner->nr]++;939 //NumBonds[(*iter)->nr]++; 891 940 } else { 892 941 // Log() << Verbose(3) << "Not adding bond, labels in wrong order." << endl; … … 896 945 // Log() << Verbose(0) << ", who has no son in this fragment molecule." << endl; 897 946 #ifdef ADDHYDROGEN 898 //Log() << Verbose(3) << "Adding Hydrogen to " << Runner->Name << " and a bond in between." << endl;899 if(!Leaf->AddHydrogenReplacementAtom((*BondRunner), Runner, FatherOfRunner, OtherFather, IsAngstroem))947 //Log() << Verbose(3) << "Adding Hydrogen to " << (*iter)->Name << " and a bond in between." << endl; 948 if(!Leaf->AddHydrogenReplacementAtom((*BondRunner), (*iter), FatherOfRunner, OtherFather, IsAngstroem)) 900 949 exit(1); 901 950 #endif 902 //NumBonds[ Runner->nr] += Binder->BondDegree;951 //NumBonds[(*iter)->nr] += Binder->BondDegree; 903 952 } 904 953 } 905 954 } else { 906 eLog() << Verbose(1) << "Son " << Runner->Name << " has father " << FatherOfRunner->Name << " but its entry in SonList is " << SonList[FatherOfRunner->nr] << "!" << endl;955 eLog() << Verbose(1) << "Son " << (*iter)->Name << " has father " << FatherOfRunner->Name << " but its entry in SonList is " << SonList[FatherOfRunner->nr] << "!" << endl; 907 956 } 908 957 if ((LonelyFlag) && (Leaf->AtomCount > 1)) { 909 Log() << Verbose(0) << * Runner<< "has got bonds only to hydrogens!" << endl;958 Log() << Verbose(0) << *(*iter) << "has got bonds only to hydrogens!" << endl; 910 959 } 911 960 #ifdef ADDHYDROGEN 912 while (( Runner->next != Leaf->end) && (Runner->next->type->Z == 1)) // skip added hydrogen913 Runner = Runner->next;961 while ((iter != Leaf->end()) && ((*iter)->type->Z == 1)) // skip added hydrogen 962 iter++; 914 963 #endif 915 964 } … … 1559 1608 1560 1609 // Construct the complete KeySet which we need for topmost level only (but for all Roots) 1561 atom *Walker = start;1562 1610 KeySet CompleteMolecule; 1563 while (Walker->next != end) { 1564 Walker = Walker->next; 1565 CompleteMolecule.insert(Walker->GetTrueFather()->nr); 1611 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) { 1612 CompleteMolecule.insert((*iter)->GetTrueFather()->nr); 1566 1613 } 1567 1614 … … 1574 1621 RootKeyNr = RootStack.front(); 1575 1622 RootStack.pop_front(); 1576 Walker = FindAtom(RootKeyNr);1623 atom *Walker = FindAtom(RootKeyNr); 1577 1624 // check cyclic lengths 1578 1625 //if ((MinimumRingSize[Walker->GetTrueFather()->nr] != -1) && (Walker->GetTrueFather()->AdaptiveOrder+1 > MinimumRingSize[Walker->GetTrueFather()->nr])) {
Note:
See TracChangeset
for help on using the changeset viewer.
