Changeset 1cbf47 for src


Ignore:
Timestamp:
Mar 18, 2010, 3:38:56 PM (15 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:
f18185
Parents:
c7b1e7
git-author:
Frederik Heber <heber@…> (03/18/10 15:29:54)
git-committer:
Frederik Heber <heber@…> (03/18/10 15:38:56)
Message:

Introduced CountHydrogenBridgeBonds() function.

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

Location:
src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/bondgraph.cpp

    rc7b1e7 r1cbf47  
    99
    1010#include "atom.hpp"
     11#include "bond.hpp"
    1112#include "bondgraph.hpp"
    1213#include "element.hpp"
     
    8687bool BondGraph::ConstructBondGraph(molecule * const mol)
    8788{
    88   bool status = true;
     89  Info FunctionInfo(__func__);
     90bool status = true;
    8991
    9092  if (mol->start->next == mol->end) // only construct if molecule is not empty
     
    119121double BondGraph::SetMaxDistanceToMaxOfCovalentRadii(const molecule * const mol)
    120122{
     123  Info FunctionInfo(__func__);
    121124  max_distance = 0.;
    122125
     
    169172};
    170173
     174/** Counts the number of hydrogen bridge bonds.
     175 * With \a *InterfaceElement an extra element can be specified that identifies some boundary.
     176 * Then, counting is for the h-bridges that connect to interface only.
     177 * \param *molecules molecules to count bonds
     178 * \param *InterfaceElement or NULL
     179 */
     180int CountHydrogenBridgeBonds(MoleculeListClass *molecules, element * InterfaceElement = NULL)
     181{
     182  Info FunctionInfo(__func__);
     183  atom *Walker = NULL;
     184  atom *Runner = NULL;
     185  atom *Hydrogen = NULL;
     186  atom *OtherHydrogen = NULL;
     187  Vector OHBond;
     188  Vector OOBond;
     189  int count = 0;
     190  bool HydrogenFlag = false;
     191  bool OtherHydrogenFlag = false;
     192  bool InterfaceFlag = false;
     193  for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin();MolWalker != molecules->ListOfMolecules.end(); MolWalker++) {
     194    Walker = (*MolWalker)->start;
     195    while (Walker->next != (*MolWalker)->end) {
     196      Walker = Walker->next;
     197      for (MoleculeList::const_iterator MolRunner = molecules->ListOfMolecules.begin();MolRunner != molecules->ListOfMolecules.end(); MolRunner++) {
     198        Runner = (*MolRunner)->start;
     199        while (Runner->next != (*MolRunner)->end) {
     200          Runner = Runner->next;
     201          if ((Runner != Walker) && (Walker->type->Z  == 8) && (Runner->type->Z  == 8)) {
     202            // check distance
     203            const double distance = Runner->x.DistanceSquared(&Walker->x);
     204            if (distance < HBRIDGEDISTANCE*HBRIDGEDISTANCE) {
     205              // get hydrogen, check for InterfaceElement
     206              HydrogenFlag = false;
     207              OtherHydrogenFlag = false;
     208              InterfaceFlag = (InterfaceElement == NULL);
     209              // on other atom(Runner) we check for bond to interface element
     210              for (BondList::const_iterator BondRunner = Runner->ListOfBonds.begin(); BondRunner != Runner->ListOfBonds.end(); BondRunner++) {
     211                atom * const OtherAtom = (*BondRunner)->GetOtherAtom(Walker);
     212                if (!OtherHydrogenFlag && (OtherAtom->type->Z == 1)) {
     213                  OtherHydrogen = OtherAtom;
     214                  OtherHydrogen = true;
     215                }
     216                InterfaceFlag = InterfaceFlag || (OtherAtom->type == InterfaceElement);
     217              }
     218              // on this element (Walker) we check for bond to hydrogen, i.e. part of water molecule
     219              for (BondList::const_iterator BondRunner = Walker->ListOfBonds.begin(); BondRunner != Walker->ListOfBonds.end(); BondRunner++) {
     220                atom * const OtherAtom = (*BondRunner)->GetOtherAtom(Walker);
     221                if (!HydrogenFlag && (OtherAtom->type->Z == 1)) {
     222                  Hydrogen = OtherAtom;
     223                  HydrogenFlag = true;
     224                }
     225              }
     226              if (InterfaceFlag && HydrogenFlag) {
     227                if ((Walker->nr < Runner->nr) || (!OtherHydrogenFlag)) {
     228                  // check angle
     229                  OHBond.CopyVector(&Walker->x);
     230                  OHBond.SubtractVector(&Hydrogen->x);
     231                  OOBond.CopyVector(&Runner->x);
     232                  OOBond.SubtractVector(&Walker->x);
     233                  const double angle = OHBond.Angle(&OOBond);
     234                  if (angle < M_PI*(30./180.)) {
     235                    DoLog(1) && (Log() << Verbose(1) << Walker->Name << ", " << Hydrogen->Name << " and " << Runner->Name << " have a hydrogen bridge bond with " << sqrt(distance) << " and at angle " << (180./M_PI)*angle << " degrees." << endl);
     236                    count++;
     237                  }
     238                }
     239              }
     240            }
     241          }
     242        }
     243      }
     244    }
     245  }
     246  return count;
     247}
  • src/bondgraph.hpp

    rc7b1e7 r1cbf47  
    2323
    2424#define BONDTHRESHOLD 0.4   //!< CSD threshold in bond check which is the width of the interval whose center is the sum of the covalent radii
     25#define HBRIDGEDISTANCE 3.5   //!< HBridge distance from PCCP Vol 10. 4802-4813
    2526
    2627/****************************************** forward declarations *****************************/
    2728
    2829class molecule;
     30class MoleculeListClass;
    2931class periodentafel;
    3032class MatrixContainer;
     
    5355};
    5456
     57int CountHydrogenBridgeBonds(MoleculeListClass * const molecules, element * InterfaceElement);
     58
    5559#endif /* BONDGRAPH_HPP_ */
  • src/builder.cpp

    rc7b1e7 r1cbf47  
    10901090  Log() << Verbose(0) << "a - simple add of one molecule to another" << endl;
    10911091  Log() << Verbose(0) << "e - embedding merge of two molecules" << endl;
     1092  Log() << Verbose(0) << "h - count the number of hydrogen bonds" << endl;
    10921093  Log() << Verbose(0) << "m - multi-merge of all molecules" << endl;
    10931094  Log() << Verbose(0) << "s - scatter merge of two molecules" << endl;
     
    11401141        if ((src != -1) && (dest != -1))
    11411142          molecules->EmbedMerge(destmol, srcmol);
     1143      }
     1144      break;
     1145
     1146    case 'h':
     1147      {
     1148        int Z;
     1149        cout << "Please enter interface element: ";
     1150        cin >> Z;
     1151        element * const InterfaceElement = periode->FindElement(Z);
     1152        cout << endl << "There are " << CountHydrogenBridgeBonds(molecules, InterfaceElement) << " hydrogen bridges with connections to " << (InterfaceElement != 0 ? InterfaceElement->name : "None") << "." << endl;
    11421153      }
    11431154      break;
Note: See TracChangeset for help on using the changeset viewer.