Changeset 9d3264 for src


Ignore:
Timestamp:
Aug 14, 2014, 2:49:51 PM (10 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:
97d6ab, 9e3fca
Parents:
3fbdca
git-author:
Frederik Heber <heber@…> (05/29/14 09:55:28)
git-committer:
Frederik Heber <heber@…> (08/14/14 14:49:51)
Message:

Refactored SaturatedFragment::saturate() using list of cut bonds.

File:
1 edited

Legend:

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

    r3fbdca r9d3264  
    101101void SaturatedFragment::saturate()
    102102{
    103   // gather all atoms in a vector
     103  // so far, we just have a set of keys. Hence, convert to atom refs
     104  // and gather all atoms in a vector
    104105  std::vector<atom *> atoms;
    105106  for (KeySet::const_iterator iter = FullMolecule.begin();
     
    114115
    115116//  bool LonelyFlag = false;
     117  // go through each atom of the fragment and gather all cut bonds in list
     118  typedef std::map<atom *, BondList > CutBonds_t;
     119  CutBonds_t CutBonds;
    116120  for (std::vector<atom *>::const_iterator iter = atoms.begin();
    117121      iter != atoms.end();
     
    125129        ++BondRunner) {
    126130      atom * const OtherWalker = (*BondRunner)->GetOtherAtom(Walker);
    127       // if in set
     131      // if other atom is in key set
    128132      if (set.find(OtherWalker->getId()) != set.end()) {
    129133        LOG(4, "DEBUG: Walker " << *Walker << " is bound to " << *OtherWalker << ".");
     
    143147        if (saturation == DoSaturate) {
    144148//          LOG(3, "ACCEPT: Adding Hydrogen to " << (*iter)->Name << " and a bond in between.");
    145           if (!AddHydrogenReplacementAtom(
    146               (*BondRunner),
    147               Walker,
    148               OtherWalker,
    149               World::getInstance().getConfig()->IsAngstroem == 1))
    150             exit(1);
     149          if (CutBonds.count(Walker) == 0)
     150            CutBonds.insert( std::make_pair(Walker, BondList() ));
     151          CutBonds[Walker].push_back(*BondRunner);
    151152        }
    152153//        } else if ((treatment == ExcludeHydrogen) && (OtherWalker->getElementNo() == (atomicNumber_t)1)) {
     
    157158        //NumBonds[(*iter)->getNr()] += Binder->getDegree();
    158159      }
     160    }
     161  }
     162
     163  // go through all cut bonds and replace with a hydrogen
     164  for (CutBonds_t::const_iterator atomiter = CutBonds.begin();
     165      atomiter != CutBonds.end(); ++atomiter) {
     166    atom * const Walker = atomiter->first;
     167    // go through each bond and replace
     168    for (BondList::const_iterator bonditer = atomiter->second.begin();
     169        bonditer != atomiter->second.end(); ++bonditer) {
     170      atom * const OtherWalker = (*bonditer)->GetOtherAtom(Walker);
     171      if (!AddHydrogenReplacementAtom(
     172          (*bonditer),
     173          Walker,
     174          OtherWalker,
     175          World::getInstance().getConfig()->IsAngstroem == 1))
     176        exit(1);
    159177    }
    160178  }
Note: See TracChangeset for help on using the changeset viewer.