SWIFTSIM / SWIFT

Modern astrophysics and cosmology particle-based code. Mirror of gitlab developments at https://gitlab.cosma.dur.ac.uk/swift/swiftsim
http://www.swiftsim.com
GNU Lesser General Public License v3.0
88 stars 58 forks source link

Energy Conservation in giant impact simulations #27

Closed joe637 closed 2 years ago

joe637 commented 2 years ago

I am currently running giant impact simulations using the EoS of Hubbard and Macfarlane (1980) and swift seems to have trouble with energy conservation whenever I set the max timestep to be large (100s) to allow swift to find its preffered timestep, it seems to have trouble with energy conservation, which in turn leads to problems with the simulation itself, but when I cap the max dt at 10s, it forces the timesteps to be smaller, and it conserves energy much better, but this in turn leads the simulation to take much longer than if I set the max dt to be 100s. I'm not quite sure what the problem here might be, so could it be a problem with swift itself Energy_10 Energy_16 ? The top graph is where the timesteps have been capped at 10s, the bottom is a maximum of 100s

MatthieuSchaller commented 2 years ago

The energy is never expected to be conserved in a system using a multiple time-step scheme where particles can change time-step sizes. That will be true for every code. The onus is on the user to chose a maximal time-step size, CFL number, and gravity time-step condition that leads to a level of accuracy they are happy with.

Some effects can be mitigated by additionally running with the time-step limiter loops (--limiter) at runtime if the losses are predominantly coming from the hydro solver.