diff --git a/src/black_holes/EAGLE/black_holes.h b/src/black_holes/EAGLE/black_holes.h index 5a0d6cbe8418fc2e446b2460e6728ded26841343..c4112f9e81f33ca0256ce8ee24077069df50ca1a 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 cfdc06ca45c722fbe55427d6f5f3abfdbcd88363..6b61a21e9607e26443168159451528f50d32561c 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 d91a3b9490d717d82978ac22eec173aa4e56ab53..f057c05655dc3874d968bc9a5d00510833a68f5a 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 d2f475af9053d148345350cc02004cf501b99165..1e3691eab5c25acb490049be807da8f998d040b4 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 2ec6bed3e1f050881258d498cb90d37ff10f3e05..a040fa630af02c8f468e488c886dfd758ddc783c 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 32d5faaac08886684ebe78ea3696f7aaacab48ea..9e99ea7bd8e34bf103deba3b31cb7b841f869ec3 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 */