From 790d13bb7a86426567a781c6efb8fbb2be8aa7d8 Mon Sep 17 00:00:00 2001
From: Matthieu Schaller <schaller@strw.leidenuniv.nl>
Date: Sun, 23 Jun 2019 23:08:54 +0100
Subject: [PATCH] Avoid rounding error in the calculation of the ages for
 feedback in the EAGLE model.

---
 src/feedback/EAGLE/feedback.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/feedback/EAGLE/feedback.c b/src/feedback/EAGLE/feedback.c
index 531f887a74..cf6848760f 100644
--- a/src/feedback/EAGLE/feedback.c
+++ b/src/feedback/EAGLE/feedback.c
@@ -140,9 +140,13 @@ INLINE static void compute_SNII_feedback(
   /* Time after birth considered for SNII feedback (internal units) */
   const double SNII_wind_delay = feedback_props->SNII_wind_delay;
 
-  /* Are we doing feedback this step? */
-  if (star_age <= SNII_wind_delay && (star_age + dt) > SNII_wind_delay) {
+  /* Are we doing feedback this step?
+   * Note that since the ages are calculated using an interpolation table we
+   * must allow some tolerance here*/
+  if (star_age <= SNII_wind_delay &&
+      (star_age + 1.0001 * dt) > SNII_wind_delay) {
 
+    /* Make sure a star does not do feedback twice! */
     if (sp->f_E != -1.f) {
 #ifdef SWIFT_DEBUG_CHECKS
       message("Star has already done feedback! sp->id=%lld age=%e d=%e", sp->id,
-- 
GitLab