diff --git a/src/black_holes/EAGLE/black_holes_iact.h b/src/black_holes/EAGLE/black_holes_iact.h index 1bc999b502c47adcdd0eadab83d0256bb3b21486..50fc94677ffdeb9a5109152d56c88aeeb4d1f21b 100644 --- a/src/black_holes/EAGLE/black_holes_iact.h +++ b/src/black_holes/EAGLE/black_holes_iact.h @@ -197,6 +197,20 @@ runner_iact_nonsym_bh_gas_density( ray_minimise_distance(r, bi->rays, arr_size, gas_id, pj->mass); break; } + case AGN_minimum_density_model: { + /* Compute the size of the array that we want to sort. If the current + * function is called for the first time (at this time-step for this BH), + * then bi->num_ngbs = 1 and there is nothing to sort. Note that the + * maximum size of the sorted array cannot be larger then the maximum + * number of rays. */ + const int arr_size = min(bi->num_ngbs, eagle_blackhole_number_of_rays); + + /* Minimise separation between the gas particles and the BH. The rays + * structs with smaller ids in the ray array will refer to the particles + * with smaller distances to the BH. */ + ray_minimise_distance(-pj->rho, bi->rays, arr_size, gas_id, pj->mass); + break; + } case AGN_random_ngb_model: { /* Compute the size of the array that we want to sort. If the current * function is called for the first time (at this time-step for this BH), diff --git a/src/black_holes/EAGLE/black_holes_properties.h b/src/black_holes/EAGLE/black_holes_properties.h index 0caa941a36c4a17bc781644d664695db5829c55f..6f20ec1884938dd49a7569fd41282f5b094fea4b 100644 --- a/src/black_holes/EAGLE/black_holes_properties.h +++ b/src/black_holes/EAGLE/black_holes_properties.h @@ -25,9 +25,10 @@ #include <string.h> enum AGN_feedback_models { - AGN_random_ngb_model, /*< Random neighbour model for AGN feedback */ - AGN_isotropic_model, /*< Isotropic model of AGN feedback */ - AGN_minimum_distance_model /*< Minimum-distance model of AGN feedback */ + AGN_random_ngb_model, /*< Random neighbour model for AGN feedback */ + AGN_isotropic_model, /*< Isotropic model of AGN feedback */ + AGN_minimum_distance_model, /*< Minimum-distance model of AGN feedback */ + AGN_minimum_density_model /*< Minimum-density model of AGN feedback */ }; /** @@ -370,10 +371,12 @@ INLINE static void black_holes_props_init(struct black_holes_props *bp, bp->feedback_model = AGN_isotropic_model; else if (strcmp(temp, "MinimumDistance") == 0) bp->feedback_model = AGN_minimum_distance_model; + else if (strcmp(temp, "MinimumDensity") == 0) + bp->feedback_model = AGN_minimum_density_model; else error( - "The AGN feedback model must be either 'Random', 'MinimumDistance' or " - "'Isotropic', not %s", + "The AGN feedback model must be either 'Random', 'MinimumDistance', " + "'MinimumDensity' or 'Isotropic', not %s", temp); bp->AGN_deterministic = diff --git a/src/feedback/EAGLE/feedback.c b/src/feedback/EAGLE/feedback.c index 953dd19459923152c86b1f8a31a1dc9e8bd276ac..7b6b881eb20492b8c13a60506b6fd1749b403aa4 100644 --- a/src/feedback/EAGLE/feedback.c +++ b/src/feedback/EAGLE/feedback.c @@ -1095,10 +1095,12 @@ void feedback_props_init(struct feedback_props* fp, fp->feedback_model = SNII_isotropic_model; else if (strcmp(model, "MinimumDistance") == 0) fp->feedback_model = SNII_minimum_distance_model; + else if (strcmp(model, "MinimumDensity") == 0) + fp->feedback_model = SNII_minimum_density_model; else error( - "The SNII feedback model must be either 'Random', 'MinimumDistance' or " - "'Isotropic', not %s", + "The SNII feedback model must be either 'Random', 'MinimumDistance', " + "'MinimumDensity' or 'Isotropic', not %s", model); /* Are we sampling the SNII lifetimes for feedback or using a fixed delay? */ diff --git a/src/feedback/EAGLE/feedback_iact.h b/src/feedback/EAGLE/feedback_iact.h index 6b599882b77c71caa0e3fe89067483fac12d1cf3..a7dde854088db446203537a71eac1dafcf9841ca 100644 --- a/src/feedback/EAGLE/feedback_iact.h +++ b/src/feedback/EAGLE/feedback_iact.h @@ -114,9 +114,9 @@ runner_iact_nonsym_feedback_density(const float r2, const float *dx, } case SNII_minimum_distance_model: { /* Compute the size of the array that we want to sort. If the current - * function is called for the first time (at this time-step for this star), - * then bi->num_ngbs = 1 and there is nothing to sort. Note that the - * maximum size of the sorted array cannot be larger then the maximum + * function is called for the first time (at this time-step for this + * star), then bi->num_ngbs = 1 and there is nothing to sort. Note that + * the maximum size of the sorted array cannot be larger then the maximum * number of rays. */ const int arr_size = min(si->feedback_data.to_collect.ngb_N, eagle_SNII_feedback_num_of_rays); @@ -128,11 +128,27 @@ runner_iact_nonsym_feedback_density(const float r2, const float *dx, pj->mass); break; } + case SNII_minimum_density_model: { + /* Compute the size of the array that we want to sort. If the current + * function is called for the first time (at this time-step for this + * star), then bi->num_ngbs = 1 and there is nothing to sort. Note that + * the maximum size of the sorted array cannot be larger then the maximum + * number of rays. */ + const int arr_size = min(si->feedback_data.to_collect.ngb_N, + eagle_SNII_feedback_num_of_rays); + + /* Minimise separation between the gas particles and the star. The rays + * structs with smaller ids in the ray array will refer to the particles + * with smaller distances to the star. */ + ray_minimise_distance(-rho, si->feedback_data.SNII_rays, arr_size, pj->id, + pj->mass); + break; + } case SNII_random_ngb_model: { /* Compute the size of the array that we want to sort. If the current - * function is called for the first time (at this time-step for this star), - * then bi->num_ngbs = 1 and there is nothing to sort. Note that the - * maximum size of the sorted array cannot be larger then the maximum + * function is called for the first time (at this time-step for this + * star), then bi->num_ngbs = 1 and there is nothing to sort. Note that + * the maximum size of the sorted array cannot be larger then the maximum * number of rays. */ const int arr_size = min(si->feedback_data.to_collect.ngb_N, eagle_SNII_feedback_num_of_rays); diff --git a/src/feedback/EAGLE/feedback_properties.h b/src/feedback/EAGLE/feedback_properties.h index 223fb0d1cf1f31e1d68eeed5d50ec5041360a7a3..db81b4fc4ebb858aacccac63792ea2e4b6e29391 100644 --- a/src/feedback/EAGLE/feedback_properties.h +++ b/src/feedback/EAGLE/feedback_properties.h @@ -23,9 +23,10 @@ #include "hydro_properties.h" enum SNII_feedback_models { - SNII_random_ngb_model, /*< Random neighbour model for SNII feedback */ - SNII_isotropic_model, /*< Isotropic model of SNII feedback */ - SNII_minimum_distance_model /*< Minimum-distance model of SNII feedback */ + SNII_random_ngb_model, /*< Random neighbour model for SNII feedback */ + SNII_isotropic_model, /*< Isotropic model of SNII feedback */ + SNII_minimum_distance_model, /*< Minimum-distance model of SNII feedback */ + SNII_minimum_density_model /*< Minimum-density model of SNII feedback */ }; /**