Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
trixi-framework
GitHub Repository: trixi-framework/Trixi.jl
Path: blob/main/src/equations/equation_of_state_helmholtz_ideal_gas.jl
5586 views
1
2
@doc raw"""
3
HelmholtzIdealGas{RealT <: Real} <: AbstractHelmholtzEOS
4
5
Ideal-gas specific Helmholtz energy from Klein et al., Appendix E, equation (E.1).
6
The specific Helmholtz energy is
7
```math
8
A = - R T \left(1 + \ln\left(T^{1/(\gamma-1)} V\right)\right),
9
```
10
with ``c_v = R / (\gamma - 1)``.
11
12
Fields:
13
- `gamma`: ratio of specific heats
14
- `R`: specific gas constant
15
"""
16
struct HelmholtzIdealGas{RealT <: Real} <: AbstractHelmholtzEOS
17
gamma::RealT
18
R::RealT
19
end
20
21
"""
22
HelmholtzIdealGas(gamma = 1.4, R = 287)
23
24
Constructs a [`HelmholtzIdealGas`](@ref) with ratio of specific heats
25
`gamma` and specific gas constant `R`. If not specified, `R` defaults
26
to 287 J/(kg K), a value typical of air (see also [`IdealGas`](@ref)).
27
"""
28
function HelmholtzIdealGas(gamma = 1.4, R = 287)
29
return HelmholtzIdealGas(promote(gamma, R)...)
30
end
31
32
@doc raw"""
33
helmholtz(V, T, eos::HelmholtzIdealGas)
34
35
Returns the specific Helmholtz energy ``A(V, T)`` for an ideal gas, Klein et al.,
36
equation (E.1), with ``\alpha = 1/(\gamma - 1) = c_v/R``,
37
```math
38
A = - R T \left(1 + \ln\left(T^{\alpha} V\right)\right).
39
```
40
"""
41
function helmholtz(V, T, eos::HelmholtzIdealGas)
42
alpha = inv(eos.gamma - 1) # = c_v / R
43
return -eos.R * T * (1 + log((T^alpha) * V))
44
end
45
46
@doc raw"""
47
temperature(V, e_internal, eos::HelmholtzIdealGas)
48
49
This is not a required interface function, but specializing it if an explicit function is
50
available can improve performance. For general EOS, this is calculated via a Newton solve.
51
52
For [`HelmholtzIdealGas`](@ref), ``e_{\text{internal}} = c_v T`` with
53
``c_v = R / (\gamma - 1)``, so ``T = e_{\text{internal}} / c_v``. The specific volume `V` is
54
unused.
55
"""
56
function temperature(V, e_internal, eos::HelmholtzIdealGas)
57
cv = eos.R / (eos.gamma - 1)
58
return e_internal / cv
59
end
60
61
@doc raw"""
62
speed_of_sound(V, T, eos::HelmholtzIdealGas)
63
64
Computes the speed of sound as ``\sqrt{\gamma p V}`` with ``p`` from [`pressure`](@ref) at
65
`(V, T, eos)`, matching [`IdealGas`](@ref) and equivalent to Klein et al., equation (C.8),
66
for this EOS. The general [`AbstractHelmholtzEOS`](@ref) implementation evaluates (C.8) from
67
derivatives of ``A(\rho, T)`` in natural variables ``(\rho, T)``.
68
"""
69
function speed_of_sound(V, T, eos::HelmholtzIdealGas)
70
(; gamma) = eos
71
p = pressure(V, T, eos)
72
return sqrt(gamma * p * V)
73
end
74
75