Commit d66e54fe authored by Yannick Bahé's avatar Yannick Bahé

Added output options for heating probabilities of BHs

parent b56cb576
......@@ -86,6 +86,8 @@ __attribute__((always_inline)) INLINE static void black_holes_first_init_bpart(
bp->swallowed_angular_momentum[0] = 0.f;
bp->swallowed_angular_momentum[1] = 0.f;
bp->swallowed_angular_momentum[2] = 0.f;
bp->cumulative_target_prob = 0.f;
bp->cumulative_actual_prob = 0.f;
black_holes_mark_bpart_as_not_swallowed(&bp->merger_data);
}
......@@ -563,12 +565,13 @@ __attribute__((always_inline)) INLINE static void black_holes_prepare_feedback(
/* Default probability of heating */
double target_prob = bp->energy_reservoir / (delta_u * bp->ngb_mass);
bp->cumulative_target_prob += target_prob;
/* Calculate the change in internal energy of the gas particles that get
* heated. Adjust the prbability if needed. */
double gas_delta_u;
double prob;
if (target_prob <= 1.) {
if (target_prob <= 0.3) {
/* Normal case */
prob = target_prob;
......@@ -576,19 +579,19 @@ __attribute__((always_inline)) INLINE static void black_holes_prepare_feedback(
} else {
/* Special case: we need to adjust the energy irrespective of the
* desired deltaT to ensure we inject all the available energy. */
prob = 1.;
gas_delta_u = bp->energy_reservoir / bp->ngb_mass;
/* Reservoir bug case... */
prob = 0.3;
gas_delta_u = delta_u;
}
/* Store all of this in the black hole for delivery onto the gas. */
bp->to_distribute.AGN_heating_probability = prob;
bp->to_distribute.AGN_delta_u = gas_delta_u;
bp->cumulative_actual_prob += prob;
bp->target_heating_prob = target_prob;
/* Decrement the energy in the reservoir by the mean expected energy */
const double energy_used = bp->energy_reservoir / max(prob, 1.);
const double energy_used = bp->energy_reservoir * (0.3 / target_prob);
bp->energy_reservoir -= energy_used;
} else {
......@@ -596,6 +599,7 @@ __attribute__((always_inline)) INLINE static void black_holes_prepare_feedback(
/* Flag that we don't want to heat anyone */
bp->to_distribute.AGN_heating_probability = 0.f;
bp->to_distribute.AGN_delta_u = 0.f;
bp->target_heating_prob = 0.f;
}
}
......@@ -748,13 +752,15 @@ INLINE static void black_holes_create_from_gas(
/* Initial seed mass */
bp->subgrid_mass = props->subgrid_seed_mass;
/* We haven't accreted anything yet */
/* We haven't accreted or heated anything yet */
bp->total_accreted_mass = 0.f;
bp->cumulative_number_seeds = 1;
bp->number_of_mergers = 0;
bp->number_of_gas_swallows = 0;
bp->number_of_direct_gas_swallows = 0;
bp->number_of_time_steps = 0;
bp->cumulative_target_prob = 0.f;
bp->cumulative_actual_prob = 0.f;
/* We haven't repositioned yet, nor attempted it */
bp->number_of_repositions = 0;
......
......@@ -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 = 27;
*num_fields = 30;
/* List what we want to write */
list[0] = io_make_output_field_convert_bpart(
......@@ -318,6 +318,29 @@ INLINE static void black_holes_write_particles(const struct bpart* bparts,
"rates have been suppressed by the Rosas-Guevara et al. (2015) "
"accretion disc model.");
list[27] = io_make_output_field(
"CumulativeHeatingProbabilities", FLOAT, 1, UNIT_CONV_NO_UNITS, 0.f,
bparts, cumulative_target_prob,
"Cumulative (ideal) probability of the black holes heating any one of "
"their gas neighbour particles. This can be combined with "
"NumberOfTimeSteps to find the average heating probability between two "
"outputs.");
list[28] = io_make_output_field(
"CumulativeActualHeatingProbabilities", FLOAT, 1, UNIT_CONV_NO_UNITS, 0.f,
bparts, cumulative_actual_prob,
"Cumulative (actual) probability of the black holes heating any one of "
"their gas neighbour particles, accounting for the maximum allowed "
"probability. This can be combined with NumberOfTimeSteps to find the "
"average heating probability between two outputs.");
list[29] = io_make_output_field(
"HeatingProbabilities", FLOAT, 1, UNIT_CONV_NO_UNITS, 0.f,
bparts, target_heating_prob,
"Instantaneous (ideal) probability of the black holes heating any one of "
"their gas neighbour particles. The actual probability might be lower if "
"this exceeds the maximum allowed probability.");
#ifdef DEBUG_INTERACTIONS_BLACK_HOLES
list += *num_fields;
......
......@@ -140,6 +140,15 @@ struct bpart {
/*! Total (physical) angular momentum accumulated by swallowing particles */
float swallowed_angular_momentum[3];
/*! Cumulative target probability of heating any one neighbour particle */
float cumulative_target_prob;
/*! Cumulative actual probability of heating any one neighbour particle */
float cumulative_actual_prob;
/*! Instantaneous target probability of heating any one neighbour particle */
float target_heating_prob;
/*! Union for the last high Eddington ratio point in time */
union {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment