From 5ce16cce1488a269d6667ff97436d541dfc10fa5 Mon Sep 17 00:00:00 2001
From: Matthieu Schaller <schaller@strw.leidenuniv.nl>
Date: Thu, 2 May 2019 11:01:09 +0200
Subject: [PATCH] Added BH formation time to the BH particles. Added many BH
 properties to the i/o.

---
 src/black_holes/EAGLE/black_holes.h      |  1 +
 src/black_holes/EAGLE/black_holes_io.h   | 12 +++++++++++-
 src/black_holes/EAGLE/black_holes_part.h | 10 ++++++++++
 3 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/src/black_holes/EAGLE/black_holes.h b/src/black_holes/EAGLE/black_holes.h
index aaeed57834..e9c873f69b 100644
--- a/src/black_holes/EAGLE/black_holes.h
+++ b/src/black_holes/EAGLE/black_holes.h
@@ -55,6 +55,7 @@ __attribute__((always_inline)) INLINE static void black_holes_first_init_bpart(
   bp->time_bin = 0;
   bp->subgrid_mass = bp->mass;
   bp->energy_reservoir = 0.;
+  bp->formation_time = -1.;
 }
 
 /**
diff --git a/src/black_holes/EAGLE/black_holes_io.h b/src/black_holes/EAGLE/black_holes_io.h
index ffd4a38a61..f794d7a298 100644
--- a/src/black_holes/EAGLE/black_holes_io.h
+++ b/src/black_holes/EAGLE/black_holes_io.h
@@ -61,7 +61,7 @@ INLINE static void black_holes_write_particles(const struct bpart *bparts,
                                                int *num_fields) {
 
   /* Say how much we want to write */
-  *num_fields = 5;
+  *num_fields = 10;
 
   /* List what we want to write */
   list[0] = io_make_output_field("Coordinates", DOUBLE, 3, UNIT_CONV_LENGTH,
@@ -74,6 +74,16 @@ INLINE static void black_holes_write_particles(const struct bpart *bparts,
                                  bparts, id);
   list[4] = io_make_output_field("SmoothingLength", FLOAT, 1, UNIT_CONV_LENGTH,
                                  bparts, h);
+  list[5] = io_make_output_field("SubgridMasses", FLOAT, 1, UNIT_CONV_MASS,
+                                 bparts, subgrid_mass);
+  list[6] = io_make_output_field("FormationTime", FLOAT, 1, UNIT_CONV_TIME,
+                                 bparts, formation_time);
+  list[7] = io_make_output_field("GasDensity", FLOAT, 1, UNIT_CONV_DENSITY,
+                                 bparts, rho_gas);
+  list[8] = io_make_output_field("GasSoundSpeed", FLOAT, 1, UNIT_CONV_SPEED,
+                                 bparts, sound_speed_gas);
+  list[9] = io_make_output_field("EnergyReservoir", FLOAT, 1, UNIT_CONV_ENERGY,
+                                 bparts, energy_reservoir);
 
 #ifdef DEBUG_INTERACTIONS_BLACK_HOLES
 
diff --git a/src/black_holes/EAGLE/black_holes_part.h b/src/black_holes/EAGLE/black_holes_part.h
index 0aa311ff80..bbb19936b6 100644
--- a/src/black_holes/EAGLE/black_holes_part.h
+++ b/src/black_holes/EAGLE/black_holes_part.h
@@ -63,6 +63,16 @@ struct bpart {
   /*! Subgrid mass of the black hole */
   float subgrid_mass;
 
+  /*! Union for the formation time and formation scale factor */
+  union {
+
+    /*! Formation time */
+    float formation_time;
+
+    /*! Formation scale factor */
+    float formation_scale_factor;
+  };
+
   /*! Energy reservoir for feedback */
   float energy_reservoir;
 
-- 
GitLab