Perfect-gas normal shock: enthalpy, sound speed, Mach number, Rankine–Hugoniot relations, entropy jump and the shock-ratio functions
DefinitionAstrophysicalFluidDynamics_ShockDefsDefinitions for a normal, non-magnetic shock in a perfect gas with constant adiabatic exponent (Ogilvie 2016, §§2.8, 4.5, 6.3.1–6.3.2, Example A.13). Throughout, is density, pressure and the velocity component normal to the shock, in the rest frame of the shock; subscript denotes the upstream (pre-shock) state and the downstream (post-shock) state.
- Specific enthalpy (eq. 6.28): .
- Adiabatic sound speed (eq. 4.36): and .
- Mach number (eq. 6.29): .
- Specific internal energy (eq. 2.22): .
- Rankine–Hugoniot relations (eqs. 6.27a–c): the upstream state and downstream state satisfy
where . 6. Entropy jump (from , §11.6.2, and ): . 7. Shock-ratio functions of the upstream Mach number (eqs. 6.30a,b, 6.31):
These are the objects in terms of which every statement of the mission is phrased.
Formalization Note All quantities are real numbers and all functions are total: division by zero returns , the logarithm satisfies and for , and the square root of a negative number is . Every theorem of the mission assumes and positive densities and pressures (and positive normal velocities where relevant), so these junk values never enter the statements. The entropy is represented only through its jump divided by , which is all the source uses.
import Mathlib
namespace AstrophysicalFluidDynamics
/-- Specific enthalpy of a perfect gas with adiabatic exponent `γ`, pressure `p` and density `ρ`:
`h = (γ / (γ - 1)) * (p / ρ)` (Ogilvie 2016, eq. (6.28)). -/
noncomputable def perfectGasEnthalpy (γ p ρ : ℝ) : ℝ :=
γ / (γ - 1) * (p / ρ)
/-- Square of the adiabatic sound speed, `v_s² = γ p / ρ` (Ogilvie 2016, eq. (4.36)). -/
noncomputable def soundSpeedSq (γ p ρ : ℝ) : ℝ :=
γ * p / ρ
/-- Adiabatic sound speed `v_s = (γ p / ρ)^{1/2}` (Ogilvie 2016, eq. (4.36)). -/
noncomputable def soundSpeed (γ p ρ : ℝ) : ℝ :=
Real.sqrt (soundSpeedSq γ p ρ)
/-- Mach number `M = u_x / v_s` of a gas with normal velocity `u`, pressure `p`, density `ρ`
(Ogilvie 2016, eq. (6.29) and Example A.13). -/
noncomputable def machNumber (γ ρ u p : ℝ) : ℝ :=
u / soundSpeed γ p ρ
/-- Specific internal (thermal) energy of a perfect gas, `e = p / ((γ - 1) ρ)`
(Ogilvie 2016, eq. (2.22)). -/
noncomputable def perfectGasInternalEnergy (γ p ρ : ℝ) : ℝ :=
p / ((γ - 1) * ρ)
/-- The Rankine–Hugoniot relations (Ogilvie 2016, eqs. (6.27a–c), (A 22)–(A 24)) for a normal,
non-magnetic shock at rest at `x = 0` in a perfect gas with adiabatic exponent `γ`.
The upstream (pre-shock) state is `(ρ₁, u₁, p₁)` and the downstream (post-shock) state is
`(ρ₂, u₂, p₂)`, where `u` is the velocity component normal to the shock. The three conditions
are continuity of the mass flux `ρ u`, of the momentum flux `ρ u² + p`, and of the energy flux
`ρ u (u²/2 + h)` with `h` the perfect-gas enthalpy. -/
def RankineHugoniot (γ ρ₁ u₁ p₁ ρ₂ u₂ p₂ : ℝ) : Prop :=
ρ₂ * u₂ = ρ₁ * u₁ ∧
ρ₂ * u₂ ^ 2 + p₂ = ρ₁ * u₁ ^ 2 + p₁ ∧
ρ₂ * u₂ * (u₂ ^ 2 / 2 + perfectGasEnthalpy γ p₂ ρ₂) =
ρ₁ * u₁ * (u₁ ^ 2 / 2 + perfectGasEnthalpy γ p₁ ρ₁)
/-- Entropy jump across the shock divided by `c_v`, `[s]₁² / c_v = ln(p₂/p₁) - γ ln(ρ₂/ρ₁)`,
computed from the specific entropy of a perfect gas `s = c_p (γ⁻¹ ln p - ln ρ) + const`
(Ogilvie 2016, §11.6.2) together with `c_p = γ c_v` (eq. (2.17)). -/
noncomputable def entropyJumpOverCv (γ ρ₁ p₁ ρ₂ p₂ : ℝ) : ℝ :=
Real.log (p₂ / p₁) - γ * Real.log (ρ₂ / ρ₁)
/-- Shock density (compression) ratio as a function of the upstream Mach number `M₁`,
`(γ + 1) M₁² / ((γ - 1) M₁² + 2)` (Ogilvie 2016, eq. (6.30a)). -/
noncomputable def shockDensityRatio (γ M₁ : ℝ) : ℝ :=
(γ + 1) * M₁ ^ 2 / ((γ - 1) * M₁ ^ 2 + 2)
/-- Shock pressure ratio as a function of the upstream Mach number `M₁`,
`(2 γ M₁² - (γ - 1)) / (γ + 1)` (Ogilvie 2016, eq. (6.30b)). -/
noncomputable def shockPressureRatio (γ M₁ : ℝ) : ℝ :=
(2 * γ * M₁ ^ 2 - (γ - 1)) / (γ + 1)
/-- Square of the downstream Mach number as a function of the upstream Mach number `M₁`,
`(2 + (γ - 1) M₁²) / (2 γ M₁² - (γ - 1))` (Ogilvie 2016, eq. (6.31)). -/
noncomputable def shockDownstreamMachSq (γ M₁ : ℝ) : ℝ :=
(2 + (γ - 1) * M₁ ^ 2) / (2 * γ * M₁ ^ 2 - (γ - 1))
end AstrophysicalFluidDynamics
Read-back
What the Lean code literally says, in plain math · Aristotle (Harmonic) — same agent as the drafter; non-blind
Read-back disclosure — NOT blind, NOT independent. This read-back was written by the same agent (Aristotle, by Harmonic) that drafted the Lean statement below, with full knowledge of the source text and of the intended meaning. It is therefore not independent testimony and must not be mistaken for a blind audit. A reviewer should compare the Lean code against the source directly; an independent blind read-back is still recommended.
The file introduces, inside the namespace AstrophysicalFluidDynamics, the following real-valued functions and one predicate (all arguments are real numbers; division by returns , returns for and for , and for ):
- .
- .
- (real square root, on non-positive input).
- (note the argument order , while the sound-speed functions take ).
- .
- The proposition is the conjunction of the three equalities
No sign, positivity or non-degeneracy condition is built into the predicate; in particular any state paired with itself satisfies it. 7. . 8. . 9. . 10. (equal to when the denominator vanishes).
No theorems or hypotheses are stated in this file; it contains only these definitions.
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.