- Timestamp:
- Oct 25, 2011, 12:08:03 PM (13 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:
- f7fd17
- Parents:
- ba94c5
- git-author:
- Frederik Heber <heber@…> (10/20/11 09:32:35)
- git-committer:
- Frederik Heber <heber@…> (10/25/11 12:08:03)
- Location:
- src
- Files:
-
- 2 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Actions/GraphAction/DepthFirstSearchAction.cpp
rba94c5 rd3abb1 28 28 #include "Graph/DepthFirstSearchAnalysis.hpp" 29 29 #include "molecule.hpp" 30 #include "MoleculeLeafClass.hpp" 30 31 #include "Descriptors/MoleculeDescriptor.hpp" 31 32 #include "Descriptors/MoleculeIdDescriptor.hpp" -
src/Fragmentation/Fragmentation.cpp
rba94c5 rd3abb1 36 36 #include "Graph/CheckAgainstAdjacencyFile.hpp" 37 37 #include "molecule.hpp" 38 #include "MoleculeLeafClass.hpp" 38 39 #include "World.hpp" 39 40 -
src/Graph/DepthFirstSearchAnalysis.cpp
rba94c5 rd3abb1 33 33 #include "Descriptors/AtomDescriptor.hpp" 34 34 #include "molecule.hpp" 35 #include "MoleculeLeafClass.hpp" 35 36 #include "World.hpp" 36 37 -
src/Makefile.am
rba94c5 rd3abb1 172 172 Formula.cpp \ 173 173 linkedcell.cpp \ 174 MoleculeLeafClass.cpp \ 174 175 moleculelist.cpp \ 175 176 molecule.cpp \ … … 195 196 Formula.hpp \ 196 197 linkedcell.hpp \ 198 MoleculeLeafClass.hpp \ 197 199 molecule.hpp \ 198 200 ThermoStatContainer.hpp \ -
src/molecule.hpp
rba94c5 rd3abb1 27 27 #include "CodePatterns/ObservedIterator.hpp" 28 28 #include "CodePatterns/Cacheable.hpp" 29 #include "Fragmentation/fragmentation_helpers.hpp"30 29 #include "Helpers/defs.hpp" 31 30 #include "Formula.hpp" … … 275 274 }; 276 275 277 /** A leaf for a tree of \a molecule class278 * Wraps molecules in a tree structure279 */280 class MoleculeLeafClass281 {282 public:283 molecule *Leaf; //!< molecule of this leaf284 //MoleculeLeafClass *UpLeaf; //!< Leaf one level up285 //MoleculeLeafClass *DownLeaf; //!< First leaf one level down286 MoleculeLeafClass *previous; //!< Previous leaf on this level287 MoleculeLeafClass *next; //!< Next leaf on this level288 289 //MoleculeLeafClass(MoleculeLeafClass *Up, MoleculeLeafClass *Previous);290 MoleculeLeafClass(MoleculeLeafClass *PreviousLeaf);291 ~MoleculeLeafClass();292 293 bool AddLeaf(molecule *ptr, MoleculeLeafClass *Previous);294 bool FillRootStackForSubgraphs(KeyStack *&RootStack, bool *AtomMask, int &FragmentCounter);295 bool AssignKeySetsToFragment(molecule *reference, Graph *KeySetList, atom ***&ListOfLocalAtoms, Graph **&FragmentList, int &FragmentCounter, bool FreeList = false);296 void TranslateIndicesToGlobalIDs(Graph **FragmentList, int &FragmentCounter, int &TotalNumberOfKeySets, Graph &TotalGraph);297 int Count() const;298 };299 276 300 277 #endif /*MOLECULES_HPP_*/ -
src/moleculelist.cpp
rba94c5 rd3abb1 19 19 #include "CodePatterns/MemDebug.hpp" 20 20 21 #include <cstring>22 23 #include <gsl/gsl_inline.h>21 //#include <cstring> 22 23 //#include <gsl/gsl_inline.h> 24 24 #include <gsl/gsl_heapsort.h> 25 26 #include "molecule.hpp" 27 28 #include "CodePatterns/Log.hpp" 25 29 26 30 #include "atom.hpp" 27 31 #include "Bond/bond.hpp" 28 #include "Tesselation/boundary.hpp"29 32 #include "Box.hpp" 30 #include "CodePatterns/Assert.hpp"31 #include "CodePatterns/Log.hpp"32 #include "CodePatterns/Verbose.hpp"33 33 #include "config.hpp" 34 34 #include "Element/element.hpp" 35 #include "Element/periodentafel.hpp" 35 36 #include "Fragmentation/Graph.hpp" 36 37 #include "Fragmentation/KeySet.hpp" … … 38 39 #include "Helpers/helpers.hpp" 39 40 #include "LinearAlgebra/RealSpaceMatrix.hpp" 40 #include "linkedcell.hpp"41 #include "molecule.hpp"42 #include "Parser/MpqcParser.hpp"43 41 #include "Parser/FormatParserStorage.hpp" 44 #include "Element/periodentafel.hpp"45 #include "Tesselation/tesselation.hpp"46 42 #include "World.hpp" 47 #include "WorldTime.hpp" 48 49 /*********************************** Functions for class MoleculeListClass *************************/ 43 50 44 51 45 /** Constructor for MoleculeListClass. … … 755 749 } 756 750 }; 757 758 759 /******************************************* Class MoleculeLeafClass ************************************************/760 761 /** Constructor for MoleculeLeafClass root leaf.762 * \param *Up Leaf on upper level763 * \param *PreviousLeaf NULL - We are the first leaf on this level, otherwise points to previous in list764 */765 //MoleculeLeafClass::MoleculeLeafClass(MoleculeLeafClass *Up = NULL, MoleculeLeafClass *Previous = NULL)766 MoleculeLeafClass::MoleculeLeafClass(MoleculeLeafClass *PreviousLeaf = NULL) :767 Leaf(NULL),768 previous(PreviousLeaf)769 {770 // if (Up != NULL)771 // if (Up->DownLeaf == NULL) // are we the first down leaf for the upper leaf?772 // Up->DownLeaf = this;773 // UpLeaf = Up;774 // DownLeaf = NULL;775 if (previous != NULL) {776 MoleculeLeafClass *Walker = previous->next;777 previous->next = this;778 next = Walker;779 } else {780 next = NULL;781 }782 };783 784 /** Destructor for MoleculeLeafClass.785 */786 MoleculeLeafClass::~MoleculeLeafClass()787 {788 // if (DownLeaf != NULL) {// drop leaves further down789 // MoleculeLeafClass *Walker = DownLeaf;790 // MoleculeLeafClass *Next;791 // do {792 // Next = Walker->NextLeaf;793 // delete(Walker);794 // Walker = Next;795 // } while (Walker != NULL);796 // // Last Walker sets DownLeaf automatically to NULL797 // }798 // remove the leaf itself799 if (Leaf != NULL) {800 Leaf->removeAtomsinMolecule();801 World::getInstance().destroyMolecule(Leaf);802 Leaf = NULL;803 }804 // remove this Leaf from level list805 if (previous != NULL)806 previous->next = next;807 // } else { // we are first in list (connects to UpLeaf->DownLeaf)808 // if ((NextLeaf != NULL) && (NextLeaf->UpLeaf == NULL))809 // NextLeaf->UpLeaf = UpLeaf; // either null as we are top level or the upleaf of the first node810 // if (UpLeaf != NULL)811 // UpLeaf->DownLeaf = NextLeaf; // either null as we are only leaf or NextLeaf if we are just the first812 // }813 // UpLeaf = NULL;814 if (next != NULL) // are we last in list815 next->previous = previous;816 next = NULL;817 previous = NULL;818 };819 820 /** Adds \a molecule leaf to the tree.821 * \param *ptr ptr to molecule to be added822 * \param *Previous previous MoleculeLeafClass referencing level and which on the level823 * \return true - success, false - something went wrong824 */825 bool MoleculeLeafClass::AddLeaf(molecule *ptr, MoleculeLeafClass *Previous)826 {827 return false;828 };829 830 /** Fills the root stack for sites to be used as root in fragmentation depending on order or adaptivity criteria831 * Again, as in \sa FillBondStructureFromReference steps recursively through each Leaf in this chain list of molecule's.832 * \param *out output stream for debugging833 * \param *&RootStack stack to be filled834 * \param *AtomMask defines true/false per global Atom::Nr to mask in/out each nuclear site835 * \param &FragmentCounter counts through the fragments in this MoleculeLeafClass836 * \return true - stack is non-empty, fragmentation necessary, false - stack is empty, no more sites to update837 */838 bool MoleculeLeafClass::FillRootStackForSubgraphs(KeyStack *&RootStack, bool *AtomMask, int &FragmentCounter)839 {840 atom *Father = NULL;841 842 if (RootStack != NULL) {843 // find first root candidates844 if (&(RootStack[FragmentCounter]) != NULL) {845 RootStack[FragmentCounter].clear();846 for(molecule::const_iterator iter = Leaf->begin(); iter != Leaf->end(); ++iter) {847 Father = (*iter)->GetTrueFather();848 if (AtomMask[Father->getNr()]) // apply mask849 #ifdef ADDHYDROGEN850 if ((*iter)->getType()->getAtomicNumber() != 1) // skip hydrogen851 #endif852 RootStack[FragmentCounter].push_front((*iter)->getNr());853 }854 if (next != NULL)855 next->FillRootStackForSubgraphs(RootStack, AtomMask, ++FragmentCounter);856 } else {857 DoLog(1) && (Log() << Verbose(1) << "Rootstack[" << FragmentCounter << "] is NULL." << endl);858 return false;859 }860 FragmentCounter--;861 return true;862 } else {863 DoLog(1) && (Log() << Verbose(1) << "Rootstack is NULL." << endl);864 return false;865 }866 };867 868 /** The indices per keyset are compared to the respective father's Atom::Nr in each subgraph and thus put into \a **&FragmentList.869 * \param *out output stream fro debugging870 * \param *reference reference molecule with the bond structure to be copied871 * \param *KeySetList list with all keysets872 * \param ***ListOfLocalAtoms Lookup table for each subgraph and index of each atom in global molecule, may be NULL on start, then it is filled873 * \param **&FragmentList list to be allocated and returned874 * \param &FragmentCounter counts the fragments as we move along the list875 * \param FreeList true - ***ListOfLocalAtoms is free'd before return, false - it is not876 * \retuen true - success, false - failure877 */878 bool MoleculeLeafClass::AssignKeySetsToFragment(molecule *reference, Graph *KeySetList, atom ***&ListOfLocalAtoms, Graph **&FragmentList, int &FragmentCounter, bool FreeList)879 {880 bool status = true;881 int KeySetCounter = 0;882 883 DoLog(1) && (Log() << Verbose(1) << "Begin of AssignKeySetsToFragment." << endl);884 // fill ListOfLocalAtoms if NULL was given885 if (!Leaf->FillListOfLocalAtoms(ListOfLocalAtoms[FragmentCounter], reference->getAtomCount())) {886 DoLog(1) && (Log() << Verbose(1) << "Filling of ListOfLocalAtoms failed." << endl);887 return false;888 }889 890 // allocate fragment list891 if (FragmentList == NULL) {892 KeySetCounter = Count();893 FragmentList = new Graph*[KeySetCounter];894 for (int i=0;i<KeySetCounter;i++)895 FragmentList[i] = NULL;896 KeySetCounter = 0;897 }898 899 if ((KeySetList != NULL) && (KeySetList->size() != 0)) { // if there are some scanned keysets at all900 // assign scanned keysets901 if (FragmentList[FragmentCounter] == NULL)902 FragmentList[FragmentCounter] = new Graph;903 KeySet *TempSet = new KeySet;904 for (Graph::iterator runner = KeySetList->begin(); runner != KeySetList->end(); runner++) { // key sets contain global numbers!905 if (ListOfLocalAtoms[FragmentCounter][reference->FindAtom(*((*runner).first.begin()))->getNr()] != NULL) {// as we may assume that that bond structure is unchanged, we only test the first key in each set906 // translate keyset to local numbers907 for (KeySet::iterator sprinter = (*runner).first.begin(); sprinter != (*runner).first.end(); sprinter++)908 TempSet->insert(ListOfLocalAtoms[FragmentCounter][reference->FindAtom(*sprinter)->getNr()]->getNr());909 // insert into FragmentList910 FragmentList[FragmentCounter]->insert(GraphPair(*TempSet, pair<int, double> (KeySetCounter++, (*runner).second.second)));911 }912 TempSet->clear();913 }914 delete (TempSet);915 if (KeySetCounter == 0) {// if there are no keysets, delete the list916 DoLog(1) && (Log() << Verbose(1) << "KeySetCounter is zero, deleting FragmentList." << endl);917 delete (FragmentList[FragmentCounter]);918 } else919 DoLog(1) && (Log() << Verbose(1) << KeySetCounter << " keysets were assigned to subgraph " << FragmentCounter << "." << endl);920 FragmentCounter++;921 if (next != NULL)922 next->AssignKeySetsToFragment(reference, KeySetList, ListOfLocalAtoms, FragmentList, FragmentCounter, FreeList);923 FragmentCounter--;924 } else925 DoLog(1) && (Log() << Verbose(1) << "KeySetList is NULL or empty." << endl);926 927 if ((FreeList) && (ListOfLocalAtoms != NULL)) {928 // free the index lookup list929 delete[](ListOfLocalAtoms[FragmentCounter]);930 }931 DoLog(1) && (Log() << Verbose(1) << "End of AssignKeySetsToFragment." << endl);932 return status;933 };934 935 /** Translate list into global numbers (i.e. ones that are valid in "this" molecule, not in MolecularWalker->Leaf)936 * \param *out output stream for debugging937 * \param **FragmentList Graph with local numbers per fragment938 * \param &FragmentCounter counts the fragments as we move along the list939 * \param &TotalNumberOfKeySets global key set counter940 * \param &TotalGraph Graph to be filled with global numbers941 */942 void MoleculeLeafClass::TranslateIndicesToGlobalIDs(Graph **FragmentList, int &FragmentCounter, int &TotalNumberOfKeySets, Graph &TotalGraph)943 {944 DoLog(1) && (Log() << Verbose(1) << "Begin of TranslateIndicesToGlobalIDs." << endl);945 KeySet *TempSet = new KeySet;946 if (FragmentList[FragmentCounter] != NULL) {947 for (Graph::iterator runner = FragmentList[FragmentCounter]->begin(); runner != FragmentList[FragmentCounter]->end(); runner++) {948 for (KeySet::iterator sprinter = (*runner).first.begin(); sprinter != (*runner).first.end(); sprinter++)949 TempSet->insert((Leaf->FindAtom(*sprinter))->GetTrueFather()->getNr());950 TotalGraph.insert(GraphPair(*TempSet, pair<int, double> (TotalNumberOfKeySets++, (*runner).second.second)));951 TempSet->clear();952 }953 delete (TempSet);954 } else {955 DoLog(1) && (Log() << Verbose(1) << "FragmentList is NULL." << endl);956 }957 if (next != NULL)958 next->TranslateIndicesToGlobalIDs(FragmentList, ++FragmentCounter, TotalNumberOfKeySets, TotalGraph);959 FragmentCounter--;960 DoLog(1) && (Log() << Verbose(1) << "End of TranslateIndicesToGlobalIDs." << endl);961 };962 963 /** Simply counts the number of items in the list, from given MoleculeLeafClass.964 * \return number of items965 */966 int MoleculeLeafClass::Count() const967 {968 if (next != NULL)969 return next->Count() + 1;970 else971 return 1;972 };973
Note:
See TracChangeset
for help on using the changeset viewer.