Thermally perfect gas as an AbstractEquationOfState#3079
Thermally perfect gas as an AbstractEquationOfState#3079DanielDoehring wants to merge 28 commits into
AbstractEquationOfState#3079Conversation
Review checklistThis checklist is meant to assist creators of PRs (to let them know what reviewers will typically look for) and reviewers (to guide them in a structured review process). Items do not need to be checked explicitly for a PR to be eligible for merging. Purpose and scope
Code quality
Documentation
Testing
Performance
Verification
Created with ❤️ by the Trixi.jl community. |
AbstractEquationOfState
AbstractEquationOfStateAbstractEquationOfState
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #3079 +/- ##
==========================================
- Coverage 96.89% 96.81% -0.08%
==========================================
Files 647 650 +3
Lines 50024 50145 +121
==========================================
+ Hits 48466 48543 +77
- Misses 1558 1602 +44
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
This is great to see, @DanielDoehring; I was hoping to add this myself eventually. Agreed that standard What about adding type parameters to NonIdealCompressibleEulerEquations which identify whether the pressure EOS is non-ideal? This could differentiate between CPG, TPG, and fully non-ideal EOS? |
… into ThermallyPerfGas
… into ThermallyPerfGas
I noticed since there are
We could think about that, does this change something in the implementation/allow for simplifications? I did not go through the entire equation of state and nonideal Euler equations, so maybe there are some spots where things could be more efficient for an ideal gas pressure/density/temperature relation. |
|
I think of thermally perfect as modifying the internal energy/temperature relationship, while a nonideal EOS modifies the pressure equation. Specializing on thermally perfect this way might not make too much of a difference computationally, however. |
| tol = 100 * eps(Float64) | ||
| dp = pressure(V, T, eos()) - p | ||
| iter = 1 | ||
| while abs(dp) / abs(p) > tol && iter < 100 | ||
| dp = pressure(V, T, eos()) - p | ||
| dpdT_V = ForwardDiff.derivative(T -> pressure(V, T, eos()), T) | ||
| T = max(tol, T - dp / dpdT_V) | ||
| iter += 1 | ||
| end | ||
| if iter == 100 | ||
| @warn "Solver for temperature(V, p) did not converge" | ||
| end |
There was a problem hiding this comment.
We use this fairly often for non ideal fluids; maybe it makes sense to factor this into a helper function? Happy to also do it if you file an issue
There was a problem hiding this comment.
Agreed👍 - then we should also query eos as equations.eos or unpack it (this is why I added eos() as a function up there (albeit unnecessary convoluted)
There was a problem hiding this comment.
Should we do the following: You @jlchan prepare this change across the repository, and I dedicate some time to adding documentation for the thermally perfect gas and the specific 9degree piecewise polynomial (following your suggestion below?)
There was a problem hiding this comment.
Sure. To clarify, are you thinking of making a separate PR for AbstractThermallyPerfectGas <: AbstractEquationOfState first, or making a PR to this PR?
There was a problem hiding this comment.
I would change this PR I think 👍
| # Fetch temperature interval index for a given temperature to select the correct polynomial coefficients. | ||
| # `clamp` ensures that even for temperatures outside the provided bounds, | ||
| # a valid index is returned to prevent a bounds error. | ||
| return clamp(searchsortedlast(eos.temperature_bounds, T), 1, N) |
There was a problem hiding this comment.
How efficient is searchsortedlast here?
|
A bit of an outsider's comment: the naming is a bit confusing (to me, at least), as the equations implement a specific (NASA 9th degree polynomial) model; so maybe something like ThermallyPerfectGas9PolyFit? |
I drafted a comment on this last night but looks like it didn't send. I think something like an |
Fine with me 👍 |
|
Should wait for #3093 |
… into ThermallyPerfGas
For high temperature flows,$c_p$ and $\gamma$ should no longer be treated as constant. In turn, they can modeled as functions of only temperature ("thermally perfect") while preserving the ideal gas relation $p = R_\text{spec} \rho T$ which makes them very attractive.$c_p$ to $T$ is given by the NASA piecewise 9-degree polynomials.
The go-to data that relates
This is an experimental implementation that implements thermally perfect gases as an equation of state.
However, I would like to not restrict this to
NonIdealCompressibleEulerEquationssince the originalCompressibleEulerEquationscould readily be extended with a non-constantgamma = gamma(T). In fact, we already have this behaviour for the viscosity:Trixi.jl/src/equations/compressible_navier_stokes_2d.jl
Lines 189 to 194 in 7091f3b
Trixi.jl/src/equations/compressible_navier_stokes.jl
Lines 125 to 137 in 7091f3b
I also added
varnamesforcons2thermo(this is probably something for a different PR) to be able to save the thermal variables to get e.g. plots of temperature conveniently:Comparison to ideal gas:
One can see that the shock is slightly further away from the cylinder compared to the real gas case.