Skip to content

Commit

Permalink
add Clausius_Clapeyron_relation
Browse files Browse the repository at this point in the history
  • Loading branch information
yairchn committed Jun 6, 2022
1 parent 92184df commit 7c4adc5
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/relations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,24 @@ vapor_specific_humidity(q::PhasePartition) = max(0, q.tot - q.liq - q.ice)
vapor_specific_humidity(param_set::APS, ts::ThermodynamicState) =
vapor_specific_humidity(PhasePartition(param_set, ts))

"""
∂q_vap_sat_∂T(param_set, ts)
The change in saturation vapor specific humidity with temperature given by the Clausius Clapeyron relation
- `param_set` an `AbstractParameterSet`, see the [`Thermodynamics`](@ref) for more details
- `ts` ThermodynamicState
"""
function ∂q_vap_sat_∂T(param_set::APS, ts::ThermodynamicState)
R_v::FT = ICP.R_v(param_set)
L_v = latent_heat_vapor(param_set, ts)
L_s = latent_heat_sublim(param_set, ts)
λ = liquid_fraction(param_set, ts)
L = λ * L_v + (1 - λ) * L_s
T = air_temperature(param_set, ts)
q_vap_sat = vapor_specific_humidity(param_set, ts)
return L * q_vap_sat / (R_v * T^2)
end

"""
cp_m(param_set, q::PhasePartition)
Expand Down
10 changes: 10 additions & 0 deletions test/relations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,16 @@ end
@test all(saturated.(param_set, ts[RH_sat_mask]))
@test !any(saturated.(param_set, ts[RH_unsat_mask]))

# test Clausius Clapeyron relation
ts = PhaseEquil_ρeq.(param_set, ρ, e_int, q_tot)
L_v = TD.latent_heat_vapor.(param_set, ts)
L_s = TD.latent_heat_sublim.(param_set, ts)
λ = TD.liquid_fraction.(param_set, ts)
L = λ .* L_v .+ (1 .- λ) .* L_s
T = TD.air_temperature.(param_set, ts)
q_vap_sat = TD.vapor_specific_humidity(param_set, ts)
@test all(TD.∂q_vap_sat_∂T(param_set, ts) .≈ L .^ 2 .* q_vap_sat ./ (R_v .* T.^2))

# PhaseEquil (freezing)
_T_freeze = FT(ICP.T_freeze(param_set))
e_int_upper =
Expand Down

0 comments on commit 7c4adc5

Please sign in to comment.