ammarhakim / gkylzero

Lowest, compiled layer of Gkeyll infrastructure.
MIT License
20 stars 4 forks source link

[DR] Refactor of SR Vlasov for energy conservation and improved robustness of correction algorithm #418

Closed JunoRavin closed 1 month ago

JunoRavin commented 1 month ago

This design review encompasses the two key improvements contained in the branch: https://github.com/ammarhakim/gkylzero/tree/dg_10m_sr_refactor

  1. In the attached pdf I outline the proof but the essential idea is that before, the SR Vlasov solve was not energy conserving. The original solver was formulated to separately compute gamma = sqrt(1 + p^2) (the particle Lorentz boost factor) and p/gamma (the relativistic velocity) independently. However, our work on Hamiltonian systems demonstrates that these two quantities are not independent and to properly have an energy conserving scheme one must

I have verified that with this construction our scheme is now energy conserving using the relativistic two-stream instability, and we obtain third order accuracy in the convergence of the energy due to the SSP RK3 method employed for time-stepping. See attached figure from the 1x1v regression test.

  1. We were previously having difficulty with the overall robustness of the LTE moment calculation and correction algorithm in relativity, principally due to the fact that in regions of strong gradients the drift velocity may be super-luminal (even if the cell average is less than the speed of light). Constraining the drift velocity to be well-behaved was even harder when trying to compute |V_drift|^2 for computing the Lorentz boost factor and the rest-frame density. This difficulty can be clearly seen in the main branch at the time of this issue (07/09/2024) where the Vlasov SR BGK Sod Shock test fails for Nx > 128 due to the initial large flow generated by the pressure gradient.

To solve this issue, I have changed the relativistic solver to utilize the spatial component of the bulk four-velocity in the LTE moment calculator and correction algorithm. The spatial component of the bulk four-velocity is guaranteed to be well behaved as it does not have to be bounded from above, and computing the needed Lorentz boost factor from this quantity is also guaranteed to be positive definite. To achieve this refactor the steps are now:

where u_i is the four-velocity GammaV*V_drift_i, p is the particle velocity, and gamma = sqrt(1 + p^2) is the particle Lorentz boost factor.

I have also rearranged things such that the SR moment calculator does not take a significant number of auxiliary variables anymore, only gamma (since you only ever need gamma or you compute the derivative of gamma inside the kernel) and instead moved the pressure computation to the "sr_vars" updater (https://github.com/ammarhakim/gkylzero/blob/dg_10m_sr_refactor/zero/dg_calc_sr_vars.c). This "sr_vars" updater is principally used by the LTE Moments routine to get the rest-frame density and rest-frame pressure, but it also provides the necessary routines for getting the initial continuous projections of gamma and 1/gamma.

This new formulation now can run the Vlasov SR BGK Sod Shock at higher resolution and has further generalized the LTE moments to be computable in 2x and 3x simulations.

SR_Vlasov_Notes.pdf Figure_2

JonathanGorard commented 1 month ago

I'm recording this comment here regarding a conversation @JunoRavin and I just had: I think it would be interesting to see (if only as an error quantification scheme, e.g. in a unit test or something) what the timelike components of the bulk four-velocity look like, when computed from the spatial components that are now being used in the LTE moment and correction routines. As far as I can tell from an initial glance, that seems like the primary thing that might potentially go wrong (even though I understand that it's already far more stable than it used to be) with the algorithm as described.

JunoRavin commented 1 month ago

Design review merged with https://github.com/ammarhakim/gkylzero/pull/429