Changeset f18185 for src/bondgraph.cpp


Ignore:
Timestamp:
Mar 19, 2010, 3:42:58 PM (16 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, Candidate_v1.7.0, 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:
dfe8ef
Parents:
1cbf47
git-author:
Frederik Heber <heber@…> (03/19/10 14:03:54)
git-committer:
Frederik Heber <heber@…> (03/19/10 15:42:58)
Message:

Implemented counting of bonds over all atoms.

Signed-off-by: Frederik Heber <heber@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/bondgraph.cpp

    r1cbf47 rf18185  
    209209              // on other atom(Runner) we check for bond to interface element
    210210              for (BondList::const_iterator BondRunner = Runner->ListOfBonds.begin(); BondRunner != Runner->ListOfBonds.end(); BondRunner++) {
    211                 atom * const OtherAtom = (*BondRunner)->GetOtherAtom(Walker);
     211                atom * const OtherAtom = (*BondRunner)->GetOtherAtom(Runner);
    212212                if (!OtherHydrogenFlag && (OtherAtom->type->Z == 1)) {
    213213                  OtherHydrogen = OtherAtom;
    214                   OtherHydrogen = true;
     214                  OtherHydrogenFlag = true;
    215215                }
    216216                InterfaceFlag = InterfaceFlag || (OtherAtom->type == InterfaceElement);
     
    227227                if ((Walker->nr < Runner->nr) || (!OtherHydrogenFlag)) {
    228228                  // check angle
    229                   OHBond.CopyVector(&Walker->x);
    230                   OHBond.SubtractVector(&Hydrogen->x);
     229                  OHBond.CopyVector(&Hydrogen->x);
     230                  OHBond.SubtractVector(&Walker->x);
    231231                  OOBond.CopyVector(&Runner->x);
    232232                  OOBond.SubtractVector(&Walker->x);
     
    246246  return count;
    247247}
     248
     249/** Counts the number of bonds between two given elements.
     250 * \param *molecules list of molecules with all atoms
     251 * \param *first pointer to first element
     252 * \param *second pointer to second element
     253 * \return number of found bonds (\a *first-\a *second)
     254 */
     255int CountBondsOfTwo(MoleculeListClass * const molecules, const element * const first, const element * const second)
     256{
     257  atom *Walker = NULL;
     258  int count = 0;
     259
     260  for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin();MolWalker != molecules->ListOfMolecules.end(); MolWalker++) {
     261    Walker = (*MolWalker)->start;
     262    while (Walker->next != (*MolWalker)->end) {
     263      Walker = Walker->next;
     264      if ((Walker->type == first) || (Walker->type == second)) {  // first element matches
     265        for (BondList::const_iterator BondRunner = Walker->ListOfBonds.begin(); BondRunner != Walker->ListOfBonds.end(); BondRunner++) {
     266          atom * const OtherAtom = (*BondRunner)->GetOtherAtom(Walker);
     267          if (((OtherAtom->type == first) || (OtherAtom->type == second)) && (Walker->nr < OtherAtom->nr)) {
     268            count++;
     269            DoLog(1) && (Log() << Verbose(1) << first->name << "-" << second->name << " bond found between " << *Walker << " and " << *OtherAtom << "." << endl);
     270          }
     271        }
     272      }
     273    }
     274  }
     275  return count;
     276};
     277
     278/** Counts the number of bonds between three given elements.
     279 * Note that we do not look for arbitrary sequence of given bonds, but \a *second will be the central atom and we check
     280 * whether it has bonds to both \a *first and \a *third.
     281 * \param *molecules list of molecules with all atoms
     282 * \param *first pointer to first element
     283 * \param *second pointer to second element
     284 * \param *third pointer to third element
     285 * \return number of found bonds (\a *first-\a *second-\a *third, \a *third-\a *second-\a *first, respectively)
     286 */
     287int CountBondsOfThree(MoleculeListClass * const molecules, const element * const first, const element * const second, const element * const third)
     288{
     289  int count = 0;
     290  bool MatchFlag[2];
     291  bool result = false;
     292  atom *Walker = NULL;
     293  const element * ElementArray[2];
     294  ElementArray[0] = first;
     295  ElementArray[1] = third;
     296
     297  for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin();MolWalker != molecules->ListOfMolecules.end(); MolWalker++) {
     298    Walker = (*MolWalker)->start;
     299    while (Walker->next != (*MolWalker)->end) {
     300      Walker = Walker->next;
     301      if (Walker->type == second) {  // first element matches
     302        for (int i=0;i<2;i++)
     303          MatchFlag[i] = false;
     304        for (BondList::const_iterator BondRunner = Walker->ListOfBonds.begin(); BondRunner != Walker->ListOfBonds.end(); BondRunner++) {
     305          atom * const OtherAtom = (*BondRunner)->GetOtherAtom(Walker);
     306          for (int i=0;i<2;i++)
     307            MatchFlag[i] = MatchFlag[i] || (OtherAtom->type == ElementArray[i]);
     308        }
     309        result = true;
     310        for (int i=0;i<2;i++)
     311          result = result && MatchFlag[i];
     312        if (result) {
     313          count++;
     314          DoLog(1) && (Log() << Verbose(1) << first->name << "-" << second->name << "-" << third->name << " bond found at " << *Walker << "." << endl);
     315        }
     316      }
     317    }
     318  }
     319  return count;
     320};
Note: See TracChangeset for help on using the changeset viewer.