From beaf7909332fd68825d0aa503a41cf4c28a6d30d Mon Sep 17 00:00:00 2001
From: Orestis Karapiperis <karapiperis@strw.leidenuniv.nl>
Date: Mon, 10 Mar 2025 17:43:56 +0000
Subject: [PATCH] Karapiperis/fixes and improvements in mhd io

---
 examples/MHDTests/RyuJones_1A/plotSolution.py |  2 +-
 examples/MHDTests/RyuJones_3B/plotSolution.py |  2 +-
 src/mhd/DirectInduction/mhd_io.h              | 16 ++++++++--------
 3 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/examples/MHDTests/RyuJones_1A/plotSolution.py b/examples/MHDTests/RyuJones_1A/plotSolution.py
index 9427505433..1559201c78 100644
--- a/examples/MHDTests/RyuJones_1A/plotSolution.py
+++ b/examples/MHDTests/RyuJones_1A/plotSolution.py
@@ -51,7 +51,7 @@ with h5py.File(args.input, "r") as handle:
     u = handle["PartType0/InternalEnergies"][:]
     B = handle["PartType0/MagneticFluxDensities"][:]
     divB = handle["PartType0/MagneticDivergences"][:]
-    psi = handle["PartType0/DednerScalars"][:]
+    psi = handle["PartType0/DednerScalarsOverCleaningSpeeds"][:]
     git = handle["Code"].attrs["Git Revision"]
     gitBranch = handle["Code"].attrs["Git Branch"]
     scheme = handle["/HydroScheme"].attrs["Scheme"]
diff --git a/examples/MHDTests/RyuJones_3B/plotSolution.py b/examples/MHDTests/RyuJones_3B/plotSolution.py
index 586f9198bd..acf4a8452f 100644
--- a/examples/MHDTests/RyuJones_3B/plotSolution.py
+++ b/examples/MHDTests/RyuJones_3B/plotSolution.py
@@ -50,7 +50,7 @@ with h5py.File(args.input, "r") as handle:
     u = handle["PartType0/InternalEnergies"][:]
     B = handle["PartType0/MagneticFluxDensities"][:]
     divB = handle["PartType0/MagneticDivergences"][:]
-    psi = handle["PartType0/DednerScalars"][:]
+    psi = handle["PartType0/DednerScalarsOverCleaningSpeeds"][:]
     git = handle["Code"].attrs["Git Revision"]
     gitBranch = handle["Code"].attrs["Git Branch"]
     scheme = handle["/HydroScheme"].attrs["Scheme"]
diff --git a/src/mhd/DirectInduction/mhd_io.h b/src/mhd/DirectInduction/mhd_io.h
index 3ea76fa063..37b6068bba 100644
--- a/src/mhd/DirectInduction/mhd_io.h
+++ b/src/mhd/DirectInduction/mhd_io.h
@@ -41,9 +41,9 @@ INLINE static int mhd_read_particles(struct part* parts,
 INLINE static void convert_B(const struct engine* e, const struct part* p,
                              const struct xpart* xp, float* ret) {
 
-  ret[0] = xp->mhd_data.B_over_rho_full[0] * p->rho;
-  ret[1] = xp->mhd_data.B_over_rho_full[1] * p->rho;
-  ret[2] = xp->mhd_data.B_over_rho_full[2] * p->rho;
+  ret[0] = p->mhd_data.B_over_rho[0] * p->rho;
+  ret[1] = p->mhd_data.B_over_rho[1] * p->rho;
+  ret[2] = p->mhd_data.B_over_rho[2] * p->rho;
 }
 
 /**
@@ -390,15 +390,15 @@ INLINE static int mhd_write_particles(const struct part* parts,
       "co-moving DivB  of the particle");
 
   list[2] = io_make_output_field(
-      "DednerScalars", FLOAT, 1, UNIT_CONV_ELECTRIC_CHARGE_FIELD_STRENGTH,
+      "DednerScalarsOverCleaningSpeeds", FLOAT, 1, UNIT_CONV_MAGNETIC_FIELD,
       -1.5f * hydro_gamma - 1.f, parts, mhd_data.psi_over_ch,
-      "Dedner scalar associated to the particle");
+      "Dedner scalars over cleaning speeds of the particles");
 
   list[3] = io_make_output_field(
-      "DednerScalarsdt", FLOAT, 1,
-      UNIT_CONV_ELECTRIC_CHARGE_FIELD_STRENGTH_RATE, 1.f, parts,
+      "DednerScalarsOverCleaningSpeedsdt", FLOAT, 1,
+      UNIT_CONV_MAGNETIC_FIELD_PER_TIME, 1.f, parts,
       mhd_data.psi_over_ch_dt,
-      "Time derivative of Dedner scalar associated to particle");
+      "Time derivative of Dedner scalars over cleaning speeds of the particles");
 
   list[4] = io_make_output_field(
       "MagneticFluxDensitiesdt", FLOAT, 3, UNIT_CONV_MAGNETIC_FIELD_PER_TIME,
-- 
GitLab