From acca34de5728366853e9e1c882a96e9cba484363 Mon Sep 17 00:00:00 2001
From: Matthieu Schaller <schaller@strw.leidenuniv.nl>
Date: Mon, 9 Nov 2020 11:04:35 +0100
Subject: [PATCH] Also deduct the nibbled mass from the BH rays

---
 src/black_holes/EAGLE/black_holes.h      | 2 +-
 src/black_holes/EAGLE/black_holes_iact.h | 5 +++++
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/black_holes/EAGLE/black_holes.h b/src/black_holes/EAGLE/black_holes.h
index 318e828e39..c94f8bb0d8 100644
--- a/src/black_holes/EAGLE/black_holes.h
+++ b/src/black_holes/EAGLE/black_holes.h
@@ -420,7 +420,7 @@ __attribute__((always_inline)) INLINE static void black_holes_swallow_part(
   bp->ngb_mass -= gas_mass;
 
   /* The ray(s) should not point to the no-longer existing particle */
-  ray_reset_part_id(bp->rays, colibre_blackhole_number_of_rays, p->id);
+  ray_reset_part_id(bp->rays, eagle_blackhole_number_of_rays, p->id);
 }
 
 /**
diff --git a/src/black_holes/EAGLE/black_holes_iact.h b/src/black_holes/EAGLE/black_holes_iact.h
index 19a9097605..1cf60a80d0 100644
--- a/src/black_holes/EAGLE/black_holes_iact.h
+++ b/src/black_holes/EAGLE/black_holes_iact.h
@@ -371,6 +371,11 @@ runner_iact_nonsym_bh_gas_swallow(const float r2, const float *dx,
                     excess_fraction;
     }
 
+    /* Correct for nibbling the particle mass that is stored in rays */
+    for (int i = 0; i < eagle_blackhole_number_of_rays; i++) {
+      if (bi->rays[i].id_min_length == pj->id) bi->rays[i].mass = new_gas_mass;
+    }
+
     /* Transfer (dynamical) mass from the gas particle to the BH */
     bi->mass += nibble_mass;
     hydro_set_mass(pj, new_gas_mass);
-- 
GitLab