Index: src/Analysis/analysis_correlation.cpp
===================================================================
--- src/Analysis/analysis_correlation.cpp	(revision 9317be0fb11b31ce2211407310d3957055993f16)
+++ src/Analysis/analysis_correlation.cpp	(revision 208237bbbc57a8a1a39e9eba2b8f9ccd181228d8)
@@ -30,5 +30,8 @@
 #include "CodePatterns/Info.hpp"
 #include "CodePatterns/Log.hpp"
+#include "CodePatterns/Verbose.hpp"
 #include "Formula.hpp"
+#include "LinearAlgebra/Vector.hpp"
+#include "LinearAlgebra/RealSpaceMatrix.hpp"
 #include "molecule.hpp"
 #include "Tesselation/tesselation.hpp"
@@ -36,9 +39,5 @@
 #include "Tesselation/triangleintersectionlist.hpp"
 #include "World.hpp"
-#include "LinearAlgebra/Vector.hpp"
-#include "LinearAlgebra/RealSpaceMatrix.hpp"
-#include "CodePatterns/Verbose.hpp"
-#include "World.hpp"
-#include "Box.hpp"
+#include "WorldTime.hpp"
 
 #include "analysis_correlation.hpp"
@@ -90,4 +89,5 @@
 
 /** Calculates the dipole angular correlation for given molecule type.
+ * Calculate the change of the dipole orientation angle over time.
  * Note given element order is unimportant (i.e. g(Si, O) === g(O, Si))
  * Angles are given in degrees.
@@ -107,5 +107,70 @@
   }
 
-  outmap = new DipoleAngularCorrelationMap;
+  // store original time step
+  const unsigned int oldtime = WorldTime::getTime();
+  World::getInstance().setTime(0);
+
+  // get highest trajectory size
+  size_t max_timesteps = 0;
+  BOOST_FOREACH(molecule *_mol, molecules) {
+    for(molecule::const_iterator iter = _mol->begin();
+        iter != _mol->end();
+        ++iter) {
+      if ((*iter)->getTrajectorySize() > max_timesteps)
+        max_timesteps  = (*iter)->getTrajectorySize();
+    }
+  }
+  // get zero orientation for each molecule.
+  std::vector<Vector> ZeroVector;
+  ZeroVector.resize(molecules.size(), zeroVec);
+  size_t i=0;
+  BOOST_FOREACH(molecule *_mol, molecules) {
+    const Vector Dipole = getDipole(_mol->begin(), _mol->end());
+    ZeroVector[i] = Dipole;
+    ++i;
+  }
+  // go through every time step
+  for (size_t step = 1; step < max_timesteps; ++step) {
+    World::getInstance().setTime(step);
+    size_t i=0;
+    BOOST_FOREACH(molecule *_mol, molecules) {
+      const Vector Dipole = getDipole(_mol->begin(), _mol->end());
+      const double angle = Dipole.Angle(ZeroVector[i]) * (180./M_PI);
+      DoLog(1) && (Log() << Verbose(1) << "Angle for molecule "
+          << _mol->getId() << " at time step " << step << " is " << angle << "." << endl);
+      outmap->insert ( make_pair (angle, _mol ) );
+      ++i;
+    }
+  }
+
+
+  // set original time step again
+  World::getInstance().setTime(oldtime);
+
+  // and return results
+  return outmap;
+};
+
+/** Calculates the dipole correlation for given molecule type.
+ * I.e. we calculate how the angle between any two given dipoles in the
+ * systems behaves. Sort of pair correlation but distance is replaced by
+ * the orientation distance, i.e. an angle.
+ * Note given element order is unimportant (i.e. g(Si, O) === g(O, Si))
+ * Angles are given in degrees.
+ * \param *molecules vector of molecules
+ * \return Map of doubles with values the pair of the two atoms.
+ */
+DipoleCorrelationMap *DipoleCorrelation(std::vector<molecule *> &molecules)
+{
+  Info FunctionInfo(__func__);
+  DipoleCorrelationMap *outmap = new DipoleCorrelationMap;
+//  double distance = 0.;
+//  Box &domain = World::getInstance().getDomain();
+//
+  if (molecules.empty()) {
+    DoeLog(1) && (eLog()<< Verbose(1) <<"No molecule given." << endl);
+    return outmap;
+  }
+
   for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin();
       MolWalker != molecules.end(); ++MolWalker) {
@@ -503,8 +568,8 @@
 void OutputDipoleAngularCorrelation_Header( ofstream * const file )
 {
-  *file << "\tAtom1\tAtom2";
-};
-
-/** Prints values stored in DipoleAngularCorrelationMap iterator.
+  *file << "\tMolecule1\tMolecule2";
+};
+
+/** Prints values stored in DipoleCorrelationMap iterator.
  *
  * @param file stream to print to
@@ -512,4 +577,24 @@
  */
 void OutputDipoleAngularCorrelation_Value( ofstream * const file, DipoleAngularCorrelationMap::const_iterator &runner )
+{
+  *file << runner->second->getId();
+};
+
+
+/** Adds header part that is unique to DipoleAngularCorrelationMap.
+ *
+ * @param file stream to print to
+ */
+void OutputDipoleCorrelation_Header( ofstream * const file )
+{
+  *file << "\tMolecule";
+};
+
+/** Prints values stored in DipoleCorrelationMap iterator.
+ *
+ * @param file stream to print to
+ * @param runner iterator pointing at values to print
+ */
+void OutputDipoleCorrelation_Value( ofstream * const file, DipoleCorrelationMap::const_iterator &runner )
 {
   *file << runner->second.first->getId() << "\t" << runner->second.second->getId();
Index: src/Analysis/analysis_correlation.hpp
===================================================================
--- src/Analysis/analysis_correlation.hpp	(revision 9317be0fb11b31ce2211407310d3957055993f16)
+++ src/Analysis/analysis_correlation.hpp	(revision 208237bbbc57a8a1a39e9eba2b8f9ccd181228d8)
@@ -46,5 +46,6 @@
 
 typedef multimap<double, pair<atom *, atom *> > PairCorrelationMap;
-typedef multimap<double, pair<molecule *, molecule *> > DipoleAngularCorrelationMap;
+typedef multimap<double, molecule * > DipoleAngularCorrelationMap;
+typedef multimap<double, pair<molecule *, molecule *> > DipoleCorrelationMap;
 typedef multimap<double, pair<atom *, const Vector *> > CorrelationToPointMap;
 typedef multimap<double, pair<atom *, BoundaryTriangleSet *> > CorrelationToSurfaceMap;
@@ -54,4 +55,5 @@
 
 DipoleAngularCorrelationMap *DipoleAngularCorrelation(std::vector<molecule *> &molecules);
+DipoleCorrelationMap *DipoleCorrelation(std::vector<molecule *> &molecules);
 PairCorrelationMap *PairCorrelation(std::vector<molecule *> &molecules, const std::vector<const element *> &elements);
 CorrelationToPointMap *CorrelationToPoint(std::vector<molecule *> &molecules, const std::vector<const element *> &elements, const Vector *point );
@@ -65,4 +67,6 @@
 void OutputDipoleAngularCorrelation_Header( ofstream * const file );
 void OutputDipoleAngularCorrelation_Value( ofstream * const file, DipoleAngularCorrelationMap::const_iterator &runner );
+void OutputDipoleCorrelation_Header( ofstream * const file );
+void OutputDipoleCorrelation_Value( ofstream * const file, DipoleCorrelationMap::const_iterator &runner );
 void OutputPairCorrelation_Header( ofstream * const file );
 void OutputPairCorrelation_Value( ofstream * const file, PairCorrelationMap::const_iterator &runner );
