Skip to content

Commit 65a9e08

Browse files
authored
Add derivation of dQ, dT, dp relationship + fixes few glitches (#46)
* add derivation of dQ, dT, dp relationship + fixes few glitches * some rephrasing * some rephrasing * clarify what's convention * puntuation * puntuation + Clapeyron typo * [ before { * some space in kwargs * some more internal/external energy mixups * define R * Q -> mathcal{Q} * it's not external energy, it's heat input * it's the work done by gas * rephrase
1 parent 85ed2f4 commit 65a9e08

File tree

2 files changed

+70
-41
lines changed

2 files changed

+70
-41
lines changed

docs/src/microphysics/saturation_adjustment.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,14 +104,14 @@ g = thermo.gravitational_acceleration
104104
fig = Figure()
105105
106106
yticks = 0:2e3:10e3
107-
axT = Axis(fig[1, 1]; xlabel="Temperature (ᵒK)", ylabel="Height (m)", yticks)
108-
axq⁺ = Axis(fig[1, 2]; xlabel="Saturation \n specific humidity \n (kg kg⁻¹)",
109-
yticks, yticklabelsvisible=false)
110-
axqˡ = Axis(fig[1, 3]; xlabel="Liquid \n specific humidity \n (kg kg⁻¹)",
111-
yticks, yticklabelsvisible=false)
107+
axT = Axis(fig[1, 1]; xlabel = "Temperature (ᵒK)", ylabel = "Height (m)", yticks)
108+
axq⁺ = Axis(fig[1, 2]; xlabel = "Saturation \n specific humidity \n (kg kg⁻¹)",
109+
yticks, yticklabelsvisible = false)
110+
axqˡ = Axis(fig[1, 3]; xlabel = "Liquid \n specific humidity \n (kg kg⁻¹)",
111+
yticks, yticklabelsvisible = false)
112112
113113
lines!(axT, T, z)
114-
lines!(axT, T[1] .- g * z / cᵖᵈ, z, linestyle=:dash, color=:orange, linewidth=2)
114+
lines!(axT, T[1] .- g * z / cᵖᵈ, z, linestyle = :dash, color = :orange, linewidth = 2)
115115
lines!(axq⁺, qᵛ⁺, z)
116116
lines!(axqˡ, qˡ, z)
117117

docs/src/thermodynamics.md

Lines changed: 64 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,42 @@ pressure ``p``, temperature ``T``, and density ``ρ``,
2525
p = ρ R T .
2626
```
2727

28-
Above, ``R = ℛ / m`` is the specific gas constant given the
28+
Above, ``R ℛ / m`` is the specific gas constant given the
2929
[molar gas constant](https://en.wikipedia.org/wiki/Gas_constant)
30-
``ℛ ≈ 8.31\;\mathrm{J} \, \mathrm{K}^{-1} \, \mathrm{mol}^{-1}`` and molar mass ``m`` of the gas species under consideration.
30+
``ℛ ≈ 8.31 \; \mathrm{J} \, \mathrm{K}^{-1} \, \mathrm{mol}^{-1}`` and molar mass ``m`` of the gas species under consideration.
3131

3232
The [first law of thermodynamics](https://en.wikipedia.org/wiki/First_law_of_thermodynamics),
33-
aka "conservation of energy", states that infinitesimal changes
34-
in internal energy ``\mathrm{d} `` are related to infinitesimal changes
35-
in temperature ``\mathrm{d} T`` and pressure ``\mathrm{d} p`` according to
33+
aka "conservation of energy", states that an infinitesimal change in the
34+
external heat changes ``\mathrm{d} \mathcal{Q}`` are related to infinitesimal changes
35+
in temperature ``\mathrm{d} T`` and pressure ``\mathrm{d} p`` according to:[^1]
3636

3737
```math
38-
\mathrm{d} = cᵖ \mathrm{d} T - \frac{\mathrm{d} p}{\rho}
38+
\mathrm{d} \mathcal{Q} = cᵖ \mathrm{d} T - \frac{\mathrm{d} p}{\rho} ,
3939
```
4040

41+
[^1]: The conservation of energy states that any external heat input into the gas must equal the sum
42+
of the change of the gas's internal energy and the work done by the gas, ``p \, \mathrm{d} V``.
43+
For atmospheric flows it's convenient to express everything per unit mass. Assuming the mass of
44+
the fluid is conserved, we have that the work done per unit mass is ``p \, \mathrm{d}(\rho^{-1})``
45+
and the internal energy per unit mass is ``cᵛ \mathrm{d} T``.
46+
Therefore, if ``\mathrm{d} \mathcal{Q}`` is the external heat change per unit mass,
47+
we have:
48+
49+
```math
50+
\mathrm{d} \mathcal{Q} = cᵛ \mathrm{d}T + p \, \mathrm{d}(ρ^{-1}) .
51+
```
52+
53+
By utilising the identity ``\mathrm{d}(p / ρ) = p \, \mathrm{d}(ρ^{-1}) + ρ^{-1} \mathrm{d}p`` and using
54+
the ideal gas, we can rewrite the above conservation law as:
55+
56+
```math
57+
\mathrm{d} \mathcal{Q} = (cᵛ + R) \mathrm{d}T - ρ^{-1} \mathrm{d}p ,
58+
```
59+
60+
which is the expression in the main text after noting that the specific heat capacities under
61+
constant pressure and under constant volume are related via ``cᵖ ≡ cᵛ + R``.
62+
63+
4164
where ``cᵖ`` is the specific heat capacity at constant pressure of the gas in question.
4265
4366
For example, to represent dry air typical for Earth, with molar mass ``m = 0.029 \; \mathrm{kg} \, \mathrm{mol}^{-1}`` and heat capacity ``c^p = 1005 \; \mathrm{J} \, \mathrm{kg}^{-1} \, \mathrm{K}^{-1}``,
@@ -50,28 +73,34 @@ dry_air = IdealGas(molar_mass=0.029, heat_capacity=1005)
5073

5174
### Adiabatic transformations and potential temperature
5275

53-
Within adiabatic transformations, ``\mathrm{d} = 0``.
54-
Combining the ideal gas law with conservation of energy then yields
76+
Within adiabatic transformations, ``\mathrm{d} \mathcal{Q} = 0``.
77+
Then, combining the ideal gas law with conservation of energy yields
5578

5679
```math
57-
\frac{\mathrm{d} p}{\mathrm{d} T} = ρ cᵖ = \frac{p}{R T} cᵖ, \qquad \text{which implies} \qquad T ∼ \left ( \frac{p}{p₀} \right )^{R / cᵖ} .
80+
\frac{\mathrm{d} T}{T} = \frac{R}{cᵖ} \frac{\mathrm{d} p}{p} ,
5881
```
5982

60-
where ``p₀`` is some reference pressure. As a result, the _potential temperature_, ``\theta``
83+
which implies that ``T ∼ ( p / p₀ )^{R / cᵖ}``,
84+
where ``p₀`` is some reference pressure value.
85+
86+
As a result, the _potential temperature_, ``θ``, defined as
6187

6288
```math
63-
θ ≡ T \left ( \frac{p}{p} \right )^{Rᵈ / cᵖ} \frac{T}{Π}, \quad \text{where} \quad Π ≡ \left ( \frac{p}{p₀} \right )^{Rᵈ / cᵖ} ,
89+
θ ≡ T \big / \left ( \frac{p}{p} \right )^{Rᵈ / cᵖ} = \frac{T}{Π} ,
6490
```
6591

66-
is constant under adiabatic transformations, defined such that ``θ(z=0) = T(z=0)``.
67-
Above, we have also defined the Exner function, ``Π``,
92+
remains constant under adiabatic transformations.
93+
Notice that above, we also defined the Exner function, ``Π ≡ ( p / p₀ )^{Rᵈ / cᵖ}``.
94+
By convention, we tend to use as reference values those at the surface ``z=0``, i.e., ``p₀ = p(z=0)``, ``T₀ = T(z=0)``, etc.
95+
This implies that the potential temperature under adiabatic transformation is ``θ(z) = θ₀ = T₀``.
6896

6997
### Hydrostatic balance
7098

71-
Next we consider a reference state with constant internal energy and thus constant potential temperature
99+
Next we consider a reference state that does not exchange energy with its environment
100+
(i.e., ``\mathrm{d} \mathcal{Q} = 0``) and thus has constant potential temperature
72101

73102
```math
74-
θ₀ = Tᵣ \left ( \frac{p₀}{pᵣ} \right )^{Rᵈ / cᵖ}
103+
θ₀ = Tᵣ \left ( \frac{p₀}{pᵣ} \right )^{Rᵈ / cᵖ} .
75104
```
76105

77106
!!! note "About subscripts"
@@ -85,32 +114,32 @@ Next we consider a reference state with constant internal energy and thus consta
85114
Hydrostatic balance requires
86115

87116
```math
88-
∂_z pᵣ = - ρᵣ g
117+
∂_z pᵣ = - ρᵣ g .
89118
```
90119

91-
we get
120+
By combining the hydrostatic balance with the ideal gas law and the definition of potential
121+
temperature we get
92122

93123
```math
94-
\frac{pᵣ}{p₀} = \left (1 - \frac{g z}{cᵖ θ₀} \right )^{cᵖ / Rᵈ}
124+
\frac{pᵣ}{p₀} = \left (1 - \frac{g z}{cᵖ θ₀} \right )^{cᵖ / Rᵈ} .
95125
```
96126

97127
Thus
98128

99129
```math
100-
Tᵣ(z) = θ₀ \left ( \frac{pᵣ}{p₀} \right )^{Rᵈ / cᵖ} = θ₀ \left ( 1 - \frac{g z}{cᵖ θ₀} \right )
130+
Tᵣ(z) = θ₀ \left ( \frac{pᵣ}{p₀} \right )^{Rᵈ / cᵖ} = θ₀ \left ( 1 - \frac{g z}{cᵖ θ₀} \right ) ,
101131
```
102132

103133
and
104134

105135
```math
106-
ρᵣ(z) = \frac{p₀}{R θ₀} \left ( 1 - \frac{g z}{cᵖ θ₀} \right )^{cᵖ / Rᵈ - 1}
136+
ρᵣ(z) = \frac{p₀}{R θ₀} \left ( 1 - \frac{g z}{cᵖ θ₀} \right )^{cᵖ / Rᵈ - 1} .
107137
```
108138

109139
## An example of a dry reference state in Breeze
110140

111-
We can visualise a hydrostatic reference profile
112-
evaluating Breeze's reference-state utilities (which assume a dry reference state)
113-
on a one-dimensional `RectilinearGrid`:
141+
We can visualise a hydrostatic reference profile evaluating Breeze's reference-state
142+
utilities (which assume a dry reference state) on a one-dimensional `RectilinearGrid`:
114143

115144
```@example reference_state
116145
using Breeze
@@ -138,16 +167,16 @@ z = KernelFunctionOperation{Center, Center, Center}(znode, grid, Center(), Cente
138167
Tᵣ₁ = Field(θ₀ * (pᵣ / p₀)^(Rᵈ / cᵖᵈ))
139168
Tᵣ₂ = Field(θ₀ * (1 - g * z / (cᵖᵈ * θ₀)))
140169
141-
fig = Figure(resolution = (900, 300))
170+
fig = Figure()
142171
143172
axT = Axis(fig[1, 1]; xlabel = "Temperature (ᵒK)", ylabel = "Height (m)")
144173
lines!(axT, Tᵣ₁)
145-
lines!(axT, Tᵣ₂, linestyle=:dash, color = :orange, linewidth=2)
174+
lines!(axT, Tᵣ₂, linestyle = :dash, color = :orange, linewidth = 2)
146175
147-
axp = Axis(fig[1, 2]; xlabel = "Pressure (10⁵ Pa)")
176+
axp = Axis(fig[1, 2]; xlabel = "Pressure (10⁵ Pa)", yticklabelsvisible = false)
148177
lines!(axp, pᵣ / 1e5)
149178
150-
axρ = Axis(fig[1, 3]; xlabel = "Density (kg m⁻³)")
179+
axρ = Axis(fig[1, 3]; xlabel = "Density (kg m⁻³)", yticklabelsvisible = false)
151180
lines!(axρ, ρᵣ)
152181
153182
fig
@@ -167,7 +196,7 @@ The partial pressure of the dry air and vapor components are related to the comp
167196
``ρᵈ`` and ``ρᵛ`` through the ideal gas law,
168197

169198
```math
170-
pᵈ = ρᵈ Rᵈ T \qquad \text{and} \qquad pᵛ = ρᵛ Rᵛ T
199+
pᵈ = ρᵈ Rᵈ T \qquad \text{and} \qquad pᵛ = ρᵛ Rᵛ T ,
171200
```
172201

173202
where ``T`` is temperature, ``Rⁱ = ℛ / m^β`` is the specific gas constant for component ``β``,
@@ -188,7 +217,7 @@ and water vapor are ``mᵈ = 0.029`` kg/mol and ``mᵛ = 0.018`` kg/mol.
188217
To write the effective gas law for moist air, we introduce the mass ratios
189218

190219
```math
191-
qᵈ \equiv \frac{ρᵈ}{ρ} \qquad \text{and} \qquad qᵛ \equiv \frac{ρᵛ}{ρ}
220+
qᵈ \frac{ρᵈ}{ρ} \qquad \text{and} \qquad qᵛ \frac{ρᵛ}{ρ} ,
192221
```
193222

194223
where ``ρ`` is total density of the fluid including dry air, vapor, and condensates,
@@ -217,13 +246,13 @@ q = 0.01 # 1% water vapor by mass
217246
cᵖᵐ = mixture_heat_capacity(qᵛ, thermo)
218247
```
219248

220-
## The Clausius-Claperyon relation and saturation specific humidity
249+
## The Clausius--Clapeyron relation and saturation specific humidity
221250

222-
The [Clausius-Claperyon relation](https://en.wikipedia.org/wiki/Clausius%E2%80%93Clapeyron_relation)
251+
The [Clausius--Clapeyron relation](https://en.wikipedia.org/wiki/Clausius%E2%80%93Clapeyron_relation)
223252
for an ideal gas
224253

225254
```math
226-
\frac{\mathrm{d} pᵛ⁺}{\mathrm{d} T} = \frac{pᵛ⁺ ℒ^β(T)}{Rᵛ T^2}
255+
\frac{\mathrm{d} pᵛ⁺}{\mathrm{d} T} = \frac{pᵛ⁺ ℒ^β(T)}{Rᵛ T^2} ,
227256
```
228257

229258
where ``pᵛ⁺`` is saturation vapor pressure, ``T`` is temperature, ``Rᵛ`` is the specific gas constant for vapor,
@@ -235,14 +264,14 @@ the latent heat of a phase transition is linear in temperature.
235264
For example, for phase change from vapor to liquid,
236265

237266
```math
238-
ℒˡ(T) = ℒˡ₀ + \big ( \underbrace{cᵖᵛ - cᵖˡ}_{≡Δcˡ} \big ) T
267+
ℒˡ(T) = ℒˡ₀ + \big ( \underbrace{cᵖᵛ - cᵖˡ}_{≡Δcˡ} \big ) T ,
239268
```
240269

241270
where ``ℒˡ₀`` is the latent heat at ``T = 0``, with ``T`` in Kelvin.
242271
Integrate that to get
243272

244273
```math
245-
pᵛ⁺(T) = pᵗʳ \left ( \frac{T}{Tᵗʳ} \right )^{Δcˡ / Rᵛ} \exp \left \{ \frac{ℒˡ₀}{Rᵛ} \left (\frac{1}{Tᵗʳ} - \frac{1}{T} \right ) \right \}
274+
pᵛ⁺(T) = pᵗʳ \left ( \frac{T}{Tᵗʳ} \right )^{Δcˡ / Rᵛ} \exp \left [ \frac{ℒˡ₀}{Rᵛ} \left (\frac{1}{Tᵗʳ} - \frac{1}{T} \right ) \right ] .
246275
```
247276

248277
Consider parameters for liquid water,
@@ -261,7 +290,7 @@ water_ice = CondensedPhase(latent_heat=2834000, heat_capacity=2108)
261290
The saturation specific humidity is
262291

263292
```math
264-
qᵛ⁺ ≡ \frac{ρᵛ⁺}{ρ} = \frac{pᵛ⁺}{Rᵐ T}
293+
qᵛ⁺ ≡ \frac{ρᵛ⁺}{ρ} = \frac{pᵛ⁺}{Rᵐ T} .
265294
```
266295

267296
This is what it looks like:

0 commit comments

Comments
 (0)