Re: Should timesteps for hydrodynamics be assigned after the force is computed?

From: Volker Springel <vspringel_at_MPA-Garching.MPG.DE>
Date: Tue, 10 Aug 2021 19:49:01 +0200

Hi Leonard,

> On 31. Jul 2021, at 13:22, Leonard Romano <> wrote:
> Dear gadget-list members,
> Recently Julianne Goddard raised an issue with crashes in cosmological simulations with subgrid physics (Cooling, star formation and feedback) due to exceedingly small timesteps
> (
> I am running similar simulations with a custom feedback model, and often times run into similar problems. Now I noticed that a major difference between previous versions of Gadget and Gadget-4 is, that in Gadget-4 the time steps for hydrodynamics are assigned before the forces are computed. Without sub-grid physics this is probably fine as changes in quantities like Entropy and velocities are small, but with sub-grid physics there can be sudden changes by orders of magnitude and so the time steps before the force calculation might be heavily overestimated possibly leading to dramatic violations of the Courant-condition.

Normally the Courant condition doesn't depend on the pressure forces, only on the sound speed and the bulk velocity of the gas (or more accurately the wave speeds). So computing hydro forces before deciding on the timestep doesn't directly influence this.

I note that the code uses the tree_based_timesteps() function to determine the first arrival of waves at a given location, in principle from everywhere in the simulation volume, i.e. if you set off a "feedback bomb" somewhere, then the timestepping should react to this appropriately before a blast wave from this arrives, thus that the Courant condition is always respected. This is however only guaranteed to work if the external energy injection happens on a globally synchronized timestep. If you apply your custom feedback on arbitrary timesteps, including ones where only a small number of particles are synchronized, then it can indeed happen that other neighbouring particles of the feedback-affected particle have already been assigned to longer, partially completed timesteps, and this can indeed cause problems. One way to avoid this would be to add strong feedback only on global synchronization points, or at least only at times when the neighboring particles of a particle that receives feedback are also acti

> This is why suggest to move the assignment of time steps in between the first force calculation and the first kick, in order to protect against such rapid changes in these quantities.

It would be possible to split up the hydro force computation and the kick such that one has also the pressure force available before setting the hydro step. (Note however that the originating particle of the high pressure force should then also be hot, so induce a short timestep via the Courant condition too). This hasn't been done in Gadget4 because of an intended analogy/similarity with Arepo (where the tree-based timestep assignment scheme has first been described), and the way one usually does mesh-based hydro.


> Best,
> Leonard
> --
> ===================================================
> Leonard Romano, B.Sc.(レオナルド・ロマノ)
> Physics Department
> Technical University of Munich (TUM), Germany
> Theoretical Astrophysics Group
> Department of Earth and Space Science
> Graduate School of Science, Osaka University, Japan
> he / him / his
> ===================================================
> -----------------------------------------------------------
> If you wish to unsubscribe from this mailing, send mail to
> with a subject of: unsubscribe gadget-list
> A web-archive of this mailing list is available here:
Received on 2021-08-10 19:49:01

This archive was generated by hypermail 2.3.0 : 2023-01-10 10:01:33 CET