Commit 9e2868ce authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Entropy_dt should not be part of the force sub-structure

parent c0c4a315
......@@ -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;
}
/**
......
......@@ -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);
}
......@@ -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 */
......@@ -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;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment