Changeset c738f1 for src/Fragmentation


Ignore:
Timestamp:
Nov 11, 2016, 2:25:35 PM (8 years ago)
Author:
Frederik Heber <heber@…>
Branches:
Action_Thermostats, Add_AtomRandomPerturbation, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_StructOpt_integration_tests, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.6.0, Candidate_v1.6.1, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, 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_ChronosMutex, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, GeometryObjects, Gui_displays_atomic_force_velocity, IndependentFragmentGrids_IntegrationTest, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, RotateToPrincipalAxisSystem_UndoRedo, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, ThirdParty_MPQC_rebuilt_buildsystem, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, Ubuntu_1604_changes, stable
Children:
884d8c
Parents:
2124aa
git-author:
Frederik Heber <heber@…> (10/04/16 20:01:24)
git-committer:
Frederik Heber <heber@…> (11/11/16 14:25:35)
Message:

FIX: SaturatedFragment::getEdges().

  • SaturatedFragment now keeps track of which hydrogens have been added in replacement for which atom not contained in the fragment.
Location:
src/Fragmentation/Exporters
Files:
2 edited

Legend:

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

    r2124aa rc738f1  
    294294        LOG(4, "DEBUG: Places to saturate for atom " << *OtherWalker
    295295            << " are " << positionsiter->second);
    296         atom * const father = Walker;
     296        atom * const father = OtherWalker;
    297297        for (SaturationsPositions_t::const_iterator positer = positionsiter->second.begin();
    298298            positer != positionsiter->second.end(); ++positer) {
     
    320320  _atom->setFather(_father);
    321321  SaturationHydrogens.insert(_atom->getId());
     322  // note down the id of the replaced atom
     323  replaced_atoms.insert( std::make_pair(_father->getId(), _atom->getId()) );
    322324
    323325  return *_atom;
     
    670672static FragmentationEdges::edges_t createEdgesFromAtoms(
    671673    const std::vector<atom *> &_atoms,
     674    const SaturatedFragment::replaced_atoms_t &replaced_atoms,
    672675    const KeySet &_FullMolecule)
    673676{
     
    682685      const atom * const OtherWalker = (*bonditer)->GetOtherAtom(walker);
    683686      const atomId_t &otherwalkerid = OtherWalker->getId();
    684       if (walkerid < otherwalkerid) {
    685         // check if it's in fullkeysets (also contains excluded and saturation hydrogens)
    686         if (_FullMolecule.count(otherwalkerid))
    687           edges.push_back( FragmentationEdges::edge_t(walkerid, otherwalkerid) );
     687      if (_FullMolecule.count(otherwalkerid)) {
     688        if (walkerid < otherwalkerid) {
     689          // check if it's in fullkeysets (also contains excluded and saturation hydrogens)
     690          if (_FullMolecule.count(otherwalkerid))
     691            edges.push_back( FragmentationEdges::edge_t(walkerid, otherwalkerid) );
     692        }
     693      } else {
     694        ASSERT( replaced_atoms.count(otherwalkerid),
     695            "createEdgesFromAtoms() - atom #"+toString(otherwalkerid)
     696            +" to a cut bond  is not in replaced_atoms.");
     697        // add bond to every saturation hydrogen instead
     698        const std::pair<
     699            SaturatedFragment::replaced_atoms_t::const_iterator,
     700            SaturatedFragment::replaced_atoms_t::const_iterator> range = replaced_atoms.equal_range(otherwalkerid);
     701        for (SaturatedFragment::replaced_atoms_t::const_iterator replaceiter = range.first;
     702            replaceiter != range.second; ++replaceiter) {
     703          edges.push_back( FragmentationEdges::edge_t(walkerid, replaceiter->second) );
     704        }
    688705      }
    689706    }
     
    739756  // gather all edges
    740757  const std::vector<atom *> atoms = gatherAllAtoms(FullMolecule);
    741   FragmentationEdges::edges_t edges = createEdgesFromAtoms(atoms, FullMolecule);
     758  FragmentationEdges::edges_t edges = createEdgesFromAtoms(atoms, replaced_atoms, FullMolecule);
    742759
    743760  // translate each edge
    744   std::map<atomId_t, atomId_t> idtable = createIdTable(atoms);
     761  const std::map<atomId_t, atomId_t> idtable = createIdTable(atoms);
    745762
    746763  // rewrite indices of edges in correct order
  • src/Fragmentation/Exporters/SaturatedFragment.hpp

    r2124aa rc738f1  
    1515
    1616#include <iosfwd>
     17#include <map>
    1718#include <set>
    1819#include <string>
     
    122123      std::ostream &out,
    123124      const ParserTypes _type) const;
     125
     126  //!> typedef for the replaced atom (due to cut bonds) and their replacement hydrogens
     127  typedef std::multimap<atomId_t, atomId_t> replaced_atoms_t;
    124128
    125129private:
     
    220224  //!> whether to actually saturate or not
    221225  const enum HydrogenSaturation saturation;
     226  //!> list of saturated hydrogens to their original atoms
     227  replaced_atoms_t replaced_atoms;
    222228};
    223229
Note: See TracChangeset for help on using the changeset viewer.