Skip to content
Snippets Groups Projects
Commit 4cb541f6 authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Apply the corrections for the Plummer-equivalent softenings.

parent 61dcf239
Branches
Tags
1 merge request!324Gravity multi dt
...@@ -27,6 +27,8 @@ ...@@ -27,6 +27,8 @@
/** /**
* @brief Computes the gravity time-step of a given particle due to self-gravity * @brief Computes the gravity time-step of a given particle due to self-gravity
* *
* We use Gadget-2's type 0 time-step criterion.
*
* @param gp Pointer to the g-particle data. * @param gp Pointer to the g-particle data.
* @param grav_props Constants used in the gravity scheme. * @param grav_props Constants used in the gravity scheme.
*/ */
...@@ -38,9 +40,10 @@ gravity_compute_timestep_self(const struct gpart* const gp, ...@@ -38,9 +40,10 @@ gravity_compute_timestep_self(const struct gpart* const gp,
gp->a_grav[1] * gp->a_grav[1] + gp->a_grav[1] * gp->a_grav[1] +
gp->a_grav[2] * gp->a_grav[2]; gp->a_grav[2] * gp->a_grav[2];
const float ac = (ac2 > 0.f) ? sqrtf(ac2) : FLT_MIN; const float ac_inv = (ac2 > 0.f) ? 1.f/sqrtf(ac2) : FLT_MAX;
const float dt = sqrtf(2.f * grav_props->eta * gp->epsilon / ac); /* Note that 0.714285714 = 2. (from Gadget) / 2.8 (Plummer softening) */
const float dt = sqrtf(0.714285714f * grav_props->eta * gp->epsilon * ac_inv);
return dt; return dt;
} }
...@@ -127,7 +130,8 @@ __attribute__((always_inline)) INLINE static void gravity_first_init_gpart( ...@@ -127,7 +130,8 @@ __attribute__((always_inline)) INLINE static void gravity_first_init_gpart(
__attribute__((always_inline)) INLINE static void gravity_init_softening( __attribute__((always_inline)) INLINE static void gravity_init_softening(
struct gpart* gp, const struct gravity_props* grav_props) { struct gpart* gp, const struct gravity_props* grav_props) {
gp->epsilon = grav_props->epsilon; /* Note 2.8 is the Plummer-equivalent correction */
gp->epsilon = 2.8f * grav_props->epsilon;
} }
#endif /* SWIFT_DEFAULT_GRAVITY_H */ #endif /* SWIFT_DEFAULT_GRAVITY_H */
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
* Taken from Gadget-2.0.7's forcetree.c lines 2755-2800 * Taken from Gadget-2.0.7's forcetree.c lines 2755-2800
* *
* @param r The distance between particles * @param r The distance between particles
* @param h The cut-off distance of the kernel * @param epsilon The cut-off distance of the kernel
*/ */
float gadget(float r, float epsilon) { float gadget(float r, float epsilon) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment