From 40d115c7293eaf54e6b89b091f8db126d4f65762 Mon Sep 17 00:00:00 2001
From: "armindamon.riess" <armindamon.riess@uzh.ch>
Date: Tue, 6 Dec 2022 13:31:10 +0100
Subject: [PATCH] softening now a single scalar for every particle

---
 lib/nBodySim.cpp | 6 ++----
 lib/nBodySim.hpp | 2 +-
 2 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/lib/nBodySim.cpp b/lib/nBodySim.cpp
index 85243dc..570011f 100644
--- a/lib/nBodySim.cpp
+++ b/lib/nBodySim.cpp
@@ -29,9 +29,8 @@ nBodySim::nBodySim(std::string datafile) {
         }
     }
 
-    softening_ = new double[nParticles_];
     for (unsigned i=0; i < nParticles_; ++i) {
-        file >> softening_[i];
+        file >> softening_;
     }
     
     potential_ = new double[nParticles_];
@@ -52,7 +51,6 @@ nBodySim::~nBodySim() {
     delete[] masses_;
     delete[] positions_;
     delete[] velocities_;
-    delete[] softening_;
     delete[] potential_;
     delete[] forces_;
 }
@@ -223,7 +221,7 @@ void nBodySim::saveState2file(unsigned step, std::string filename) const {
     }
     // save softening
     for (unsigned i=0; i < nParticles_; ++i) {
-        file << softening_[i] << std::endl;
+        file << softening_ << std::endl;
     }
     // save potential
     for (unsigned i=0; i < nParticles_; ++i) {
diff --git a/lib/nBodySim.hpp b/lib/nBodySim.hpp
index c6fc75c..997cf3b 100644
--- a/lib/nBodySim.hpp
+++ b/lib/nBodySim.hpp
@@ -37,7 +37,7 @@ private:
     double* masses_;
     double* positions_;
     double* velocities_;
-    double* softening_;
+    double softening_;
     double* potential_;
     double* forces_;
     double meanInterparticleDistance_;
-- 
GitLab