Commit 03c29d56 authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Add a field to the black holes to store the last time they reached above a...

Add a field to the black holes to store the last time they reached above a given Eddington ratio. Set that threshold to 0.1 in all the examples.
parent 0490be3e
......@@ -176,6 +176,7 @@ EAGLEFeedback:
EAGLEAGN:
subgrid_seed_mass_Msun: 1.5e5 # Black hole subgrid mass at creation time in solar masses.
max_eddington_fraction: 1.5 # Maximal allowed accretion rate in units of the Eddington rate.
eddington_fraction_for_recording: 0.1 # Record the last time BHs reached an Eddington ratio above this threshold.
viscous_alpha: 1e6 # Normalisation constant of the Bondi viscuous time-scale accretion reduction term
radiative_efficiency: 0.1 # Fraction of the accreted mass that gets radiated.
coupling_efficiency: 0.15 # Fraction of the radiated energy that couples to the gas in feedback events.
......
......@@ -177,6 +177,7 @@ EAGLEFeedback:
EAGLEAGN:
subgrid_seed_mass_Msun: 1.5e5 # Black hole subgrid mass at creation time in solar masses.
max_eddington_fraction: 1.5 # Maximal allowed accretion rate in units of the Eddington rate.
eddington_fraction_for_recording: 0.1 # Record the last time BHs reached an Eddington ratio above this threshold.
viscous_alpha: 1e6 # Normalisation constant of the Bondi viscuous time-scale accretion reduction term
radiative_efficiency: 0.1 # Fraction of the accreted mass that gets radiated.
coupling_efficiency: 0.15 # Fraction of the radiated energy that couples to the gas in feedback events.
......
......@@ -177,6 +177,7 @@ EAGLEFeedback:
EAGLEAGN:
subgrid_seed_mass_Msun: 1.5e5 # Black hole subgrid mass at creation time in solar masses.
max_eddington_fraction: 1.5 # Maximal allowed accretion rate in units of the Eddington rate.
eddington_fraction_for_recording: 0.1 # Record the last time BHs reached an Eddington ratio above this threshold.
viscous_alpha: 1e6 # Normalisation constant of the Bondi viscuous time-scale accretion reduction term
radiative_efficiency: 0.1 # Fraction of the accreted mass that gets radiated.
coupling_efficiency: 0.15 # Fraction of the radiated energy that couples to the gas in feedback events.
......
......@@ -171,6 +171,7 @@ EAGLEFeedback:
EAGLEAGN:
subgrid_seed_mass_Msun: 1.5e5 # Black hole subgrid mass at creation time in solar masses.
max_eddington_fraction: 1.5 # Maximal allowed accretion rate in units of the Eddington rate.
eddington_fraction_for_recording: 0.1 # Record the last time BHs reached an Eddington ratio above this threshold.
viscous_alpha: 1e6 # Normalisation constant of the Bondi viscuous time-scale accretion reduction term
radiative_efficiency: 0.1 # Fraction of the accreted mass that gets radiated.
coupling_efficiency: 0.15 # Fraction of the radiated energy that couples to the gas in feedback events.
......
......@@ -179,6 +179,7 @@ EAGLEFeedback:
EAGLEAGN:
subgrid_seed_mass_Msun: 1.5e5 # Black hole subgrid mass at creation time in solar masses.
max_eddington_fraction: 1.5 # Maximal allowed accretion rate in units of the Eddington rate.
eddington_fraction_for_recording: 0.1 # Record the last time BHs reached an Eddington ratio above this threshold.
viscous_alpha: 1e6 # Normalisation constant of the Bondi viscuous time-scale accretion reduction term
radiative_efficiency: 0.1 # Fraction of the accreted mass that gets radiated.
coupling_efficiency: 0.15 # Fraction of the radiated energy that couples to the gas in feedback events.
......
......@@ -170,6 +170,7 @@ EAGLEFeedback:
EAGLEAGN:
subgrid_seed_mass_Msun: 1.5e5 # Black hole subgrid mass at creation time in solar masses.
max_eddington_fraction: 1.5 # Maximal allowed accretion rate in units of the Eddington rate.
eddington_fraction_for_recording: 0.1 # Record the last time BHs reached an Eddington ratio above this threshold.
viscous_alpha: 1e6 # Normalisation constant of the Bondi viscuous time-scale accretion reduction term
radiative_efficiency: 0.1 # Fraction of the accreted mass that gets radiated.
coupling_efficiency: 0.15 # Fraction of the radiated energy that couples to the gas in feedback events.
......
......@@ -180,6 +180,7 @@ EAGLEFeedback:
EAGLEAGN:
subgrid_seed_mass_Msun: 1.5e5 # Black hole subgrid mass at creation time in solar masses.
max_eddington_fraction: 1.5 # Maximal allowed accretion rate in units of the Eddington rate.
eddington_fraction_for_recording: 0.1 # Record the last time BHs reached an Eddington ratio above this threshold.
viscous_alpha: 1e6 # Normalisation constant of the Bondi viscuous time-scale accretion reduction term
radiative_efficiency: 0.1 # Fraction of the accreted mass that gets radiated.
coupling_efficiency: 0.15 # Fraction of the radiated energy that couples to the gas in feedback events.
......
......@@ -428,6 +428,7 @@ EAGLEFeedback:
EAGLEAGN:
subgrid_seed_mass_Msun: 1.5e5 # Black hole subgrid mass at creation time in solar masses.
max_eddington_fraction: 1. # Maximal allowed accretion rate in units of the Eddington rate.
eddington_fraction_for_recording: 0.1 # Record the last time BHs reached an Eddington ratio above this threshold.
viscous_alpha: 1e6 # Normalisation constant of the Bondi viscuous time-scale accretion reduction term
radiative_efficiency: 0.1 # Fraction of the accreted mass that gets radiated.
coupling_efficiency: 0.15 # Fraction of the radiated energy that couples to the gas in feedback events.
......
......@@ -180,12 +180,14 @@ __attribute__((always_inline)) INLINE static void black_holes_swallow_bpart(
* @param props The properties of the black hole scheme.
* @param constants The physical constants (in internal units).
* @param cosmo The cosmological model.
* @param time Time since the start of the simulation (non-cosmo mode).
* @param with_cosmology Are we running with cosmology?
* @param dt The time-step size (in physical internal units).
*/
__attribute__((always_inline)) INLINE static void black_holes_prepare_feedback(
struct bpart* restrict bp, const struct black_holes_props* props,
const struct phys_const* constants, const struct cosmology* cosmo,
const double dt) {}
const double time, const int with_cosmology, const double dt) {}
/**
* @brief Finish the calculation of the new BH position.
......
......@@ -62,6 +62,9 @@ __attribute__((always_inline)) INLINE static void black_holes_first_init_bpart(
bp->formation_time = -1.f;
bp->cumulative_number_seeds = 1;
bp->number_of_mergers = 0;
bp->last_high_Eddington_fraction_scale_factor = -1.f;
black_holes_mark_bpart_as_not_swallowed(&bp->merger_data);
}
/**
......@@ -325,12 +328,14 @@ __attribute__((always_inline)) INLINE static void black_holes_swallow_bpart(
* @param props The properties of the black hole scheme.
* @param constants The physical constants (in internal units).
* @param cosmo The cosmological model.
* @param time Time since the start of the simulation (non-cosmo mode).
* @param with_cosmology Are we running with cosmology?
* @param dt The time-step size (in physical internal units).
*/
__attribute__((always_inline)) INLINE static void black_holes_prepare_feedback(
struct bpart* restrict bp, const struct black_holes_props* props,
const struct phys_const* constants, const struct cosmology* cosmo,
const double dt) {
const double time, const int with_cosmology, const double dt) {
if (dt == 0.) return;
......@@ -342,6 +347,7 @@ __attribute__((always_inline)) INLINE static void black_holes_prepare_feedback(
/* Gather the parameters of the model */
const double f_Edd = props->f_Edd;
const double f_Edd_recording = props->f_Edd_recording;
const double epsilon_r = props->epsilon_r;
const double epsilon_f = props->epsilon_f;
const double num_ngbs_to_heat = props->num_ngbs_to_heat;
......@@ -409,6 +415,15 @@ __attribute__((always_inline)) INLINE static void black_holes_prepare_feedback(
const double Eddington_rate =
4. * M_PI * G * BH_mass * proton_mass / (epsilon_r * c * sigma_Thomson);
/* Shall we record this high rate? */
if (Bondi_rate > f_Edd_recording * Eddington_rate) {
if (with_cosmology) {
bp->last_high_Eddington_fraction_scale_factor = cosmo->a;
} else {
bp->last_high_Eddington_fraction_time = time;
}
}
/* Limit the accretion rate to the Eddington fraction */
const double accr_rate = min(Bondi_rate, f_Edd * Eddington_rate);
bp->accretion_rate = accr_rate;
......@@ -555,6 +570,9 @@ INLINE static void black_holes_create_from_gas(
const struct chemistry_part_data* p_chem = &p->chemistry_data;
chemistry_bpart_from_part(bp_chem, p_chem, gas_mass);
/* Last time this BH had a high Eddington fraction */
bp->last_high_Eddington_fraction_scale_factor = -1.f;
/* First initialisation */
black_holes_init_bpart(bp);
......
......@@ -114,7 +114,7 @@ INLINE static void black_holes_write_particles(const struct bpart* bparts,
int with_cosmology) {
/* Say how much we want to write */
*num_fields = 14;
*num_fields = 15;
/* List what we want to write */
list[0] = io_make_output_field_convert_bpart(
......@@ -180,11 +180,26 @@ INLINE static void black_holes_write_particles(const struct bpart* bparts,
cumulative_number_seeds,
"Total number of BH seeds that have merged into this black hole");
list[13] = io_make_output_field("NumberOfMergers", INT, 1, UNIT_CONV_NO_UNITS,
0.f, bparts, number_of_mergers,
"Number of mergers black holes went through. "
"This does not include the number of mergers "
"accumulated by any merged black hole.");
list[13] =
io_make_output_field("NumberOfMergers", INT, 1, UNIT_CONV_NO_UNITS, 0.f,
bparts, number_of_mergers,
"Number of mergers the black holes went through. "
"This does not include the number of mergers "
"accumulated by any merged black hole.");
if (with_cosmology) {
list[14] = io_make_output_field(
"LastHighEddingtonFractionScaleFactors", FLOAT, 1, UNIT_CONV_NO_UNITS,
0.f, bparts, last_high_Eddington_fraction_scale_factor,
"Scale-factors at which the black holes last reached an Eddington "
"ratio > 0.1. -1 if never reached.");
} else {
list[14] = io_make_output_field(
"LastHighEddingtonFractionTimes", FLOAT, 1, UNIT_CONV_TIME, 0.f, bparts,
last_high_Eddington_fraction_time,
"Times at which the black holes last reached an Eddington ratio > 0.1. "
"-1 if never reached.");
}
#ifdef DEBUG_INTERACTIONS_BLACK_HOLES
......
......@@ -111,6 +111,16 @@ struct bpart {
/*! Total number of BH merger events (i.e. not including all progenies) */
int number_of_mergers;
/*! Union for the last high Eddington ratio point in time */
union {
/*! Last time the BH had a a high Eddington fraction */
float last_high_Eddington_fraction_time;
/*! Last scale factor the BH had a a high Eddington fraction */
float last_high_Eddington_fraction_scale_factor;
};
/*! Properties used in the feedback loop to distribute to gas neighbours. */
struct {
......
......@@ -66,6 +66,9 @@ struct black_holes_props {
/*! Normalisation of the viscuous angular momentum accretion reduction */
float alpha_visc;
/*! Eddington fraction threshold for recording */
float f_Edd_recording;
/* ---- Properties of the feedback model ------- */
/*! Temperature increase induced by AGN feedback (Kelvin) */
......@@ -148,6 +151,8 @@ INLINE static void black_holes_props_init(struct black_holes_props *bp,
/* Accretion parameters ---------------------------------- */
bp->f_Edd = parser_get_param_float(params, "EAGLEAGN:max_eddington_fraction");
bp->f_Edd_recording =
parser_get_param_float(params, "EAGLEAGN:eddington_fraction_for_recording");
bp->epsilon_r =
parser_get_param_float(params, "EAGLEAGN:radiative_efficiency");
bp->epsilon_f =
......
......@@ -838,7 +838,8 @@ void runner_do_black_holes_swallow_ghost(struct runner *r, struct cell *c,
/* Compute variables required for the feedback loop */
black_holes_prepare_feedback(bp, e->black_holes_properties,
e->physical_constants, e->cosmology, dt);
e->physical_constants, e->cosmology,
e->time, with_cosmology, dt);
}
}
}
......
Supports Markdown
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