Changeset b4f72c for src/Fragmentation


Ignore:
Timestamp:
Dec 3, 2012, 9:50:01 AM (12 years ago)
Author:
Frederik Heber <heber@…>
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:
2ab6b6
Parents:
dcbb5d
git-author:
Frederik Heber <heber@…> (09/20/12 13:44:17)
git-committer:
Frederik Heber <heber@…> (12/03/12 09:50:01)
Message:

ExportGraph_ToFiles now does not require molecule reference anymore.

  • SortIndex is now just a dummy (identity) map.
  • FragmentationAction combines all graphs from each Fragmentationm call and exports these in one go.
Location:
src/Fragmentation
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • src/Fragmentation/Exporters/ExportGraph_ToFiles.cpp

    rdcbb5d rb4f72c  
    5454 *
    5555 * @param _graph instance of Graph containing keyset of each fragment
    56  * @param _mol molecule as reference
    57  */
    58 ExportGraph_ToFiles::ExportGraph_ToFiles(const Graph &_graph, molecule *&_mol, const enum HydrogenSaturation _saturation) :
     56 * @param saturation whether to saturate dangling bonds with hydrogen or not
     57 */
     58ExportGraph_ToFiles::ExportGraph_ToFiles(const Graph &_graph, const enum HydrogenSaturation _saturation) :
    5959                ExportGraph(_graph),
    60                 mol(_mol),
    6160                BondFragments(World::getPointer()),
    6261                saturation(_saturation)
     
    107106  // store force index reference file
    108107  {
    109     SortIndex_t SortIndex(mol);
     108    SortIndex_t SortIndex;
    110109    BondFragments.StoreForcesFile(prefix, SortIndex);
    111110  }
     
    113112  // store keysets file
    114113  TotalGraph.StoreKeySetFile(prefix);
    115 
    116   {
    117     // store Adjacency file
    118     std::string filename = prefix + ADJACENCYFILE;
    119     mol->StoreAdjacencyToFile(filename);
    120   }
    121114
    122115  // store Hydrogen saturation correction file
     
    137130    LOG(2, "DEBUG: Fragment No." << (*runner).second.first << " with TEFactor "
    138131                << (*runner).second.second << ".");
    139     BondFragments.insert(StoreFragmentFromKeySet(mol, test, World::getInstance().getConfig()));
     132    BondFragments.insert(StoreFragmentFromKeySet(test, World::getInstance().getConfig()));
    140133    ++count;
    141134  }
     
    147140 * First creates the minimal set of atoms from the KeySet, then creates the bond structure from the complete
    148141 * molecule and adds missing hydrogen where bonds were cut.
    149  * \param *mol reference molecule
    150142 * \param &Leaflet pointer to KeySet structure
    151143 * \param IsAngstroem whether we have Ansgtroem or bohrradius
    152144 * \return pointer to constructed molecule
    153145 */
    154 molecule * ExportGraph_ToFiles::StoreFragmentFromKeySet(molecule *mol, KeySet &Leaflet, bool IsAngstroem)
     146molecule * ExportGraph_ToFiles::StoreFragmentFromKeySet(KeySet &Leaflet, bool IsAngstroem)
    155147{
    156148  Info info(__func__);
     
    158150  molecule *Leaf = World::getInstance().createMolecule();
    159151
    160   StoreFragmentFromKeySet_Init(mol, Leaf, Leaflet, SonList);
     152  StoreFragmentFromKeySet_Init(Leaf, Leaflet, SonList);
    161153  // create the bonds between all: Make it an induced subgraph and add hydrogen
    162154//  LOG(2, "Creating bonds from father graph (i.e. induced subgraph creation).");
    163   CreateInducedSubgraphOfFragment(mol, Leaf, SonList, IsAngstroem);
     155  CreateInducedSubgraphOfFragment(Leaf, SonList, IsAngstroem);
    164156
    165157  //Leaflet->Leaf->ScanForPeriodicCorrection(out);
     
    168160
    169161/** Initializes some value for putting fragment of \a *mol into \a *Leaf.
    170  * \param *mol total molecule
    171162 * \param *Leaf fragment molecule
    172163 * \param &Leaflet pointer to KeySet structure
     
    174165 * \return number of atoms in fragment
    175166 */
    176 int ExportGraph_ToFiles::StoreFragmentFromKeySet_Init(molecule *mol, molecule *Leaf, KeySet &Leaflet, ListOfLocalAtoms_t &SonList)
     167int ExportGraph_ToFiles::StoreFragmentFromKeySet_Init(molecule *Leaf, KeySet &Leaflet, ListOfLocalAtoms_t &SonList)
    177168{
    178169  atom *FatherOfRunner = NULL;
    179170
    180171  // first create the minimal set of atoms from the KeySet
     172  World &world = World::getInstance();
    181173  int size = 0;
    182174  for(KeySet::const_iterator runner = Leaflet.begin(); runner != Leaflet.end(); runner++) {
    183     FatherOfRunner = mol->FindAtom((*runner));  // find the id
     175    FatherOfRunner = world.getAtom(AtomById(*runner));  // find the id
    184176    SonList.insert( std::make_pair(FatherOfRunner->getNr(), Leaf->AddCopyAtom(FatherOfRunner) ) );
    185177    size++;
     
    189181
    190182/** Creates an induced subgraph out of a fragmental key set, adding bonds and hydrogens (if treated specially).
    191  * \param *out output stream for debugging messages
    192  * \param *mol total molecule
    193183 * \param *Leaf fragment molecule
    194184 * \param IsAngstroem whether we have Ansgtroem or bohrradius
    195  * \param SonList list which atom of \a *Leaf is a son of which atom in \a *mol
    196  */
    197 void ExportGraph_ToFiles::CreateInducedSubgraphOfFragment(molecule *mol, molecule *Leaf, ListOfLocalAtoms_t &SonList, bool IsAngstroem)
     185 * \param SonList list which atom of \a *Leaf is another atom's son
     186 */
     187void ExportGraph_ToFiles::CreateInducedSubgraphOfFragment(molecule *Leaf, ListOfLocalAtoms_t &SonList, bool IsAngstroem)
    198188{
    199189  bool LonelyFlag = false;
  • src/Fragmentation/Exporters/ExportGraph_ToFiles.hpp

    rdcbb5d rb4f72c  
    2222
    2323class ListOfLocalAtoms_t;
     24class molecule;
    2425
    2526/** ExportGraph_ToFiles implements an ExportGraph as storing all fragmentary
     
    2930{
    3031public:
    31         ExportGraph_ToFiles(const Graph &_graph, molecule *&_mol, const enum HydrogenSaturation _saturation);
     32        ExportGraph_ToFiles(const Graph &_graph, const enum HydrogenSaturation _saturation);
    3233        virtual ~ExportGraph_ToFiles();
    3334
     
    4546
    4647        void prepareMolecule();
    47   molecule * StoreFragmentFromKeySet(molecule *mol, KeySet &Leaflet, bool IsAngstroem);
    48   int StoreFragmentFromKeySet_Init(molecule *mol, molecule *Leaf, KeySet &Leaflet, ListOfLocalAtoms_t &SonList);
    49   void CreateInducedSubgraphOfFragment(molecule *mol, molecule *Leaf, ListOfLocalAtoms_t &SonList, bool IsAngstroem);
     48  molecule * StoreFragmentFromKeySet(KeySet &Leaflet, bool IsAngstroem);
     49  int StoreFragmentFromKeySet_Init(molecule *Leaf, KeySet &Leaflet, ListOfLocalAtoms_t &SonList);
     50  void CreateInducedSubgraphOfFragment(molecule *Leaf, ListOfLocalAtoms_t &SonList, bool IsAngstroem);
    5051
    5152private:
    52   //!> molecule as reference
    53   molecule *mol;
    5453  //!> internal list of created molecules
    5554        MoleculeListClass BondFragments;
  • src/Fragmentation/Fragmentation.cpp

    rdcbb5d rb4f72c  
    163163  LOG(1, "STATUS: We have created " << TotalGraph.size() << " fragments.");
    164164
     165  {
     166    // store Adjacency file
     167    std::string filename = prefix + ADJACENCYFILE;
     168    mol->StoreAdjacencyToFile(filename);
     169  }
     170
    165171  // store adaptive orders into file
    166172  StoreOrderAtSiteFile(prefix);
  • src/Fragmentation/Graph.cpp

    rdcbb5d rb4f72c  
    6464 * \param *counter keyset counter that gets increased
    6565 */
    66 void Graph::InsertGraph(Graph &graph, int *counter)
     66void Graph::InsertGraph(const Graph &graph, int &counter)
    6767{
    6868  GraphTestPair testGraphInsert;
    6969
    70   for(Graph::iterator runner = graph.begin(); runner != graph.end(); runner++) {
    71     testGraphInsert = insert(GraphPair ((*runner).first,pair<int,double>((*counter)++,((*runner).second).second)));  // store fragment number and current factor
     70  for(Graph::const_iterator runner = graph.begin(); runner != graph.end(); runner++) {
     71    testGraphInsert = insert(GraphPair ((*runner).first,pair<int,double>(++counter,((*runner).second).second)));  // store fragment number and current factor
    7272    if (testGraphInsert.second) {
    73       LOG(2, "INFO: KeySet " << (*counter)-1 << " successfully inserted.");
     73      LOG(2, "INFO: KeySet " << counter-1 << " successfully inserted.");
    7474    } else {
    75       LOG(2, "INFO: KeySet " << (*counter)-1 << " failed to insert, present fragment is " << ((*(testGraphInsert.first)).second).first);
     75      LOG(2, "INFO: KeySet " << counter-1 << " failed to insert, present fragment is " << ((*(testGraphInsert.first)).second).first);
    7676      ((*(testGraphInsert.first)).second).second += (*runner).second.second;
    7777      LOG(2, "INFO: New factor is " << (*(testGraphInsert.first)).second.second << ".");
  • src/Fragmentation/Graph.hpp

    rdcbb5d rb4f72c  
    3030  ~Graph();
    3131
    32   void InsertGraph(Graph &graph, int *counter);
     32  void InsertGraph(const Graph &graph, int &counter);
    3333
    3434  bool ParseKeySetFile(std::string &path);
  • src/Fragmentation/SortIndex.cpp

    rdcbb5d rb4f72c  
    4646{}
    4747
    48 /** Constructor for SortIndex from the internal numbering in a molecule.
    49  *
    50  * \param *mol molecule to place in the internal index
    51  */
    52 SortIndex_t::SortIndex_t(const molecule *mol)
    53 {
    54   int AtomNo = 0;
    55   for(molecule::const_iterator iter=mol->begin();iter!=mol->end();++iter){
    56 #ifndef NDEBUG
    57     std::pair<index_t::iterator, bool> inserter =
    58 #endif
    59         index.insert( std::make_pair((*iter)->getNr(), AtomNo) );
    60     ASSERT( inserter.second,
    61         "SortIndex_t::SortIndex_t() - index "+toString((*iter)->getNr())+" already present.");
    62     ++AtomNo;
    63   }
    64 }
    65 
    6648
    6749int SortIndex_t::find(atomId_t id) const
    6850{
    69   index_t::const_iterator iter = index.find(id);
    70   if (iter == index.end())
    71     return -1;
    72   else
    73     return iter->second;
     51  return id;
    7452}
  • src/Fragmentation/SortIndex.hpp

    rdcbb5d rb4f72c  
    2828public:
    2929  SortIndex_t();
    30   SortIndex_t(const molecule *mol);
    3130
    3231  int find(atomId_t id) const;
  • src/Fragmentation/fragmentation_helpers.cpp

    rdcbb5d rb4f72c  
    102102    for(int i=0;i<NumLevels;i++) {
    103103      if (FragmentLowerOrdersList[RootNr][i] != NULL) {
    104         FragmentList.InsertGraph((*FragmentLowerOrdersList[RootNr][i]), &counter);
     104        FragmentList.InsertGraph((*FragmentLowerOrdersList[RootNr][i]), counter);
    105105      }
    106106    }
Note: See TracChangeset for help on using the changeset viewer.