From 20dd176ff2c12e757ee2fbbccc1171c075b3f77f Mon Sep 17 00:00:00 2001
From: Andre <upwli@student.kit.edu>
Date: Fri, 7 Jan 2022 12:10:45 +0100
Subject: [PATCH] Changed tests

---
 corsika/detail/media/GeomagneticModel.inl |  3 ++
 corsika/detail/modules/TrackWriter.inl    |  2 +-
 tests/media/testMagneticField.cpp         | 64 +++++++++++------------
 3 files changed, 36 insertions(+), 33 deletions(-)

diff --git a/corsika/detail/media/GeomagneticModel.inl b/corsika/detail/media/GeomagneticModel.inl
index 9e15b454d..2595f4505 100644
--- a/corsika/detail/media/GeomagneticModel.inl
+++ b/corsika/detail/media/GeomagneticModel.inl
@@ -156,6 +156,9 @@ namespace corsika {
         auto const nextEpoch = --iEpoch; // next epoch
         ParameterLine const next_p = nextEpoch->second[j];
         const double length = nextEpoch->first - epoch;
+        CORSIKA_LOG_WARN("Length {}.", length);
+        CORSIKA_LOG_WARN("year {}. Epoch {}", year, epoch);
+        CORSIKA_LOG_WARN("g {}. h {}", next_p.g, next_p.h);
         p.g = p.g + (next_p.g - p.g) * (year - epoch) / length;
         p.h = p.h + (next_p.h - p.h) * (year - epoch) / length;
       }
diff --git a/corsika/detail/modules/TrackWriter.inl b/corsika/detail/modules/TrackWriter.inl
index 5a0f8bf71..c6af922f0 100644
--- a/corsika/detail/modules/TrackWriter.inl
+++ b/corsika/detail/modules/TrackWriter.inl
@@ -28,7 +28,7 @@ namespace corsika {
 
     // write the track to the file
     TOutput::write(vP.getPID(), vP.getEnergy(), vP.getWeight(), start,
-                   vP.getTime() - vT.getDuration(), end, vP.getTime());
+                   vP.getTime(), end, vP.getTime() + vT.getDuration());
 
     return ProcessReturn::Ok;
   }
diff --git a/tests/media/testMagneticField.cpp b/tests/media/testMagneticField.cpp
index 3d311e64b..a680eae6a 100644
--- a/tests/media/testMagneticField.cpp
+++ b/tests/media/testMagneticField.cpp
@@ -88,43 +88,43 @@ TEST_CASE("UniformMagneticField w/ Homogeneous Medium") {
       GeomagneticModel wmm(gOrigin, corsika_data("GeoMag/WMM.COF"));
 
       // create earth magnetic field vector
-      MagneticFieldVector Earth_B_1 = wmm.getField(2022.5, 100_km, -80, -120);
-      MagneticFieldVector Earth_B_2 = wmm.getField(2022.5, 0_km, 0, 120);
-      MagneticFieldVector Earth_B_3 = wmm.getField(2020, 100_km, 80, 0);
-      MagneticFieldVector Earth_B_4 = wmm.getField(2019.999, 100_km, 80, 0);
-      CHECK(Earth_B_1.getX(gCS) / 1_nT == Approx(5815).margin(0.05));
-      CHECK(Earth_B_1.getY(gCS) / 1_nT == Approx(-14803).margin(0.05));
-      CHECK(Earth_B_1.getZ(gCS) / 1_nT == Approx(49755.3).margin(0.05));
-      CHECK(Earth_B_2.getX(gCS) / 1_nT == Approx(39684.7).margin(0.05));
-      CHECK(Earth_B_2.getY(gCS) / 1_nT == Approx(42.2).margin(0.05));
-      CHECK(Earth_B_2.getZ(gCS) / 1_nT == Approx(10809.5).margin(0.05));
-      CHECK(Earth_B_3.getX(gCS) / 1_nT == Approx(6261.8).margin(0.05));
-      CHECK(Earth_B_3.getY(gCS) / 1_nT == Approx(185.5).margin(0.05));
-      CHECK(Earth_B_3.getZ(gCS) / 1_nT == Approx(-52429.1).margin(0.05));
-      CHECK(Earth_B_4.getX(gCS) / 1_nT == Approx(6261.8).margin(0.05));
-      CHECK(Earth_B_4.getY(gCS) / 1_nT == Approx(185.5).margin(0.05));
-      CHECK(Earth_B_4.getZ(gCS) / 1_nT == Approx(-52429.1).margin(0.05));
+      MagneticFieldVector WMM_B_1 = wmm.getField(2022.5, 100_km, -80, -120);
+      MagneticFieldVector WMM_B_2 = wmm.getField(2022.5, 0_km, 0, 120);
+      MagneticFieldVector WMM_B_3 = wmm.getField(2020, 100_km, 80, 0);
+      MagneticFieldVector WMM_B_4 = wmm.getField(2019.999, 100_km, 80, 0);
+      CHECK(WMM_B_1.getX(gCS) / 1_nT == Approx(5815).margin(0.05));
+      CHECK(WMM_B_1.getY(gCS) / 1_nT == Approx(-14803).margin(0.05));
+      CHECK(WMM_B_1.getZ(gCS) / 1_nT == Approx(49755.3).margin(0.05));
+      CHECK(WMM_B_2.getX(gCS) / 1_nT == Approx(39684.7).margin(0.05));
+      CHECK(WMM_B_2.getY(gCS) / 1_nT == Approx(42.2).margin(0.05));
+      CHECK(WMM_B_2.getZ(gCS) / 1_nT == Approx(10809.5).margin(0.05));
+      CHECK(WMM_B_3.getX(gCS) / 1_nT == Approx(6261.8).margin(0.05));
+      CHECK(WMM_B_3.getY(gCS) / 1_nT == Approx(185.5).margin(0.05));
+      CHECK(WMM_B_3.getZ(gCS) / 1_nT == Approx(-52429.1).margin(0.05));
+      CHECK(WMM_B_4.getX(gCS) / 1_nT == Approx(6262).margin(0.5));
+      CHECK(WMM_B_4.getY(gCS) / 1_nT == Approx(186).margin(0.5));
+      CHECK(WMM_B_4.getZ(gCS) / 1_nT == Approx(-52429).margin(0.5));
     }
     {
       GeomagneticModel igrf(gOrigin, corsika_data("GeoMag/IGRF13.COF"));
 
       // create earth magnetic field vector
-      MagneticFieldVector Earth_B_1 = igrf.getField(2022.5, 100_km, -80, -120);
-      MagneticFieldVector Earth_B_2 = igrf.getField(1937.5, 10_km, 80, 120);
-      MagneticFieldVector Earth_B_3 = igrf.getField(1990, 50_km, 80, 0);
-      MagneticFieldVector Earth_B_4 = igrf.getField(2012, 0_km, 0, -120);
-      CHECK(Earth_B_1.getX(gCS) / 1_nT == Approx(5821).margin(0.5));
-      CHECK(Earth_B_1.getY(gCS) / 1_nT == Approx(-14796).margin(0.5));
-      CHECK(Earth_B_1.getZ(gCS) / 1_nT == Approx(49776).margin(0.5));
-      CHECK(Earth_B_2.getX(gCS) / 1_nT == Approx(2957).margin(0.5));
-      CHECK(Earth_B_2.getY(gCS) / 1_nT == Approx(-1014).margin(0.5));
-      CHECK(Earth_B_2.getZ(gCS) / 1_nT == Approx(-57610).margin(0.5));
-      CHECK(Earth_B_3.getX(gCS) / 1_nT == Approx(6545).margin(0.5));
-      CHECK(Earth_B_3.getY(gCS) / 1_nT == Approx(1473).margin(0.5));
-      CHECK(Earth_B_3.getZ(gCS) / 1_nT == Approx(-52884).margin(0.5));
-      CHECK(Earth_B_4.getX(gCS) / 1_nT == Approx(30052).margin(0.5));
-      CHECK(Earth_B_4.getY(gCS) / 1_nT == Approx(-4738).margin(0.5));
-      CHECK(Earth_B_4.getZ(gCS) / 1_nT == Approx(-5190).margin(0.5));
+      MagneticFieldVector IGRF_B_1 = igrf.getField(2022.5, 100_km, -80, -120);
+      MagneticFieldVector IGRF_B_2 = igrf.getField(1937.5, 10_km, 80, 120);
+      MagneticFieldVector IGRF_B_3 = igrf.getField(1990, 50_km, 80, 0);
+      MagneticFieldVector IGRF_B_4 = igrf.getField(2012, 0_km, 0, -120);
+      CHECK(IGRF_B_1.getX(gCS) / 1_nT == Approx(5821).margin(0.5));
+      CHECK(IGRF_B_1.getY(gCS) / 1_nT == Approx(-14796).margin(0.5));
+      CHECK(IGRF_B_1.getZ(gCS) / 1_nT == Approx(49776).margin(0.5));
+      CHECK(IGRF_B_2.getX(gCS) / 1_nT == Approx(2957).margin(0.5));
+      CHECK(IGRF_B_2.getY(gCS) / 1_nT == Approx(-1014).margin(0.5));
+      CHECK(IGRF_B_2.getZ(gCS) / 1_nT == Approx(-57610).margin(0.5));
+      CHECK(IGRF_B_3.getX(gCS) / 1_nT == Approx(6545).margin(0.5));
+      CHECK(IGRF_B_3.getY(gCS) / 1_nT == Approx(1473).margin(0.5));
+      CHECK(IGRF_B_3.getZ(gCS) / 1_nT == Approx(-52884).margin(0.5));
+      CHECK(IGRF_B_4.getX(gCS) / 1_nT == Approx(30052).margin(0.5));
+      CHECK(IGRF_B_4.getY(gCS) / 1_nT == Approx(-4738).margin(0.5));
+      CHECK(IGRF_B_4.getZ(gCS) / 1_nT == Approx(-5190).margin(0.5));
     }
   }
 }
-- 
GitLab