Index: src/bondgraph.cpp
===================================================================
--- src/bondgraph.cpp	(revision c7b1e7cc5f71dc867ab9cd60f52387cc20f52e45)
+++ src/bondgraph.cpp	(revision 1cbf477d77154171f9c093ad6d333a48cd3d068b)
@@ -9,4 +9,5 @@
 
 #include "atom.hpp"
+#include "bond.hpp"
 #include "bondgraph.hpp"
 #include "element.hpp"
@@ -86,5 +87,6 @@
 bool BondGraph::ConstructBondGraph(molecule * const mol)
 {
-  bool status = true;
+  Info FunctionInfo(__func__);
+bool status = true;
 
   if (mol->start->next == mol->end) // only construct if molecule is not empty
@@ -119,4 +121,5 @@
 double BondGraph::SetMaxDistanceToMaxOfCovalentRadii(const molecule * const mol)
 {
+  Info FunctionInfo(__func__);
   max_distance = 0.;
 
@@ -169,2 +172,76 @@
 };
 
+/** Counts the number of hydrogen bridge bonds.
+ * With \a *InterfaceElement an extra element can be specified that identifies some boundary.
+ * Then, counting is for the h-bridges that connect to interface only.
+ * \param *molecules molecules to count bonds
+ * \param *InterfaceElement or NULL
+ */
+int CountHydrogenBridgeBonds(MoleculeListClass *molecules, element * InterfaceElement = NULL)
+{
+  Info FunctionInfo(__func__);
+  atom *Walker = NULL;
+  atom *Runner = NULL;
+  atom *Hydrogen = NULL;
+  atom *OtherHydrogen = NULL;
+  Vector OHBond;
+  Vector OOBond;
+  int count = 0;
+  bool HydrogenFlag = false;
+  bool OtherHydrogenFlag = false;
+  bool InterfaceFlag = false;
+  for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin();MolWalker != molecules->ListOfMolecules.end(); MolWalker++) {
+    Walker = (*MolWalker)->start;
+    while (Walker->next != (*MolWalker)->end) {
+      Walker = Walker->next;
+      for (MoleculeList::const_iterator MolRunner = molecules->ListOfMolecules.begin();MolRunner != molecules->ListOfMolecules.end(); MolRunner++) {
+        Runner = (*MolRunner)->start;
+        while (Runner->next != (*MolRunner)->end) {
+          Runner = Runner->next;
+          if ((Runner != Walker) && (Walker->type->Z  == 8) && (Runner->type->Z  == 8)) {
+            // check distance
+            const double distance = Runner->x.DistanceSquared(&Walker->x);
+            if (distance < HBRIDGEDISTANCE*HBRIDGEDISTANCE) {
+              // get hydrogen, check for InterfaceElement
+              HydrogenFlag = false;
+              OtherHydrogenFlag = false;
+              InterfaceFlag = (InterfaceElement == NULL);
+              // on other atom(Runner) we check for bond to interface element
+              for (BondList::const_iterator BondRunner = Runner->ListOfBonds.begin(); BondRunner != Runner->ListOfBonds.end(); BondRunner++) {
+                atom * const OtherAtom = (*BondRunner)->GetOtherAtom(Walker);
+                if (!OtherHydrogenFlag && (OtherAtom->type->Z == 1)) {
+                  OtherHydrogen = OtherAtom;
+                  OtherHydrogen = true;
+                }
+                InterfaceFlag = InterfaceFlag || (OtherAtom->type == InterfaceElement);
+              }
+              // on this element (Walker) we check for bond to hydrogen, i.e. part of water molecule
+              for (BondList::const_iterator BondRunner = Walker->ListOfBonds.begin(); BondRunner != Walker->ListOfBonds.end(); BondRunner++) {
+                atom * const OtherAtom = (*BondRunner)->GetOtherAtom(Walker);
+                if (!HydrogenFlag && (OtherAtom->type->Z == 1)) {
+                  Hydrogen = OtherAtom;
+                  HydrogenFlag = true;
+                }
+              }
+              if (InterfaceFlag && HydrogenFlag) {
+                if ((Walker->nr < Runner->nr) || (!OtherHydrogenFlag)) {
+                  // check angle
+                  OHBond.CopyVector(&Walker->x);
+                  OHBond.SubtractVector(&Hydrogen->x);
+                  OOBond.CopyVector(&Runner->x);
+                  OOBond.SubtractVector(&Walker->x);
+                  const double angle = OHBond.Angle(&OOBond);
+                  if (angle < M_PI*(30./180.)) {
+                    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);
+                    count++;
+                  }
+                }
+              }
+            }
+          }
+        }
+      }
+    }
+  }
+  return count;
+}
Index: src/bondgraph.hpp
===================================================================
--- src/bondgraph.hpp	(revision c7b1e7cc5f71dc867ab9cd60f52387cc20f52e45)
+++ src/bondgraph.hpp	(revision 1cbf477d77154171f9c093ad6d333a48cd3d068b)
@@ -23,8 +23,10 @@
 
 #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
+#define HBRIDGEDISTANCE 3.5   //!< HBridge distance from PCCP Vol 10. 4802-4813
 
 /****************************************** forward declarations *****************************/
 
 class molecule;
+class MoleculeListClass;
 class periodentafel;
 class MatrixContainer;
@@ -53,3 +55,5 @@
 };
 
+int CountHydrogenBridgeBonds(MoleculeListClass * const molecules, element * InterfaceElement);
+
 #endif /* BONDGRAPH_HPP_ */
Index: src/builder.cpp
===================================================================
--- src/builder.cpp	(revision c7b1e7cc5f71dc867ab9cd60f52387cc20f52e45)
+++ src/builder.cpp	(revision 1cbf477d77154171f9c093ad6d333a48cd3d068b)
@@ -1090,4 +1090,5 @@
   Log() << Verbose(0) << "a - simple add of one molecule to another" << endl;
   Log() << Verbose(0) << "e - embedding merge of two molecules" << endl;
+  Log() << Verbose(0) << "h - count the number of hydrogen bonds" << endl;
   Log() << Verbose(0) << "m - multi-merge of all molecules" << endl;
   Log() << Verbose(0) << "s - scatter merge of two molecules" << endl;
@@ -1140,4 +1141,14 @@
         if ((src != -1) && (dest != -1))
           molecules->EmbedMerge(destmol, srcmol);
+      }
+      break;
+
+    case 'h':
+      {
+        int Z;
+        cout << "Please enter interface element: ";
+        cin >> Z;
+        element * const InterfaceElement = periode->FindElement(Z);
+        cout << endl << "There are " << CountHydrogenBridgeBonds(molecules, InterfaceElement) << " hydrogen bridges with connections to " << (InterfaceElement != 0 ? InterfaceElement->name : "None") << "." << endl;
       }
       break;
