From fc552a28c757477105a895280b079f7e649e7d16 Mon Sep 17 00:00:00 2001
From: Josh Borrow <joshua.borrow@durham.ac.uk>
Date: Fri, 16 Aug 2019 11:23:52 +0100
Subject: [PATCH] Fixed incorrect cosmology factors for pressure and internal
 energy in the i/o

---
 src/hydro/AnarchyDU/hydro_io.h                   |  4 ++--
 src/hydro/AnarchyPU/hydro_io.h                   |  4 ++--
 src/hydro/Default/hydro_io.h                     |  4 ++--
 src/hydro/Gadget2/hydro_io.h                     |  4 ++--
 src/hydro/GizmoMFM/hydro_io.h                    |  8 ++++----
 src/hydro/GizmoMFV/hydro_io.h                    |  8 ++++----
 src/hydro/Minimal/hydro_io.h                     |  4 ++--
 src/hydro/Planetary/hydro_io.h                   |  4 ++--
 src/hydro/PressureEnergy/hydro_io.h              |  4 ++--
 .../PressureEnergyMorrisMonaghanAV/hydro_io.h    |  4 ++--
 src/hydro/PressureEntropy/hydro_io.h             |  4 ++--
 src/hydro/Shadowswift/hydro_io.h                 | 16 ++++++++--------
 12 files changed, 34 insertions(+), 34 deletions(-)

diff --git a/src/hydro/AnarchyDU/hydro_io.h b/src/hydro/AnarchyDU/hydro_io.h
index d78d16c35b..4044a0c1f1 100644
--- a/src/hydro/AnarchyDU/hydro_io.h
+++ b/src/hydro/AnarchyDU/hydro_io.h
@@ -182,7 +182,7 @@ INLINE static void hydro_write_particles(const struct part* parts,
 
   list[4] = io_make_output_field(
       "InternalEnergies", FLOAT, 1, UNIT_CONV_ENERGY_PER_UNIT_MASS,
-      3. * hydro_gamma_minus_one, parts, u,
+      -3.f * hydro_gamma_minus_one, parts, u,
       "Co-moving thermal energies per unit mass of the particles");
 
   list[5] =
@@ -198,7 +198,7 @@ INLINE static void hydro_write_particles(const struct part* parts,
       xparts, convert_S, "Co-moving entropies per unit mass of the particles");
 
   list[8] = io_make_output_field_convert_part(
-      "Pressures", FLOAT, 1, UNIT_CONV_PRESSURE, 3.f * hydro_gamma, parts,
+      "Pressures", FLOAT, 1, UNIT_CONV_PRESSURE, -3.f * hydro_gamma, parts,
       xparts, convert_P, "Co-moving pressures of the particles");
 
   list[9] = io_make_output_field_convert_part(
diff --git a/src/hydro/AnarchyPU/hydro_io.h b/src/hydro/AnarchyPU/hydro_io.h
index 499ef5dc2d..7dfe61f198 100644
--- a/src/hydro/AnarchyPU/hydro_io.h
+++ b/src/hydro/AnarchyPU/hydro_io.h
@@ -184,7 +184,7 @@ INLINE static void hydro_write_particles(const struct part* parts,
 
   list[4] = io_make_output_field(
       "InternalEnergies", FLOAT, 1, UNIT_CONV_ENERGY_PER_UNIT_MASS,
-      3. * hydro_gamma_minus_one, parts, u,
+      -3.f * hydro_gamma_minus_one, parts, u,
       "Co-moving thermal energies per unit mass of the particles");
 
   list[5] =
@@ -196,7 +196,7 @@ INLINE static void hydro_write_particles(const struct part* parts,
                                  "Co-moving mass densities of the particles");
 
   list[7] = io_make_output_field(
-      "Pressure", FLOAT, 1, UNIT_CONV_PRESSURE, 3.f * hydro_gamma, parts,
+      "Pressures", FLOAT, 1, UNIT_CONV_PRESSURE, -3.f * hydro_gamma, parts,
       pressure_bar, "Co-moving smoothed pressures of the particles");
 
   list[8] = io_make_output_field_convert_part(
diff --git a/src/hydro/Default/hydro_io.h b/src/hydro/Default/hydro_io.h
index 5d92383776..1944f677ff 100644
--- a/src/hydro/Default/hydro_io.h
+++ b/src/hydro/Default/hydro_io.h
@@ -183,7 +183,7 @@ INLINE static void hydro_write_particles(const struct part* parts,
 
   list[4] = io_make_output_field(
       "InternalEnergies", FLOAT, 1, UNIT_CONV_ENERGY_PER_UNIT_MASS,
-      3. * hydro_gamma_minus_one, parts, u,
+      -3.f * hydro_gamma_minus_one, parts, u,
       "Co-moving thermal energies per unit mass of the particles");
 
   list[5] =
@@ -195,7 +195,7 @@ INLINE static void hydro_write_particles(const struct part* parts,
                                  "Co-moving mass densities of the particles");
 
   list[7] = io_make_output_field_convert_part(
-      "Pressures", FLOAT, 1, UNIT_CONV_PRESSURE, 3.f * hydro_gamma, parts,
+      "Pressures", FLOAT, 1, UNIT_CONV_PRESSURE, -3.f * hydro_gamma, parts,
       xparts, convert_P, "Co-moving pressures of the particles");
 
   list[8] = io_make_output_field_convert_part(
diff --git a/src/hydro/Gadget2/hydro_io.h b/src/hydro/Gadget2/hydro_io.h
index 9715558be3..20ad8e2d0c 100644
--- a/src/hydro/Gadget2/hydro_io.h
+++ b/src/hydro/Gadget2/hydro_io.h
@@ -177,11 +177,11 @@ INLINE static void hydro_write_particles(const struct part* parts,
 
   list[7] = io_make_output_field_convert_part(
       "InternalEnergies", FLOAT, 1, UNIT_CONV_ENERGY_PER_UNIT_MASS,
-      3. * hydro_gamma_minus_one, parts, xparts, convert_part_u,
+      -3.f * hydro_gamma_minus_one, parts, xparts, convert_part_u,
       "Co-moving thermal energies per unit mass of the particles");
 
   list[8] = io_make_output_field_convert_part(
-      "Pressures", FLOAT, 1, UNIT_CONV_PRESSURE, 3.f * hydro_gamma, parts,
+      "Pressures", FLOAT, 1, UNIT_CONV_PRESSURE, -3.f * hydro_gamma, parts,
       xparts, convert_part_P, "Co-moving pressures of the particles");
 
   list[9] = io_make_output_field_convert_part(
diff --git a/src/hydro/GizmoMFM/hydro_io.h b/src/hydro/GizmoMFM/hydro_io.h
index b1d51cff90..711eee9e31 100644
--- a/src/hydro/GizmoMFM/hydro_io.h
+++ b/src/hydro/GizmoMFM/hydro_io.h
@@ -220,15 +220,15 @@ INLINE static void hydro_write_particles(const struct part* parts,
                                  "Co-moving mass densities of the particles");
 
   list[7] = io_make_output_field_convert_part(
-      "Entropy", FLOAT, 1, UNIT_CONV_ENTROPY, 0.f, parts, xparts, convert_A,
+      "Entropies", FLOAT, 1, UNIT_CONV_ENTROPY, 0.f, parts, xparts, convert_A,
       "Co-moving entropies of the particles");
 
-  list[8] = io_make_output_field("Pressure", FLOAT, 1, UNIT_CONV_PRESSURE,
-                                 3.f * hydro_gamma, parts, P,
+  list[8] = io_make_output_field("Pressures", FLOAT, 1, UNIT_CONV_PRESSURE,
+                                 -3.f * hydro_gamma, parts, P,
                                  "Co-moving pressures of the particles");
 
   list[9] = io_make_output_field_convert_part(
-      "TotalEnergies", FLOAT, 1, UNIT_CONV_ENERGY, 3.f * hydro_gamma_minus_one,
+      "TotalEnergies", FLOAT, 1, UNIT_CONV_ENERGY, -3.f * hydro_gamma_minus_one,
       parts, xparts, convert_Etot, "Total (co-moving) energy of the particles");
 
   list[10] = io_make_output_field_convert_part(
diff --git a/src/hydro/GizmoMFV/hydro_io.h b/src/hydro/GizmoMFV/hydro_io.h
index 7288df0c51..11b8e95867 100644
--- a/src/hydro/GizmoMFV/hydro_io.h
+++ b/src/hydro/GizmoMFV/hydro_io.h
@@ -219,15 +219,15 @@ INLINE static void hydro_write_particles(const struct part* parts,
                                  "Co-moving mass densities of the particles");
 
   list[7] = io_make_output_field_convert_part(
-      "Entropy", FLOAT, 1, UNIT_CONV_ENTROPY, 0.f, parts, xparts, convert_A,
+      "Entropies", FLOAT, 1, UNIT_CONV_ENTROPY, 0.f, parts, xparts, convert_A,
       "Co-moving entropies of the particles");
 
-  list[8] = io_make_output_field("Pressure", FLOAT, 1, UNIT_CONV_PRESSURE,
-                                 3.f * hydro_gamma, parts, primitives.P,
+  list[8] = io_make_output_field("Pressures", FLOAT, 1, UNIT_CONV_PRESSURE,
+                                 -3.f * hydro_gamma, parts, primitives.P,
                                  "Co-moving pressures of the particles");
 
   list[9] = io_make_output_field_convert_part(
-      "TotalEnergies", FLOAT, 1, UNIT_CONV_ENERGY, 3.f * hydro_gamma_minus_one,
+      "TotalEnergies", FLOAT, 1, UNIT_CONV_ENERGY, -3.f * hydro_gamma_minus_one,
       parts, xparts, convert_Etot, "Total (co-moving) energy of the particles");
 
   list[10] = io_make_output_field_convert_part(
diff --git a/src/hydro/Minimal/hydro_io.h b/src/hydro/Minimal/hydro_io.h
index a32e2c1a87..ba62489bcc 100644
--- a/src/hydro/Minimal/hydro_io.h
+++ b/src/hydro/Minimal/hydro_io.h
@@ -179,7 +179,7 @@ INLINE static void hydro_write_particles(const struct part* parts,
 
   list[4] = io_make_output_field(
       "InternalEnergies", FLOAT, 1, UNIT_CONV_ENERGY_PER_UNIT_MASS,
-      3. * hydro_gamma_minus_one, parts, u,
+      -3.f * hydro_gamma_minus_one, parts, u,
       "Co-moving thermal energies per unit mass of the particles");
 
   list[5] =
@@ -195,7 +195,7 @@ INLINE static void hydro_write_particles(const struct part* parts,
       xparts, convert_S, "Co-moving entropies per unit mass of the particles");
 
   list[8] = io_make_output_field_convert_part(
-      "Pressures", FLOAT, 1, UNIT_CONV_PRESSURE, 3.f * hydro_gamma, parts,
+      "Pressures", FLOAT, 1, UNIT_CONV_PRESSURE, -3.f * hydro_gamma, parts,
       xparts, convert_P, "Co-moving pressures of the particles");
 }
 
diff --git a/src/hydro/Planetary/hydro_io.h b/src/hydro/Planetary/hydro_io.h
index 6dd84b3e1b..782e4de6dc 100644
--- a/src/hydro/Planetary/hydro_io.h
+++ b/src/hydro/Planetary/hydro_io.h
@@ -176,7 +176,7 @@ INLINE static void hydro_write_particles(const struct part* parts,
       "Smoothing lengths (FWHM of the kernel) of the particles");
   list[4] = io_make_output_field(
       "InternalEnergies", FLOAT, 1, UNIT_CONV_ENERGY_PER_UNIT_MASS,
-      3. * hydro_gamma_minus_one, parts, u,
+      -3.f * hydro_gamma_minus_one, parts, u,
       "Thermal energies per unit mass of the particles");
   list[5] =
       io_make_output_field("ParticleIDs", ULONGLONG, 1, UNIT_CONV_NO_UNITS, 0.f,
@@ -190,7 +190,7 @@ INLINE static void hydro_write_particles(const struct part* parts,
       io_make_output_field("MaterialIDs", INT, 1, UNIT_CONV_NO_UNITS, 0.f,
                            parts, mat_id, "Material IDs of the particles");
   list[9] = io_make_output_field_convert_part(
-      "Pressures", FLOAT, 1, UNIT_CONV_PRESSURE, 3.f * hydro_gamma, parts,
+      "Pressures", FLOAT, 1, UNIT_CONV_PRESSURE, -3.f * hydro_gamma, parts,
       xparts, convert_P, "Pressures of the particles");
   list[10] = io_make_output_field_convert_part(
       "Potentials", FLOAT, 1, UNIT_CONV_POTENTIAL, 0.f, parts, xparts,
diff --git a/src/hydro/PressureEnergy/hydro_io.h b/src/hydro/PressureEnergy/hydro_io.h
index 0582d39955..896d0137ca 100644
--- a/src/hydro/PressureEnergy/hydro_io.h
+++ b/src/hydro/PressureEnergy/hydro_io.h
@@ -175,7 +175,7 @@ INLINE static void hydro_write_particles(const struct part* parts,
 
   list[4] = io_make_output_field(
       "InternalEnergies", FLOAT, 1, UNIT_CONV_ENERGY_PER_UNIT_MASS,
-      3. * hydro_gamma_minus_one, parts, u,
+      -3.f * hydro_gamma_minus_one, parts, u,
       "Co-moving thermal energies per unit mass of the particles");
 
   list[5] =
@@ -187,7 +187,7 @@ INLINE static void hydro_write_particles(const struct part* parts,
                                  "Co-moving mass densities of the particles");
 
   list[7] = io_make_output_field(
-      "Pressures", FLOAT, 1, UNIT_CONV_PRESSURE, 3.f * hydro_gamma, parts,
+      "Pressures", FLOAT, 1, UNIT_CONV_PRESSURE, -3.f * hydro_gamma, parts,
       pressure_bar, "Co-moving smoothed pressures of the particles");
 
   list[8] = io_make_output_field_convert_part(
diff --git a/src/hydro/PressureEnergyMorrisMonaghanAV/hydro_io.h b/src/hydro/PressureEnergyMorrisMonaghanAV/hydro_io.h
index 3996197422..7da369847a 100644
--- a/src/hydro/PressureEnergyMorrisMonaghanAV/hydro_io.h
+++ b/src/hydro/PressureEnergyMorrisMonaghanAV/hydro_io.h
@@ -176,7 +176,7 @@ INLINE static void hydro_write_particles(const struct part* parts,
 
   list[4] = io_make_output_field(
       "InternalEnergies", FLOAT, 1, UNIT_CONV_ENERGY_PER_UNIT_MASS,
-      3. * hydro_gamma_minus_one, parts, u,
+      -3.f * hydro_gamma_minus_one, parts, u,
       "Co-moving thermal energies per unit mass of the particles");
 
   list[5] =
@@ -188,7 +188,7 @@ INLINE static void hydro_write_particles(const struct part* parts,
                                  "Co-moving mass densities of the particles");
 
   list[7] = io_make_output_field(
-      "Pressures", FLOAT, 1, UNIT_CONV_PRESSURE, 3.f * hydro_gamma, parts,
+      "Pressures", FLOAT, 1, UNIT_CONV_PRESSURE, -3.f * hydro_gamma, parts,
       pressure_bar, "Co-moving smoothed pressures of the particles");
 
   list[8] = io_make_output_field_convert_part(
diff --git a/src/hydro/PressureEntropy/hydro_io.h b/src/hydro/PressureEntropy/hydro_io.h
index d7591fbdea..8ac77f31ef 100644
--- a/src/hydro/PressureEntropy/hydro_io.h
+++ b/src/hydro/PressureEntropy/hydro_io.h
@@ -188,11 +188,11 @@ INLINE static void hydro_write_particles(const struct part* parts,
 
   list[7] = io_make_output_field_convert_part(
       "InternalEnergies", FLOAT, 1, UNIT_CONV_ENERGY_PER_UNIT_MASS,
-      3. * hydro_gamma_minus_one, parts, xparts, convert_u,
+      -3.f * hydro_gamma_minus_one, parts, xparts, convert_u,
       "Co-moving thermal energies per unit mass of the particles");
 
   list[8] = io_make_output_field_convert_part(
-      "Pressures", FLOAT, 1, UNIT_CONV_PRESSURE, 3.f * hydro_gamma, parts,
+      "Pressures", FLOAT, 1, UNIT_CONV_PRESSURE, -3.f * hydro_gamma, parts,
       xparts, convert_P, "Co-moving smoothed pressures of the particles");
 
   list[9] = io_make_output_field(
diff --git a/src/hydro/Shadowswift/hydro_io.h b/src/hydro/Shadowswift/hydro_io.h
index e6190e5a67..31840a05ee 100644
--- a/src/hydro/Shadowswift/hydro_io.h
+++ b/src/hydro/Shadowswift/hydro_io.h
@@ -156,7 +156,7 @@ INLINE static void hydro_write_particles(const struct part* parts,
 
   list[4] = io_make_output_field_convert_part(
       "InternalEnergies", FLOAT, 1, UNIT_CONV_ENERGY_PER_UNIT_MASS,
-      3. * hydro_gamma_minus_one, parts, xparts, convert_u,
+      -3.f * hydro_gamma_minus_one, parts, xparts, convert_u,
       "Co-moving thermal energies per unit mass of the particles");
 
   list[5] =
@@ -168,13 +168,13 @@ INLINE static void hydro_write_particles(const struct part* parts,
                                  "Accelerations of the particles(does not "
                                  "work in non-cosmological runs).");
 
-  list[7] = io_make_output_field("Densities", FLOAT, 1, UNIT_CONV_DENSITY,
-                                 3.f * hydro_gamma, parts, primitives.rho,
+  list[7] = io_make_output_field("Densities", FLOAT, 1, UNIT_CONV_DENSITY, -3.f,
+                                 parts, primitives.rho,
                                  "Co-moving mass densities of the particles");
 
-  list[8] = io_make_output_field("Volumes", FLOAT, 1, UNIT_CONV_VOLUME,
-                                 3.f * hydro_gamma, parts, cell.volume,
-                                 "Co-moving volumes of the particles");
+  list[8] =
+      io_make_output_field("Volumes", FLOAT, 1, UNIT_CONV_VOLUME, -3.f, parts,
+                           cell.volume, "Co-moving volumes of the particles");
 
   list[9] = io_make_output_field("GradDensities", FLOAT, 3, UNIT_CONV_DENSITY,
                                  1.f, parts, primitives.gradients.rho,
@@ -185,11 +185,11 @@ INLINE static void hydro_write_particles(const struct part* parts,
       "Co-moving entropies of the particles");
 
   list[11] = io_make_output_field("Pressures", FLOAT, 1, UNIT_CONV_PRESSURE,
-                                  3.f * hydro_gamma, parts, primitives.P,
+                                  -3.f * hydro_gamma, parts, primitives.P,
                                   "Co-moving pressures of the particles");
 
   list[12] = io_make_output_field_convert_part(
-      "TotalEnergies", FLOAT, 1, UNIT_CONV_ENERGY, 3.f * hydro_gamma_minus_one,
+      "TotalEnergies", FLOAT, 1, UNIT_CONV_ENERGY, -3.f * hydro_gamma_minus_one,
       parts, xparts, convert_Etot, "Total (co-moving) energy of the particles");
 }
 
-- 
GitLab