Skip to content
Snippets Groups Projects
Commit de0c518c authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Read the maximal BH mass to reposition from the parameter file.

parent 3682311f
No related branches found
No related tags found
1 merge request!876Black holes repositioning
...@@ -171,3 +171,4 @@ EAGLEAGN: ...@@ -171,3 +171,4 @@ EAGLEAGN:
coupling_efficiency: 0.15 # Fraction of the radiated energy that couples to the gas in feedback events. coupling_efficiency: 0.15 # Fraction of the radiated energy that couples to the gas in feedback events.
AGN_delta_T_K: 3.16228e8 # Change in temperature to apply to the gas particle in an AGN feedback event in Kelvin. AGN_delta_T_K: 3.16228e8 # Change in temperature to apply to the gas particle in an AGN feedback event in Kelvin.
AGN_num_ngb_to_heat: 1. # Target number of gas neighbours to heat in an AGN feedback event. AGN_num_ngb_to_heat: 1. # Target number of gas neighbours to heat in an AGN feedback event.
max_reposition_mass: 2e8 # Maximal BH mass considered for BH repositioning in solar masses.
\ No newline at end of file
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include "black_holes_struct.h" #include "black_holes_struct.h"
#include "cosmology.h" #include "cosmology.h"
#include "dimension.h" #include "dimension.h"
#include "gravity.h"
#include "kernel_hydro.h" #include "kernel_hydro.h"
#include "minmax.h" #include "minmax.h"
#include "physical_constants.h" #include "physical_constants.h"
...@@ -457,6 +458,24 @@ __attribute__((always_inline)) INLINE static void black_holes_prepare_feedback( ...@@ -457,6 +458,24 @@ __attribute__((always_inline)) INLINE static void black_holes_prepare_feedback(
} }
} }
__attribute__((always_inline)) INLINE static void
black_holes_end_reposition(struct bpart* restrict bp,
const struct black_holes_props* props,
const struct phys_const* constants,
const struct cosmology* cosmo) {
const float potential = gravity_get_comoving_potential(bp->gpart);
/* Is the potential lower (i.e. the BH is at the bottom already)
* OR is the BH massive enough that we don't reposition? */
if (potential < bp->reposition.min_potential ||
bp->subgrid_mass > props->max_reposition_mass) {
/* No need to reposition */
bp->reposition.min_potential = FLT_MAX;
}
}
/** /**
* @brief Reset acceleration fields of a particle * @brief Reset acceleration fields of a particle
* *
......
...@@ -74,6 +74,11 @@ struct black_holes_props { ...@@ -74,6 +74,11 @@ struct black_holes_props {
/*! Number of gas neighbours to heat in a feedback event */ /*! Number of gas neighbours to heat in a feedback event */
float num_ngbs_to_heat; float num_ngbs_to_heat;
/* ---- Properties of the repositioning model --- */
/*! Maximal mass of BH to reposition */
float max_reposition_mass;
/* ---- Common conversion factors --------------- */ /* ---- Common conversion factors --------------- */
/*! Conversion factor from temperature to internal energy */ /*! Conversion factor from temperature to internal energy */
...@@ -157,6 +162,14 @@ INLINE static void black_holes_props_init(struct black_holes_props *bp, ...@@ -157,6 +162,14 @@ INLINE static void black_holes_props_init(struct black_holes_props *bp,
bp->num_ngbs_to_heat = bp->num_ngbs_to_heat =
parser_get_param_float(params, "EAGLEAGN:AGN_num_ngb_to_heat"); parser_get_param_float(params, "EAGLEAGN:AGN_num_ngb_to_heat");
/* Reposition parameters --------------------------------- */
bp->max_reposition_mass =
parser_get_param_float(params, "EAGLEAGN:max_reposition_mass");
/* Convert to internal units */
bp->max_reposition_mass *= phys_const->const_solar_mass;
/* Common conversion factors ----------------------------- */ /* Common conversion factors ----------------------------- */
/* Calculate temperature to internal energy conversion factor (all internal /* Calculate temperature to internal energy conversion factor (all internal
......
...@@ -905,6 +905,10 @@ void runner_do_black_holes_swallow_ghost(struct runner *r, struct cell *c, ...@@ -905,6 +905,10 @@ void runner_do_black_holes_swallow_ghost(struct runner *r, struct cell *c,
if (bpart_is_active(bp, e)) { if (bpart_is_active(bp, e)) {
/* Compute the final operations for repositioning of this BH */
black_holes_end_reposition(bp, e->black_holes_properties,
e->physical_constants, e->cosmology);
/* Get particle time-step */ /* Get particle time-step */
double dt; double dt;
if (with_cosmology) { if (with_cosmology) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment