Skip dual-energy fix for unphysical results in Hydro_FullStepUpdate() #504
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivations
In this PR, I propose we skip the dual-energy fix inside
Hydro_FullStepUpdatewhen the results are unphysical.If there are some reasons that the Riemann solver gets large fluxes, the full-step updated density can be low, the velocity can be high, the kinetic energy may be unphysically large, the total energy can be negative or positive, but the internal energy can be largely negative.
We expect the dual-energy fix to work when the internal energy is low or even slightly negative while other variables are normal. But when the other variables are obviously unphysical, we should not update the total energy by dual-energy fix and let the unphysical results be detected by the check later to invoke 1st-order flux correction or
AUTO_REDUCE_DT.The dual-energy fix may falsely mask the unphysical results updated by the full-step fluxes.
Example
This is one real case in my isolated galaxy simulations:
Input
[Dens, MomX, MomY, MomZ, Engy] = [ 1.67E-06, -1.67E-04, 1.59E-03, -1.18E-03, 5.07E+01 ]so
[DENS, VELX, VELY, VELZ, EINT] = [ 1.67E-06, -9.99E+01, 9.57E+02, -7.08E+02, 4.96E+01 ]After the full-step update, it becomes
Output
[Dens, MomX, MomY, MomZ, Engy] = [ 4.52E-07, -2.52E-03, -3.98E-02, -4.54E-04, -5.16E+01 ]which is
[DENS, VELX, VELY, VELZ, EINT] = [ 4.52E-07, -5.58E+03, -8.80E+04, -1.00E+03, -1.81E+03 ]The total energy is negative, and the velocity is unreasonably large, so the internal energy is largely negative.
After the dual-energy fix inside
Hydro_FullStepUpdate(), the total energy will be updated by the sum of the kinetic energy and the internal energy from dual energy and become largely positive (dominated by the kinetic energy).Output
Engyafter dual-energy fix =1.7622859e+03, and the internal energy is also positive.In
Flu_Close()->CorrectUnphysical(), we will not notice there are unphysical problems in this cell.The large total energy will cause other problems later, such as an explosion.
Changes
In
Hydro_FullStepUpdate(), only apply the dual-energy fix when the density is positive and the kinetic energy is less than twice the total energy. In this way, the negative total energy or negative internal energy will be kept and noticed.