From c0c0a209816ca8b20640848a1acdc1efb98b2693 Mon Sep 17 00:00:00 2001
From: Filip Husko <filip.husko@durham.ac.uk>
Date: Sat, 5 Oct 2024 12:01:47 +0000
Subject: [PATCH] Add manual time-step calculation for cone

---
 src/timestep.h | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/src/timestep.h b/src/timestep.h
index 5e5af80746..44d921c35f 100644
--- a/src/timestep.h
+++ b/src/timestep.h
@@ -201,6 +201,24 @@ __attribute__((always_inline)) INLINE static integertime_t get_part_timestep(
   /* Apply cosmology correction (This is 1 if non-cosmological) */
   new_dt *= e->cosmology->time_step_factor;
 
+  const double time = e->time;
+  const float mass = p->mass;
+
+  const double number_of_kicks = (e->hydro_properties->jet_power * e->hydro_properties->jet_duration)/(0.5 * mass * e->hydro_properties->v_jet * e->hydro_properties->v_jet);
+  const float time_of_launching = (double)p->id / number_of_kicks * e->hydro_properties->jet_duration;
+
+  if (p->hit_by_jet_feedback<=0 && p->id<0.98*e->hydro_properties->max_id) {
+    float delta_t = (time_of_launching - time)/8;
+    const float min_timestep_jet = 2.*e->hydro_properties->jet_duration / number_of_kicks;
+
+    if (time>2e-4) {
+      delta_t = max(min_timestep_jet, delta_t);
+    } else {
+      delta_t = min_timestep_jet;
+    }
+    new_dt = delta_t;
+  }
+
   /* Limit timestep within the allowed range */
   new_dt = min(new_dt, e->dt_max);
 
-- 
GitLab