Index: src/Makefile.am
===================================================================
--- src/Makefile.am	(revision 12098a4b39967b9685cdc4ee1bad7bc1723f2073)
+++ src/Makefile.am	(revision 6bb72a1d333eb13b241f2296056b61a3f431aa72)
@@ -31,4 +31,5 @@
 include Parameters/Makefile.am
 include Parser/Makefile.am
+include Potentials/Makefile.am
 include RandomNumbers/Makefile.am
 include Shapes/Makefile.am
Index: src/Potentials/EmpiricalPotential.hpp
===================================================================
--- src/Potentials/EmpiricalPotential.hpp	(revision 6bb72a1d333eb13b241f2296056b61a3f431aa72)
+++ src/Potentials/EmpiricalPotential.hpp	(revision 6bb72a1d333eb13b241f2296056b61a3f431aa72)
@@ -0,0 +1,76 @@
+/*
+ * EmpiricalPotential.hpp
+ *
+ *  Created on: Sep 26, 2012
+ *      Author: heber
+ */
+
+#ifndef EMPIRICALPOTENTIAL_HPP_
+#define EMPIRICALPOTENTIAL_HPP_
+
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <vector>
+
+/** An EmpiricalPotential is a function that is given a vector of objects as
+ * arguments which it uses to evaluate an internal function and returns a
+ * value representing the energy of this configuration indicated by the
+ * arguments.
+ *
+ * It is to be used inside an std::accumulate function after a vector of
+ * arguments (i.e. a vector of a vector) has been prepared initially.
+ *
+ */
+class EmpiricalPotential
+{
+public:
+  /** This class encapsulates all information with respect to a single argument
+   *  for a empirical potential function.
+   */
+  struct argument_t
+  {
+    //!> indices between which the distance is given
+    std::pair<size_t, size_t> indices;
+    //!> distance
+    double distance;
+  };
+
+  //!> typedef on the result value of operator()
+  typedef double result_t;
+  //!> typedef on the result value of derivative()
+  typedef std::vector<result_t> derivative_components_t;
+  //!> typedef for the list of argument_t to be given to operator().
+  typedef std::vector<argument_t> arguments_t;
+public:
+  /** Default constructor for class EmpiricalPotential.
+   *
+   */
+  EmpiricalPotential();
+
+  /** Destructor for class EmpiricalPotential.
+   *
+   */
+  virtual ~EmpiricalPotential() {}
+
+  /** This evaluates the internal function with the given list of \a arguments.
+   *
+   * @param arguments arguments for the internal function
+   * @return result of the function evaluation
+   */
+  result_t operator()(const arguments_t &arguments) const;
+
+  /** This evaluates the first derivative of the internal function with the
+   * given list of \a arguments.
+   *
+   * @param arguments arguments for the internal function
+   * @return result vector with same number of components as \a arguments
+   */
+  derivative_components_t derivative(const arguments_t &arguments) const;
+};
+
+
+#endif /* EMPIRICALPOTENTIAL_HPP_ */
Index: src/Potentials/Makefile.am
===================================================================
--- src/Potentials/Makefile.am	(revision 6bb72a1d333eb13b241f2296056b61a3f431aa72)
+++ src/Potentials/Makefile.am	(revision 6bb72a1d333eb13b241f2296056b61a3f431aa72)
@@ -0,0 +1,52 @@
+# PLEASE adhere to the alphabetical ordering in this Makefile!
+# Also indentation by a single tab
+
+POTENTIALSSOURCE = \
+  Potentials/Specifics/PairPotential_Harmonic.cpp
+
+POTENTIALSHEADER = \
+  Potentials/EmpiricalPotential.hpp \
+  Potentials/helpers.hpp \
+  Potentials/Specifics/PairPotential_Harmonic.hpp
+
+
+noinst_LTLIBRARIES += libMolecuilderPotentials.la
+libMolecuilderPotentials_la_includedir = $(includedir)/MoleCuilder/Potentials/
+
+nobase_libMolecuilderPotentials_la_include_HEADERS = ${POTENTIALSHEADER}
+
+## Define the source file list for the "libexample-@MOLECUILDER_API_VERSION@.la"
+## target.  Note that @MOLECUILDER_API_VERSION@ is not interpreted by Automake and
+## will therefore be treated as if it were literally part of the target name,
+## and the variable name derived from that.
+## The file extension .cc is recognized by Automake, and makes it produce
+## rules which invoke the C++ compiler to produce a libtool object file (.lo)
+## from each source file.  Note that it is not necessary to list header files
+## which are already listed elsewhere in a _HEADERS variable assignment.
+libMolecuilderPotentials_la_SOURCES = ${POTENTIALSSOURCE}
+
+## Instruct libtool to include ABI version information in the generated shared
+## library file (.so).  The library ABI version is defined in configure.ac, so
+## that all version information is kept in one place.
+#libMolecuilderPotentials_la_LDFLAGS = -version-info $(MOLECUILDER_SO_VERSION)
+
+## The generated configuration header is installed in its own subdirectory of
+## $(libdir).  The reason for this is that the configuration information put
+## into this header file describes the target platform the installed library
+## has been built for.  Thus the file must not be installed into a location
+## intended for architecture-independent files, as defined by the Filesystem
+## Hierarchy Standard (FHS).
+## The nodist_ prefix instructs Automake to not generate rules for including
+## the listed files in the distribution on 'make dist'.  Files that are listed
+## in _HEADERS variables are normally included in the distribution, but the
+## configuration header file is generated at configure time and should not be
+## shipped with the source tarball.
+#libMolecuilderPotentials_libincludedir = $(libdir)/MoleCuilder/include
+#nodist_libMolecuilderPotentials_libinclude_HEADERS = $(top_builddir)/libmolecuilder_config.h
+
+## Install the generated pkg-config file (.pc) into the expected location for
+## architecture-dependent package configuration information.  Occasionally,
+## pkg-config files are also used for architecture-independent data packages,
+## in which case the correct install location would be $(datadir)/pkgconfig.
+#pkgconfigdir = $(libdir)/pkgconfig
+#pkgconfig_DATA = $(top_builddir)/MoleCuilder.pc
Index: src/Potentials/Specifics/PairPotential_Harmonic.cpp
===================================================================
--- src/Potentials/Specifics/PairPotential_Harmonic.cpp	(revision 6bb72a1d333eb13b241f2296056b61a3f431aa72)
+++ src/Potentials/Specifics/PairPotential_Harmonic.cpp	(revision 6bb72a1d333eb13b241f2296056b61a3f431aa72)
@@ -0,0 +1,70 @@
+/*
+ * Project: MoleCuilder
+ * Description: creates and alters molecular systems
+ * Copyright (C)  2012 University of Bonn. All rights reserved.
+ * Please see the COPYING file or "Copyright notice" in builder.cpp for details.
+ * 
+ *
+ *   This file is part of MoleCuilder.
+ *
+ *    MoleCuilder is free software: you can redistribute it and/or modify
+ *    it under the terms of the GNU General Public License as published by
+ *    the Free Software Foundation, either version 2 of the License, or
+ *    (at your option) any later version.
+ *
+ *    MoleCuilder is distributed in the hope that it will be useful,
+ *    but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *    GNU General Public License for more details.
+ *
+ *    You should have received a copy of the GNU General Public License
+ *    along with MoleCuilder.  If not, see <http://www.gnu.org/licenses/>. 
+ */
+
+/*
+ * PairPotential_Harmonic.cpp
+ *
+ *  Created on: Sep 26, 2012
+ *      Author: heber
+ */
+
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "CodePatterns/MemDebug.hpp"
+
+#include "PairPotential_Harmonic.hpp"
+
+#include "CodePatterns/Assert.hpp"
+
+#include "Potentials/helpers.hpp"
+
+EmpiricalPotential::result_t
+PairPotential_Harmonic::operator()(
+    const arguments_t &arguments
+    ) const
+{
+  ASSERT( arguments.size() == 1,
+      "PairPotential_Harmonic::operator() - requires exactly one argument.");
+  const argument_t &r_ij = arguments[0];
+  const result_t result = spring_constant * Helpers::pow( r_ij.distance - equilibrium_distance, 2 );
+  return result;
+}
+
+EmpiricalPotential::derivative_components_t
+PairPotential_Harmonic::derivative(
+    const arguments_t &arguments
+    ) const
+{
+  ASSERT( arguments.size() == 1,
+      "PairPotential_Harmonic::operator() - requires exactly one argument.");
+  derivative_components_t result;
+  const argument_t &r_ij = arguments[0];
+  result.push_back( 2. * spring_constant * ( r_ij.distance - equilibrium_distance) );
+  ASSERT( result.size() == 1,
+      "PairPotential_Harmonic::operator() - we did not create exactly one component.");
+  return result;
+}
Index: src/Potentials/Specifics/PairPotential_Harmonic.hpp
===================================================================
--- src/Potentials/Specifics/PairPotential_Harmonic.hpp	(revision 6bb72a1d333eb13b241f2296056b61a3f431aa72)
+++ src/Potentials/Specifics/PairPotential_Harmonic.hpp	(revision 6bb72a1d333eb13b241f2296056b61a3f431aa72)
@@ -0,0 +1,57 @@
+/*
+ * PairPotential_Harmonic.hpp
+ *
+ *  Created on: Sep 26, 2012
+ *      Author: heber
+ */
+
+#ifndef PAIRPOTENTIAL_HARMONIC_HPP_
+#define PAIRPOTENTIAL_HARMONIC_HPP_
+
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+
+#include "Potentials/EmpiricalPotential.hpp"
+
+/** This is the implementation of a harmonic pair potential.
+ *
+ * This evaluates \f$ k \cdot (r -r_0)^2 \f$.
+ *
+ */
+class PairPotential_Harmonic : public EmpiricalPotential
+{
+public:
+  PairPotential_Harmonic(
+      const double _spring_constant,
+      const double _equilibrium_distance) :
+    spring_constant(_spring_constant),
+    equilibrium_distance(_equilibrium_distance)
+  {}
+  virtual ~PairPotential_Harmonic() {}
+
+  /** Evaluates the harmonic potential function for the given arguments.
+   *
+   * @param arguments single distance
+   * @return value of the potential function
+   */
+  result_t operator()(const arguments_t &arguments) const;
+
+  /** Evaluates the derivative of the potential function.
+   *
+   * @param arguments single distance
+   * @return vector with derivative with respect to the input degrees of freedom
+   */
+  derivative_components_t derivative(const arguments_t &arguments) const;
+
+private:
+  //!> the spring constant for the harmonic potential
+  const double spring_constant;
+  //!> the equilibrium distance indicating the potential minimum
+  const double equilibrium_distance;
+};
+
+#endif /* PAIRPOTENTIAL_HARMONIC_HPP_ */
Index: src/Potentials/helpers.hpp
===================================================================
--- src/Potentials/helpers.hpp	(revision 6bb72a1d333eb13b241f2296056b61a3f431aa72)
+++ src/Potentials/helpers.hpp	(revision 6bb72a1d333eb13b241f2296056b61a3f431aa72)
@@ -0,0 +1,65 @@
+/*
+ * helpers.hpp
+ *
+ *  Created on: Sep 26, 2012
+ *      Author: heber
+ */
+
+#ifndef POTENTIALS_HELPERS_HPP_
+#define POTENTIALS_HELPERS_HPP_
+
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+namespace Helpers
+{
+
+  /** Integer-optimized version for power of n.
+   *
+   * This is taken from Julian Iseringhausen's VMG project which is under
+   * GPL.
+   *
+   * @param base base
+   * @param power power to take \a base to
+   * @return \a base to the power of \a power
+   */
+  inline int intpow(int base, unsigned int power)
+  {
+    int result = 1;
+    while (power != 0) {
+      if (power & 1)
+        result *= base;
+      base *= base;
+      power >>= 1;
+    }
+    return result;
+  }
+
+  /** Double-optimized version for power of n.
+   *
+   * This is taken from Julian Iseringhausen's VMG project which is under
+   * GPL.
+   *
+   * @param base base
+   * @param power power to take \a base to
+   * @return \a base to the power of \a power
+   */
+  inline double pow(double base, unsigned int power)
+  {
+    double result = 1.0;
+    while (power != 0) {
+      if (power & 1)
+        result *= base;
+      base *= base;
+      power >>= 1;
+    }
+    return result;
+  }
+
+}; /* namespace Helpers */
+
+
+#endif /* POTENTIALS_HELPERS_HPP_ */
