From 1ec0b471c8b45574d8ddde2f864560f8b8635e51 Mon Sep 17 00:00:00 2001 From: Matthieu Schaller <schaller@strw.leidenuniv.nl> Date: Fri, 16 Oct 2020 23:17:22 +0200 Subject: [PATCH] Implement a minimum-density feedback on top of the isotropic ray mechanism --- src/black_holes/EAGLE/black_holes_iact.h | 14 ++++++++++ .../EAGLE/black_holes_properties.h | 13 +++++---- src/feedback/EAGLE/feedback.c | 6 ++-- src/feedback/EAGLE/feedback_iact.h | 28 +++++++++++++++---- src/feedback/EAGLE/feedback_properties.h | 7 +++-- 5 files changed, 52 insertions(+), 16 deletions(-) diff --git a/src/black_holes/EAGLE/black_holes_iact.h b/src/black_holes/EAGLE/black_holes_iact.h index 1bc999b502..50fc94677f 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 0caa941a36..6f20ec1884 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 953dd19459..7b6b881eb2 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 6b599882b7..a7dde85408 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 223fb0d1cf..db81b4fc4e 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 */ }; /** -- GitLab