Index: src/Potentials/PartialNucleiChargeFitter.cpp
===================================================================
--- src/Potentials/PartialNucleiChargeFitter.cpp	(revision 58fcbe5782c0a7715965a667901d08d7cdb12447)
+++ src/Potentials/PartialNucleiChargeFitter.cpp	(revision f60d95c3ae3cef9f355c1dae4c3b898b32e5c978)
@@ -187,4 +187,25 @@
       "PartialNucleiChargeFitter::PartialNucleiChargeFitter() - not enough or more than calculated sample points.");
 
+#ifndef NDEBUG
+  // write vector as paraview csv file file
+  {
+    size_t N[3];
+    size_t index = 0;
+    std::ofstream paraview_output("solution.csv");
+    paraview_output << "x coord,y coord,z coord,scalar" << std::endl;
+    for(N[0]=0; N[0] < total[0]; ++N[0]) {
+      for(N[1]=0; N[1] < total[1]; ++N[1]) {
+        for(N[2]=0; N[2] < total[2]; ++N[2]) {
+          paraview_output
+              << (double)N[0]/(double)total[0] << ","
+              << (double)N[1]/(double)total[1] << ","
+              << (double)N[2]/(double)total[2] << ","
+              << SampledPotential.at(index++) << std::endl;
+        }
+      }
+    }
+    paraview_output.close();
+  }
+#endif
 
   LOG(1, "INFO: I masked " << masked_points << " points in right-hand-side.");
@@ -275,9 +296,72 @@
           SampledPotential);
 
-  LOG(4, "DEBUG: Solution vector is " << (*PotentialFromCharges) * (*PartialCharges) << ".");
+//  LOG(4, "DEBUG: Solution vector is " << (*PotentialFromCharges) * (*PartialCharges) << ".");
 
   // calculate residual vector
   VectorContent residuum = (*PotentialFromCharges) * (*PartialCharges) - SampledPotential;
+
+#ifndef NDEBUG
+  // write solution to file
+  writeMatrix();
+
+  // write vector as paraview csv file file
+  {
+    size_t N[3];
+    size_t index = 0;
+    std::ofstream paraview_output("residuum.csv");
+    paraview_output << "x coord,y coord,z coord,scalar" << std::endl;
+    for(N[0]=0; N[0] < total[0]; ++N[0]) {
+      for(N[1]=0; N[1] < total[1]; ++N[1]) {
+        for(N[2]=0; N[2] < total[2]; ++N[2]) {
+          paraview_output
+              << (double)N[0]/(double)total[0] << ","
+              << (double)N[1]/(double)total[1] << ","
+              << (double)N[2]/(double)total[2] << ","
+              << residuum.at(index++) << std::endl;
+        }
+      }
+    }
+    paraview_output.close();
+  }
+#endif
+
+  // calculate L1 and L2 errors
+  double residuum_l1 = 0.;
+  for (size_t i=0; i< residuum.getDimension(); ++i)
+    if (residuum_l1 < residuum[i])
+      residuum_l1 = residuum[i];
+  LOG(1, "INFO: L2-Norm of residuum is " << residuum.Norm() << ".");
+  LOG(1, "INFO: L1-Norm of residuum is " << residuum_l1 << ".");
+
   return residuum.Norm();
+}
+
+void PartialNucleiChargeFitter::writeMatrix()
+{
+  constructMatrix();
+
+  // write matrix as paraview csv file file
+    size_t N[3];
+    size_t index=0;
+    std::string filename = std::string("potential.csv");
+    std::ofstream paraview_output(filename.c_str());
+    paraview_output << "x coord,y coord,z coord,scalar" << std::endl;
+    for(N[0]=0; N[0] < total[0]; ++N[0]) {
+      for(N[1]=0; N[1] < total[1]; ++N[1]) {
+        for(N[2]=0; N[2] < total[2]; ++N[2]) {
+          double sum = 0.;
+          for (size_t nuclei_index = 0; nuclei_index < positions.size(); ++nuclei_index) {
+            sum+= PotentialFromCharges->at(index, nuclei_index)*PartialCharges->at(nuclei_index);
+          }
+          paraview_output
+              << (double)N[0]/(double)total[0] << ","
+              << (double)N[1]/(double)total[1] << ","
+              << (double)N[2]/(double)total[2] << ","
+              << sum << std::endl;
+          index++;
+        }
+      }
+    }
+    paraview_output.close();
 }
 
Index: src/Potentials/PartialNucleiChargeFitter.hpp
===================================================================
--- src/Potentials/PartialNucleiChargeFitter.hpp	(revision 58fcbe5782c0a7715965a667901d08d7cdb12447)
+++ src/Potentials/PartialNucleiChargeFitter.hpp	(revision f60d95c3ae3cef9f355c1dae4c3b898b32e5c978)
@@ -105,4 +105,6 @@
    charges_t getSolutionAsCharges_t() const;
 
+   void writeMatrix();
+
 private:
    /** Helper function to construct the problem Matrix A.
