Changeset 388ddd for src/World.cpp


Ignore:
Timestamp:
Sep 8, 2014, 9:36:29 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:
dc798d
Parents:
553c54
git-author:
Frederik Heber <heber@…> (08/15/14 00:00:21)
git-committer:
Frederik Heber <heber@…> (09/08/14 21:36:29)
Message:

World::setTime() now only copies bond graph, does not re-create it.

  • this gives us more flexibility when doing MD/Opt because we may decice for ourselves whether we want to remain (within the fragmentation scheme) in the structure governed by the same bond graph ... or seek even for a different structure (although that's not so easy due to charge neutrality).
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/World.cpp

    r553c54 r388ddd  
    194194}
    195195
     196bool areBondsPresent(const unsigned int _step)
     197{
     198  bool status = false;
     199
     200  for (World::AtomConstIterator iter = const_cast<const World &>(World::getInstance()).getAtomIter();
     201      (!status) && (iter != const_cast<const World &>(World::getInstance()).atomEnd()); ++iter) {
     202    const atom * const Walker = *iter;
     203    status |= !Walker->getListOfBondsAtStep(_step).empty();
     204  }
     205
     206  return status;
     207}
     208
     209void copyBondgraph(const unsigned int _srcstep, const unsigned int _deststep)
     210{
     211  // gather all bonds from _srcstep
     212  std::set<bond *> SetOfBonds;
     213  for (World::AtomConstIterator iter = const_cast<const World &>(World::getInstance()).getAtomIter();
     214      iter != const_cast<const World &>(World::getInstance()).atomEnd(); ++iter) {
     215    const atom * const Walker = *iter;
     216    const BondList bonds = Walker->getListOfBondsAtStep(_srcstep);
     217    BOOST_FOREACH( bond::ptr bondptr, bonds) {
     218      SetOfBonds.insert(bondptr.get());
     219    }
     220  }
     221  LOG(4, "DEBUG: We gathered " << SetOfBonds.size() << " bonds in total.");
     222
     223  // copy bond to new time step
     224  for (std::set<bond *>::const_iterator bonditer = SetOfBonds.begin();
     225      bonditer != SetOfBonds.end(); ++bonditer) {
     226    const atom * const Walker = (*bonditer)->leftatom;
     227    const atom * const OtherWalker = (*bonditer)->rightatom;
     228    const_cast<atom *>(Walker)->addBond(_deststep, const_cast<atom *>(OtherWalker));
     229  }
     230}
     231
    196232void World::setTime(const unsigned int _step)
    197233{
    198234  if (_step != WorldTime::getTime()) {
     235    const unsigned int oldstep = WorldTime::getTime();
    199236    // set new time
    200237    WorldTime::getInstance().setTime(_step);
     
    207244      destroyMolecule(*iter);
    208245    }
    209     // 2. (re-)create bondgraph
    210     AtomComposite Set = getAllAtoms();
    211     BG->CreateAdjacency(Set);
     246    // 2. copy bond graph
     247    if (!areBondsPresent(_step)) {
     248//      AtomComposite Set = getAllAtoms();
     249//      BG->cleanAdjacencyList(Set);
     250      copyBondgraph(oldstep, _step);
     251    }
    212252
    213253    // 3. scan for connected subgraphs => molecules
Note: See TracChangeset for help on using the changeset viewer.