Index: src/Makefile.am
===================================================================
--- src/Makefile.am	(revision ea2c76cb353581745939e7353cd8282849c7f9d3)
+++ src/Makefile.am	(revision 194649564d0311bec3d5d03acaa519a7a24a5611)
@@ -100,5 +100,22 @@
   Descriptors/MoleculePtrDescriptor.hpp \
   Descriptors/MoleculeSelectionDescriptor.cpp
-
+  
+THERMOSTATSOURCE = \
+  Thermostats/Berendsen.cpp \
+  Thermostats/GaussianThermostat.cpp \
+  Thermostats/Langevin.cpp \
+  Thermostats/NoseHoover.cpp \
+  Thermostats/NoThermostat.cpp \
+  Thermostats/Thermostat.cpp \
+  Thermostats/Woodcock.cpp
+
+THERMOSTATHEADER = \
+  Thermostats/Berendsen.hpp \
+  Thermostats/GaussianThermostat.hpp \
+  Thermostats/Langevin.hpp \
+  Thermostats/NoseHoover.hpp \
+  Thermostats/NoThermostat.hpp \
+  Thermostats/Thermostat.hpp \
+  Thermostats/Woodcock.hpp
 
 QTUIMOC_HEADER = UIElements/QT4/QTDialog.hpp \
@@ -153,4 +170,5 @@
   ${SHAPESOURCE} \
   ${DESCRIPTORSOURCE} \
+  ${THERMOSTATSOURCE} \
   ${TESSELATIONSOURCE} \
   bond.cpp \
@@ -190,4 +208,5 @@
   ${SHAPEHEADER} \
   ${DESCRIPTORHEADER} \
+  ${THERMOSTATHEADER} \
   ${TESSELATIONHEADER} \
   bond.hpp \
Index: src/Thermostats/Berendsen.cpp
===================================================================
--- src/Thermostats/Berendsen.cpp	(revision 194649564d0311bec3d5d03acaa519a7a24a5611)
+++ src/Thermostats/Berendsen.cpp	(revision 194649564d0311bec3d5d03acaa519a7a24a5611)
@@ -0,0 +1,47 @@
+/*
+ * Berendsen.cpp
+ *
+ *  Created on: Aug 20, 2010
+ *      Author: crueger
+ */
+
+#include "Berendsen.hpp"
+#include "element.hpp"
+#include "config.hpp"
+#include "Helpers/Verbose.hpp"
+#include "Helpers/Log.hpp"
+#include "ThermoStatContainer.hpp"
+
+Berendsen::Berendsen(double _ActualTemp) :
+  ActualTemp(_ActualTemp)
+{}
+
+Berendsen::~Berendsen()
+{}
+
+double Berendsen::scaleAtoms(config &configuration,unsigned int step,ATOMSET(std::list) atoms){
+  return doScaleAtoms(configuration,step,atoms.begin(),atoms.end());
+}
+
+double Berendsen::scaleAtoms(config &configuration,unsigned int step,ATOMSET(std::vector) atoms){
+  return doScaleAtoms(configuration,step,atoms.begin(),atoms.end());
+}
+
+double Berendsen::scaleAtoms(config &configuration,unsigned int step,ATOMSET(std::set) atoms){
+  return doScaleAtoms(configuration,step,atoms.begin(),atoms.end());
+}
+
+template <class ForwardIterator>
+double Berendsen::doScaleAtoms(config &configuration,unsigned int step,ForwardIterator begin, ForwardIterator end){
+  DoLog(2) && (Log() << Verbose(2) <<  "Applying Berendsen-VanGunsteren thermostat..." << endl);
+  double ekin;
+  double ScaleTempFactor = configuration.Thermostats->TargetTemp/ActualTemp;
+  for(ForwardIterator iter=begin;iter!=end;++iter){
+    Vector &U = (*iter)->Trajectory.U.at(step);
+    if ((*iter)->FixedIon == 0) { // even FixedIon moves, only not by other's forces
+      U *= sqrt(1+(configuration.Deltat/configuration.Thermostats->TempFrequency)*(ScaleTempFactor-1));
+      ekin += 0.5*(*iter)->getType()->mass * U.NormSquared();
+    }
+  }
+  return ekin;
+}
Index: src/Thermostats/Berendsen.hpp
===================================================================
--- src/Thermostats/Berendsen.hpp	(revision 194649564d0311bec3d5d03acaa519a7a24a5611)
+++ src/Thermostats/Berendsen.hpp	(revision 194649564d0311bec3d5d03acaa519a7a24a5611)
@@ -0,0 +1,31 @@
+/*
+ * Berendsen.hpp
+ *
+ *  Created on: Aug 20, 2010
+ *      Author: crueger
+ */
+
+#ifndef BERENDSEN_HPP_
+#define BERENDSEN_HPP_
+
+#include "Thermostats/Thermostat.hpp"
+
+class Berendsen : public Thermostat
+{
+public:
+  Berendsen(double);
+  virtual ~Berendsen();
+
+  virtual double scaleAtoms(config &configuration,unsigned int step,ATOMSET(std::list));
+  virtual double scaleAtoms(config &configuration,unsigned int step,ATOMSET(std::vector));
+  virtual double scaleAtoms(config &configuration,unsigned int step,ATOMSET(std::set));
+
+  virtual std::string name() { return "Berendsen";}
+private:
+  template <class ForwardIterator>
+  double doScaleAtoms(config &configuration,unsigned int step,ForwardIterator begin, ForwardIterator end);
+
+  double ActualTemp;
+};
+
+#endif /* BERENDSEN_HPP_ */
Index: src/Thermostats/GaussianThermostat.cpp
===================================================================
--- src/Thermostats/GaussianThermostat.cpp	(revision 194649564d0311bec3d5d03acaa519a7a24a5611)
+++ src/Thermostats/GaussianThermostat.cpp	(revision 194649564d0311bec3d5d03acaa519a7a24a5611)
@@ -0,0 +1,72 @@
+/*
+ * GaussianThermostat.cpp
+ *
+ *  Created on: Aug 18, 2010
+ *      Author: crueger
+ */
+
+#include "GaussianThermostat.hpp"
+#include "LinearAlgebra/Vector.hpp"
+#include "Helpers/Log.hpp"
+#include "Helpers/Verbose.hpp"
+#include "AtomSet.hpp"
+#include "element.hpp"
+#include "config.hpp"
+#include <set>
+
+GaussianThermostat::GaussianThermostat() : E(0),G(0)
+{}
+
+GaussianThermostat::~GaussianThermostat()
+{}
+
+double GaussianThermostat::scaleAtoms(config &configuration,unsigned int step,ATOMSET(std::list) atoms){
+  return doScaleAtoms(configuration,step,atoms.begin(),atoms.end());
+}
+
+double GaussianThermostat::scaleAtoms(config &configuration,unsigned int step,ATOMSET(std::vector) atoms){
+  return doScaleAtoms(configuration,step,atoms.begin(),atoms.end());
+}
+
+double GaussianThermostat::scaleAtoms(config &configuration,unsigned int step,ATOMSET(std::set) atoms){
+  return doScaleAtoms(configuration,step,atoms.begin(),atoms.end());
+}
+
+template <class ForwardIterator>
+double GaussianThermostat::doScaleAtoms(config &configuration,unsigned int step,ForwardIterator begin, ForwardIterator end){
+  DoLog(2) && (Log() << Verbose(2) <<  "Applying Gaussian thermostat..." << endl);
+  init(step,begin,end);
+  double G_over_E = G/E;
+  DoLog(1) && (Log() << Verbose(1) << "Gaussian Least Constraint constant is " << G_over_E << "." << endl);
+  double ekin =0;
+  for(ForwardIterator iter=begin;iter!=end;++iter){
+    Vector &U = (*iter)->Trajectory.U.at(step);
+    if ((*iter)->FixedIon == 0) {// even FixedIon moves, only not by other's forces
+      U += configuration.Deltat * G_over_E * U;
+      ekin += (*iter)->getType()->mass * U.NormSquared();
+    }
+  }
+  return ekin;
+}
+
+template <class ForwardIterator>
+void GaussianThermostat::init(unsigned int step,ForwardIterator begin, ForwardIterator end){
+  E=0;
+  G=0;
+  for(ForwardIterator iter=begin;iter!=end;++iter){
+    Vector &U = (*iter)->Trajectory.U.at(step);
+    Vector &F = (*iter)->Trajectory.F.at(step);
+    if ((*iter)->FixedIon == 0){ // even FixedIon moves, only not by other's forces
+      G += U.ScalarProduct(F);
+      E += U.NormSquared()*(*iter)->getType()->mass;
+    }
+  }
+}
+
+double GaussianThermostat::getE() const{
+  return E;
+}
+
+double GaussianThermostat::getG() const{
+  return G;
+}
Index: src/Thermostats/GaussianThermostat.hpp
===================================================================
--- src/Thermostats/GaussianThermostat.hpp	(revision 194649564d0311bec3d5d03acaa519a7a24a5611)
+++ src/Thermostats/GaussianThermostat.hpp	(revision 194649564d0311bec3d5d03acaa519a7a24a5611)
@@ -0,0 +1,36 @@
+/*
+ * GaussianThermostat.hpp
+ *
+ *  Created on: Aug 18, 2010
+ *      Author: crueger
+ */
+
+#ifndef GAUSSIANTHERMOSTAT_HPP_
+#define GAUSSIANTHERMOSTAT_HPP_
+
+#include "Thermostats/Thermostat.hpp"
+
+class config;
+
+class GaussianThermostat : public Thermostat
+{
+public:
+  GaussianThermostat();
+  virtual ~GaussianThermostat();
+
+  virtual double scaleAtoms(config &configuration,unsigned int step,ATOMSET(std::list));
+  virtual double scaleAtoms(config &configuration,unsigned int step,ATOMSET(std::vector));
+  virtual double scaleAtoms(config &configuration,unsigned int step,ATOMSET(std::set));
+
+  virtual std::string name() { return "Gaussian";}
+  double getE() const;
+  double getG() const;
+private:
+  template <class ForwardIterator>
+  void init(unsigned int step,ForwardIterator begin, ForwardIterator end);
+  template <class ForwardIterator>
+  double doScaleAtoms(config &configuration,unsigned int step,ForwardIterator begin, ForwardIterator end);
+  double E,G;
+};
+
+#endif /* GAUSSIANTHERMOSTAT_HPP_ */
Index: src/Thermostats/Langevin.cpp
===================================================================
--- src/Thermostats/Langevin.cpp	(revision 194649564d0311bec3d5d03acaa519a7a24a5611)
+++ src/Thermostats/Langevin.cpp	(revision 194649564d0311bec3d5d03acaa519a7a24a5611)
@@ -0,0 +1,60 @@
+/*
+ * Langevin.cpp
+ *
+ *  Created on: Aug 20, 2010
+ *      Author: crueger
+ */
+
+#include "Langevin.hpp"
+#include "element.hpp"
+#include "config.hpp"
+#include "Helpers/Verbose.hpp"
+#include "Helpers/Log.hpp"
+#include "ThermoStatContainer.hpp"
+
+Langevin::Langevin()
+{
+  gsl_rng_env_setup();
+  T = gsl_rng_default;
+  r = gsl_rng_alloc (T);
+}
+
+Langevin::~Langevin()
+{
+  gsl_rng_free (r);
+}
+
+double Langevin::scaleAtoms(config &configuration,unsigned int step,ATOMSET(std::list) atoms){
+  return doScaleAtoms(configuration,step,atoms.begin(),atoms.end());
+}
+
+double Langevin::scaleAtoms(config &configuration,unsigned int step,ATOMSET(std::vector) atoms){
+  return doScaleAtoms(configuration,step,atoms.begin(),atoms.end());
+}
+
+double Langevin::scaleAtoms(config &configuration,unsigned int step,ATOMSET(std::set) atoms){
+  return doScaleAtoms(configuration,step,atoms.begin(),atoms.end());
+}
+
+template <class ForwardIterator>
+double Langevin::doScaleAtoms(config &configuration,unsigned int step,ForwardIterator begin, ForwardIterator end){
+  DoLog(2) && (Log() << Verbose(2) <<  "Applying Langevin thermostat..." << endl);
+  double ekin=0;
+  for(ForwardIterator iter=begin;iter!=end;++iter){
+    double sigma  = sqrt(configuration.Thermostats->TargetTemp/(*iter)->getType()->mass); // sigma = (k_b T)/m (Hartree/atomicmass = atomiclength/atomictime)
+    Vector &U = (*iter)->Trajectory.U.at(step);
+    if ((*iter)->FixedIon == 0) { // even FixedIon moves, only not by other's forces
+      // throw a dice to determine whether it gets hit by a heat bath particle
+      if (((((rand()/(double)RAND_MAX))*configuration.Thermostats->TempFrequency) < 1.)) {
+        DoLog(3) && (Log() << Verbose(3) << "Particle " << (**iter) << " was hit (sigma " << sigma << "): " << sqrt(U[0]*U[0]+U[1]*U[1]+U[2]*U[2]) << " -> ");
+        // pick three random numbers from a Boltzmann distribution around the desired temperature T for each momenta axis
+        for (int d=0; d<NDIM; d++) {
+          U[d] = gsl_ran_gaussian (r, sigma);
+        }
+        DoLog(2) && (Log() << Verbose(2) << sqrt(U[0]*U[0]+U[1]*U[1]+U[2]*U[2]) << endl);
+      }
+      ekin += 0.5*(*iter)->getType()->mass * U.NormSquared();
+    }
+  }
+  return ekin;
+}
Index: src/Thermostats/Langevin.hpp
===================================================================
--- src/Thermostats/Langevin.hpp	(revision 194649564d0311bec3d5d03acaa519a7a24a5611)
+++ src/Thermostats/Langevin.hpp	(revision 194649564d0311bec3d5d03acaa519a7a24a5611)
@@ -0,0 +1,33 @@
+/*
+ * Langevin.hpp
+ *
+ *  Created on: Aug 20, 2010
+ *      Author: crueger
+ */
+
+#ifndef LANGEVIN_HPP_
+#define LANGEVIN_HPP_
+
+#include "Thermostats/Thermostat.hpp"
+
+class Langevin : public Thermostat
+{
+public:
+  Langevin();
+  virtual ~Langevin();
+
+  virtual double scaleAtoms(config &configuration,unsigned int step,ATOMSET(std::list))=0;
+  virtual double scaleAtoms(config &configuration,unsigned int step,ATOMSET(std::vector))=0;
+  virtual double scaleAtoms(config &configuration,unsigned int step,ATOMSET(std::set))=0;
+
+  virtual std::string name(){return "Langevin";}
+
+private:
+  template <class ForwardIterator>
+  double doScaleAtoms(config &configuration,unsigned int step,ForwardIterator begin, ForwardIterator end);
+
+  gsl_rng * r;
+  const gsl_rng_type * T;
+};
+
+#endif /* LANGEVIN_HPP_ */
Index: src/Thermostats/NoThermostat.cpp
===================================================================
--- src/Thermostats/NoThermostat.cpp	(revision 194649564d0311bec3d5d03acaa519a7a24a5611)
+++ src/Thermostats/NoThermostat.cpp	(revision 194649564d0311bec3d5d03acaa519a7a24a5611)
@@ -0,0 +1,26 @@
+/*
+ * NoThermostat.cpp
+ *
+ *  Created on: Aug 20, 2010
+ *      Author: crueger
+ */
+
+#include "NoThermostat.hpp"
+
+NoThermostat::NoThermostat()
+{}
+
+NoThermostat::~NoThermostat()
+{}
+
+double NoThermostat::scaleAtoms(config &configuration,unsigned int step,ATOMSET(std::list) atoms){
+  return 0;
+}
+
+double NoThermostat::scaleAtoms(config &configuration,unsigned int step,ATOMSET(std::vector) atoms){
+  return 0;
+}
+
+double NoThermostat::scaleAtoms(config &configuration,unsigned int step,ATOMSET(std::set) atoms){
+  return 0;
+}
Index: src/Thermostats/NoThermostat.hpp
===================================================================
--- src/Thermostats/NoThermostat.hpp	(revision 194649564d0311bec3d5d03acaa519a7a24a5611)
+++ src/Thermostats/NoThermostat.hpp	(revision 194649564d0311bec3d5d03acaa519a7a24a5611)
@@ -0,0 +1,26 @@
+/*
+ * NoThermostat.hpp
+ *
+ *  Created on: Aug 20, 2010
+ *      Author: crueger
+ */
+
+#ifndef NOTHERMOSTAT_HPP_
+#define NOTHERMOSTAT_HPP_
+
+#include "Thermostats/Thermostat.hpp"
+
+class NoThermostat : public Thermostat
+{
+public:
+  NoThermostat();
+  virtual ~NoThermostat();
+
+  virtual double scaleAtoms(config &configuration,unsigned int step,ATOMSET(std::list));
+  virtual double scaleAtoms(config &configuration,unsigned int step,ATOMSET(std::vector));
+  virtual double scaleAtoms(config &configuration,unsigned int step,ATOMSET(std::set));
+
+  virtual std::string name() { return "None";}
+};
+
+#endif /* NOTHERMOSTAT_HPP_ */
Index: src/Thermostats/NoseHoover.cpp
===================================================================
--- src/Thermostats/NoseHoover.cpp	(revision 194649564d0311bec3d5d03acaa519a7a24a5611)
+++ src/Thermostats/NoseHoover.cpp	(revision 194649564d0311bec3d5d03acaa519a7a24a5611)
@@ -0,0 +1,64 @@
+/*
+ * NoseHoover.cpp
+ *
+ *  Created on: Aug 20, 2010
+ *      Author: crueger
+ */
+
+#include "NoseHoover.hpp"
+
+#include "element.hpp"
+#include "config.hpp"
+#include "Helpers/Verbose.hpp"
+#include "Helpers/Log.hpp"
+#include "ThermoStatContainer.hpp"
+
+NoseHoover::NoseHoover()
+{}
+
+NoseHoover::~NoseHoover()
+{}
+
+
+double NoseHoover::scaleAtoms(config &configuration,unsigned int step,ATOMSET(std::list) atoms){
+  return doScaleAtoms(configuration,step,atoms.begin(),atoms.end());
+}
+
+double NoseHoover::scaleAtoms(config &configuration,unsigned int step,ATOMSET(std::vector) atoms){
+  return doScaleAtoms(configuration,step,atoms.begin(),atoms.end());
+}
+
+double NoseHoover::scaleAtoms(config &configuration,unsigned int step,ATOMSET(std::set) atoms){
+  return doScaleAtoms(configuration,step,atoms.begin(),atoms.end());
+}
+
+template <class ForwardIterator>
+double NoseHoover::doScaleAtoms(config &configuration,unsigned int step,ForwardIterator begin, ForwardIterator end){
+  DoLog(2) && (Log() << Verbose(2) <<  "Applying Nose-Hoover thermostat..." << endl);
+  init(step,begin,end);
+  delta_alpha = (delta_alpha - (3.*count+1.) * configuration.Thermostats->TargetTemp)/(configuration.Thermostats->HooverMass*Units2Electronmass);
+  configuration.Thermostats->alpha += delta_alpha*configuration.Deltat;
+  DoLog(3) && (Log() << Verbose(3) << "alpha = " << delta_alpha << " * " << configuration.Deltat << " = " << configuration.Thermostats->alpha << "." << endl);
+  double ekin =0;
+  for(ForwardIterator iter=begin;iter!=end;++iter){
+    Vector &U = (*iter)->Trajectory.U.at(step);
+    if ((*iter)->FixedIon == 0) { // even FixedIon moves, only not by other's forces
+      U += configuration.Deltat/(*iter)->getType()->mass * (configuration.Thermostats->alpha * (U * (*iter)->getType()->mass));
+      ekin += (0.5*(*iter)->getType()->mass) * U.NormSquared();
+    }
+  }
+  return ekin;
+}
+
+template <class ForwardIterator>
+void NoseHoover::init(unsigned int step,ForwardIterator begin, ForwardIterator end){
+  delta_alpha=0;
+  count=0;
+  for(ForwardIterator iter = begin;iter!=end;++iter){
+    Vector &U = (*iter)->Trajectory.U.at(step);
+    if ((*iter)->FixedIon == 0) { // even FixedIon moves, only not by other's forces
+      delta_alpha += U.NormSquared()*(*iter)->getType()->mass;
+    }
+    ++count;
+  }
+}
Index: src/Thermostats/NoseHoover.hpp
===================================================================
--- src/Thermostats/NoseHoover.hpp	(revision 194649564d0311bec3d5d03acaa519a7a24a5611)
+++ src/Thermostats/NoseHoover.hpp	(revision 194649564d0311bec3d5d03acaa519a7a24a5611)
@@ -0,0 +1,35 @@
+/*
+ * NoseHoover.hpp
+ *
+ *  Created on: Aug 20, 2010
+ *      Author: crueger
+ */
+
+#ifndef NOSEHOOVER_HPP_
+#define NOSEHOOVER_HPP_
+
+#include "Thermostats/Thermostat.hpp"
+
+class NoseHoover : public Thermostat
+{
+public:
+  NoseHoover();
+  virtual ~NoseHoover();
+
+  virtual double scaleAtoms(config &configuration,unsigned int step,ATOMSET(std::list));
+  virtual double scaleAtoms(config &configuration,unsigned int step,ATOMSET(std::vector));
+  virtual double scaleAtoms(config &configuration,unsigned int step,ATOMSET(std::set));
+
+  virtual std::string name() { return "Nose-Hoover";}
+
+private:
+  template <class ForwardIterator>
+  void init(unsigned int step,ForwardIterator begin, ForwardIterator end);
+  template <class ForwardIterator>
+  double doScaleAtoms(config &configuration,unsigned int step,ForwardIterator begin, ForwardIterator end);
+
+  double delta_alpha;
+  int count;
+};
+
+#endif /* NOSEHOOVER_HPP_ */
Index: src/Thermostats/Thermostat.cpp
===================================================================
--- src/Thermostats/Thermostat.cpp	(revision 194649564d0311bec3d5d03acaa519a7a24a5611)
+++ src/Thermostats/Thermostat.cpp	(revision 194649564d0311bec3d5d03acaa519a7a24a5611)
@@ -0,0 +1,14 @@
+/*
+ * Thermostat.cpp
+ *
+ *  Created on: Aug 18, 2010
+ *      Author: crueger
+ */
+
+#include "Thermostat.hpp"
+
+Thermostat::Thermostat()
+{}
+
+Thermostat::~Thermostat()
+{}
Index: src/Thermostats/Thermostat.hpp
===================================================================
--- src/Thermostats/Thermostat.hpp	(revision 194649564d0311bec3d5d03acaa519a7a24a5611)
+++ src/Thermostats/Thermostat.hpp	(revision 194649564d0311bec3d5d03acaa519a7a24a5611)
@@ -0,0 +1,33 @@
+/*
+ * Thermostat.hpp
+ *
+ *  Created on: Aug 18, 2010
+ *      Author: crueger
+ */
+
+#ifndef THERMOSTAT_HPP_
+#define THERMOSTAT_HPP_
+
+class config;
+
+#include <string>
+#include <set>
+#include <vector>
+#include <list>
+#include "AtomSet.hpp"
+
+class Thermostat
+{
+public:
+  Thermostat();
+  virtual  ~Thermostat();
+
+  // cannot template this, because we need virtual functions
+  virtual double scaleAtoms(config &configuration,unsigned int step,ATOMSET(std::list))=0;
+  virtual double scaleAtoms(config &configuration,unsigned int step,ATOMSET(std::vector))=0;
+  virtual double scaleAtoms(config &configuration,unsigned int step,ATOMSET(std::set))=0;
+
+  virtual std::string name()=0;
+};
+
+#endif /* THERMOSTAT_HPP_ */
Index: src/Thermostats/Woodcock.cpp
===================================================================
--- src/Thermostats/Woodcock.cpp	(revision 194649564d0311bec3d5d03acaa519a7a24a5611)
+++ src/Thermostats/Woodcock.cpp	(revision 194649564d0311bec3d5d03acaa519a7a24a5611)
@@ -0,0 +1,52 @@
+/*
+ * Woodcock.cpp
+ *
+ *  Created on: Aug 20, 2010
+ *      Author: crueger
+ */
+
+#include "Woodcock.hpp"
+
+#include "element.hpp"
+#include "config.hpp"
+#include "Helpers/Verbose.hpp"
+#include "Helpers/Log.hpp"
+#include "ThermoStatContainer.hpp"
+
+Woodcock::Woodcock(int _MDSteps, double _ActualTemp) :
+  MDSteps(_MDSteps),
+  ActualTemp(_ActualTemp)
+{}
+
+Woodcock::~Woodcock()
+{}
+
+double Woodcock::scaleAtoms(config &configuration,unsigned int step,ATOMSET(std::list) atoms){
+  return doScaleAtoms(configuration,step,atoms.begin(),atoms.end());
+}
+
+double Woodcock::scaleAtoms(config &configuration,unsigned int step,ATOMSET(std::vector) atoms){
+  return doScaleAtoms(configuration,step,atoms.begin(),atoms.end());
+}
+
+double Woodcock::scaleAtoms(config &configuration,unsigned int step,ATOMSET(std::set) atoms){
+  return doScaleAtoms(configuration,step,atoms.begin(),atoms.end());
+}
+
+template <class ForwardIterator>
+double Woodcock::doScaleAtoms(config &configuration,unsigned int step,ForwardIterator begin,ForwardIterator end){
+  double ekin=0;
+  if ((configuration.Thermostats->ScaleTempStep > 0) && ((MDSteps-1) % configuration.Thermostats->ScaleTempStep == 0)) {
+    double ScaleTempFactor = sqrt(configuration.Thermostats->TargetTemp/ActualTemp);
+    DoLog(2) && (Log() << Verbose(2) <<  "Applying Woodcock thermostat..." << endl);
+    double ekin;
+    for (ForwardIterator iter = begin; iter!=end;++iter){
+      Vector &U = (*iter)->Trajectory.U.at(step);
+      if ((*iter)->FixedIon == 0){ // even FixedIon moves, only not by other's forces
+        U *= ScaleTempFactor;
+        ekin += 0.5*(*iter)->getType()->mass * U.NormSquared();
+      }
+    }
+  }
+  return ekin;
+}
Index: src/Thermostats/Woodcock.hpp
===================================================================
--- src/Thermostats/Woodcock.hpp	(revision 194649564d0311bec3d5d03acaa519a7a24a5611)
+++ src/Thermostats/Woodcock.hpp	(revision 194649564d0311bec3d5d03acaa519a7a24a5611)
@@ -0,0 +1,33 @@
+/*
+ * Woodcock.hpp
+ *
+ *  Created on: Aug 20, 2010
+ *      Author: crueger
+ */
+
+#ifndef WOODCOCK_HPP_
+#define WOODCOCK_HPP_
+
+#include "Thermostats/Thermostat.hpp"
+
+class Woodcock : public Thermostat
+{
+public:
+  Woodcock(int,double);
+  virtual ~Woodcock();
+
+  virtual double scaleAtoms(config &configuration,unsigned int step,ATOMSET(std::list));
+  virtual double scaleAtoms(config &configuration,unsigned int step,ATOMSET(std::vector));
+  virtual double scaleAtoms(config &configuration,unsigned int step,ATOMSET(std::set));
+
+  virtual std::string name(){return "Woodcock";}
+
+private:
+  template <class ForwardIterator>
+  double doScaleAtoms(config &configuration,unsigned int step,ForwardIterator begin,ForwardIterator end);
+
+  int MDSteps;
+  double ActualTemp;
+};
+
+#endif /* WOODCOCK_HPP_ */
