Index: src/Dynamics/unittests/BondVectorsUnitTest.cpp
===================================================================
--- src/Dynamics/unittests/BondVectorsUnitTest.cpp	(revision d3d9643f5c7763e0bc8151d916a1c92bd8dcadeb)
+++ src/Dynamics/unittests/BondVectorsUnitTest.cpp	(revision d3d9643f5c7763e0bc8151d916a1c92bd8dcadeb)
@@ -0,0 +1,266 @@
+/*
+ * Project: MoleCuilder
+ * Description: creates and alters molecular systems
+ * Copyright (C)  2017 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/>.
+ */
+
+/*
+ * BondVectorsUnitTest.cpp
+ *
+ *  Created on: Jun 29, 2017
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <cppunit/CompilerOutputter.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/ui/text/TestRunner.h>
+
+#include "CodePatterns/Assert.hpp"
+#include "CodePatterns/Log.hpp"
+
+#include <boost/assign.hpp>
+
+#include "BondVectorsUnitTest.hpp"
+
+#include "Atom/atom.hpp"
+#include "Bond/bond.hpp"
+#include "Dynamics/BondVectors.hpp"
+#include "Element/periodentafel.hpp"
+#include "World.hpp"
+#include "WorldTime.hpp"
+
+#ifdef HAVE_TESTRUNNER
+#include "UnitTestMain.hpp"
+#endif /*HAVE_TESTRUNNER*/
+
+using namespace boost::assign;
+
+/********************************************** Test classes **************************************/
+
+// Registers the fixture into the 'registry'
+CPPUNIT_TEST_SUITE_REGISTRATION( BondVectorsTest );
+
+
+void BondVectorsTest::setUp()
+{
+  // failing asserts should be thrown
+  ASSERT_DO(Assert::Throw);
+
+  // create an atom
+  carbon = World::getInstance().getPeriode()->FindElement(6);
+  CPPUNIT_ASSERT(carbon != NULL);
+
+  _atom = World::getInstance().createAtom();
+  _atom->setType(carbon);
+  _atom->setPosition( zeroVec );
+  atoms.push_back(_atom);
+  _atom = World::getInstance().createAtom();
+  _atom->setType(carbon);
+  _atom->setPosition( Vector(1.6,0.,0.) );
+  atoms.push_back(_atom);
+  _atom = World::getInstance().createAtom();
+  _atom->setType(carbon);
+  _atom->setPosition( Vector(3.2,0.,0.) );
+  atoms.push_back(_atom);
+  _atom = World::getInstance().createAtom();
+  _atom->setType(carbon);
+  _atom->setPosition( Vector(1.6,1.6,0.) );
+  atoms.push_back(_atom);
+  _atom = World::getInstance().createAtom();
+  _atom->setType(carbon);
+  _atom->setPosition( Vector(2.8,2.8,0.) );
+  atoms.push_back(_atom);
+  _atom = World::getInstance().createAtom();
+  _atom->setType(carbon);
+  _atom->setPosition( Vector(1.6,-1.6,0.) );
+  atoms.push_back(_atom);
+  _atom = World::getInstance().createAtom();
+  _atom->setType(carbon);
+  _atom->setPosition( Vector(2.8,-1.2,0.) );
+  atoms.push_back(_atom);
+
+  bv = new BondVectors;
+}
+
+static void clearbondvector(
+    std::vector<bond::ptr> &_bondvector)
+{
+  // remove bonds
+  for (std::vector<bond::ptr>::iterator iter = _bondvector.begin();
+      !_bondvector.empty(); iter = _bondvector.begin()) {
+    (*iter)->leftatom->removeBond((*iter)->rightatom);
+    _bondvector.erase(iter);
+  }
+}
+
+
+void BondVectorsTest::tearDown()
+{
+  delete bv;
+
+  atoms.clear();
+  atomvector.clear();
+  clearbondvector(bondvector);
+  carbon = NULL;
+
+  World::purgeInstance();
+  WorldTime::purgeInstance();
+}
+
+/** Test whether current_mapped is kept up-to-date
+ *
+ */
+void BondVectorsTest::current_mappedTest()
+{
+  {
+    // gather atoms
+    atomvector += atoms[center], atoms[left];
+    // create bonds
+    bondvector += atoms[center]->addBond(atoms[left]);
+    // prepare bondvectors
+    bv->setFromAtomRange< std::vector<atom *> >(atomvector.begin(), atomvector.end(), WorldTime::getTime());
+    // get bond vectors
+    const std::vector<Vector> Bondvectors =
+        bv->getAtomsBondVectorsAtStep(*atoms[center], WorldTime::getTime());
+    // check number of bond vectors
+    CPPUNIT_ASSERT_EQUAL( Bondvectors.size(), (size_t)1 );
+    // check norm of bond vector
+    CPPUNIT_ASSERT( fabs(Bondvectors[0].Norm() - 1.) < MYEPSILON );
+
+    // clear set of atoms and use a different one
+    clearbondvector(bondvector);
+    atomvector.clear();
+  }
+
+  {
+    // gather atoms
+    atomvector += atoms[center], atoms[left], atoms[right], atoms[top];
+    // create bonds
+    bondvector +=
+        atoms[center]->addBond(atoms[left]),
+        atoms[center]->addBond(atoms[right]),
+        atoms[center]->addBond(atoms[top]);
+    // prepare bondvectors
+    bv->setFromAtomRange< std::vector<atom *> >(atomvector.begin(), atomvector.end(), WorldTime::getTime());
+    // get bond vectors
+    const std::vector<Vector> Bondvectors =
+        bv->getAtomsBondVectorsAtStep(*atoms[center], WorldTime::getTime());
+    // check number of bond vectors
+    CPPUNIT_ASSERT_EQUAL( Bondvectors.size(), (size_t)3 );
+    // check norm of bond vector
+    for (size_t i=0;i<3;++i)
+      CPPUNIT_ASSERT( fabs(Bondvectors[i].Norm() - 1.) < MYEPSILON );
+  }
+}
+
+/** Test whether calculating weights works on single bond
+ *
+ */
+void BondVectorsTest::weights_singlebondTest()
+{
+  // gather atoms
+  atomvector += atoms[center], atoms[left];
+  // create bonds
+  bondvector += atoms[center]->addBond(atoms[left]);
+  // prepare bondvectors
+  bv->setFromAtomRange< std::vector<atom *> >(atomvector.begin(), atomvector.end(), WorldTime::getTime());
+  // calculate weights
+  BondVectors::weights_t weights = bv->getWeightsForAtomAtStep(*atoms[center], WorldTime::getTime());
+  LOG(2, "DEBUG: Single bond weights are " << weights);
+  // check number of weights
+  CPPUNIT_ASSERT_EQUAL( weights.size(), (size_t)1 );
+  // check sum of weights
+  const double weight_sum = std::accumulate(weights.begin(), weights.end(), 0.);
+  CPPUNIT_ASSERT( fabs(weight_sum - 1.) < MYEPSILON );
+  // check weight
+  CPPUNIT_ASSERT_EQUAL( weights[0], 1. );
+}
+
+/** Test whether calculating weights works on linear chain config
+ *
+ */
+void BondVectorsTest::weights_linearchainTest()
+{
+  // gather atoms
+  atomvector += atoms[center], atoms[left], atoms[right];
+  // create bonds
+  bondvector += atoms[center]->addBond(atoms[left]), atoms[center]->addBond(atoms[right]);
+  // prepare bondvectors
+  bv->setFromAtomRange< std::vector<atom *> >(atomvector.begin(), atomvector.end(), WorldTime::getTime());
+  // calculate weights
+  BondVectors::weights_t weights = bv->getWeightsForAtomAtStep(*atoms[center], WorldTime::getTime());
+  LOG(2, "DEBUG: Linear chain weights are " << weights);
+  // check number of weights
+  CPPUNIT_ASSERT_EQUAL( weights.size(), (size_t)2 );
+  // check sum of weights
+  const double weight_sum = std::accumulate(weights.begin(), weights.end(), 0.);
+  CPPUNIT_ASSERT( fabs(weight_sum - 1.) < 1e-10 );
+}
+
+/** Test whether calculating weights works on right angle config
+ *
+ */
+void BondVectorsTest::weights_rightangleTest()
+{
+  // gather atoms
+  atomvector += atoms[center], atoms[left], atoms[top];
+  // create bonds
+  bondvector +=
+      atoms[center]->addBond(atoms[left]),
+      atoms[center]->addBond(atoms[top]);
+  // prepare bondvectors
+  bv->setFromAtomRange< std::vector<atom *> >(atomvector.begin(), atomvector.end(), WorldTime::getTime());
+  // calculate weights
+  BondVectors::weights_t weights = bv->getWeightsForAtomAtStep(*atoms[center], WorldTime::getTime());
+  LOG(2, "DEBUG: Right angle weights are " << weights);
+  // check number of weights
+  CPPUNIT_ASSERT_EQUAL( weights.size(), (size_t)2 );
+  // check sum of weights: two independent vectors == 1+1
+  const double weight_sum = std::accumulate(weights.begin(), weights.end(), 0.);
+  CPPUNIT_ASSERT( fabs(weight_sum - 2.) < 1e-10 );
+}
+
+/** Test whether calculating weights works on triangle config
+ *
+ */
+void BondVectorsTest::weights_triangleTest()
+{
+  // gather atoms
+  atomvector += atoms[center], atoms[left], atoms[right], atoms[top];
+  // create bonds
+  bondvector +=
+      atoms[center]->addBond(atoms[left]),
+      atoms[center]->addBond(atoms[right]),
+      atoms[center]->addBond(atoms[top]);
+  // prepare bondvectors
+  bv->setFromAtomRange< std::vector<atom *> >(atomvector.begin(), atomvector.end(), WorldTime::getTime());
+  // calculate weights
+  BondVectors::weights_t weights = bv->getWeightsForAtomAtStep(*atoms[center], WorldTime::getTime());
+  LOG(2, "DEBUG: triangle weights are " << weights);
+  // check number of weights
+  CPPUNIT_ASSERT_EQUAL( weights.size(), (size_t)3 );
+  // check sum of weights: one linear independent, two dependent vectors = 1 + 2*0.5
+  const double weight_sum = std::accumulate(weights.begin(), weights.end(), 0.);
+  CPPUNIT_ASSERT( fabs(weight_sum - 2.) < 1e-10 );
+}
Index: src/Dynamics/unittests/BondVectorsUnitTest.hpp
===================================================================
--- src/Dynamics/unittests/BondVectorsUnitTest.hpp	(revision d3d9643f5c7763e0bc8151d916a1c92bd8dcadeb)
+++ src/Dynamics/unittests/BondVectorsUnitTest.hpp	(revision d3d9643f5c7763e0bc8151d916a1c92bd8dcadeb)
@@ -0,0 +1,69 @@
+/*
+ * BondVectorsUnitTest.hpp
+ *
+ *  Created on: Jun 29, 2017
+ *      Author: heber
+ */
+
+#ifndef BONDVECTORSUNITTEST_HPP_
+#define BONDVECTORSUNITTEST_HPP_
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+
+#include <cppunit/extensions/HelperMacros.h>
+
+#include <vector>
+
+#include "Bond/bond.hpp"
+
+class atom;
+class BondVectors;
+class element;
+
+/********************************************** Test classes **************************************/
+
+class BondVectorsTest : public CppUnit::TestFixture
+{
+    CPPUNIT_TEST_SUITE( BondVectorsTest) ;
+    CPPUNIT_TEST ( current_mappedTest );
+    CPPUNIT_TEST ( weights_singlebondTest );
+    CPPUNIT_TEST ( weights_linearchainTest );
+    CPPUNIT_TEST ( weights_rightangleTest );
+    CPPUNIT_TEST ( weights_triangleTest );
+    CPPUNIT_TEST_SUITE_END();
+
+public:
+      void setUp();
+      void tearDown();
+      void current_mappedTest();
+      void weights_singlebondTest();
+      void weights_linearchainTest();
+      void weights_rightangleTest();
+      void weights_triangleTest();
+
+private:
+      enum atomPositions
+      {
+        left,
+        center,
+        right,
+        top,
+        topright,
+        bottom,
+        bottomright
+      };
+
+      BondVectors *bv;
+      std::vector<atom *> atoms;
+      std::vector<atom *> atomvector;
+      std::vector<bond::ptr> bondvector;
+      atom * _atom;
+      bond * _bond;
+      const element * carbon;
+};
+
+#endif /* BONDVECTORSUNITTEST_HPP_ */
Index: src/Dynamics/unittests/Makefile.am
===================================================================
--- src/Dynamics/unittests/Makefile.am	(revision d3d9643f5c7763e0bc8151d916a1c92bd8dcadeb)
+++ src/Dynamics/unittests/Makefile.am	(revision d3d9643f5c7763e0bc8151d916a1c92bd8dcadeb)
@@ -0,0 +1,37 @@
+# PLEASE adhere to the alphabetical ordering in this Makefile!
+# Also indentation by a single tab
+
+DYNAMICSTESTSSOURCES = \
+  ../Dynamics/unittests/BondVectorsUnitTest.cpp
+
+DYNAMICSTESTSHEADERS = \
+  ../Dynamics/unittests/BondVectorsUnitTest.hpp
+
+DYNAMICSTESTS = \
+  BondVectorsUnitTest
+  
+TESTS += $(DYNAMICSTESTS)
+check_PROGRAMS += $(DYNAMICSTESTS) 
+noinst_PROGRAMS += $(DYNAMICSTESTS)
+
+DYNAMICSLIBS = \
+	libUnitTest.la \
+	../libMolecuilder.la \
+	../libMolecuilderUI.la
+if CONDJOBMARKET
+DYNAMICSLIBS += \
+	../libMolecuilderJobs.la \
+	../libMolecuilderJobs_Work.la
+endif
+DYNAMICSLIBS += \
+	$(top_builddir)/ThirdParty/LinearAlgebra/src/LinearAlgebra/libLinearAlgebra.la \
+	${CodePatterns_LIBS} \
+	$(BOOST_LIB)
+
+BondVectorsUnitTest_SOURCES = \
+	../Dynamics/unittests/BondVectorsUnitTest.cpp \
+	../Dynamics/unittests/BondVectorsUnitTest.hpp
+BondVectorsUnitTest_LDADD = $(DYNAMICSLIBS)
+
+
+#AUTOMAKE_OPTIONS = parallel-tests
