Skip to content

Commit

Permalink
Merge pull request #165 from CliMA/aj/supersat
Browse files Browse the repository at this point in the history
Change supersaturation definition
  • Loading branch information
trontrytel authored Sep 6, 2023
2 parents e7a012f + e3477be commit b49cb72
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
17 changes: 8 additions & 9 deletions src/relations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1154,34 +1154,33 @@ end
- `Liquid()`, `Ice()` - liquid or ice phase to dispatch over.
- `ts` thermodynamic state
Returns supersaturation (qv/qv_sat -1) over water or ice.
Returns supersaturation (pv/pv_sat -1) over water or ice.
"""
function supersaturation(
param_set::APS,
q::PhasePartition{FT},
ρ::FT,
T::FT,
::Liquid,
phase::Phase,
) where {FT <: Real}

q_sat::FT = q_vap_saturation_generic(param_set, T, ρ, Liquid())
q_vap::FT = vapor_specific_humidity(q)
p_v_sat = saturation_vapor_pressure(param_set, T, phase)

return q_vap / q_sat - FT(1)
return supersaturation(param_set, q, ρ, T, p_v_sat)
end
function supersaturation(
param_set::APS,
q::PhasePartition{FT},
ρ::FT,
T::FT,
::Ice,
p_v_sat::FT,
) where {FT <: Real}

q_sat::FT = q_vap_saturation_generic(param_set, T, ρ, Ice())
q_vap::FT = vapor_specific_humidity(q)
p_v::FT = vapor_specific_humidity(q) ** TP.R_v(param_set) * T)

return q_vap / q_sat - FT(1)
return p_v / p_v_sat - FT(1)
end

supersaturation(param_set::APS, ts::ThermodynamicState, phase::Phase) =
supersaturation(
param_set,
Expand Down
14 changes: 14 additions & 0 deletions test/relations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,13 @@ end
_T_triple,
Liquid(),
) 0.998 * q_tot / ρ_v_triple / ρ - 1
@test supersaturation(
param_set,
PhasePartition(q_tot, 1e-3 * q_tot, 1e-3 * q_tot),
ρ,
_T_triple,
saturation_vapor_pressure(param_set, _T_triple, Liquid()),
) 0.998 * q_tot / ρ_v_triple / ρ - 1

@test supersaturation(
param_set,
Expand All @@ -286,6 +293,13 @@ end
_T_triple,
Ice(),
) 0.998 * q_tot / ρ_v_triple / ρ - 1
@test supersaturation(
param_set,
PhasePartition(q_tot, 1e-3 * q_tot, 1e-3 * q_tot),
ρ,
_T_triple,
saturation_vapor_pressure(param_set, _T_triple, Ice()),
) 0.998 * q_tot / ρ_v_triple / ρ - 1

# energy functions and inverse (temperature)
T = FT(300)
Expand Down

0 comments on commit b49cb72

Please sign in to comment.