Index: src/Potentials/Specifics/FourBodyPotential_Torsion.cpp
===================================================================
--- src/Potentials/Specifics/FourBodyPotential_Torsion.cpp	(revision e2037e5d443e6ac456d3cbf14b2e4127a4bbd7a6)
+++ src/Potentials/Specifics/FourBodyPotential_Torsion.cpp	(revision e2037e5d443e6ac456d3cbf14b2e4127a4bbd7a6)
@@ -0,0 +1,256 @@
+/*
+ * Project: MoleCuilder
+ * Description: creates and alters molecular systems
+ * Copyright (C)  2013 Frederik Heber. 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/>. 
+ */
+
+/*
+ * FourBodyPotential_Torsion.cpp
+ *
+ *  Created on: Jul 08, 2013
+ *      Author: heber
+ */
+
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "CodePatterns/MemDebug.hpp"
+
+#include "FourBodyPotential_Torsion.hpp"
+
+#include <boost/assign/list_of.hpp> // for 'map_list_of()'
+#include <boost/bind.hpp>
+#include <boost/lambda/lambda.hpp>
+#include <string>
+
+#include "CodePatterns/Assert.hpp"
+
+#include "FunctionApproximation/Extractors.hpp"
+#include "FunctionApproximation/TrainingData.hpp"
+#include "Potentials/helpers.hpp"
+#include "Potentials/ParticleTypeCheckers.hpp"
+
+class Fragment;
+
+// static definitions
+const FourBodyPotential_Torsion::ParameterNames_t
+FourBodyPotential_Torsion::ParameterNames =
+      boost::assign::list_of<std::string>
+      ("spring_constant")
+      ("equilibrium_distance")
+    ;
+const std::string FourBodyPotential_Torsion::potential_token("torsion");
+
+FourBodyPotential_Torsion::FourBodyPotential_Torsion() :
+  EmpiricalPotential(),
+  params(parameters_t(MAXPARAMS, 0.))
+{
+  // have some decent defaults for parameter_derivative checking
+  params[spring_constant] = 1.;
+  params[equilibrium_distance] = 0.1;
+}
+
+FourBodyPotential_Torsion::FourBodyPotential_Torsion(
+    const ParticleTypes_t &_ParticleTypes
+    ) :
+  EmpiricalPotential(_ParticleTypes),
+  params(parameters_t(MAXPARAMS, 0.))
+{
+  // have some decent defaults for parameter_derivative checking
+  params[spring_constant] = 1.;
+  params[equilibrium_distance] = 0.1;
+}
+
+FourBodyPotential_Torsion::FourBodyPotential_Torsion(
+    const ParticleTypes_t &_ParticleTypes,
+    const double _spring_constant,
+    const double _equilibrium_distance) :
+  EmpiricalPotential(_ParticleTypes),
+  params(parameters_t(MAXPARAMS, 0.))
+{
+  params[spring_constant] = _spring_constant;
+  params[equilibrium_distance] = _equilibrium_distance;
+}
+
+void FourBodyPotential_Torsion::setParameters(const parameters_t &_params)
+{
+  const size_t paramsDim = _params.size();
+  ASSERT( paramsDim <= getParameterDimension(),
+      "FourBodyPotential_Torsion::setParameters() - we need not more than "
+      +toString(getParameterDimension())+" parameters.");
+  for(size_t i=0;i<paramsDim;++i)
+    params[i] = _params[i];
+
+#ifndef NDEBUG
+  parameters_t check_params(getParameters());
+  check_params.resize(paramsDim); // truncate to same size
+  ASSERT( check_params == _params,
+      "FourBodyPotential_Torsion::setParameters() - failed, mismatch in to be set "
+      +toString(_params)+" and set "+toString(check_params)+" params.");
+#endif
+}
+
+FourBodyPotential_Torsion::result_t
+FourBodyPotential_Torsion::function_theta(
+    const double &r_ij,
+    const double &r_ik,
+    const double &r_il,
+    const double &r_jk,
+    const double &r_jl,
+    const double &r_kl
+  ) const
+{
+//  Info info(__func__);
+  const double h_1 = .5*sqrt(2.*(Helpers::pow(r_ij,2)+Helpers::pow(r_ik,2))-Helpers::pow(r_jk,2));
+  const double h_2 = .5*sqrt(2.*(Helpers::pow(r_jl,2)+Helpers::pow(r_kl,2))-Helpers::pow(r_jk,2));
+  const double angle = Helpers::pow(h_1,2) + Helpers::pow(h_2,2) - Helpers::pow(r_il,2);
+  const double divisor = 2.* h_1 * h_2;
+
+//  LOG(2, "DEBUG: cos(theta)= " << angle/divisor);
+  if (divisor == 0.)
+    return 0.;
+  else
+    return angle/divisor;
+}
+
+FourBodyPotential_Torsion::results_t
+FourBodyPotential_Torsion::operator()(
+    const arguments_t &arguments
+    ) const
+{
+  ASSERT( arguments.size() == getSpecificArgumentCount(),
+      "FourBodyPotential_Torsion::operator() - requires exactly three arguments.");
+  ASSERT( ParticleTypeChecker::checkArgumentsAgainstParticleTypes(
+      arguments, getParticleTypes()),
+      "FourBodyPotential_Torsion::operator() - types don't match with ones in arguments.");
+  const argument_t &r_ij = arguments[0]; // 01
+  const argument_t &r_ik = arguments[1]; // 02
+  const argument_t &r_il = arguments[2]; // 03
+  const argument_t &r_jk = arguments[3]; // 12
+  const argument_t &r_jl = arguments[4]; // 13
+  const argument_t &r_kl = arguments[5]; // 23
+  const result_t result =
+      params[spring_constant]
+             * Helpers::pow( function_theta(r_ij.distance, r_ik.distance, r_il.distance, r_jk.distance, r_jl.distance, r_kl.distance) - params[equilibrium_distance], 2 );
+  return std::vector<result_t>(1, result);
+}
+
+FourBodyPotential_Torsion::derivative_components_t
+FourBodyPotential_Torsion::derivative(
+    const arguments_t &arguments
+    ) const
+{
+  ASSERT( arguments.size() == getSpecificArgumentCount(),
+      "FourBodyPotential_Torsion::operator() - requires exactly three arguments.");
+  ASSERT( ParticleTypeChecker::checkArgumentsAgainstParticleTypes(
+      arguments, getParticleTypes()),
+      "FourBodyPotential_Torsion::operator() - types don't match with ones in arguments.");
+  derivative_components_t result;
+  const argument_t &r_ij = arguments[0]; // 01
+  const argument_t &r_ik = arguments[1]; // 02
+  const argument_t &r_il = arguments[2]; // 03
+  const argument_t &r_jk = arguments[3]; // 12
+  const argument_t &r_jl = arguments[4]; // 13
+  const argument_t &r_kl = arguments[5]; // 23
+  result.push_back( 2. * params[spring_constant] * ( function_theta(r_ij.distance, r_ik.distance, r_il.distance, r_jk.distance, r_jl.distance, r_kl.distance) - params[equilibrium_distance]) );
+  ASSERT( result.size() == 1,
+      "FourBodyPotential_Torsion::operator() - we did not create exactly one component.");
+  return result;
+}
+
+FourBodyPotential_Torsion::results_t
+FourBodyPotential_Torsion::parameter_derivative(
+    const arguments_t &arguments,
+    const size_t index
+    ) const
+{
+  ASSERT( arguments.size() == getSpecificArgumentCount(),
+      "FourBodyPotential_Torsion::parameter_derivative() - requires exactly three arguments.");
+  ASSERT( ParticleTypeChecker::checkArgumentsAgainstParticleTypes(
+      arguments, getParticleTypes()),
+      "FourBodyPotential_Torsion::operator() - types don't match with ones in arguments.");
+  const argument_t &r_ij = arguments[0]; // 01
+  const argument_t &r_ik = arguments[1]; // 02
+  const argument_t &r_il = arguments[2]; // 03
+  const argument_t &r_jk = arguments[3]; // 12
+  const argument_t &r_jl = arguments[4]; // 13
+  const argument_t &r_kl = arguments[5]; // 23
+  switch (index) {
+    case spring_constant:
+    {
+      const result_t result =
+                 Helpers::pow( function_theta(r_ij.distance, r_ik.distance, r_il.distance, r_jk.distance, r_jl.distance, r_kl.distance) - params[equilibrium_distance], 2 );
+      return std::vector<result_t>(1, result);
+      break;
+    }
+    case equilibrium_distance:
+    {
+      const result_t result =
+          -2. * params[spring_constant]
+                 * ( function_theta(r_ij.distance, r_ik.distance, r_il.distance, r_jk.distance, r_jl.distance, r_kl.distance) - params[equilibrium_distance]);
+      return std::vector<result_t>(1, result);
+      break;
+    }
+    default:
+      ASSERT(0, "FourBodyPotential_Torsion::parameter_derivative() - derivative to unknown parameter desired.");
+      break;
+  }
+}
+
+FunctionModel::extractor_t
+FourBodyPotential_Torsion::getSpecificExtractor() const
+{
+  Fragment::charges_t charges;
+  charges.resize(getParticleTypes().size());
+  std::transform(getParticleTypes().begin(), getParticleTypes().end(),
+      charges.begin(), boost::lambda::_1);
+  FunctionModel::extractor_t returnfunction =
+      boost::bind(&Extractors::gatherDistancesFromFragment,
+          boost::bind(&Fragment::getPositions, _1),
+          boost::bind(&Fragment::getCharges, _1),
+          charges,
+          _2);
+  return returnfunction;
+}
+
+FunctionModel::filter_t
+FourBodyPotential_Torsion::getSpecificFilter() const
+{
+  FunctionModel::filter_t returnfunction =
+      boost::bind(&Extractors::reorderArgumentsByParticleTypes,
+        boost::bind(&Extractors::filterArgumentsByParticleTypes,
+            _1,
+            getParticleTypes()),
+        getParticleTypes()
+      );
+  return returnfunction;
+}
+
+void
+FourBodyPotential_Torsion::setParametersToRandomInitialValues(
+    const TrainingData &data)
+{
+  params[FourBodyPotential_Torsion::spring_constant] = 2.*rand()/(double)RAND_MAX;
+  params[FourBodyPotential_Torsion::equilibrium_distance] = -.5+1.*rand()/(double)RAND_MAX;
+}
+
Index: src/Potentials/Specifics/FourBodyPotential_Torsion.hpp
===================================================================
--- src/Potentials/Specifics/FourBodyPotential_Torsion.hpp	(revision e2037e5d443e6ac456d3cbf14b2e4127a4bbd7a6)
+++ src/Potentials/Specifics/FourBodyPotential_Torsion.hpp	(revision e2037e5d443e6ac456d3cbf14b2e4127a4bbd7a6)
@@ -0,0 +1,212 @@
+/*
+ * FourBodyPotential_Torsion.hpp
+ *
+ *  Created on: Jul 08, 2013
+ *      Author: heber
+ */
+
+#ifndef FOURBODYPOTENTIAL_ANGLE_HPP_
+#define FOURBODYPOTENTIAL_ANGLE_HPP_
+
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <limits>
+
+#include "Potentials/EmpiricalPotential.hpp"
+
+class PotentialFactory;
+class TrainingData;
+
+/** This is the implementation of a torsion potential.
+ *
+ * This evaluates \f$ k \cdot (\theta -\theta_0)^2 \f$
+ * where \f$\theta\f$ is the angle between the two planes
+ * described by positions 012 and 123, respectively.
+ *
+ */
+class FourBodyPotential_Torsion :
+  public EmpiricalPotential
+{
+  //!> grant unit test access to internal parts
+  friend class FourBodyPotential_TorsionTest;
+  //!> grant PotentialFactory access to default cstor
+  friend class PotentialFactory;
+  // some repeated typedefs to avoid ambiguities
+  typedef FunctionModel::arguments_t arguments_t;
+  typedef FunctionModel::result_t result_t;
+  typedef FunctionModel::results_t results_t;
+  typedef EmpiricalPotential::derivative_components_t derivative_components_t;
+  typedef FunctionModel::parameters_t parameters_t;
+private:
+  /** Private default constructor.
+   *
+   * This prevents creation of potential without set ParticleTypes_t.
+   *
+   * \note PotentialFactory may use this default cstor
+   *
+   */
+  FourBodyPotential_Torsion();
+
+public:
+  FourBodyPotential_Torsion(const ParticleTypes_t &_ParticleTypes);
+  FourBodyPotential_Torsion(
+      const ParticleTypes_t &_ParticleTypes,
+      const double _spring_constant,
+      const double _equilibrium_distance);
+  virtual ~FourBodyPotential_Torsion() {}
+
+  /** Setter for parameters as required by FunctionModel interface.
+   *
+   * \param _params given set of parameters
+   */
+  void setParameters(const parameters_t &_params);
+
+  /** Getter for parameters as required by FunctionModel interface.
+   *
+   * \return set of parameters
+   */
+  parameters_t getParameters() const
+  {
+    return params;
+  }
+
+  /** Sets the parameter randomly within the sensible range of each parameter.
+   *
+   * \param data container with training data for guesstimating range
+   */
+  void setParametersToRandomInitialValues(const TrainingData &data);
+
+  /** Getter for the number of parameters of this model function.
+   *
+   * \return number of parameters
+   */
+  size_t getParameterDimension() const
+  {
+    return MAXPARAMS;
+  }
+
+  /** Evaluates the harmonic potential function for the given arguments.
+   *
+   * @param arguments single distance
+   * @return value of the potential function
+   */
+  results_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;
+
+  /** Evaluates the derivative of the function with the given \a arguments
+   * with respect to a specific parameter indicated by \a index.
+   *
+   * \param arguments set of arguments as input variables to the function
+   * \param index derivative of which parameter
+   * \return result vector containing the derivative with respect to the given
+   *         input
+   */
+  results_t parameter_derivative(const arguments_t &arguments, const size_t index) const;
+
+  /** Return the token name of this specific potential.
+   *
+   * \return token name of the potential
+   */
+  const std::string& getToken() const
+  { return potential_token; }
+
+  /** Returns a vector of parameter names.
+   *
+   * This is required from the specific implementation
+   *
+   * \return vector of strings containing parameter names
+   */
+  const ParameterNames_t& getParameterNames() const
+  { return ParameterNames; }
+
+  /** States whether lower and upper boundaries should be used to constraint
+   * the parameter search for this function model.
+   *
+   * \return true - constraints should be used, false - else
+   */
+  bool isBoxConstraint() const {
+    return true;
+  }
+
+  /** Returns a vector which are the lower boundaries for each parameter_t
+   * of this FunctionModel.
+   *
+   * \return vector of parameter_t resembling lowest allowed values
+   */
+  parameters_t getLowerBoxConstraints() const {
+    parameters_t lowerbounds(getParameterDimension(), -std::numeric_limits<double>::max());
+    lowerbounds[spring_constant] = 0.;
+    lowerbounds[equilibrium_distance] = -1.;
+    return lowerbounds;
+  }
+
+  /** Returns a vector which are the upper boundaries for each parameter_t
+   * of this FunctionModel.
+   *
+   * \return vector of parameter_t resembling highest allowed values
+   */
+  parameters_t getUpperBoxConstraints() const {
+    parameters_t upperbounds(getParameterDimension(), std::numeric_limits<double>::max());
+    upperbounds[equilibrium_distance] = 1.;
+    return upperbounds;
+  }
+
+  /** Returns a bound function to be used with TrainingData, extracting distances
+   * from a Fragment.
+   *
+   * \return bound function extracting distances from a fragment
+   */
+  FunctionModel::extractor_t getSpecificExtractor() const;
+
+  /** Returns a bound function to be used with TrainingData, extracting distances
+   * from a Fragment.
+   *
+   * \return bound function extracting distances from a fragment
+   */
+  FunctionModel::filter_t getSpecificFilter() const;
+
+  /** Returns the number of arguments the underlying function requires.
+   *
+   * \return number of arguments of the function
+   */
+  size_t getSpecificArgumentCount() const
+  { return 6; }
+
+  enum parameter_enum_t {
+    spring_constant=0,
+    equilibrium_distance=1,
+    MAXPARAMS
+  };
+
+private:
+  result_t
+  function_theta(
+      const double &r_ij,
+      const double &r_ik,
+      const double &r_il,
+      const double &r_jk,
+      const double &r_jl,
+      const double &r_kl
+    ) const;
+private:
+  //!> parameter vector with parameters as in enum parameter_enum_t
+  parameters_t params;
+
+  //!> static definitions of the parameter name for this potential
+  static const ParameterNames_t ParameterNames;
+
+  //!> static token of this potential type
+  static const std::string potential_token;
+};
+
+#endif /* FOURBODYPOTENTIAL_ANGLE_HPP_ */
Index: src/Potentials/Specifics/PotentialTypes.def
===================================================================
--- src/Potentials/Specifics/PotentialTypes.def	(revision 484e2ac103bbd121925bede487af209b526f8d12)
+++ src/Potentials/Specifics/PotentialTypes.def	(revision e2037e5d443e6ac456d3cbf14b2e4127a4bbd7a6)
@@ -1,4 +1,4 @@
 //!> preprocessor sequence of all known potential types. Just add new parser here
-#define POTENTIALSEQUENCE (constant)(tersoff)(morse)(harmonic)(harmonic_angle)(lennardjones)
+#define POTENTIALSEQUENCE (constant)(tersoff)(morse)(harmonic)(harmonic_angle)(lennardjones)(torsion)
 //!> Number of enumerations calculate automatically
 #define PotentialTypes_END BOOST_PP_SEQ_SIZE(POTENTIALSEQUENCE)
Index: src/Potentials/Specifics/unittests/FourBodyPotential_TorsionUnitTest.cpp
===================================================================
--- src/Potentials/Specifics/unittests/FourBodyPotential_TorsionUnitTest.cpp	(revision e2037e5d443e6ac456d3cbf14b2e4127a4bbd7a6)
+++ src/Potentials/Specifics/unittests/FourBodyPotential_TorsionUnitTest.cpp	(revision e2037e5d443e6ac456d3cbf14b2e4127a4bbd7a6)
@@ -0,0 +1,183 @@
+/*
+ * Project: MoleCuilder
+ * Description: creates and alters molecular systems
+ * Copyright (C)  2013 Frederik Heber. All rights reserved.
+ * 
+ *
+ *   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/>.
+ */
+
+/*
+ * FourBodyPotential_TorsionUnitTest.cpp
+ *
+ *  Created on: Jul 08, 2013
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+using namespace std;
+
+#include <cppunit/CompilerOutputter.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/ui/text/TestRunner.h>
+
+#include "FourBodyPotential_TorsionUnitTest.hpp"
+
+#include <boost/assign.hpp>
+
+#include "CodePatterns/Assert.hpp"
+
+#include "FunctionApproximation/FunctionArgument.hpp"
+#include "Potentials/Specifics/FourBodyPotential_Torsion.hpp"
+#include "Potentials/helpers.hpp"
+
+using namespace boost::assign;
+
+#ifdef HAVE_TESTRUNNER
+#include "UnitTestMain.hpp"
+#endif /*HAVE_TESTRUNNER*/
+
+/********************************************** Test classes **************************************/
+
+// Registers the fixture into the 'registry'
+CPPUNIT_TEST_SUITE_REGISTRATION( FourBodyPotential_TorsionTest );
+
+const double spring_constant = .5;
+
+void FourBodyPotential_TorsionTest::setUp()
+{
+  // failing asserts should be thrown
+  ASSERT_DO(Assert::Throw);
+
+  // create three distances to have the desired angle
+  typedef std::vector<double> angles_t;
+  angles_t angles;
+  angles += -0.5, -.4, -.3, -.2, -.1, 0., .1, .2, .3, .4, .5;
+  FunctionModel::arguments_t tempvector(6);
+  tempvector[0] = argument_t( std::make_pair(0,1), std::make_pair(0,1), 1.);
+  tempvector[1] = argument_t( std::make_pair(0,2), std::make_pair(0,1), 1.);
+  tempvector[2] = argument_t( std::make_pair(0,3), std::make_pair(0,0), 0.);
+  tempvector[3] = argument_t( std::make_pair(1,2), std::make_pair(1,1), 1.);
+  tempvector[4] = argument_t( std::make_pair(1,3), std::make_pair(0,1), 1.);
+  tempvector[5] = argument_t( std::make_pair(2,3), std::make_pair(0,1), 1.);
+  // we have two equilateral triangles (length 1)
+  // height is then \sqrt(2*(1+1)-1)*.5=sqrt(3)*.5
+  // then angle in triangle of both heights and connecting line is
+  // (h_1^2+h_2^2 - x^2) / (2*h_1*h_2) = cos(theta). Solving this equation
+  // for the unknown distance x is what we need
+  // 3/4+3/4-x/(2*sqrt(3)*.5*sqrt(3)*.5)
+  // x = sqrt(h_1^2+h_2^2 - cos(theta) * (2*h_1*h_2))
+  for (angles_t::const_iterator iter = angles.begin(); iter != angles.end(); ++iter) {
+    tempvector[2].distance = sqrt(.75+.75 - (*iter)*(1.5));
+    input += tempvector;
+  }
+  output +=
+      spring_constant*0.25,
+      spring_constant*0.16,
+      spring_constant*0.09,
+      spring_constant*0.04,
+      spring_constant*0.01,
+      spring_constant*0.,
+      spring_constant*0.01,
+      spring_constant*0.04,
+      spring_constant*0.09,
+      spring_constant*0.16,
+      spring_constant*0.25;
+
+  CPPUNIT_ASSERT_EQUAL( input.size(), output.size() );
+}
+
+
+void FourBodyPotential_TorsionTest::tearDown()
+{
+}
+
+/** UnitTest for operator()
+ */
+void FourBodyPotential_TorsionTest::operatorTest()
+{
+  FourBodyPotential_Torsion::ParticleTypes_t types =
+      boost::assign::list_of<FourBodyPotential_Torsion::ParticleType_t>
+        (0)(1)(1)(0)
+      ;
+  FourBodyPotential_Torsion angle(types, spring_constant,0.);
+  for (size_t index = 0; index < input.size(); ++index) {
+    const FourBodyPotential_Torsion::results_t result =
+        angle( input[index] );
+    CPPUNIT_ASSERT(
+        Helpers::isEqual(
+            output[index],
+            result[0]
+        )
+    );
+  }
+}
+
+/** UnitTest for derivative()
+ */
+void FourBodyPotential_TorsionTest::derivativeTest()
+{
+  FourBodyPotential_Torsion::ParticleTypes_t types =
+      boost::assign::list_of<FourBodyPotential_Torsion::ParticleType_t>
+        (0)(1)(1)(0)
+      ;
+  FourBodyPotential_Torsion angle(types, spring_constant,0.);
+  CPPUNIT_ASSERT(
+      Helpers::isEqual(
+          0.,
+          angle.derivative(
+              input[5]
+          )[0],
+          10.
+      )
+  );
+}
+
+
+/** UnitTest for parameter_derivative()
+ */
+void FourBodyPotential_TorsionTest::parameter_derivativeTest()
+{
+  FourBodyPotential_Torsion::ParticleTypes_t types =
+      boost::assign::list_of<FourBodyPotential_Torsion::ParticleType_t>
+        (0)(1)(1)(0)
+      ;
+  FourBodyPotential_Torsion angle(types, spring_constant,0.);
+  CPPUNIT_ASSERT(
+      Helpers::isEqual(
+          0.,
+          angle.parameter_derivative(
+              input[5],
+              0
+          )[0],
+          10.
+      )
+  );
+  CPPUNIT_ASSERT(
+      Helpers::isEqual(
+          0.,
+          angle.parameter_derivative(
+              input[5],
+              1
+          )[0],
+          10.
+      )
+  );
+}
Index: src/Potentials/Specifics/unittests/FourBodyPotential_TorsionUnitTest.hpp
===================================================================
--- src/Potentials/Specifics/unittests/FourBodyPotential_TorsionUnitTest.hpp	(revision e2037e5d443e6ac456d3cbf14b2e4127a4bbd7a6)
+++ src/Potentials/Specifics/unittests/FourBodyPotential_TorsionUnitTest.hpp	(revision e2037e5d443e6ac456d3cbf14b2e4127a4bbd7a6)
@@ -0,0 +1,46 @@
+/*
+ * FourBodyPotential_TorsionUnitTest.hpp
+ *
+ *  Created on: Jul 08, 2013
+ *      Author: heber
+ */
+
+#ifndef FOURBODYPOTENTIAL_TORSIONUNITTEST_HPP_
+#define FOURBODYPOTENTIAL_TORSIONUNITTEST_HPP_
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+
+#include <cppunit/extensions/HelperMacros.h>
+
+#include "FunctionApproximation/FunctionModel.hpp"
+
+class FourBodyPotential_Torsion;
+
+/********************************************** Test classes **************************************/
+
+class FourBodyPotential_TorsionTest : public CppUnit::TestFixture
+{
+    CPPUNIT_TEST_SUITE( FourBodyPotential_TorsionTest) ;
+    CPPUNIT_TEST ( operatorTest );
+    CPPUNIT_TEST ( derivativeTest );
+    CPPUNIT_TEST ( parameter_derivativeTest );
+    CPPUNIT_TEST_SUITE_END();
+
+public:
+      void setUp();
+      void tearDown();
+      void operatorTest();
+      void derivativeTest();
+      void parameter_derivativeTest();
+
+private:
+      typedef std::vector<double> data_t;
+      std::vector<FunctionModel::arguments_t> input;
+      data_t output;
+};
+
+#endif /* FOURBODYPOTENTIAL_TORSIONUNITTEST_HPP_ */
Index: src/Potentials/Specifics/unittests/Makefile.am
===================================================================
--- src/Potentials/Specifics/unittests/Makefile.am	(revision 484e2ac103bbd121925bede487af209b526f8d12)
+++ src/Potentials/Specifics/unittests/Makefile.am	(revision e2037e5d443e6ac456d3cbf14b2e4127a4bbd7a6)
@@ -4,4 +4,5 @@
 POTENTIALSSPECIFICSTESTSSOURCES = \
 	../Potentials/Specifics/unittests/ConstantPotentialUnitTest.cpp \
+	../Potentials/Specifics/unittests/FourBodyPotential_TorsionUnitTest.cpp \
 	../Potentials/Specifics/unittests/ManyBodyPotential_TersoffUnitTest.cpp \
 	../Potentials/Specifics/unittests/PairPotential_HarmonicUnitTest.cpp \
@@ -12,4 +13,5 @@
 POTENTIALSSPECIFICSTESTSHEADERS = \
 	../Potentials/Specifics/unittests/ConstantPotentialUnitTest.hpp \
+	../Potentials/Specifics/unittests/FourBodyPotential_TorsionUnitTest.hpp \
 	../Potentials/Specifics/unittests/ManyBodyPotential_TersoffUnitTest.hpp \
 	../Potentials/Specifics/unittests/PairPotential_HarmonicUnitTest.hpp \
@@ -20,4 +22,5 @@
 POTENTIALSSPECIFICSTESTS = \
 	ConstantPotentialUnitTest \
+	FourBodyPotential_TorsionUnitTest \
 	ManyBodyPotential_TersoffUnitTest \
 	PairPotential_HarmonicUnitTest \
@@ -44,4 +47,9 @@
 	../Potentials/Specifics/unittests/ConstantPotentialUnitTest.hpp
 ConstantPotentialUnitTest_LDADD = ${POTENTIALSSPECIFICSLIBS}
+
+FourBodyPotential_TorsionUnitTest_SOURCES = $(top_srcdir)/src/unittests/UnitTestMain.cpp \
+	../Potentials/Specifics/unittests/FourBodyPotential_TorsionUnitTest.cpp \
+	../Potentials/Specifics/unittests/FourBodyPotential_TorsionUnitTest.hpp
+FourBodyPotential_TorsionUnitTest_LDADD = ${POTENTIALSSPECIFICSLIBS}
 
 ManyBodyPotential_TersoffUnitTest_SOURCES = $(top_srcdir)/src/unittests/UnitTestMain.cpp \
