Skip to content

Commit 0edb0e4

Browse files
committed
Formatting and doc cleanup
1 parent 1f866c8 commit 0edb0e4

File tree

2 files changed

+22
-11
lines changed

2 files changed

+22
-11
lines changed

src/air_saturation_functions.jl

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -390,9 +390,19 @@ Derivative of saturation vapor specific humidity with respect to temperature.
390390
# Returns
391391
- `∂q_v^* / ∂T`: Derivative of saturation specific humidity with respect to temperature [kg/kg/K].
392392
393-
Computed via the Clausius-Clapeyron relation: `∂q_sat/∂T = q_sat * (L / (Rv * T^2) - 1 / T)`, which
394-
follows from `q_sat = p_sat / (ρ * R_v * T)` and the Clausius-Clapeyron relation
395-
`∂ln(p_sat)/∂T = L / (Rv * T^2)` by differentiation with respect to `T` while holding `ρ` constant.
393+
Computed via the Clausius-Clapeyron relation:
394+
```math
395+
\frac{\partial q_v^*}{\partial T} = q_v^* \left( \frac{L}{R_v T^2} - \frac{1}{T} \right)
396+
```
397+
which follows from the definition of saturation specific humidity
398+
```math
399+
q_v^* = \frac{p_v^*}{\rho R_v T}
400+
```
401+
(where `` q_v^* `` is `q_vap_sat` and `` p_v^* `` is saturation vapor pressure) and the Clausius-Clapeyron relation
402+
```math
403+
\frac{\partial \ln p_v^*}{\partial T} = \frac{L}{R_v T^2}
404+
```
405+
by differentiation with respect to `` T `` while holding `` \rho `` constant.
396406
397407
If `q_liq` and `q_ice` are provided, the saturation specific humidity derivative is computed
398408
assuming a phase mixture defined by the liquid fraction (see [`liquid_fraction`](@ref)).

test/ad_tests.jl

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -300,35 +300,36 @@ using Thermodynamics: ρe, pe, ph
300300
# Test that the different method signatures return consistent values
301301
# Above freezing: Phase(Liquid()) should match (q_liq=0, q_ice=0) which defaults to liquid
302302
# Below freezing: Phase(Ice()) should match (q_liq=0, q_ice=0) which defaults to ice
303-
303+
304304
ρ = FT(1.0)
305-
305+
306306
# Above freezing (T > T_freeze): expects liquid saturation
307307
T_above = FT(290.0)
308308
dq_dT_default = TD.∂q_vap_sat_∂T(param_set, T_above, ρ)
309309
dq_dT_explicit = TD.∂q_vap_sat_∂T(param_set, T_above, ρ, FT(0), FT(0))
310310
dq_dT_liquid = TD.∂q_vap_sat_∂T(param_set, T_above, ρ, TD.Liquid())
311-
311+
312312
@test isapprox(dq_dT_default, dq_dT_explicit; rtol = FT(1e-10))
313313
@test isapprox(dq_dT_default, dq_dT_liquid; rtol = FT(1e-10))
314-
314+
315315
# Below freezing (T < T_icenuc): expects ice saturation
316316
T_below = FT(220.0)
317317
dq_dT_default_cold = TD.∂q_vap_sat_∂T(param_set, T_below, ρ)
318318
dq_dT_explicit_cold = TD.∂q_vap_sat_∂T(param_set, T_below, ρ, FT(0), FT(0))
319319
dq_dT_ice = TD.∂q_vap_sat_∂T(param_set, T_below, ρ, TD.Ice())
320-
320+
321321
@test isapprox(dq_dT_default_cold, dq_dT_explicit_cold; rtol = FT(1e-10))
322322
@test isapprox(dq_dT_default_cold, dq_dT_ice; rtol = FT(1e-10))
323-
323+
324324
# Mixed phase region (T_icenuc < T < T_freeze):
325325
# Default method uses liquid_fraction_ramp, should differ from pure phases
326326
T_mixed = FT(260.0)
327327
dq_dT_mixed_default = TD.∂q_vap_sat_∂T(param_set, T_mixed, ρ)
328328
dq_dT_mixed_liquid = TD.∂q_vap_sat_∂T(param_set, T_mixed, ρ, TD.Liquid())
329329
dq_dT_mixed_ice = TD.∂q_vap_sat_∂T(param_set, T_mixed, ρ, TD.Ice())
330-
330+
331331
# In mixed phase, default should be between pure liquid and pure ice
332-
@test min(dq_dT_mixed_liquid, dq_dT_mixed_ice) <= dq_dT_mixed_default <= max(dq_dT_mixed_liquid, dq_dT_mixed_ice)
332+
@test min(dq_dT_mixed_liquid, dq_dT_mixed_ice) <= dq_dT_mixed_default <=
333+
max(dq_dT_mixed_liquid, dq_dT_mixed_ice)
333334
end
334335
end

0 commit comments

Comments
 (0)