diff --git a/examples/EAGLE_low_z/EAGLE_6/eagle_6.yml b/examples/EAGLE_low_z/EAGLE_6/eagle_6.yml index f726ebaedab5434809197890240ccdc7b3d056ae..b468e3ad3c7a3cb3497f652debe44677d55d600c 100644 --- a/examples/EAGLE_low_z/EAGLE_6/eagle_6.yml +++ b/examples/EAGLE_low_z/EAGLE_6/eagle_6.yml @@ -64,14 +64,14 @@ SPH: # Parameters for the Friends-Of-Friends algorithm FOF: - basename: fof_output # Filename for the FOF outputs. - min_group_size: 256 # The minimum no. of particles required for a group. - linking_length_ratio: 0.2 # Linking length in units of the main inter-particle separation. - black_hole_seed_halo_mass: 1.5e10 # Minimal halo mass in which to seed a black hole (in solar masses). - absolute_linking_length: -1. # (Optional) Absolute linking length (in internal units) - run_freq: 100 # (Optional) The no. of steps between each FOF search. - group_id_default: 2147483647 # (Optional) Sets the group ID of particles in groups below the minimum size. Defaults to 2^31 - 1 if unspecified. Has to be positive. - group_id_offset: 1 # (Optional) Sets the offset of group ID labeling. Defaults to 1 if unspecified. + basename: fof_output # Filename for the FOF outputs. + min_group_size: 256 # The minimum no. of particles required for a group. + linking_length_ratio: 0.2 # Linking length in units of the main inter-particle separation. + black_hole_seed_halo_mass_Msun: 1.5e10 # Minimal halo mass in which to seed a black hole (in solar masses). + absolute_linking_length: -1. # (Optional) Absolute linking length (in internal units) + run_freq: 100 # (Optional) The no. of steps between each FOF search. + group_id_default: 2147483647 # (Optional) Sets the group ID of particles in groups below the minimum size. Defaults to 2^31 - 1 if unspecified. Has to be positive. + group_id_offset: 1 # (Optional) Sets the offset of group ID labeling. Defaults to 1 if unspecified. # Parameters related to the initial conditions InitialConditions: @@ -80,10 +80,6 @@ InitialConditions: cleanup_h_factors: 1 # Remove the h-factors inherited from Gadget cleanup_velocity_factors: 1 # Remove the sqrt(a) factor in the velocities inherited from Gadget -# EAGLE black hole seeding parameters -EAGLEBlackHoles: - seed_halo_mass: 1.5e10 # The minimum group mass required for black hole seeding - EAGLEChemistry: # Solar abundances init_abundance_metal: 0.014 init_abundance_Hydrogen: 0.70649785 @@ -133,8 +129,10 @@ EAGLEEntropyFloor: # EAGLE AGN model 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. 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 diff --git a/src/black_holes/Default/black_holes.h b/src/black_holes/Default/black_holes.h index 3c35d0862df99ff194fd609d6058c1be7065b0bf..fa40c3acb004df86297c62e21f7c8e607406f251 100644 --- a/src/black_holes/Default/black_holes.h +++ b/src/black_holes/Default/black_holes.h @@ -175,4 +175,11 @@ __attribute__((always_inline)) INLINE static void black_holes_reset_feedback( #endif } +INLINE static void black_holes_create_from_gas( + struct bpart* bp, const struct black_holes_props* props, + const struct phys_const* constants, const struct cosmology* cosmo, + const struct part* p) { + black_holes_init_bpart(bp); +} + #endif /* SWIFT_DEFAULT_BLACK_HOLES_H */ diff --git a/src/black_holes/EAGLE/black_holes.h b/src/black_holes/EAGLE/black_holes.h index 94962b7deea4900598a565dfd6ea90cfc6e17798..6377127d2675e41542538718761fcdb7bb24b05b 100644 --- a/src/black_holes/EAGLE/black_holes.h +++ b/src/black_holes/EAGLE/black_holes.h @@ -312,4 +312,22 @@ __attribute__((always_inline)) INLINE static void black_holes_reset_feedback( #endif } +INLINE static void black_holes_create_from_gas( + struct bpart* bp, const struct black_holes_props* props, + const struct phys_const* constants, const struct cosmology* cosmo, + const struct part* p) { + + /* All the non-basic properties of the black hole have been zeroed + in the FOF code. We just update the rest. */ + + /* Birth time */ + bp->formation_scale_factor = cosmo->a; + + /* Initial seed mass */ + bp->subgrid_mass = props->subgrid_seed_mass; + + /* First initialisation */ + black_holes_init_bpart(bp); +} + #endif /* SWIFT_EAGLE_BLACK_HOLES_H */ diff --git a/src/black_holes/EAGLE/black_holes_properties.h b/src/black_holes/EAGLE/black_holes_properties.h index 01e420509d6eaee7dd07e5af23fc845acbcd330d..6cb0b4ea7056c19b7c131a9d226675b5c888b5ce 100644 --- a/src/black_holes/EAGLE/black_holes_properties.h +++ b/src/black_holes/EAGLE/black_holes_properties.h @@ -49,6 +49,9 @@ struct black_holes_props { /* ----- Initialisation properties ------ */ + /*! Mass of a BH seed at creation time */ + float subgrid_seed_mass; + /* ----- Properties of the accretion model ------ */ /*! Maximal fraction of the Eddington rate allowed. */ @@ -126,6 +129,14 @@ INLINE static void black_holes_props_init(struct black_holes_props *bp, else bp->log_max_h_change = logf(powf(max_volume_change, hydro_dimension_inv)); + /* Initialisation properties ---------------------------- */ + + bp->subgrid_seed_mass = + parser_get_param_float(params, "EAGLEAGN:subgrid_seed_mass_Msun"); + + /* Convert to internal units */ + bp->subgrid_seed_mass *= phys_const->const_solar_mass; + /* Accretion parameters ---------------------------------- */ bp->f_Edd = parser_get_param_float(params, "EAGLEAGN:max_eddington_fraction"); diff --git a/src/engine.c b/src/engine.c index fd74cd50d3be620083db548b43527daf0d57677c..3d51a4a7510de4950b53247bf226ba4ba9018269 100644 --- a/src/engine.c +++ b/src/engine.c @@ -6312,7 +6312,8 @@ void engine_fof(struct engine *e) { /* Perform FOF search over foreign particles and * find groups which require black hole seeding. */ - fof_search_tree(e->fof_properties, e->s, /*dump_results=*/1, + fof_search_tree(e->fof_properties, e->black_holes_properties, + e->physical_constants, e->cosmology, e->s, /*dump_results=*/1, /*seed_black_holes=*/1); /* Reset flag. */ diff --git a/src/fof.c b/src/fof.c index b47da9f847f3e552a63d99e053a0c65ae116f0a4..dea3608df93ae9ae443935b50d66673a60b9ca9d 100644 --- a/src/fof.c +++ b/src/fof.c @@ -34,6 +34,7 @@ #include "fof.h" /* Local headers. */ +#include "black_holes.h" #include "c_hashmap/hashmap.h" #include "common_io.h" #include "engine.h" @@ -127,7 +128,7 @@ void fof_init(struct fof_props *props, struct swift_params *params, /* Read the minimal halo mass for black hole seeding */ props->seed_halo_mass = - parser_get_param_double(params, "FOF:black_hole_seed_halo_mass"); + parser_get_param_double(params, "FOF:black_hole_seed_halo_mass_Msun"); /* Convert to internal units */ props->seed_halo_mass *= phys_const->const_solar_mass; @@ -1757,7 +1758,10 @@ void fof_find_foreign_links_mapper(void *map_data, int num_elements, #endif } -void fof_seed_black_holes(const struct fof_props *props, struct space *s, +void fof_seed_black_holes(const struct fof_props *props, + const struct black_holes_props *bh_props, + const struct phys_const *constants, + const struct cosmology *cosmo, struct space *s, int num_groups, struct group_length *group_sizes) { const long long *max_part_density_index = props->max_part_density_index; @@ -1822,6 +1826,7 @@ void fof_seed_black_holes(const struct fof_props *props, struct space *s, /* Basic properties of the black hole */ struct bpart *bp = &s->bparts[k]; + bzero(bp, sizeof(struct bpart)); bp->time_bin = gp->time_bin; /* Re-link things */ @@ -1845,6 +1850,9 @@ void fof_seed_black_holes(const struct fof_props *props, struct space *s, bp->ti_drift = p->ti_drift; #endif + /* Copy over all the gas properties that we want */ + black_holes_create_from_gas(bp, bh_props, constants, cosmo, p); + /* Move to the next BH slot */ k++; } @@ -2356,7 +2364,10 @@ void fof_search_foreign_cells(struct fof_props *props, const struct space *s) { * @param dump_results Do we want to write the group catalogue to a file? * @param seed_black_holes Do we want to seed black holes in haloes? */ -void fof_search_tree(struct fof_props *props, struct space *s, +void fof_search_tree(struct fof_props *props, + const struct black_holes_props *bh_props, + const struct phys_const *constants, + const struct cosmology *cosmo, struct space *s, const int dump_results, const int seed_black_holes) { const size_t nr_gparts = s->nr_gparts; @@ -2678,8 +2689,10 @@ void fof_search_tree(struct fof_props *props, struct space *s, high_group_sizes); } + /* Seed black holes */ if (seed_black_holes) { - fof_seed_black_holes(props, s, num_groups_local, high_group_sizes); + fof_seed_black_holes(props, bh_props, constants, cosmo, s, num_groups_local, + high_group_sizes); } /* Free the left-overs */ diff --git a/src/fof.h b/src/fof.h index c30782afa276ba8c0e9568088787d706d35e9356..93d3a0beb2ecf22adcd808fe4879a86806301e5a 100644 --- a/src/fof.h +++ b/src/fof.h @@ -32,6 +32,8 @@ struct space; struct engine; struct unit_system; struct phys_const; +struct black_holes_props; +struct cosmology; /* MPI message required for FOF. */ struct fof_mpi { @@ -165,7 +167,10 @@ void fof_init(struct fof_props *props, struct swift_params *params, void fof_create_mpi_types(void); void fof_allocate(const struct space *s, const long long total_nr_DM_particles, struct fof_props *props); -void fof_search_tree(struct fof_props *props, struct space *s, +void fof_search_tree(struct fof_props *props, + const struct black_holes_props *bh_props, + const struct phys_const *constants, + const struct cosmology *cosmo, struct space *s, const int dump_results, const int seed_black_holes); void rec_fof_search_self(const struct fof_props *props, const double dim[3], const double search_r2, const int periodic,