From 45716e127d53cd992e560546542e6733d7a864b8 Mon Sep 17 00:00:00 2001 From: Stuart McAlpine <stuart.mcalpine@helsinki.fi> Date: Mon, 3 Aug 2020 17:16:50 +0100 Subject: [PATCH] Store BH birth density and metallicity --- src/black_holes/EAGLE/black_holes.h | 3 ++- src/black_holes/EAGLE/black_holes_io.h | 9 ++++++++- src/black_holes/EAGLE/black_holes_part.h | 3 +++ src/chemistry/EAGLE/chemistry.h | 3 +++ src/chemistry/EAGLE/chemistry_io.h | 14 +++++++++++++- src/chemistry/EAGLE/chemistry_struct.h | 6 ++++++ 6 files changed, 35 insertions(+), 3 deletions(-) diff --git a/src/black_holes/EAGLE/black_holes.h b/src/black_holes/EAGLE/black_holes.h index 5a0d6cbe84..c4112f9e81 100644 --- a/src/black_holes/EAGLE/black_holes.h +++ b/src/black_holes/EAGLE/black_holes.h @@ -821,8 +821,9 @@ INLINE static void black_holes_create_from_gas( * in the FOF code. We update them here. * (i.e. position, velocity, mass, time-step have been set) */ - /* Birth time */ + /* Birth time and density */ bp->formation_scale_factor = cosmo->a; + bp->formation_gas_density = hydro_get_physical_density(p, cosmo); /* Initial seed mass */ bp->subgrid_mass = props->subgrid_seed_mass; diff --git a/src/black_holes/EAGLE/black_holes_io.h b/src/black_holes/EAGLE/black_holes_io.h index cfdc06ca45..6b61a21e96 100644 --- a/src/black_holes/EAGLE/black_holes_io.h +++ b/src/black_holes/EAGLE/black_holes_io.h @@ -139,7 +139,7 @@ INLINE static void black_holes_write_particles(const struct bpart* bparts, int with_cosmology) { /* Say how much we want to write */ - *num_fields = 29; + *num_fields = 30; /* List what we want to write */ list[0] = io_make_output_field_convert_bpart( @@ -328,6 +328,13 @@ INLINE static void black_holes_write_particles(const struct bpart* bparts, sound_speed_subgrid_gas, "Physical subgrid sound-speeds used in the subgrid-Bondi model."); + list[29] = io_make_output_field( + "BirthGasDensities", FLOAT, 1, UNIT_CONV_DENSITY, 0.f, bparts, + formation_gas_density, + "Physical densities of the converted part at the time of birth. " + "We store the physical density at the birth redshift, no conversion is " + "needed."); + #ifdef DEBUG_INTERACTIONS_BLACK_HOLES list += *num_fields; diff --git a/src/black_holes/EAGLE/black_holes_part.h b/src/black_holes/EAGLE/black_holes_part.h index d91a3b9490..f057c05655 100644 --- a/src/black_holes/EAGLE/black_holes_part.h +++ b/src/black_holes/EAGLE/black_holes_part.h @@ -74,6 +74,9 @@ struct bpart { float formation_scale_factor; }; + /*! Physical density of the converted part (internal units) */ + float formation_gas_density; + /*! Subgrid mass of the black hole */ float subgrid_mass; diff --git a/src/chemistry/EAGLE/chemistry.h b/src/chemistry/EAGLE/chemistry.h index d2f475af90..1e3691eab5 100644 --- a/src/chemistry/EAGLE/chemistry.h +++ b/src/chemistry/EAGLE/chemistry.h @@ -348,6 +348,9 @@ __attribute__((always_inline)) INLINE static void chemistry_bpart_from_part( p_data->metal_mass_fraction_from_AGB * gas_mass; bp_data->iron_mass_from_SNIa = p_data->iron_mass_fraction_from_SNIa * gas_mass; + bp_data->formation_metallicity = p_data->metal_mass_fraction_total; + bp_data->smoothed_formation_metallicity = + p_data->smoothed_metal_mass_fraction_total; } /** diff --git a/src/chemistry/EAGLE/chemistry_io.h b/src/chemistry/EAGLE/chemistry_io.h index 2ec6bed3e1..a040fa630a 100644 --- a/src/chemistry/EAGLE/chemistry_io.h +++ b/src/chemistry/EAGLE/chemistry_io.h @@ -271,7 +271,19 @@ INLINE static int chemistry_write_bparticles(const struct bpart* bparts, "Masses of the BH particles in iron that have been " "produced by SNIa stars"); - return 9; + list[9] = + io_make_output_field("BirthMetallicities", FLOAT, 1, UNIT_CONV_NO_UNITS, + 0.f, bparts, chemistry_data.formation_metallicity, + "Metallicities (metal mass fractions) of the gas " + "particles the black holes formed from"); + + list[10] = io_make_output_field( + "SmoothedBirthMetallicities", FLOAT, 1, UNIT_CONV_NO_UNITS, 0.f, bparts, + chemistry_data.smoothed_formation_metallicity, + "Smoothed metallicities (metal mass fractions) of the gas particles the " + "black holes formed from"); + + return 11; } #ifdef HAVE_HDF5 diff --git a/src/chemistry/EAGLE/chemistry_struct.h b/src/chemistry/EAGLE/chemistry_struct.h index 32d5faaac0..9e99ea7bd8 100644 --- a/src/chemistry/EAGLE/chemistry_struct.h +++ b/src/chemistry/EAGLE/chemistry_struct.h @@ -120,6 +120,12 @@ struct chemistry_bpart_data { /*! Iron mass coming from SNIa */ float iron_mass_from_SNIa; + + /*! Metallicity of converted part. */ + float formation_metallicity; + + /*! Smoothed metallicity of converted part. */ + float smoothed_formation_metallicity; }; #endif /* SWIFT_CHEMISTRY_STRUCT_EAGLE_H */ -- GitLab