Ignore:
Timestamp:
Dec 3, 2012, 9:49:30 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:
de0af2
Parents:
b9401e
git-author:
Frederik Heber <heber@…> (09/19/12 14:32:32)
git-committer:
Frederik Heber <heber@…> (12/03/12 09:49:30)
Message:

Fragmentation now operates on a single molecule.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/MoleculeLeafClass.cpp

    rb9401e r339910  
    116116};
    117117
    118 /** Fills the root stack for sites to be used as root in fragmentation depending on order or adaptivity criteria
    119  * Again, as in \sa FillBondStructureFromReference steps recursively through each Leaf in this chain list of molecule's.
    120  * \param *out output stream for debugging
    121  * \param *&RootStack stack to be filled
    122  * \param AtomMask defines true/false per global Atom::Nr to mask in/out each nuclear site
    123  * \param &FragmentCounter counts through the fragments in this MoleculeLeafClass
    124  * \param saturation whether to treat hydrogen special or not
    125  * \return true - stack is non-empty, fragmentation necessary, false - stack is empty, no more sites to update
    126  */
    127 bool MoleculeLeafClass::FillRootStackForSubgraphs(KeyStack *&RootStack, const AtomMask_t &AtomMask, int &FragmentCounter, const enum HydrogenSaturation saturation)
    128 {
    129   if (RootStack != NULL) {
    130     // find first root candidates
    131     if (&(RootStack[FragmentCounter]) != NULL) {
    132       RootStack[FragmentCounter].clear();
    133       for(molecule::const_iterator iter = Leaf->begin(); iter != Leaf->end(); ++iter) {
    134         const atom * const Father = (*iter)->GetTrueFather();
    135         if (AtomMask.isTrue(Father->getNr())) // apply mask
    136           if ((saturation == DontSaturate) || ((*iter)->getType()->getAtomicNumber() != 1)) // skip hydrogen
    137             RootStack[FragmentCounter].push_front((*iter)->getNr());
    138       }
    139       if (next != NULL)
    140         next->FillRootStackForSubgraphs(RootStack, AtomMask, ++FragmentCounter, saturation);
    141     } else {
    142       LOG(1, "Rootstack[" << FragmentCounter << "] is NULL.");
    143       return false;
    144     }
    145     FragmentCounter--;
    146     return true;
    147   } else {
    148     LOG(1, "Rootstack is NULL.");
    149     return false;
    150   }
    151 };
    152118
    153 /** The indices per keyset are compared to the respective father's Atom::Nr in each subgraph and thus put into \a **&FragmentList.
    154  * \param *out output stream fro debugging
    155  * \param *reference reference molecule with the bond structure to be copied
    156  * \param *KeySetList list with all keysets
    157  * \param *ListOfLocalAtoms Lookup table for each subgraph and index of each atom in global molecule, may be NULL on start, then it is filled
    158  * \param **&FragmentList list to be allocated and returned
    159  * \param &FragmentCounter counts the fragments as we move along the list
    160  * \param FreeList true - ***ListOfLocalAtoms is free'd before return, false - it is not
    161  * \retuen true - success, false - failure
    162  */
    163 bool MoleculeLeafClass::AssignKeySetsToFragment(molecule *reference, Graph *KeySetList, ListOfLocalAtoms_t *&ListOfLocalAtoms, Graph **&FragmentList, int &FragmentCounter, bool FreeList)
    164 {
    165   bool status = true;
    166   int KeySetCounter = 0;
    167 
    168   LOG(1, "Begin of AssignKeySetsToFragment.");
    169   // fill ListOfLocalAtoms if NULL was given
    170   if (!Leaf->FillListOfLocalAtoms(ListOfLocalAtoms[FragmentCounter], reference->getAtomCount())) {
    171     LOG(1, "Filling of ListOfLocalAtoms failed.");
    172     return false;
    173   }
    174 
    175   // allocate fragment list
    176   if (FragmentList == NULL) {
    177     KeySetCounter = Count();
    178     FragmentList = new Graph*[KeySetCounter];
    179     for (int i=0;i<KeySetCounter;i++)
    180       FragmentList[i] = NULL;
    181     KeySetCounter = 0;
    182   }
    183 
    184   if ((KeySetList != NULL) && (KeySetList->size() != 0)) { // if there are some scanned keysets at all
    185     // assign scanned keysets
    186     if (FragmentList[FragmentCounter] == NULL)
    187       FragmentList[FragmentCounter] = new Graph;
    188     KeySet *TempSet = new KeySet;
    189     for (Graph::iterator runner = KeySetList->begin(); runner != KeySetList->end(); runner++) { // key sets contain global numbers!
    190       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 set
    191         // translate keyset to local numbers
    192         for (KeySet::iterator sprinter = (*runner).first.begin(); sprinter != (*runner).first.end(); sprinter++)
    193           TempSet->insert(ListOfLocalAtoms[FragmentCounter][reference->FindAtom(*sprinter)->getNr()]->getNr());
    194         // insert into FragmentList
    195         FragmentList[FragmentCounter]->insert(GraphPair(*TempSet, pair<int, double> (KeySetCounter++, (*runner).second.second)));
    196       }
    197       TempSet->clear();
    198     }
    199     delete (TempSet);
    200     if (KeySetCounter == 0) {// if there are no keysets, delete the list
    201       LOG(1, "KeySetCounter is zero, deleting FragmentList.");
    202       delete (FragmentList[FragmentCounter]);
    203     } else
    204       LOG(1, KeySetCounter << " keysets were assigned to subgraph " << FragmentCounter << ".");
    205     FragmentCounter++;
    206     if (next != NULL)
    207       next->AssignKeySetsToFragment(reference, KeySetList, ListOfLocalAtoms, FragmentList, FragmentCounter, FreeList);
    208     FragmentCounter--;
    209   } else
    210     LOG(1, "KeySetList is NULL or empty.");
    211 
    212   if ((FreeList) && (ListOfLocalAtoms != NULL)) {
    213     // free the index lookup list
    214     (ListOfLocalAtoms[FragmentCounter]).clear();
    215   }
    216   LOG(1, "End of AssignKeySetsToFragment.");
    217   return status;
    218 };
    219 
    220 /** Translate list into global numbers (i.e. ones that are valid in "this" molecule, not in MolecularWalker->Leaf)
    221  * \param *out output stream for debugging
    222  * \param **FragmentList Graph with local numbers per fragment
    223  * \param &FragmentCounter counts the fragments as we move along the list
    224  * \param &TotalNumberOfKeySets global key set counter
    225  * \param &TotalGraph Graph to be filled with global numbers
    226  */
    227 void MoleculeLeafClass::TranslateIndicesToGlobalIDs(Graph **FragmentList, int &FragmentCounter, int &TotalNumberOfKeySets, Graph &TotalGraph)
    228 {
    229   LOG(1, "Begin of TranslateIndicesToGlobalIDs.");
    230   KeySet *TempSet = new KeySet;
    231   if (FragmentList[FragmentCounter] != NULL) {
    232     for (Graph::iterator runner = FragmentList[FragmentCounter]->begin(); runner != FragmentList[FragmentCounter]->end(); runner++) {
    233       for (KeySet::iterator sprinter = (*runner).first.begin(); sprinter != (*runner).first.end(); sprinter++)
    234         TempSet->insert((Leaf->FindAtom(*sprinter))->GetTrueFather()->getNr());
    235       TotalGraph.insert(GraphPair(*TempSet, pair<int, double> (TotalNumberOfKeySets++, (*runner).second.second)));
    236       TempSet->clear();
    237     }
    238     delete (TempSet);
    239   } else {
    240     LOG(1, "FragmentList is NULL.");
    241   }
    242   if (next != NULL)
    243     next->TranslateIndicesToGlobalIDs(FragmentList, ++FragmentCounter, TotalNumberOfKeySets, TotalGraph);
    244   FragmentCounter--;
    245   LOG(1, "End of TranslateIndicesToGlobalIDs.");
    246 };
    247119
    248120/** Simply counts the number of items in the list, from given MoleculeLeafClass.
Note: See TracChangeset for help on using the changeset viewer.