Changeset 07a47e for src/Fragmentation


Ignore:
Timestamp:
Oct 26, 2011, 3:02:53 PM (13 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:
41d023
Parents:
99b0dc
Message:

Replaced enable/disable-hydrogen by internal switch.

Location:
src/Fragmentation
Files:
1 added
6 edited

Legend:

Unmodified
Added
Removed
  • src/Fragmentation/BondsPerShortestPath.cpp

    r99b0dc r07a47e  
    101101 * \param _RootKeyNr index of root node
    102102 * \param RestrictedKeySet Restricted vertex set to use in context of molecule
    103  */
    104 void BondsPerShortestPath::FillSPListandLabelVertices(int _RootKeyNr, KeySet &RestrictedKeySet)
     103 * \param saturation this tells whether to treat hydrogen special or not.
     104 */
     105void BondsPerShortestPath::FillSPListandLabelVertices(int _RootKeyNr, KeySet &RestrictedKeySet, const enum HydrogenSaturation saturation)
    105106{
    106107  // Actually, we should construct a spanning tree vom the root atom and select all edges therefrom and put them into
     
    146147        OtherWalker = (*Runner)->GetOtherAtom(Walker);
    147148        if ((RestrictedKeySet.find(OtherWalker->getNr()) != RestrictedKeySet.end())
    148   #ifdef ADDHYDROGEN
    149          && (OtherWalker->getType()->getAtomicNumber() != 1)
    150   #endif
    151                                                               ) {  // skip hydrogens and restrict to fragment
     149            // skip hydrogens if desired and restrict to fragment
     150            && ((saturation == DontSaturate) || (OtherWalker->getType()->getAtomicNumber() != 1))) {
    152151          DoLog(2) && (Log() << Verbose(2) << "Current partner is " << *OtherWalker << " with nr " << OtherWalker->getNr() << " in bond " << *(*Runner) << "." << endl);
    153152          // set the label if not set (and push on root stack as well)
  • src/Fragmentation/BondsPerShortestPath.hpp

    r99b0dc r07a47e  
    1313#include <config.h>
    1414#endif
     15
     16#include "Fragmentation/HydrogenSaturation_enum.hpp"
    1517
    1618#include <list>
     
    3133  void SetSPList(atom *_Root);
    3234  void ResetSPList();
    33   void FillSPListandLabelVertices(int _RootKeyNr, KeySet &RestrictedKeySet);
     35  void FillSPListandLabelVertices(int _RootKeyNr, KeySet &RestrictedKeySet, const enum HydrogenSaturation saturation);
    3436  void OutputSPList();
    3537  int CountNumbersInBondsList();
  • src/Fragmentation/Fragmentation.cpp

    r99b0dc r07a47e  
    4545/** Constructor of class Fragmentation.
    4646 *
    47  */
    48 Fragmentation::Fragmentation(molecule *_mol) :
    49   mol(_mol)
     47 * \param _mol molecule for internal use (looking up atoms)
     48 * \param _saturation whether to treat hydrogen special and saturate dangling bonds or not
     49 */
     50Fragmentation::Fragmentation(molecule *_mol, const enum HydrogenSaturation _saturation) :
     51  mol(_mol),
     52  saturation(_saturation)
    5053{}
    5154
     
    9093
    9194  DoLog(0) && (Log() << Verbose(0) << endl);
    92 #ifdef ADDHYDROGEN
    93   DoLog(0) && (Log() << Verbose(0) << "I will treat hydrogen special and saturate dangling bonds with it." << endl);
    94 #else
    95   DoLog(0) && (Log() << Verbose(0) << "Hydrogen is treated just like the rest of the lot." << endl);
    96 #endif
     95  switch (saturation) {
     96    case DoSaturate:
     97      DoLog(0) && (Log() << Verbose(0) << "I will treat hydrogen special and saturate dangling bonds with it." << endl);
     98      break;
     99    case DontSaturate:
     100      DoLog(0) && (Log() << Verbose(0) << "Hydrogen is treated just like the rest of the lot." << endl);
     101      break;
     102    default:
     103      ASSERT(0, "Fragmentation::FragmentMolecule() - there is a saturation setting which I have no idea about.");
     104      break;
     105  }
    97106
    98107  // ++++++++++++++++++++++++++++ INITIAL STUFF: Bond structure analysis, file parsing, ... ++++++++++++++++++++++++++++++++++++++++++
     
    151160    AtomMask[mol->getAtomCount()] = true;   // last plus one entry is used as marker that we have been through this loop once already in CheckOrderAtSite()
    152161    // ===== 6b. fill RootStack for each subgraph (second adaptivity check) =====
    153     Subgraphs->next->FillRootStackForSubgraphs(RootStack, AtomMask, (FragmentCounter = 0));
     162    Subgraphs->next->FillRootStackForSubgraphs(RootStack, AtomMask, (FragmentCounter = 0), saturation);
    154163
    155164    // ===== 7. fill the bond fragment list =====
     
    359368      FragmentLowerOrdersList[RootNr][0] = new Graph;
    360369      FragmentSearch.PrepareForPowersetGeneration(1., FragmentLowerOrdersList[RootNr][0], Walker);
    361       NumMoleculesOfOrder[RootNr] = PSG(CompleteMolecule);
     370      NumMoleculesOfOrder[RootNr] = PSG(CompleteMolecule, saturation);
    362371
    363372      // output resulting number
     
    487496      DoeLog(2) && (eLog()<< Verbose(2) << "Unable to parse file, incrementing all." << endl);
    488497      for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
    489     #ifdef ADDHYDROGEN
    490         if ((*iter)->getType()->getAtomicNumber() != 1) // skip hydrogen
    491     #endif
     498        if ((saturation == DontSaturate) || ((*iter)->getType()->getAtomicNumber() != 1)) // skip hydrogen
    492499        {
    493500          AtomMask[(*iter)->getNr()] = true;  // include all (non-hydrogen) atoms
     
    502509  } else { // global increase of Bond Order
    503510    for(molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
    504   #ifdef ADDHYDROGEN
    505       if ((*iter)->getType()->getAtomicNumber() != 1) // skip hydrogen
    506   #endif
     511      if ((saturation == DontSaturate) || ((*iter)->getType()->getAtomicNumber() != 1)) // skip hydrogen
    507512      {
    508513        AtomMask[(*iter)->getNr()] = true;  // include all (non-hydrogen) atoms
     
    670675  atom *FatherOfRunner = NULL;
    671676
    672 #ifdef ADDHYDROGEN
    673   molecule::const_iterator runner;
    674 #endif
    675677  // we increment the iter just before skipping the hydrogen
    676678  for (molecule::const_iterator iter = Leaf->begin(); iter != Leaf->end();) {
     
    700702        } else {
    701703//          Log() << Verbose(0) << ", who has no son in this fragment molecule." << endl;
    702 #ifdef ADDHYDROGEN
    703704          //Log() << Verbose(3) << "Adding Hydrogen to " << (*iter)->Name << " and a bond in between." << endl;
    704           if(!Leaf->AddHydrogenReplacementAtom((*BondRunner), (*iter), FatherOfRunner, OtherFather, IsAngstroem))
    705             exit(1);
    706 #endif
     705          if (saturation == DoSaturate)
     706            if (!Leaf->AddHydrogenReplacementAtom((*BondRunner), (*iter), FatherOfRunner, OtherFather, IsAngstroem))
     707              exit(1);
    707708          //NumBonds[(*iter)->getNr()] += Binder->BondDegree;
    708709        }
     
    715716    }
    716717    ++iter;
    717 #ifdef ADDHYDROGEN
    718     while ((iter != Leaf->end()) && ((*iter)->getType()->getAtomicNumber() == 1)){ // skip added hydrogen
    719       iter++;
    720     }
    721 #endif
     718    if (saturation == DoSaturate) {
     719      while ((iter != Leaf->end()) && ((*iter)->getType()->getAtomicNumber() == 1)){ // skip added hydrogen
     720        iter++;
     721      }
     722    }
    722723  }
    723724};
  • src/Fragmentation/Fragmentation.hpp

    r99b0dc r07a47e  
    1818#include "Graph/DepthFirstSearchAnalysis.hpp"
    1919
     20#include "Fragmentation/HydrogenSaturation_enum.hpp"
    2021#include "Fragmentation/fragmentation_helpers.hpp"
    2122
     
    3132{
    3233public:
    33   Fragmentation(molecule *_mol);
     34  Fragmentation(molecule *_mol, const enum HydrogenSaturation _saturation);
    3435  ~Fragmentation();
    3536
     
    5859  //!> pointer to molecule that is fragmented
    5960  molecule *mol;
     61  //!> whether to saturate dangling bonds with hydrogen and hence treat hydrogen special
     62  const enum HydrogenSaturation saturation;
    6063  //!> list of parser types for which a configuration file per fragment is stored
    6164  std::vector<std::string> typelist;
  • src/Fragmentation/PowerSetGenerator.cpp

    r99b0dc r07a47e  
    172172 * with SP of 2, then those with SP of 3, then those with SP of 4 and so on.
    173173 * \param RestrictedKeySet Restricted vertex set to use in context of molecule
     174 * \param saturation whether to treat hydrogen special or not
    174175 * \return number of inserted fragments
    175176 * \note ShortestPathList in FragmentSearch structure is probably due to NumberOfAtomsSPLevel and SP not needed anymore
    176177 */
    177 int PowerSetGenerator::operator()(KeySet &RestrictedKeySet)
     178int PowerSetGenerator::operator()(KeySet &RestrictedKeySet, const enum HydrogenSaturation saturation)
    178179{
    179180  int Counter = FragmentSearch->FragmentCounter; // mark current value of counter
     
    185186
    186187  // do a BFS search to fill the SP lists and label the found vertices
    187   BondsPerSPList.FillSPListandLabelVertices(FragmentSearch->getRoot()->GetTrueFather()->getNr(), RestrictedKeySet);
     188  BondsPerSPList.FillSPListandLabelVertices(FragmentSearch->getRoot()->GetTrueFather()->getNr(), RestrictedKeySet, saturation);
    188189
    189190  // outputting all list for debugging
  • src/Fragmentation/PowerSetGenerator.hpp

    r99b0dc r07a47e  
    1818
    1919#include "Fragmentation/BondsPerShortestPath.hpp"
     20#include "Fragmentation/HydrogenSaturation_enum.hpp"
    2021
    2122class bond;
     
    2930
    3031  void SPFragmentGenerator(int RootDistance, std::vector<bond *> &BondsSet, int SetDimension, int SubOrder);
    31   int operator()(KeySet &RestrictedKeySet);
     32  int operator()(KeySet &RestrictedKeySet, const enum HydrogenSaturation saturation);
    3233  void RemoveAllTouchedFromSnakeStack(int verbosity, KeySet *FragmentSet, int *&TouchedList, int &TouchedIndex);
    3334  int FillBondsList(std::vector<bond *> &BondsList, std::list<bond *>::const_iterator SetFirst, std::list<bond *>::const_iterator SetLast, int *&TouchedList, int TouchedIndex);
Note: See TracChangeset for help on using the changeset viewer.