From 9e2868ceb7484d73594929522a54a6b69a34c118 Mon Sep 17 00:00:00 2001
From: Matthieu Schaller <matthieu.schaller@durham.ac.uk>
Date: Sat, 13 Feb 2016 14:14:21 +0000
Subject: [PATCH] Entropy_dt should not be part of the force sub-structure

---
 src/hydro/Gadget2/hydro.h       | 14 +++++++-------
 src/hydro/Gadget2/hydro_debug.h |  2 +-
 src/hydro/Gadget2/hydro_iact.h  |  6 +++---
 src/hydro/Gadget2/hydro_part.h  |  8 ++++----
 4 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/src/hydro/Gadget2/hydro.h b/src/hydro/Gadget2/hydro.h
index d8380fe5a3..0c359cce21 100644
--- a/src/hydro/Gadget2/hydro.h
+++ b/src/hydro/Gadget2/hydro.h
@@ -125,7 +125,7 @@ INLINE static void hydro_prepare_force(struct part* p, struct xpart* xp, float t
   /* Compute the pressure */
   const float dt = time - 0.5f * (p->t_begin + p->t_end);
   p->force.pressure =
-      (p->entropy + p->force.entropy_dt * dt) * powf(p->rho, const_hydro_gamma);
+      (p->entropy + p->entropy_dt * dt) * powf(p->rho, const_hydro_gamma);
 }
 
 /**
@@ -147,7 +147,7 @@ __attribute__((always_inline))
   p->force.h_dt = 0.0f;
 
   /* Reset the time derivatives. */
-  p->force.entropy_dt = 0.0f;
+  p->entropy_dt = 0.0f;
 
   /* Reset maximal signal velocity */
   p->force.v_sig = 0.0f;
@@ -169,7 +169,7 @@ __attribute__((always_inline)) INLINE static void hydro_predict_extra(
 
   const float dt_entr = t1 - 0.5f * (p->t_begin + p->t_end);
   p->force.pressure =
-      (p->entropy + p->force.entropy_dt * dt_entr) * powf(p->rho, const_hydro_gamma);
+      (p->entropy + p->entropy_dt * dt_entr) * powf(p->rho, const_hydro_gamma);
 }
 
 /**
@@ -182,7 +182,7 @@ __attribute__((always_inline)) INLINE static void hydro_predict_extra(
 __attribute__((always_inline))
     INLINE static void hydro_end_force(struct part* p) {
 
-  p->force.entropy_dt *=
+  p->entropy_dt *=
       (const_hydro_gamma - 1.f) * powf(p->rho, -(const_hydro_gamma - 1.f));
 }
 
@@ -195,15 +195,15 @@ __attribute__((always_inline))
     INLINE static void hydro_kick_extra(struct part* p, float dt) {
 
   /* Do not decrease the entropy (temperature) by more than a factor of 2*/
-  const float entropy_change = p->force.entropy_dt * dt;
+  const float entropy_change = p->entropy_dt * dt;
   if (entropy_change > -0.5f * p->entropy)
     p->entropy += entropy_change;
   else
    p->entropy *= 0.5f;
 
   /* Do not 'overcool' when timestep increases */
-  if (p->entropy + 0.5f * p->force.entropy_dt * dt < 0.5f * p->entropy)
-    p->force.entropy_dt = -0.5f * p->entropy / dt;
+  if (p->entropy + 0.5f * p->entropy_dt * dt < 0.5f * p->entropy)
+    p->entropy_dt = -0.5f * p->entropy / dt;
 }
 
 /**
diff --git a/src/hydro/Gadget2/hydro_debug.h b/src/hydro/Gadget2/hydro_debug.h
index 26a9b2fdcc..9948d8f0f4 100644
--- a/src/hydro/Gadget2/hydro_debug.h
+++ b/src/hydro/Gadget2/hydro_debug.h
@@ -30,7 +30,7 @@ __attribute__((always_inline))
       p->x[0], p->x[1], p->x[2], p->v[0], p->v[1], p->v[2], xp->v_full[0],
       xp->v_full[1], xp->v_full[2], p->a_hydro[0], p->a_hydro[1], p->a_hydro[2],
       p->h, (int)p->density.wcount, p->mass, p->rho_dh, p->rho, p->force.pressure,
-      p->entropy, p->force.entropy_dt, p->div_v, p->force.curl_v, p->density.rot_v[0],
+      p->entropy, p->entropy_dt, p->div_v, p->force.curl_v, p->density.rot_v[0],
       p->density.rot_v[1], p->density.rot_v[2], p->force.v_sig, p->force.h_dt,
       p->t_begin, p->t_end);
 }
diff --git a/src/hydro/Gadget2/hydro_iact.h b/src/hydro/Gadget2/hydro_iact.h
index 4960df57c1..80111a759e 100644
--- a/src/hydro/Gadget2/hydro_iact.h
+++ b/src/hydro/Gadget2/hydro_iact.h
@@ -289,8 +289,8 @@ __attribute__((always_inline)) INLINE static void runner_iact_force(
   pj->force.v_sig = fmaxf(pj->force.v_sig, v_sig);
 
   /* Change in entropy */
-  pi->force.entropy_dt += 0.5f * visc_term * dvdr;
-  pj->force.entropy_dt -= 0.5f * visc_term * dvdr;
+  pi->entropy_dt += 0.5f * visc_term * dvdr;
+  pj->entropy_dt -= 0.5f * visc_term * dvdr;
 }
 
 /**
@@ -377,7 +377,7 @@ __attribute__((always_inline)) INLINE static void runner_iact_nonsym_force(
   pi->force.v_sig = fmaxf(pi->force.v_sig, v_sig);
 
   /* Change in entropy */
-  pi->force.entropy_dt += 0.5f * visc_term * dvdr;
+  pi->entropy_dt += 0.5f * visc_term * dvdr;
 }
 
 #endif /* SWIFT_RUNNER_IACT_LEGACY_H */
diff --git a/src/hydro/Gadget2/hydro_part.h b/src/hydro/Gadget2/hydro_part.h
index bbd0fc82ea..3fbf5dfb82 100644
--- a/src/hydro/Gadget2/hydro_part.h
+++ b/src/hydro/Gadget2/hydro_part.h
@@ -59,6 +59,9 @@ struct part {
 
   /* Particle entropy. */
   float entropy;
+
+  /* Entropy time derivative */
+  float entropy_dt;
   
   /* Particle mass. */
   float mass;
@@ -88,10 +91,7 @@ struct part {
 
       /* Signal velocity */
       float v_sig;
-
-      /* Entropy time derivative */
-      float entropy_dt;
-
+      
       /* Particle pressure */
       float pressure;
 
-- 
GitLab