Index: src/Parser/TremoloAtomInfoContainer.cpp
===================================================================
--- src/Parser/TremoloAtomInfoContainer.cpp	(revision 311da7bdf02dce8825b29e60fbe79e0688c15ca6)
+++ src/Parser/TremoloAtomInfoContainer.cpp	(revision 528b3e649ba6df7f9bb48df7750426f110ae4f92)
@@ -20,4 +20,6 @@
 #include "CodePatterns/MemDebug.hpp"
 
+#include "CodePatterns/toString.hpp"
+
 #include <iostream>
 
@@ -30,4 +32,5 @@
   imprData("-"),
   GroupMeasureTypeNo("0"),
+  Type("-"),
   extType("-"),
   name("-"),
@@ -59,4 +62,7 @@
     case TremoloKey::GroupMeasureTypeNo :
       GroupMeasureTypeNo = value;
+      break;
+    case TremoloKey::Type :
+      Type = value;
       break;
     case TremoloKey::extType :
@@ -104,5 +110,6 @@
 }
 
-std::string TremoloAtomInfoContainer::get(TremoloKey::atomDataKey key) {
+std::string TremoloAtomInfoContainer::get(TremoloKey::atomDataKey key) const
+{
   switch (key) {
     case TremoloKey::F :
@@ -114,4 +121,6 @@
     case TremoloKey::GroupMeasureTypeNo :
       return GroupMeasureTypeNo;
+    case TremoloKey::Type :
+      return Type;
     case TremoloKey::extType :
       return extType;
@@ -146,2 +155,26 @@
 }
 
+std::ostream& operator<<(std::ostream& out, const TremoloAtomInfoContainer& info)
+{
+  out << info.get(TremoloKey::F) << "\t";
+  out << info.get(TremoloKey::stress) << "\t";
+  out << info.get(TremoloKey::imprData) << "\t";
+  out << info.get(TremoloKey::GroupMeasureTypeNo) << "\t";
+  out << info.get(TremoloKey::Type) << "\t";
+  out << info.get(TremoloKey::extType) << "\t";
+  out << info.get(TremoloKey::name) << "\t";
+  out << info.get(TremoloKey::resName) << "\t";
+  out << info.get(TremoloKey::chainID) << "\t";
+  out << info.get(TremoloKey::resSeq) << "\t";
+  out << info.get(TremoloKey::occupancy) << "\t";
+  out << info.get(TremoloKey::tempFactor) << "\t";
+  out << info.get(TremoloKey::segID) << "\t";
+  out << info.get(TremoloKey::Charge) << "\t";
+  out << info.get(TremoloKey::charge) << "\t";
+  out << info.get(TremoloKey::GrpTypeNo) << "\t";
+  out << info.get(TremoloKey::torsion) << "\t";
+  out << info.neighbors << "\t";
+  out << info.neighbors_processed;
+
+  return out;
+}
Index: src/Parser/TremoloAtomInfoContainer.hpp
===================================================================
--- src/Parser/TremoloAtomInfoContainer.hpp	(revision 311da7bdf02dce8825b29e60fbe79e0688c15ca6)
+++ src/Parser/TremoloAtomInfoContainer.hpp	(revision 528b3e649ba6df7f9bb48df7750426f110ae4f92)
@@ -27,9 +27,10 @@
   TremoloAtomInfoContainer();
   void set(TremoloKey::atomDataKey key, std::string value);
-  std::string get(TremoloKey::atomDataKey key);
+  std::string get(TremoloKey::atomDataKey key) const;
   std::string F;
   std::string stress;
   std::string imprData;
   std::string GroupMeasureTypeNo;
+  std::string Type;
   std::string extType;
   std::string name;
@@ -48,4 +49,5 @@
 };
 
+std::ostream& operator<<(std::ostream& out, const TremoloAtomInfoContainer&);
 
 #endif /* TREMOLOATOMINFOCONTAINER_HPP_ */
Index: src/Parser/TremoloParser.cpp
===================================================================
--- src/Parser/TremoloParser.cpp	(revision 311da7bdf02dce8825b29e60fbe79e0688c15ca6)
+++ src/Parser/TremoloParser.cpp	(revision 528b3e649ba6df7f9bb48df7750426f110ae4f92)
@@ -22,4 +22,5 @@
 #include "CodePatterns/Assert.hpp"
 #include "CodePatterns/Log.hpp"
+#include "CodePatterns/toString.hpp"
 #include "CodePatterns/Verbose.hpp"
 #include "TremoloParser.hpp"
@@ -66,4 +67,6 @@
   knownKeys["torsion"] = TremoloKey::torsion;
 
+  createKnownTypesByIdentity();
+
   // default behavior: use all possible keys on output
   for (std::map<std::string, TremoloKey::atomDataKey>::iterator iter = knownKeys.begin(); iter != knownKeys.end(); ++iter)
@@ -72,4 +75,10 @@
   // and noKey afterwards(!) such that it is not used in usedFields
   knownKeys[" "] = TremoloKey::noKey; // with this we can detect invalid keys
+
+  // invert knownKeys for debug output
+  for (std::map<std::string, TremoloKey::atomDataKey>::iterator iter = knownKeys.begin(); iter != knownKeys.end(); ++iter)
+    knownKeyNames.insert( make_pair( iter->second, iter->first) );
+
+  additionalAtomData.clear();
 }
 
@@ -131,4 +140,6 @@
   vector<string>::iterator it;
 
+  DoLog(3) && (Log() << Verbose(3) << "additionalAtomData contains: " << additionalAtomData << std::endl);
+
   *file << "# ATOMDATA";
   for (it=usedFields.begin(); it < usedFields.end(); it++) {
@@ -162,4 +173,6 @@
   vector<string>::iterator it;
   TremoloKey::atomDataKey currentField;
+
+  DoLog(4) && (Log() << Verbose(4) << "INFO: Saving atom " << *currentAtom << ", its father id is " << currentAtom->GetTrueFather()->getId() << std::endl);
 
   for (it = usedFields.begin(); it != usedFields.end(); it++) {
@@ -168,4 +181,5 @@
       case TremoloKey::x :
         // for the moment, assume there are always three dimensions
+        DoLog(3) && (Log() << Verbose(3) << "Writing for type " << knownKeyNames[currentField] << ": " << currentAtom->getPosition() << std::endl);
         *file << currentAtom->at(0) << "\t";
         *file << currentAtom->at(1) << "\t";
@@ -174,4 +188,5 @@
       case TremoloKey::u :
         // for the moment, assume there are always three dimensions
+        DoLog(3) && (Log() << Verbose(3) << "Writing for type " << knownKeyNames[currentField] << ": " << currentAtom->AtomicVelocity << std::endl);
         *file << currentAtom->AtomicVelocity[0] << "\t";
         *file << currentAtom->AtomicVelocity[1] << "\t";
@@ -179,28 +194,55 @@
         break;
       case TremoloKey::Type :
-        *file << currentAtom->getType()->getSymbol() << "\t";
+        if (additionalAtomData.count(currentAtom->getId())) {
+          if (additionalAtomData[currentAtom->getId()].get(currentField) != "-") {
+            DoLog(3) && (Log() << Verbose(3) << "Writing for type " << knownKeyNames[currentField] << ": " << additionalAtomData[currentAtom->getId()].get(currentField) << std::endl);
+            *file << additionalAtomData[currentAtom->getId()].get(currentField) << "\t";
+          } else {
+            DoLog(3) && (Log() << Verbose(3) << "Writing for type " << knownKeyNames[currentField] << " default value: " << currentAtom->getType()->getSymbol() << std::endl);
+            *file << currentAtom->getType()->getSymbol() << "\t";
+          }
+        } else if (additionalAtomData.count(currentAtom->GetTrueFather()->getId())) {
+          if (additionalAtomData[currentAtom->GetTrueFather()->getId()].get(currentField) != "-") {
+            DoLog(3) && (Log() << Verbose(3) << "Writing for type " << knownKeyNames[currentField] << " stuff from father: " << additionalAtomData[currentAtom->GetTrueFather()->getId()].get(currentField) << std::endl);
+            *file << additionalAtomData[currentAtom->GetTrueFather()->getId()].get(currentField) << "\t";
+          } else {
+            DoLog(3) && (Log() << Verbose(3) << "Writing for type " << knownKeyNames[currentField] << " default value from father: " << currentAtom->GetTrueFather()->getType()->getSymbol() << std::endl);
+            *file << currentAtom->GetTrueFather()->getType()->getSymbol() << "\t";
+          }
+        } else {
+          DoLog(3) && (Log() << Verbose(3) << "Writing for type " << knownKeyNames[currentField] << " its default value: " << currentAtom->getType()->getSymbol() << std::endl);
+          *file << currentAtom->getType()->getSymbol() << "\t";
+        }
         break;
       case TremoloKey::Id :
+        DoLog(3) && (Log() << Verbose(3) << "Writing for type " << knownKeyNames[currentField] << ": " << currentAtom->getId()+1 << std::endl);
         *file << currentAtom->getId()+1 << "\t";
         break;
       case TremoloKey::neighbors :
+        DoLog(3) && (Log() << Verbose(3) << "Writing type " << knownKeyNames[currentField] << std::endl);
         writeNeighbors(file, atoi(it->substr(it->find("=") + 1, 1).c_str()), currentAtom);
         break;
       case TremoloKey::resSeq :
-        if (additionalAtomData.find(currentAtom->getId()) != additionalAtomData.end()) {
+        if (additionalAtomData.count(currentAtom->getId())) {
+          DoLog(3) && (Log() << Verbose(3) << "Writing for type " << knownKeyNames[currentField] << ": " << additionalAtomData[currentAtom->getId()].get(currentField) << std::endl);
           *file << additionalAtomData[currentAtom->getId()].get(currentField);
         } else if (currentAtom->getMolecule() != NULL) {
+          DoLog(3) && (Log() << Verbose(3) << "Writing for type " << knownKeyNames[currentField] << " its own id: " << currentAtom->getMolecule()->getId()+1 << std::endl);
           *file << setw(4) << currentAtom->getMolecule()->getId()+1;
         } else {
+          DoLog(3) && (Log() << Verbose(3) << "Writing for type " << knownKeyNames[currentField] << " default value: " << defaultAdditionalData.get(currentField) << std::endl);
           *file << defaultAdditionalData.get(currentField);
         }
         *file << "\t";
-      break;
+        break;
       default :
-        if (additionalAtomData.find(currentAtom->getId()) != additionalAtomData.end()) {
+        if (additionalAtomData.count(currentAtom->getId())) {
+          DoLog(3) && (Log() << Verbose(3) << "Writing for type " << knownKeyNames[currentField] << ": " << additionalAtomData[currentAtom->getId()].get(currentField) << std::endl);
           *file << additionalAtomData[currentAtom->getId()].get(currentField);
-        } else if (additionalAtomData.find(currentAtom->GetTrueFather()->getId()) != additionalAtomData.end()) {
+        } else if (additionalAtomData.count(currentAtom->GetTrueFather()->getId())) {
+          DoLog(3) && (Log() << Verbose(3) << "Writing for type " << knownKeyNames[currentField] << " stuff from father: " << additionalAtomData[currentAtom->GetTrueFather()->getId()].get(currentField) << std::endl);
           *file << additionalAtomData[currentAtom->GetTrueFather()->getId()].get(currentField);
         } else {
+          DoLog(3) && (Log() << Verbose(3) << "Writing for type " << knownKeyNames[currentField] << " the default: " << defaultAdditionalData.get(currentField) << std::endl);
           *file << defaultAdditionalData.get(currentField);
         }
@@ -306,13 +348,16 @@
         break;
       case TremoloKey::Type :
-        char type[3];
+      {
         ASSERT(tok_iter != tokens.end(), "TremoloParser::readAtomDataLine() - no value for "+keyName+"!");
-        //DoLog(1) && (Log() << Verbose(1) << "INFO: Parsing key " << keyName << " with next token " << *tok_iter << std::endl);
-        strncpy(type, (*tok_iter).c_str(), 3);
+        DoLog(1) && (Log() << Verbose(1) << "INFO: Parsing key " << keyName << " with next token " << *tok_iter << std::endl);
+        std::string element(knownTypes[(*tok_iter)]);
+        // put type name into container for later use
+        atomInfo->set(currentField, *tok_iter);
+        DoLog(1) && (Log() << Verbose(1) << "INFO: Parsing element " << (*tok_iter) << " as " << element << " according to KnownTypes." << std::endl);
         tok_iter++;
-        //type[1]='\0'; // cutoff after first char, correct for ATOM entries
-        newAtom->setType(World::getInstance().getPeriode()->FindElement(type));
+        newAtom->setType(World::getInstance().getPeriode()->FindElement(element));
         ASSERT(newAtom->getType(), "Type was not set for this atom");
         break;
+      }
       case TremoloKey::Id :
         ASSERT(tok_iter != tokens.end(), "TremoloParser::readAtomDataLine() - no value for "+keyName+"!");
@@ -476,2 +521,83 @@
 }
 
+/** Creates knownTypes as the identity, e.g. H -> H, He -> He, ... .
+ *
+ */
+void TremoloParser::createKnownTypesByIdentity()
+{
+  // remove old mapping
+  knownTypes.clear();
+  // make knownTypes the identity mapping
+  const periodentafel *periode = World::getInstance().getPeriode();
+  for (periodentafel::const_iterator iter = periode->begin();
+      iter != periode->end();
+      ++iter) {
+    knownTypes.insert( make_pair(iter->second->getSymbol(), iter->second->getSymbol()) );
+  }
+}
+
+/** Parses a .potentials file and creates from it the knownTypes file.
+ *
+ * @param file input stream of .potentials file
+ */
+void TremoloParser::parseKnownTypes(std::istream &file)
+{
+  const periodentafel *periode = World::getInstance().getPeriode();
+  // remove old mapping
+  knownTypes.clear();
+
+  DoLog(3) && (Log() << Verbose(3) << "additionalAtomData contains: " << additionalAtomData << std::endl);
+
+  // parse in file
+  typedef boost::tokenizer<boost::char_separator<char> >
+      tokenizer;
+  boost::char_separator<char> tokensep(":\t ,;");
+  boost::char_separator<char> equalitysep("\t =");
+  std::string line;
+  while (file.good()) {
+    std::getline( file, line );
+    DoLog(4) && (Log() << Verbose(4) << "INFO: full line of parameters is '" << line << "'" << std::endl);
+    if (line.find("particle:") != string::npos) {
+      DoLog(3) && (Log() << Verbose(3) << "INFO: found line '" << line << "' containing keyword 'particle:'." << std::endl);
+      tokenizer tokens(line, tokensep);
+      ASSERT(tokens.begin() != tokens.end(),
+          "TremoloParser::parseKnownTypes() - line with 'particle:' but no particles separated by comma.");
+      // look for particle_type
+      std::string particle_type("NULL");
+      std::string element_type("NULL");
+      for (tokenizer::iterator tok_iter = tokens.begin();
+          tok_iter != tokens.end();
+          ++tok_iter) {
+        if ((*tok_iter).find("particle_type") != string::npos) {
+          DoLog(3) && (Log() << Verbose(3) << "INFO: found line '" << line << "' containing keyword 'particle_type'." << std::endl);
+          tokenizer token((*tok_iter), equalitysep);
+          ASSERT(token.begin() != token.end(),
+                    "TremoloParser::parseKnownTypes() - could not split particle_type by equality sign");
+          tokenizer::iterator particle_iter = token.begin();
+          particle_iter++;
+          particle_type = *particle_iter;
+        }
+        if ((*tok_iter).find("element_name") != string::npos) {
+          DoLog(3) && (Log() << Verbose(3) << "INFO: found line '" << line << "' containing keyword 'element_name'." << std::endl);
+          tokenizer token((*tok_iter), equalitysep);
+          ASSERT(token.begin() != token.end(),
+                    "TremoloParser::parseKnownTypes() - could not split particle_type by equality sign");
+          tokenizer::iterator element_iter = token.begin();
+          element_iter++;
+          element_type = *element_iter;
+        }
+      }
+      if ((particle_type != "NULL") && (element_type != "NULL")) {
+        if (periode->FindElement(element_type) != NULL) {
+          DoLog(1) && (Log() << Verbose(1) << "INFO: Added Type " << particle_type << " as reference to element " << element_type << "." << std::endl);
+          knownTypes.insert( make_pair (particle_type, element_type) );
+        } else {
+          DoeLog(1) && (Log() << Verbose(1) << "INFO: Either Type " << particle_type << " or " << element_type << " could not be recognized." << std::endl);
+        }
+      } else {
+        DoeLog(1) && (Log() << Verbose(1) << "INFO: Desired element " << element_type << " is not known." << std::endl);
+      }
+    }
+  }
+
+}
Index: src/Parser/TremoloParser.hpp
===================================================================
--- src/Parser/TremoloParser.hpp	(revision 311da7bdf02dce8825b29e60fbe79e0688c15ca6)
+++ src/Parser/TremoloParser.hpp	(revision 528b3e649ba6df7f9bb48df7750426f110ae4f92)
@@ -35,4 +35,7 @@
   void setFieldsForSave(std::string atomDataLine);
 
+  void parseKnownTypes(std::istream &file);
+  void createKnownTypesByIdentity();
+
 
 private:
@@ -50,7 +53,17 @@
 
   /**
+   * Map to associate the elements with stuff in "Type", e.g. OC2 -> O.
+   */
+  std::map<std::string, std::string> knownTypes;
+
+  /**
    * Map to associate the known keys with numbers.
    */
   std::map<std::string, TremoloKey::atomDataKey> knownKeys;
+
+  /**
+   * Inverse Map to have a name to each known keys.
+   */
+  std::map<TremoloKey::atomDataKey, std::string> knownKeyNames;
 
   /**
Index: src/Parser/unittests/ParserTremoloUnitTest.cpp
===================================================================
--- src/Parser/unittests/ParserTremoloUnitTest.cpp	(revision 311da7bdf02dce8825b29e60fbe79e0688c15ca6)
+++ src/Parser/unittests/ParserTremoloUnitTest.cpp	(revision 528b3e649ba6df7f9bb48df7750426f110ae4f92)
@@ -44,12 +44,40 @@
 CPPUNIT_TEST_SUITE_REGISTRATION( ParserTremoloUnitTest );
 
-static string Tremolo_Atomdata1 = "# ATOMDATA\tId\tname\tType\tx=3\n";
-static string Tremolo_Atomdata2 = "#\n#ATOMDATA Id name Type x=3\n1 hydrogen H 3.0 4.5 0.1\n\n";
-static string Tremolo_invalidkey = "#\n#ATOMDATA Id name foo Type x=3\n\n\n";
-static string Tremolo_velocity = "#\n#ATOMDATA Id name Type u=3\n1 hydrogen H 3.0 4.5 0.1\n\n";
-static string Tremolo_neighbours = "#\n#ATOMDATA Id Type neighbors=2\n1 H 3 0\n2 H 3 0\n3 O 1 2\n";
-static string Tremolo_improper = "#\n#ATOMDATA Id Type imprData\n8 H 9-10\n9 H 10-8,8-10\n10 O -\n";
-static string Tremolo_torsion = "#\n#ATOMDATA Id Type torsion\n8 H 9-10\n9 H 10-8,8-10\n10 O -\n";
-static string Tremolo_full = "# ATOMDATA\tx=3\tu=3\tF\tstress\tId\tneighbors=5\timprData\tGroupMeasureTypeNo\tType\textType\tname\tresName\tchainID\tresSeq\toccupancy\ttempFactor\tsegID\tCharge\tcharge\tGrpTypeNo\ttorsion\n0\t0\t0\t0\t0\t0\t0\t0\t1\t0\t0\t0\t0\t0\t-\t0\tH\t-\t-\t-\t0\t0\t0\t0\t0\t0\t0\t0\t-\t\n";
+static string Tremolo_Atomdata1 = "\
+# ATOMDATA\tId\tname\tType\tx=3\n";
+static string Tremolo_Atomdata2 = "\
+#\n\
+#ATOMDATA Id name Type x=3\n\
+1 hydrogen H 3.0 4.5 0.1\n\
+\n";
+static string Tremolo_invalidkey = "\
+#\n\
+#ATOMDATA Id name foo Type x=3\n\
+\n\n";
+static string Tremolo_velocity = "\
+#\n\
+#ATOMDATA Id name Type u=3\n\
+1 hydrogen H 3.0 4.5 0.1\n\
+\n";
+static string Tremolo_neighbours = "#\n\
+#ATOMDATA Id Type neighbors=2\n\
+1 H 3 0\n\
+2 H 3 0\n\
+3 O 1 2\n";
+static string Tremolo_improper = "\
+#\n\
+#ATOMDATA Id Type imprData\n\
+8 H 9-10\n\
+9 H 10-8,8-10\n\
+10 O -\n";
+static string Tremolo_torsion = "\
+#\n\
+#ATOMDATA Id Type torsion\n\
+8 H 9-10\n\
+9 H 10-8,8-10\n\
+10 O -\n";
+static string Tremolo_full = "\
+# ATOMDATA\tx=3\tu=3\tF\tstress\tId\tneighbors=5\timprData\tGroupMeasureTypeNo\tType\textType\tname\tresName\tchainID\tresSeq\toccupancy\ttempFactor\tsegID\tCharge\tcharge\tGrpTypeNo\ttorsion\n\
+0\t0\t0\t0\t0\t0\t0\t0\t1\t0\t0\t0\t0\t0\t-\t0\tH\t-\t-\t-\t0\t0\t0\t0\t0\t0\t0\t0\t-\t\n";
 
 void ParserTremoloUnitTest::setUp() {
@@ -79,4 +107,6 @@
     std::vector<atom *> atoms = World::getInstance().getAllAtoms();
     testParser->save(&output, atoms);
+//    std::cout << output.str() << std::endl;
+//    std::cout << Tremolo_Atomdata1 << std::endl;
     CPPUNIT_ASSERT(Tremolo_Atomdata1 == output.str());
     input.clear();
@@ -90,4 +120,5 @@
     std::vector<atom *> atoms = World::getInstance().getAllAtoms();
     testParser->save(&output, atoms);
+    std::cout << output.str() << std::endl;
     CPPUNIT_ASSERT(output.str().find("hydrogen") != string::npos);
     input.clear();
@@ -149,4 +180,5 @@
     testParser->save(&output, atoms);
     CPPUNIT_ASSERT_EQUAL(3, World::getInstance().numAtoms());
+    std::cout << output.str() << std::endl;
     CPPUNIT_ASSERT(output.str().find("2-0,0-2") != string::npos);
     input.clear();
@@ -166,4 +198,5 @@
     testParser->save(&output, atoms);
     CPPUNIT_ASSERT_EQUAL(3, World::getInstance().numAtoms());
+    std::cout << output.str() << std::endl;
     CPPUNIT_ASSERT(output.str().find("2-0,0-2") != string::npos);
     input.clear();
