Index: src/atom_atominfo.cpp
===================================================================
--- src/atom_atominfo.cpp	(revision 6b020f24f85828b35cb7d1e2cb4137d9b9ad39e1)
+++ src/atom_atominfo.cpp	(revision 1b558c94a455c9a61f4f1954f9b8d7b149b1532f)
@@ -27,4 +27,5 @@
 #include "periodentafel.hpp"
 #include "World.hpp"
+#include "WorldTime.hpp"
 #include "atom_atominfo.hpp"
 
@@ -80,14 +81,18 @@
 const double& AtomInfo::operator[](size_t i) const
 {
-  ASSERT(AtomicPosition.size() > 0,
-      "AtomInfo::operator[]() - Access out of range.");
-  return AtomicPosition[0][i];
+  ASSERT(AtomicPosition.size() > WorldTime::getTime(),
+      "AtomInfo::operator[]() - Access out of range: "
+      +toString(WorldTime::getTime())
+      +" not in [0,"+toString(AtomicPosition.size())+").");
+  return AtomicPosition[WorldTime::getTime()][i];
 }
 
 const double& AtomInfo::at(size_t i) const
 {
-  ASSERT(AtomicPosition.size() > 0,
-      "AtomInfo::at() - Access out of range.");
-  return AtomicPosition[0].at(i);
+  ASSERT(AtomicPosition.size() > WorldTime::getTime(),
+      "AtomInfo::at() - Access out of range: "
+      +toString(WorldTime::getTime())
+      +" not in [0,"+toString(AtomicPosition.size())+").");
+  return AtomicPosition[WorldTime::getTime()].at(i);
 }
 
@@ -95,5 +100,7 @@
 {
   ASSERT(AtomicPosition.size() > _step,
-      "AtomInfo::atStep() - Access out of range.");
+      "AtomInfo::atStep() - Access out of range: "
+      +toString(_step)
+      +" not in [0,"+toString(AtomicPosition.size())+").");
   return AtomicPosition[_step].at(i);
 }
@@ -101,14 +108,18 @@
 void AtomInfo::set(size_t i, const double value)
 {
-  ASSERT(AtomicPosition.size() > 0,
-      "AtomInfo::set() - Access out of range.");
-  AtomicPosition[0].at(i) = value;
+  ASSERT(AtomicPosition.size() > WorldTime::getTime(),
+      "AtomInfo::set() - Access out of range: "
+      +toString(WorldTime::getTime())
+      +" not in [0,"+toString(AtomicPosition.size())+").");
+  AtomicPosition[WorldTime::getTime()].at(i) = value;
 }
 
 const Vector& AtomInfo::getPosition() const
 {
-  ASSERT(AtomicPosition.size() > 0,
-      "AtomInfo::getPosition() - Access out of range.");
-  return AtomicPosition[0];
+  ASSERT(AtomicPosition.size() > WorldTime::getTime(),
+      "AtomInfo::getPosition() - Access out of range: "
+      +toString(WorldTime::getTime())
+      +" not in [0,"+toString(AtomicPosition.size())+").");
+  return AtomicPosition[WorldTime::getTime()];
 }
 
@@ -116,5 +127,7 @@
 {
   ASSERT(_step < AtomicPosition.size(),
-      "AtomInfo::getPositionAtStep() - Access out of range.");
+      "AtomInfo::getPositionAtStep() - Access out of range: "
+      +toString(_step)
+      +" not in [0,"+toString(AtomicPosition.size())+").");
   return AtomicPosition[_step];
 }
@@ -144,6 +157,8 @@
 {
   ASSERT(AtomicVelocity.size() > 0,
-      "AtomInfo::getAtomicVelocity() - Access out of range.");
-  return AtomicVelocity[0];
+      "AtomInfo::getAtomicVelocity() - Access out of range: "
+      +toString(WorldTime::getTime())
+      +" not in [0,"+toString(AtomicPosition.size())+").");
+  return AtomicVelocity[WorldTime::getTime()];
 }
 
@@ -151,5 +166,7 @@
 {
   ASSERT(_step < AtomicVelocity.size(),
-      "AtomInfo::getAtomicVelocity() - Access out of range.");
+      "AtomInfo::getAtomicVelocity() - Access out of range: "
+      +toString(_step)
+      +" not in [0,"+toString(AtomicPosition.size())+").");
   return AtomicVelocity[_step];
 }
@@ -157,16 +174,21 @@
 void AtomInfo::setAtomicVelocity(const Vector &_newvelocity)
 {
-  ASSERT(0 < AtomicVelocity.size(),
-      "AtomInfo::setAtomicVelocity() - Access out of range.");
-  AtomicVelocity[0] = _newvelocity;
+  ASSERT(WorldTime::getTime() < AtomicVelocity.size(),
+      "AtomInfo::setAtomicVelocity() - Access out of range: "
+      +toString(WorldTime::getTime())
+      +" not in [0,"+toString(AtomicPosition.size())+").");
+  AtomicVelocity[WorldTime::getTime()] = _newvelocity;
 }
 
 void AtomInfo::setAtomicVelocityAtStep(const unsigned int _step, const Vector &_newvelocity)
 {
-  ASSERT(_step <= AtomicVelocity.size(),
-      "AtomInfo::setAtomicVelocityAtStep() - Access out of range.");
-  if(_step < AtomicVelocity.size()) {
+  const unsigned int size = AtomicVelocity.size();
+  ASSERT(_step <= size,
+      "AtomInfo::setAtomicVelocityAtStep() - Access out of range: "
+      +toString(_step)
+      +" not in [0,"+toString(size)+"].");
+  if(_step < size) {
     AtomicVelocity[_step] = _newvelocity;
-  } else if (_step == AtomicVelocity.size()) {
+  } else if (_step == size) {
     AtomicVelocity.push_back(_newvelocity);
   }
@@ -175,7 +197,9 @@
 const Vector& AtomInfo::getAtomicForce() const
 {
-  ASSERT(0 < AtomicForce.size(),
-      "AtomInfo::getAtomicForce() - Access out of range.");
-  return AtomicForce[0];
+  ASSERT(WorldTime::getTime() < AtomicForce.size(),
+      "AtomInfo::getAtomicForce() - Access out of range: "
+      +toString(WorldTime::getTime())
+      +" not in [0,"+toString(AtomicPosition.size())+").");
+  return AtomicForce[WorldTime::getTime()];
 }
 
@@ -183,5 +207,7 @@
 {
   ASSERT(_step < AtomicForce.size(),
-      "AtomInfo::getAtomicForce() - Access out of range.");
+      "AtomInfo::getAtomicForce() - Access out of range: "
+      +toString(_step)
+      +" not in [0,"+toString(AtomicPosition.size())+").");
   return AtomicForce[_step];
 }
@@ -189,7 +215,9 @@
 void AtomInfo::setAtomicForce(const Vector &_newforce)
 {
-  ASSERT(0 < AtomicForce.size(),
-      "AtomInfo::setAtomicForce() - Access out of range.");
-  AtomicForce[0] = _newforce;
+  ASSERT(WorldTime::getTime() < AtomicForce.size(),
+      "AtomInfo::setAtomicForce() - Access out of range: "
+      +toString(WorldTime::getTime())
+      +" not in [0,"+toString(AtomicPosition.size())+").");
+  AtomicForce[WorldTime::getTime()] = _newforce;
 }
 
@@ -198,5 +226,7 @@
   const unsigned int size = AtomicForce.size();
   ASSERT(_step <= size,
-      "AtomInfo::setAtomicForce() - Access out of range.");
+      "AtomInfo::setAtomicForce() - Access out of range: "
+      +toString(_step)
+      +" not in [0,"+toString(AtomicPosition.size())+"].");
   if(_step < size) {
     AtomicForce[_step] = _newforce;
@@ -218,7 +248,9 @@
 void AtomInfo::setPosition(const Vector& _vector)
 {
-  ASSERT(0 < AtomicPosition.size(),
-      "AtomInfo::setPosition() - Access out of range.");
-  AtomicPosition[0] = _vector;
+  ASSERT(WorldTime::getTime() < AtomicPosition.size(),
+      "AtomInfo::setPosition() - Access out of range: "
+      +toString(WorldTime::getTime())
+      +" not in [0,"+toString(AtomicPosition.size())+").");
+  AtomicPosition[WorldTime::getTime()] = _vector;
   //cout << "AtomInfo::setPosition: " << getType()->symbol << " at " << getPosition() << endl;
 }
@@ -226,9 +258,12 @@
 void AtomInfo::setPositionAtStep(unsigned int _step, const Vector& _vector)
 {
-  ASSERT(_step <= AtomicPosition.size(),
-      "AtomInfo::setPosition() - Access out of range.");
-  if(_step < AtomicPosition.size()) {
+  const unsigned int size = AtomicPosition.size();
+  ASSERT(_step <= size,
+      "AtomInfo::setPosition() - Access out of range: "
+      +toString(_step)
+      +" not in [0,"+toString(size)+"].");
+  if(_step < size) {
     AtomicPosition[_step] = _vector;
-  } else if (_step == AtomicPosition.size()) {
+  } else if (_step == size) {
     AtomicPosition.push_back(_vector);
   }
@@ -238,7 +273,9 @@
 const VectorInterface& AtomInfo::operator+=(const Vector& b)
 {
-  ASSERT(0 < AtomicPosition.size(),
-      "AtomInfo::operator+=() - Access out of range.");
-  AtomicPosition[0] += b;
+  ASSERT(WorldTime::getTime() < AtomicPosition.size(),
+      "AtomInfo::operator+=() - Access out of range: "
+      +toString(WorldTime::getTime())
+      +" not in [0,"+toString(AtomicPosition.size())+").");
+  AtomicPosition[WorldTime::getTime()] += b;
   return *this;
 }
@@ -246,7 +283,9 @@
 const VectorInterface& AtomInfo::operator-=(const Vector& b)
 {
-  ASSERT(0 < AtomicPosition.size(),
-      "AtomInfo::operator-=() - Access out of range.");
-  AtomicPosition[0] -= b;
+  ASSERT(WorldTime::getTime() < AtomicPosition.size(),
+      "AtomInfo::operator-=() - Access out of range: "
+      +toString(WorldTime::getTime())
+      +" not in [0,"+toString(AtomicPosition.size())+").");
+  AtomicPosition[WorldTime::getTime()] -= b;
   return *this;
 }
@@ -254,7 +293,9 @@
 Vector const AtomInfo::operator+(const Vector& b) const
 {
-  ASSERT(0 < AtomicPosition.size(),
-      "AtomInfo::operator+() - Access out of range.");
-  Vector a(AtomicPosition[0]);
+  ASSERT(WorldTime::getTime() < AtomicPosition.size(),
+      "AtomInfo::operator+() - Access out of range: "
+      +toString(WorldTime::getTime())
+      +" not in [0,"+toString(AtomicPosition.size())+").");
+  Vector a(AtomicPosition[WorldTime::getTime()]);
   a += b;
   return a;
@@ -263,7 +304,9 @@
 Vector const AtomInfo::operator-(const Vector& b) const
 {
-  ASSERT(0 < AtomicPosition.size(),
-      "AtomInfo::operator-() - Access out of range.");
-  Vector a(AtomicPosition[0]);
+  ASSERT(WorldTime::getTime() < AtomicPosition.size(),
+      "AtomInfo::operator-() - Access out of range: "
+      +toString(WorldTime::getTime())
+      +" not in [0,"+toString(AtomicPosition.size())+").");
+  Vector a(AtomicPosition[WorldTime::getTime()]);
   a -= b;
   return a;
@@ -272,35 +315,45 @@
 double AtomInfo::distance(const Vector &point) const
 {
-  ASSERT(0 < AtomicPosition.size(),
-      "AtomInfo::distance() - Access out of range.");
-  return AtomicPosition[0].distance(point);
+  ASSERT(WorldTime::getTime() < AtomicPosition.size(),
+      "AtomInfo::distance() - Access out of range: "
+      +toString(WorldTime::getTime())
+      +" not in [0,"+toString(AtomicPosition.size())+").");
+  return AtomicPosition[WorldTime::getTime()].distance(point);
 }
 
 double AtomInfo::DistanceSquared(const Vector &y) const
 {
-  ASSERT(0 < AtomicPosition.size(),
-      "AtomInfo::DistanceSquared() - Access out of range.");
-  return AtomicPosition[0].DistanceSquared(y);
+  ASSERT(WorldTime::getTime() < AtomicPosition.size(),
+      "AtomInfo::DistanceSquared() - Access out of range: "
+      +toString(WorldTime::getTime())
+      +" not in [0,"+toString(AtomicPosition.size())+").");
+  return AtomicPosition[WorldTime::getTime()].DistanceSquared(y);
 }
 
 double AtomInfo::distance(const VectorInterface &_atom) const
 {
-  ASSERT(0 < AtomicPosition.size(),
-      "AtomInfo::distance() - Access out of range.");
-  return _atom.distance(AtomicPosition[0]);
+  ASSERT(WorldTime::getTime() < AtomicPosition.size(),
+      "AtomInfo::distance() - Access out of range: "
+      +toString(WorldTime::getTime())
+      +" not in [0,"+toString(AtomicPosition.size())+").");
+  return _atom.distance(AtomicPosition[WorldTime::getTime()]);
 }
 
 double AtomInfo::DistanceSquared(const VectorInterface &_atom) const
 {
-  ASSERT(0 < AtomicPosition.size(),
-      "AtomInfo::DistanceSquared() - Access out of range.");
-  return _atom.DistanceSquared(AtomicPosition[0]);
+  ASSERT(WorldTime::getTime() < AtomicPosition.size(),
+      "AtomInfo::DistanceSquared() - Access out of range: "
+      +toString(WorldTime::getTime())
+      +" not in [0,"+toString(AtomicPosition.size())+").");
+  return _atom.DistanceSquared(AtomicPosition[WorldTime::getTime()]);
 }
 
 VectorInterface &AtomInfo::operator=(const Vector& _vector)
 {
-  ASSERT(0 < AtomicPosition.size(),
-      "AtomInfo::operator=() - Access out of range.");
-  AtomicPosition[0] = _vector;
+  ASSERT(WorldTime::getTime() < AtomicPosition.size(),
+      "AtomInfo::operator=() - Access out of range: "
+      +toString(WorldTime::getTime())
+      +" not in [0,"+toString(AtomicPosition.size())+").");
+  AtomicPosition[WorldTime::getTime()] = _vector;
   return *this;
 }
@@ -308,42 +361,54 @@
 void AtomInfo::ScaleAll(const double *factor)
 {
-  ASSERT(0 < AtomicPosition.size(),
-      "AtomInfo::ScaleAll() - Access out of range.");
-  AtomicPosition[0].ScaleAll(factor);
+  ASSERT(WorldTime::getTime() < AtomicPosition.size(),
+      "AtomInfo::ScaleAll() - Access out of range: "
+      +toString(WorldTime::getTime())
+      +" not in [0,"+toString(AtomicPosition.size())+").");
+  AtomicPosition[WorldTime::getTime()].ScaleAll(factor);
 }
 
 void AtomInfo::ScaleAll(const Vector &factor)
 {
-  ASSERT(0 < AtomicPosition.size(),
-      "AtomInfo::ScaleAll() - Access out of range.");
-  AtomicPosition[0].ScaleAll(factor);
+  ASSERT(WorldTime::getTime() < AtomicPosition.size(),
+      "AtomInfo::ScaleAll() - Access out of range: "
+      +toString(WorldTime::getTime())
+      +" not in [0,"+toString(AtomicPosition.size())+").");
+  AtomicPosition[WorldTime::getTime()].ScaleAll(factor);
 }
 
 void AtomInfo::Scale(const double factor)
 {
-  ASSERT(0 < AtomicPosition.size(),
-      "AtomInfo::Scale() - Access out of range.");
-  AtomicPosition[0].Scale(factor);
+  ASSERT(WorldTime::getTime() < AtomicPosition.size(),
+      "AtomInfo::Scale() - Access out of range: "
+      +toString(WorldTime::getTime())
+      +" not in [0,"+toString(AtomicPosition.size())+").");
+  AtomicPosition[WorldTime::getTime()].Scale(factor);
 }
 
 void AtomInfo::Zero()
 {
-  ASSERT(0 < AtomicPosition.size(),
-      "AtomInfo::Zero() - Access out of range.");
-  AtomicPosition[0].Zero();
+  ASSERT(WorldTime::getTime() < AtomicPosition.size(),
+      "AtomInfo::Zero() - Access out of range: "
+      +toString(WorldTime::getTime())
+      +" not in [0,"+toString(AtomicPosition.size())+").");
+  AtomicPosition[WorldTime::getTime()].Zero();
 }
 
 void AtomInfo::One(const double one)
 {
-  ASSERT(0 < AtomicPosition.size(),
-      "AtomInfo::One() - Access out of range.");
-  AtomicPosition[0].One(one);
+  ASSERT(WorldTime::getTime() < AtomicPosition.size(),
+      "AtomInfo::One() - Access out of range: "
+      +toString(WorldTime::getTime())
+      +" not in [0,"+toString(AtomicPosition.size())+").");
+  AtomicPosition[WorldTime::getTime()].One(one);
 }
 
 void AtomInfo::LinearCombinationOfVectors(const Vector &x1, const Vector &x2, const Vector &x3, const double * const factors)
 {
-  ASSERT(0 < AtomicPosition.size(),
-      "AtomInfo::LinearCombinationOfVectors() - Access out of range.");
-  AtomicPosition[0].LinearCombinationOfVectors(x1,x2,x3,factors);
+  ASSERT(WorldTime::getTime() < AtomicPosition.size(),
+      "AtomInfo::LinearCombinationOfVectors() - Access out of range: "
+      +toString(WorldTime::getTime())
+      +" not in [0,"+toString(AtomicPosition.size())+").");
+  AtomicPosition[WorldTime::getTime()].LinearCombinationOfVectors(x1,x2,x3,factors);
 }
 
@@ -353,5 +418,7 @@
 double AtomInfo::getKineticEnergy(const unsigned int _step) const{
   ASSERT(_step < AtomicPosition.size(),
-      "AtomInfo::getKineticEnergy() - Access out of range.");
+      "AtomInfo::getKineticEnergy() - Access out of range: "
+      +toString(WorldTime::getTime())
+      +" not in [0,"+toString(AtomicPosition.size())+").");
   return getMass() * AtomicVelocity[_step].NormSquared();
 }
@@ -359,5 +426,7 @@
 Vector AtomInfo::getMomentum(const unsigned int _step) const{
   ASSERT(_step < AtomicPosition.size(),
-      "AtomInfo::getMomentum() - Access out of range.");
+      "AtomInfo::getMomentum() - Access out of range: "
+      +toString(WorldTime::getTime())
+      +" not in [0,"+toString(AtomicPosition.size())+").");
   return getMass()*AtomicVelocity[_step];
 }
@@ -375,4 +444,9 @@
     AtomicForce.resize(MaxSteps+1, zeroVec);
   }
+  for (size_t i = AtomicPosition.size(); i <= MaxSteps; ++i) {
+    AtomicPosition[i] = zeroVec;
+    AtomicVelocity[i] = zeroVec;
+    AtomicForce[i] = zeroVec;
+  }
 };
 
@@ -396,7 +470,11 @@
 
   ASSERT(dest < AtomicPosition.size(),
-      "AtomInfo::CopyStepOnStep() - destination outside of current trajectory array.");
+      "AtomInfo::CopyStepOnStep() - destination outside of current trajectory array: "
+      +toString(dest)
+      +" not in [0,"+toString(AtomicPosition.size())+").");
   ASSERT(src < AtomicPosition.size(),
-      "AtomInfo::CopyStepOnStep() - source outside of current trajectory array.");
+      "AtomInfo::CopyStepOnStep() - source outside of current trajectory array: "
+      +toString(src)
+      +" not in [0,"+toString(AtomicPosition.size())+").");
   for (int n=NDIM;n--;) {
     AtomicPosition.at(dest)[n] = AtomicPosition.at(src)[n];
