From 22082da27e5e5ae2a383bb75a13b54eebcc23fad Mon Sep 17 00:00:00 2001 From: Matthieu Schaller <schaller@strw.leidenuniv.nl> Date: Thu, 2 May 2019 14:19:06 +0200 Subject: [PATCH] Optionally read the energy reservoir values from the ICs. Can be useful for debugging tests. --- examples/EAGLE_low_z/EAGLE_6/eagle_6.yml | 3 ++- src/black_holes/EAGLE/black_holes.h | 4 ++-- src/black_holes/EAGLE/black_holes_io.h | 4 +++- src/black_holes/EAGLE/black_holes_properties.h | 2 ++ src/space.c | 3 ++- 5 files changed, 11 insertions(+), 5 deletions(-) diff --git a/examples/EAGLE_low_z/EAGLE_6/eagle_6.yml b/examples/EAGLE_low_z/EAGLE_6/eagle_6.yml index 7e61b46edb..8871aa619c 100644 --- a/examples/EAGLE_low_z/EAGLE_6/eagle_6.yml +++ b/examples/EAGLE_low_z/EAGLE_6/eagle_6.yml @@ -159,4 +159,5 @@ EAGLEAGN: 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. 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. \ No newline at end of file + AGN_num_ngb_to_heat: 1. # Target number of gas neighbours to heat in an AGN feedback event. + diff --git a/src/black_holes/EAGLE/black_holes.h b/src/black_holes/EAGLE/black_holes.h index cf9acbc610..4850f6ebf2 100644 --- a/src/black_holes/EAGLE/black_holes.h +++ b/src/black_holes/EAGLE/black_holes.h @@ -48,13 +48,13 @@ __attribute__((always_inline)) INLINE static float black_holes_compute_timestep( * read in to do some conversions. * * @param bp The particle to act upon + * @param props The properties of the black holes model. */ __attribute__((always_inline)) INLINE static void black_holes_first_init_bpart( - struct bpart* bp) { + struct bpart* bp, const struct black_holes_props* props) { bp->time_bin = 0; bp->subgrid_mass = bp->mass; - bp->energy_reservoir = 0.f; bp->accretion_rate = 0.f; bp->formation_time = -1.f; } diff --git a/src/black_holes/EAGLE/black_holes_io.h b/src/black_holes/EAGLE/black_holes_io.h index 92bd061f94..d91288e01d 100644 --- a/src/black_holes/EAGLE/black_holes_io.h +++ b/src/black_holes/EAGLE/black_holes_io.h @@ -34,7 +34,7 @@ INLINE static void black_holes_read_particles(struct bpart *bparts, int *num_fields) { /* Say how much we want to read */ - *num_fields = 5; + *num_fields = 6; /* List what we want to read */ list[0] = io_make_input_field("Coordinates", DOUBLE, 3, COMPULSORY, @@ -47,6 +47,8 @@ INLINE static void black_holes_read_particles(struct bpart *bparts, UNIT_CONV_NO_UNITS, bparts, id); list[4] = io_make_input_field("SmoothingLength", FLOAT, 1, OPTIONAL, UNIT_CONV_LENGTH, bparts, h); + list[5] = io_make_input_field("EnergyReservoir", FLOAT, 1, OPTIONAL, + UNIT_CONV_ENERGY, bparts, energy_reservoir); } /** diff --git a/src/black_holes/EAGLE/black_holes_properties.h b/src/black_holes/EAGLE/black_holes_properties.h index cf239e9def..c7b78d2e6b 100644 --- a/src/black_holes/EAGLE/black_holes_properties.h +++ b/src/black_holes/EAGLE/black_holes_properties.h @@ -47,6 +47,8 @@ struct black_holes_props { /*! Maximal change of h over one time-step */ float log_max_h_change; + /* ----- Initialisation properties ------ */ + /* ----- Properties of the accretion model ------ */ /*! Maximal fraction of the Eddington rate allowed. */ diff --git a/src/space.c b/src/space.c index 60ee47d5b9..e4703ddf84 100644 --- a/src/space.c +++ b/src/space.c @@ -4230,6 +4230,7 @@ void space_first_init_bparts_mapper(void *restrict map_data, int count, struct bpart *restrict bp = (struct bpart *)map_data; const struct space *restrict s = (struct space *)extra_data; const struct engine *e = s->e; + const struct black_holes_props *props = e->black_holes_properties; #ifdef SWIFT_DEBUG_CHECKS const ptrdiff_t delta = bp - s->bparts; @@ -4273,7 +4274,7 @@ void space_first_init_bparts_mapper(void *restrict map_data, int count, /* Initialise the rest */ for (int k = 0; k < count; k++) { - black_holes_first_init_bpart(&bp[k]); + black_holes_first_init_bpart(&bp[k], props); #ifdef SWIFT_DEBUG_CHECKS if (bp[k].gpart && bp[k].gpart->id_or_neg_offset != -(k + delta)) -- GitLab