Conservative GIZMO flux exchange.
This merge request reinstates the conservative flux exchange for GIZMO particle interactions. With these changes, the conservative variables for a particle (mass, momentum, energy) can only be changed by exchanging a flux with another particle, so that the sum of the conserved variables for the particle pair remains exactly the same (up to machine precision). This guarantees conservation of mass, momentum and energy up to machine precision for hydro-only tests.
The conservative flux exchange depends on a few assumptions:
- The update for the conserved variables for the full time step happens during kick 2, no conserved variables are updated during kick 1. This ensures that the conservative scheme works in the presence of the time step limiter or time step sync.
- If a particle interacts with an inactive particle, it is still possible to update the inactive particle's variables. This is the only way fluxes can be exchanged with inactive particles.
The second point is currently not guaranteed for MPI runs, where an active particle on node A cannot update the fluxes for an inactive particle on node B if the latter is part of a cell that only has inactive particles, since the corresponding task will simply not exist on node B. This needs to be addressed.
The drift for the primitive variables (density, velocity, pressure) is currently broken, because it depends on knowledge of the fluxes - a rate of change of the conserved quantities - while the flux variables now (confusingly?) store the time-integrated fluxes - a change in conserved quantities. This is again crucial to correctly account for fluxes in inactive particles. The old drift could be restored by introducing new variables, but I don't know if this is worth the effort and extra memory footprint.
To do:
-
resolve MPI issues -
fix or clean up drift -
run the co-moving Sod shock to check I didn't mess up the cosmology factors