Changeset ed0f88 for src/Actions
- Timestamp:
- May 18, 2016, 10:02:54 PM (9 years ago)
- 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)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Actions/PotentialAction/FitPartialChargesAction.cpp
r91f907 red0f88 91 91 typedef std::set<size_t> AtomsGraphIndices_t; 92 92 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; 97 97 98 98 typedef std::map<std::set<size_t>, std::string> GraphToNameMap_t; … … 277 277 } 278 278 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) 279 const atom * getNonHydrogenSurrogate(const atom * const _walker) 284 280 { 285 281 const atom * surrogate = _walker; … … 289 285 const BondList &ListOfBonds = surrogate->getListOfBonds(); 290 286 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; 293 289 } 294 290 surrogate = (*ListOfBonds.begin())->GetOtherAtom(surrogate); 295 291 } 292 return surrogate; 293 } 294 295 double 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); 296 302 const atomId_t walkerid = surrogate->getId(); 297 303 const AtomFragmentsMap::AtomFragmentsMap_t &atommap = _atomfragments.getMap(); … … 357 363 detail::AtomParticleNames_t &_atom_particlenames) 358 364 { 359 detail::GraphToNameMap_t GraphToNameMap;360 365 for (detail::fitted_charges_t::const_iterator chargeiter = _fitted_charges.begin(); 361 366 chargeiter != _fitted_charges.end(); ++chargeiter) { 362 367 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(); 365 380 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]; 368 383 } 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>()) ); 372 387 const double &charge = chargeiter->second; 373 const atomicNumber_t elementno = walker->getElementNo();374 388 name = Particle::findFreeName(periode, elementno); 375 GraphToNameMap[graphiter->second] = name;389 _atom_particlenames[graphiter->second][elementno] = name; 376 390 LOG(1, "INFO: Adding particle " << name << " for atom " 377 391 << *walker << " with element " << elementno << ", charge " << charge); 378 392 factory.createInstance(name, elementno, charge); 379 393 } 380 _atom_particlenames.insert( std::make_pair(atomid, name) );381 394 } 382 395 } … … 439 452 LOG(2, "DEBUG: There are " << index << " unique graphs in the homology container."); 440 453 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 443 455 detail::GraphIndices_t GraphIndices; 444 456 const AtomFragmentsMap::AtomFragmentsMap_t &atommap = atomfragments.getMap(); 445 457 for (World::AtomSelectionConstIterator atomiter = world.beginAtomSelection(); 446 458 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; 448 463 const AtomFragmentsMap::AtomFragmentsMap_t::const_iterator keysetsiter = 449 atommap.find( walkerid);464 atommap.find(atomiter->first); 450 465 ASSERT(keysetsiter != atommap.end(), 451 466 "PotentialFitPartialChargesAction::performCall() - we checked already that " … … 453 468 const AtomFragmentsMap::keysets_t & keysets = keysetsiter->second; 454 469 470 // go over all fragments associated to this atom 455 471 detail::AtomsGraphIndices_t AtomsGraphIndices; 456 457 // go over all fragments associated to this atom458 472 for (AtomFragmentsMap::keysets_t::const_iterator keysetsiter = keysets.begin(); 459 473 keysetsiter != keysets.end(); ++keysetsiter) { … … 471 485 AtomsGraphIndices.insert( indexiter->second ); 472 486 } 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); 475 508 } 476 509
Note:
See TracChangeset
for help on using the changeset viewer.