Changeset ed0f88 for src/Actions


Ignore:
Timestamp:
May 18, 2016, 10:02:54 PM (9 years ago)
Author:
Frederik Heber <heber@…>
Branches:
Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Added_ParseSaveFragmentResults, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_ParticleName_to_Atom, Adding_StructOpt_integration_tests, 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_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, FragmentMolecule_checks_bonddegrees, GeometryObjects, Gui_Fixes, Gui_displays_atomic_force_velocity, IndependentFragmentGrids, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, 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:
c4aeda
Parents:
91f907
git-author:
Frederik Heber <heber@…> (03/07/16 22:20:45)
git-committer:
Frederik Heber <heber@…> (05/18/16 22:02:54)
Message:

Using unique graph set as key to particle name in FitPartialChargesAction.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Actions/PotentialAction/FitPartialChargesAction.cpp

    r91f907 red0f88  
    9191  typedef std::set<size_t> AtomsGraphIndices_t;
    9292  typedef boost::bimaps::bimap<
    93       AtomsGraphIndices_t,
    94       boost::bimaps::multiset_of<atomId_t> > GraphIndices_t;
    95 
    96   typedef std::map<atomId_t, std::string> AtomParticleNames_t;
     93      boost::bimaps::multiset_of<AtomsGraphIndices_t>,
     94      atomId_t > GraphIndices_t;
     95
     96  typedef std::map<std::set<size_t>, std::map<atomicNumber_t, std::string> > AtomParticleNames_t;
    9797
    9898  typedef std::map<std::set<size_t>, std::string> GraphToNameMap_t;
     
    277277}
    278278
    279 double fitAverageChargeToAtom(
    280     const atom * const _walker,
    281     const AtomFragmentsMap &_atomfragments,
    282     const detail::KeysetsToGraph_t &_keyset_graphs,
    283     const detail::GraphFittedChargeMap_t &_fittedcharges_per_fragment)
     279const atom * getNonHydrogenSurrogate(const atom * const _walker)
    284280{
    285281  const atom * surrogate = _walker;
     
    289285    const BondList &ListOfBonds = surrogate->getListOfBonds();
    290286    if ( ListOfBonds.size() != 1) {
    291       ELOG(1, "Solitary hydrogen in atom " << surrogate->getId() << " detected, skipping.");
    292       return 0.;
     287      ELOG(1, "Solitary hydrogen in atom " << surrogate->getId() << " detected.");
     288      return _walker;
    293289    }
    294290    surrogate = (*ListOfBonds.begin())->GetOtherAtom(surrogate);
    295291  }
     292  return surrogate;
     293}
     294
     295double fitAverageChargeToAtom(
     296    const atom * const _walker,
     297    const AtomFragmentsMap &_atomfragments,
     298    const detail::KeysetsToGraph_t &_keyset_graphs,
     299    const detail::GraphFittedChargeMap_t &_fittedcharges_per_fragment)
     300{
     301  const atom * const surrogate = getNonHydrogenSurrogate(_walker);
    296302  const atomId_t walkerid = surrogate->getId();
    297303  const AtomFragmentsMap::AtomFragmentsMap_t &atommap = _atomfragments.getMap();
     
    357363    detail::AtomParticleNames_t &_atom_particlenames)
    358364{
    359   detail::GraphToNameMap_t GraphToNameMap;
    360365  for (detail::fitted_charges_t::const_iterator chargeiter = _fitted_charges.begin();
    361366      chargeiter != _fitted_charges.end(); ++chargeiter) {
    362367    const atomId_t &atomid = chargeiter->first;
    363     const detail::GraphIndices_t::right_const_iterator graphiter = _GraphIndices.right.find(atomid);
    364     const detail::GraphToNameMap_t::const_iterator nameiter = GraphToNameMap.find(graphiter->second);
     368    const atom * const walker = World::getInstance().getAtom(AtomById(atomid));
     369    ASSERT( walker != NULL,
     370        "addToParticleRegistry() - atom "+toString(atomid)
     371        +" not present in the World?");
     372    const detail::GraphIndices_t::right_const_iterator graphiter =
     373        _GraphIndices.right.find(atomid);
     374    ASSERT(graphiter != _GraphIndices.right.end(),
     375        "addToParticleRegistry() - atom #"+toString(atomid)
     376        +" not contained in GraphIndices.");
     377    const detail::AtomParticleNames_t::iterator nameiter =
     378        _atom_particlenames.find(graphiter->second);
     379    const atomicNumber_t elementno = walker->getElementNo();
    365380    std::string name;
    366     if (nameiter != GraphToNameMap.end()) {
    367       name = nameiter->second;
     381    if ((nameiter != _atom_particlenames.end()) && (nameiter->second.count(elementno))) {
     382        name = (nameiter->second)[elementno];
    368383    } else {
    369       const atom * const walker = World::getInstance().getAtom(AtomById(atomid));
    370       ASSERT( walker != NULL,
    371           "addToParticleRegistry() - atom "+toString(atomid)+" not present in the World?");
     384      if (nameiter == _atom_particlenames.end())
     385        _atom_particlenames.insert(
     386            std::make_pair(graphiter->second, std::map<atomicNumber_t, std::string>()) );
    372387      const double &charge = chargeiter->second;
    373       const atomicNumber_t elementno = walker->getElementNo();
    374388      name = Particle::findFreeName(periode, elementno);
    375       GraphToNameMap[graphiter->second] = name;
     389      _atom_particlenames[graphiter->second][elementno] = name;
    376390      LOG(1, "INFO: Adding particle " << name << " for atom "
    377391          << *walker << " with element " << elementno << ", charge " << charge);
    378392      factory.createInstance(name, elementno, charge);
    379393    }
    380     _atom_particlenames.insert( std::make_pair(atomid, name) );
    381394  }
    382395}
     
    439452  LOG(2, "DEBUG: There are " << index << " unique graphs in the homology container.");
    440453
    441   // go through every atom, get all graphs, convert to GraphIndex and store
    442 
     454  // go through every non-hydrogen atom, get all graphs, convert to GraphIndex and store
    443455  detail::GraphIndices_t GraphIndices;
    444456  const AtomFragmentsMap::AtomFragmentsMap_t &atommap = atomfragments.getMap();
    445457  for (World::AtomSelectionConstIterator atomiter = world.beginAtomSelection();
    446458      atomiter != world.endAtomSelection(); ++atomiter) {
    447     const atomId_t walkerid = atomiter->first;
     459    // use the non-hydrogen here
     460    const atomId_t walkerid = getNonHydrogenSurrogate(atomiter->second)->getId();
     461    if (walkerid != atomiter->first)
     462      continue;
    448463    const AtomFragmentsMap::AtomFragmentsMap_t::const_iterator keysetsiter =
    449         atommap.find(walkerid);
     464        atommap.find(atomiter->first);
    450465    ASSERT(keysetsiter != atommap.end(),
    451466        "PotentialFitPartialChargesAction::performCall() - we checked already that "
     
    453468    const AtomFragmentsMap::keysets_t & keysets = keysetsiter->second;
    454469
     470    // go over all fragments associated to this atom
    455471    detail::AtomsGraphIndices_t AtomsGraphIndices;
    456 
    457     // go over all fragments associated to this atom
    458472    for (AtomFragmentsMap::keysets_t::const_iterator keysetsiter = keysets.begin();
    459473        keysetsiter != keysets.end(); ++keysetsiter) {
     
    471485      AtomsGraphIndices.insert( indexiter->second );
    472486    }
    473     GraphIndices.left.insert( std::make_pair(AtomsGraphIndices, walkerid) );
    474     LOG(2, "DEBUG: Atom " << *atomiter->second << " has graph indices " << AtomsGraphIndices);
     487
     488    GraphIndices.insert( detail::GraphIndices_t::value_type(AtomsGraphIndices, atomiter->first) );
     489
     490    LOG(2, "DEBUG: Atom #" << atomiter->first << "," << *atomiter->second
     491        << ". has graph indices " << AtomsGraphIndices);
     492  }
     493  // then graphs from non-hydrogen bond partner for all hydrogens
     494  for (World::AtomSelectionConstIterator atomiter = world.beginAtomSelection();
     495      atomiter != world.endAtomSelection(); ++atomiter) {
     496    // use the non-hydrogen here
     497    const atomId_t walkerid = getNonHydrogenSurrogate(atomiter->second)->getId();
     498    if (walkerid == atomiter->first)
     499      continue;
     500    detail::GraphIndices_t::right_const_iterator graphiter = GraphIndices.right.find(walkerid);
     501    ASSERT( graphiter != GraphIndices.right.end(),
     502        "PotentialFitPartialChargesAction::performCall() - atom #"+toString(walkerid)
     503        +" not contained in GraphIndices.");
     504    const detail::AtomsGraphIndices_t &AtomsGraphIndices = graphiter->second;
     505    GraphIndices.insert( detail::GraphIndices_t::value_type(AtomsGraphIndices, atomiter->first) );
     506    LOG(2, "DEBUG: Hydrogen #" << atomiter->first << ", " << *atomiter->second
     507        << ", has graph indices " << AtomsGraphIndices);
    475508  }
    476509
Note: See TracChangeset for help on using the changeset viewer.