From 45bfc03c0de0cafb253f53b9f7039d0bf07b3956 Mon Sep 17 00:00:00 2001
From: Josh Borrow <joshua.borrow@durham.ac.uk>
Date: Thu, 20 Sep 2018 09:33:35 +0100
Subject: [PATCH] Added minimal internal energy limit to kick_extra for PU
 scheme

---
 src/hydro/PressureEnergy/hydro.h | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/src/hydro/PressureEnergy/hydro.h b/src/hydro/PressureEnergy/hydro.h
index ebbd2a7d65..8490e3cfe8 100644
--- a/src/hydro/PressureEnergy/hydro.h
+++ b/src/hydro/PressureEnergy/hydro.h
@@ -593,6 +593,14 @@ __attribute__((always_inline)) INLINE static void hydro_kick_extra(
   }
   xp->u_full += p->u_dt * dt_therm;
 
+  /* Apply the minimal energy limit */
+  const float min_energy =
+      hydro_props->minimal_internal_energy / cosmo->a_factor_internal_energy;
+  if (xp->u_full < min_energy) {
+    xp->u_full = min_energy;
+    p->u_dt = 0.f;
+  }
+
   /* Compute the sound speed */
   const float soundspeed = hydro_get_comoving_soundspeed(p);
 
-- 
GitLab