Changeset c9bce3e for src/moleculelist.cpp
- Timestamp:
- Nov 4, 2009, 3:08:11 PM (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, 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:
- 99593f
- Parents:
- a5551b
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/moleculelist.cpp
ra5551b rc9bce3e 734 734 }; 735 735 736 /** Dissects given \a *mol into connected subgraphs and inserts them as new molecules but with old atoms into \a this. 737 * \param *out output stream for debugging 738 * \param *mol molecule with atoms to dissect 739 * \param *configuration config with BondGraph 740 */ 741 void MoleculeListClass::DissectMoleculeIntoConnectedSubgraphs(ofstream * const out, molecule * const mol, config * const configuration) 742 { 743 // 1. dissect the molecule into connected subgraphs 744 configuration ->BG->ConstructBondGraph(out, mol); 745 746 // 2. scan for connected subgraphs 747 MoleculeLeafClass *Subgraphs = NULL; // list of subgraphs from DFS analysis 748 class StackClass<bond *> *BackEdgeStack = NULL; 749 Subgraphs = mol->DepthFirstSearchAnalysis(out, BackEdgeStack); 750 delete(BackEdgeStack); 751 752 // 3. dissect (the following construct is needed to have the atoms not in the order of the DFS, but in 753 // the original one as parsed in) 754 // TODO: Optimize this, when molecules just contain pointer list of global atoms! 755 756 // 4a. create array of molecules to fill 757 const int MolCount = Subgraphs->next->Count(); 758 molecule **molecules = Malloc<molecule *>(MolCount, "config::Load() - **molecules"); 759 for (int i=0;i<MolCount;i++) { 760 molecules[i] = (molecule*) new molecule(mol->elemente); 761 molecules[i]->ActiveFlag = true; 762 insert(molecules[i]); 763 } 764 765 // 4b. create and fill map of which atom is associated to which connected molecule (note, counting starts at 1) 766 int FragmentCounter = 0; 767 int *MolMap = Calloc<int>(mol->AtomCount, "config::Load() - *MolMap"); 768 MoleculeLeafClass *MolecularWalker = Subgraphs; 769 atom *Walker = NULL; 770 while (MolecularWalker->next != NULL) { 771 MolecularWalker = MolecularWalker->next; 772 Walker = MolecularWalker->Leaf->start; 773 while (Walker->next != MolecularWalker->Leaf->end) { 774 Walker = Walker->next; 775 MolMap[Walker->GetTrueFather()->nr] = FragmentCounter+1; 776 } 777 FragmentCounter++; 778 } 779 780 // 4c. relocate atoms to new molecules and remove from Leafs 781 Walker = mol->start; 782 while (mol->start->next != mol->end) { 783 Walker = mol->start->next; 784 if ((Walker->nr <0) || (Walker->nr >= mol->AtomCount)) { 785 cerr << "Index of atom " << *Walker << " is invalid!" << endl; 786 performCriticalExit(); 787 } 788 FragmentCounter = MolMap[Walker->nr]; 789 if (FragmentCounter != 0) { 790 cout << Verbose(3) << "Re-linking " << *Walker << "..." << endl; 791 unlink(Walker); 792 molecules[FragmentCounter-1]->AddAtom(Walker); // counting starts at 1 793 } else { 794 cerr << "Atom " << *Walker << " not associated to molecule!" << endl; 795 performCriticalExit(); 796 } 797 } 798 // 4d. we don't need to redo bonds, as they are connected subgraphs and still maintained their ListOfBonds 799 // 4e. free Leafs 800 MolecularWalker = Subgraphs; 801 while (MolecularWalker->next != NULL) { 802 MolecularWalker = MolecularWalker->next; 803 delete(MolecularWalker->previous); 804 } 805 delete(MolecularWalker); 806 Free(&MolMap); 807 Free(&molecules); 808 cout << Verbose(1) << "I scanned " << FragmentCounter << " molecules." << endl; 809 }; 736 810 737 811 /******************************************* Class MoleculeLeafClass ************************************************/
Note:
See TracChangeset
for help on using the changeset viewer.