diff --git a/src/black_holes/EAGLE/black_holes.h b/src/black_holes/EAGLE/black_holes.h index ac12102803a9d30eaa1b5e906d51f1014ea92986..70c8bce403eaea3c6ba9bfa56e5abb892af9718f 100644 --- a/src/black_holes/EAGLE/black_holes.h +++ b/src/black_holes/EAGLE/black_holes.h @@ -59,6 +59,8 @@ __attribute__((always_inline)) INLINE static void black_holes_first_init_bpart( bp->total_accreted_mass = 0.f; bp->accretion_rate = 0.f; bp->formation_time = -1.f; + bp->cumulative_number_seeds = 1; + bp->number_of_mergers = 0; } /** @@ -244,6 +246,36 @@ __attribute__((always_inline)) INLINE static void black_holes_swallow_part( */ __attribute__((always_inline)) INLINE static void black_holes_swallow_bpart( struct bpart* bpi, const struct bpart* bpj, const struct cosmology* cosmo) { + + /* Get the current dynamical masses */ + const float bpi_dyn_mass = bpi->mass; + const float bpj_dyn_mass = bpj->mass; + + /* Increase the masses of the BH. */ + bpi->mass += bpj->mass; + bpi->gpart->mass += bpj->mass; + bpi->subgrid_mass += bpj->subgrid_mass; + + /* Update the BH momentum */ + const float BH_mom[3] = {bpi_dyn_mass * bpi->v[0] + bpj_dyn_mass * bpj->v[0], + bpi_dyn_mass * bpi->v[1] + bpj_dyn_mass * bpj->v[1], + bpi_dyn_mass * bpi->v[2] + bpj_dyn_mass * bpj->v[2]}; + + bpi->v[0] = BH_mom[0] / bpi->mass; + bpi->v[1] = BH_mom[1] / bpi->mass; + bpi->v[2] = BH_mom[2] / bpi->mass; + bpi->gpart->v_full[0] = bpi->v[0]; + bpi->gpart->v_full[1] = bpi->v[1]; + bpi->gpart->v_full[2] = bpi->v[2]; + + /* Update the energy reservoir */ + bpi->energy_reservoir += bpj->energy_reservoir; + + /* Add up all the BH seeds */ + bpi->cumulative_number_seeds += bpj->cumulative_number_seeds; + + /* We had another merger */ + bpi->number_of_mergers++; } /** @@ -446,6 +478,8 @@ INLINE static void black_holes_create_from_gas( /* We haven't accreted anything yet */ bp->total_accreted_mass = 0.f; + bp->cumulative_number_seeds = 1; + bp->number_of_mergers = 0; /* Initial metal masses */ const float gas_mass = hydro_get_mass(p); diff --git a/src/black_holes/EAGLE/black_holes_io.h b/src/black_holes/EAGLE/black_holes_io.h index f5a8da344ffe0d37564710b9ce9bc3e0d8f3d705..c02cb59fcce73feefc749ed1d0ba5fa60145419f 100644 --- a/src/black_holes/EAGLE/black_holes_io.h +++ b/src/black_holes/EAGLE/black_holes_io.h @@ -77,7 +77,7 @@ INLINE static void black_holes_write_particles(const struct bpart *bparts, int *num_fields) { /* Say how much we want to write */ - *num_fields = 12; + *num_fields = 13; /* List what we want to write */ list[0] = io_make_output_field_convert_bpart( @@ -106,6 +106,9 @@ INLINE static void black_holes_write_particles(const struct bpart *bparts, list[11] = io_make_output_field("TotalAccretedMass", FLOAT, 1, UNIT_CONV_MASS_PER_UNIT_TIME, bparts, total_accreted_mass); + list[12] = + io_make_output_field("CumulativeNumberSeeds", INT, 1, UNIT_CONV_NO_UNITS, + bparts, cumulative_number_seeds); #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 3c10fb8963d65244f6d9ba2ba9d543eb7f635241..c75f2feef27ed065706e80aad97d0d912e1a165e 100644 --- a/src/black_holes/EAGLE/black_holes_part.h +++ b/src/black_holes/EAGLE/black_holes_part.h @@ -103,6 +103,12 @@ struct bpart { /*! Integer number of neighbours */ int num_ngbs; + /*! Number of seeds in this BH (i.e. itself + the merged ones) */ + int cumulative_number_seeds; + + /*! Total number of BH merger events (i.e. not including all progenies) */ + int number_of_mergers; + /*! Properties used in the feedback loop to distribute to gas neighbours. */ struct {