From bc822c3fb19c06d785ef5ed646cac468f1579b41 Mon Sep 17 00:00:00 2001
From: loikki <loic.hausammann@protonmail.ch>
Date: Tue, 13 Aug 2019 08:57:50 +0200
Subject: [PATCH] GEAR: implement correctly cosmology

---
 src/pressure_floor/GEAR/pressure_floor_iact.h | 6 ++++--
 src/star_formation/GEAR/star_formation.h      | 2 +-
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/pressure_floor/GEAR/pressure_floor_iact.h b/src/pressure_floor/GEAR/pressure_floor_iact.h
index ff4dfc3b3a..1ecf8c29ea 100644
--- a/src/pressure_floor/GEAR/pressure_floor_iact.h
+++ b/src/pressure_floor/GEAR/pressure_floor_iact.h
@@ -53,11 +53,13 @@ __attribute__((always_inline)) INLINE static void runner_iact_pressure_floor(
   /* Delta v */
   float dv[3] = {pi->v[0] - pj->v[0], pi->v[1] - pj->v[1], pi->v[2] - pj->v[2]};
 
-  /* Norms at power 2 */
+  /* Norms */
   const float norm_v2 = dv[0] * dv[0] + dv[1] * dv[1] + dv[2] * dv[2];
+  const float norm_v = sqrtf(norm_v2);
+  const float r = sqrtf(r2);
 
   /* Compute the velocity dispersion */
-  const float sigma2 = norm_v2 + H * r2;
+  const float sigma2 = norm_v2 + H * H * r2 + 2 * H * r * norm_v;
 
   /* Compute the velocity dispersion */
   pi->pressure_floor_data.sigma2 += sigma2 * wi * hydro_get_mass(pj);
diff --git a/src/star_formation/GEAR/star_formation.h b/src/star_formation/GEAR/star_formation.h
index 499594b937..5fc3380fe6 100644
--- a/src/star_formation/GEAR/star_formation.h
+++ b/src/star_formation/GEAR/star_formation.h
@@ -70,7 +70,7 @@ INLINE static int star_formation_is_star_forming(
   }
 
   /* Get the required variables */
-  const float sigma2 = p->pressure_floor_data.sigma2;
+  const float sigma2 = p->pressure_floor_data.sigma2 * cosmo->a * cosmo->a;
   const float n_jeans_2_3 = starform->n_jeans_2_3;
 
   const float h = p->h;
-- 
GitLab