diff --git a/src/hydro/Default/hydro.h b/src/hydro/Default/hydro.h index 03953b07ad4e172d96b6e3382814e036a538e2bd..301d957b89702b492bb616e32e6edbe160ab9efb 100644 --- a/src/hydro/Default/hydro.h +++ b/src/hydro/Default/hydro.h @@ -93,7 +93,7 @@ __attribute__((always_inline)) /* Final operation on the density (add self-contribution). */ p->rho += p->mass * kernel_root; - p->rho_dh -= 3.0f * p->mass * kernel_root * kernel_igamma; + p->rho_dh -= 3.0f * p->mass * kernel_root; p->density.wcount += kernel_root; /* Finish the calculation by inserting the missing h-factors */ @@ -101,6 +101,11 @@ __attribute__((always_inline)) p->rho_dh *= ih4; p->density.wcount *= (4.0f / 3.0f * M_PI * kernel_gamma3); p->density.wcount_dh *= ih * (4.0f / 3.0f * M_PI * kernel_gamma4); + + const float irho = 1.f / p->rho; + + /* Compute the derivative term */ + p->rho_dh = 1.f / (1.f + 0.33333333f * p->h * p->rho_dh * irho); } /** diff --git a/src/hydro/Gadget2/hydro.h b/src/hydro/Gadget2/hydro.h index 22c5734ed5762400285521b30f9aa60795c45325..19ab4beb373fa013fc62c8273b2feed35aa36546 100644 --- a/src/hydro/Gadget2/hydro.h +++ b/src/hydro/Gadget2/hydro.h @@ -94,7 +94,7 @@ __attribute__((always_inline)) /* Final operation on the density (add self-contribution). */ p->rho += p->mass * kernel_root; - p->rho_dh -= 3.0f * p->mass * kernel_root * kernel_igamma; + p->rho_dh -= 3.0f * p->mass * kernel_root; p->density.wcount += kernel_root; /* Finish the calculation by inserting the missing h-factors */ diff --git a/src/hydro/Gadget2/hydro_iact.h b/src/hydro/Gadget2/hydro_iact.h index d988c678affcf4ca722a965a7e52a7c120b4a924..8fcae293280e55bb838edf3c243f4e322914216f 100644 --- a/src/hydro/Gadget2/hydro_iact.h +++ b/src/hydro/Gadget2/hydro_iact.h @@ -65,7 +65,7 @@ __attribute__((always_inline)) INLINE static void runner_iact_density( /* Compute contribution to the density */ pi->rho += mj * wi; - pi->rho_dh -= mj * kernel_igamma * (3.f * wi + ui * wi_dx); + pi->rho_dh -= mj * (3.f * wi + ui * wi_dx); /* Compute contribution to the number of neighbours */ pi->density.wcount += wi; @@ -78,7 +78,7 @@ __attribute__((always_inline)) INLINE static void runner_iact_density( /* Compute contribution to the density */ pj->rho += mi * wj; - pj->rho_dh -= mi * kernel_igamma * (3.f * wj + uj * wj_dx); + pj->rho_dh -= mi * (3.f * wj + uj * wj_dx); /* Compute contribution to the number of neighbours */ pj->density.wcount += wj; @@ -134,7 +134,7 @@ __attribute__((always_inline)) INLINE static void runner_iact_nonsym_density( /* Compute contribution to the density */ pi->rho += mj * wi; - pi->rho_dh -= mj * kernel_igamma * (3.f * wi + u * wi_dx); + pi->rho_dh -= mj * (3.f * wi + u * wi_dx); /* Compute contribution to the number of neighbours */ pi->density.wcount += wi; diff --git a/src/hydro/Minimal/hydro.h b/src/hydro/Minimal/hydro.h index 7db3c275ce7e3389610e8297c287cbd5301c6c64..661f0eee18b46256fdbb693e7b4d76a1375dd92b 100644 --- a/src/hydro/Minimal/hydro.h +++ b/src/hydro/Minimal/hydro.h @@ -94,7 +94,7 @@ __attribute__((always_inline)) /* Final operation on the density (add self-contribution). */ p->rho += p->mass * kernel_root; - p->rho_dh -= 3.0f * p->mass * kernel_root * kernel_igamma; + p->rho_dh -= 3.0f * p->mass * kernel_root; p->density.wcount += kernel_root; /* Finish the calculation by inserting the missing h-factors */