Fix for the high temperature bug
When a particle has very small neighbour contributions to its running neighbour sum (wcount
), those can lead to issues with the derivative used in the Newton-Raphson scheme that updates the smoothing length. Very rarely, a small value of the derivative can lead to a decrease in the predicted smoothing length rather than an increase as logic would dictate. If this happens, the bisection bounds kick in and wrongfully signal a converged result. The algorithm then progresses into hydro_prepare_gradient
, where a variable that is the product of the same derivative with a constant factor is used in a division. This division will overflow, causing large accelerations in the force loop, which lead to high particle velocities and occasionally particles with extreme thermal energies and temperatures, the so called high temperature bug.
This MR contains two fixes:
- all three variants of the ghost (stars, BHs, gas) now treat all particles with
wcount < 1.e-5 * kernel_root
as if they had no neighbours, rather than only particles withwcount==0.f
. Since the aim of the iterative scheme is to findwcount=eta
, witheta
a value of order unity (as is the case forkernel_root
), this cannot affect the outcome of the iterative scheme. This relaxed no neighbours condition should avoid overflow in the Newton-Raphson derivative. - all hydro schemes (except GIZMO and Shadowfax) now contain an additional check for small denominators in the calculation of the
force.f
variable which can lead to very large accelerations. While the first fix should avoid this scenario, having an explicit check is nonetheless useful in case a very weird particle distribution leads to a weird denominator (e.g. when two particles sit on top of each other).
In addition to this, we now print warnings whenever a no neighbour particle is encountered in any of the ghosts, and we output a warning whenever a condition triggers in the force.f
calculation in any of the SPH hydro schemes. This should help detect weird particle configurations if they happen.