Skip to content

Commit

Permalink
Change supersaturation definition
Browse files Browse the repository at this point in the history
  • Loading branch information
trontrytel committed Sep 6, 2023
1 parent e7a012f commit 6777935
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/relations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1154,34 +1154,34 @@ 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::FT = saturation_vapor_pressure(param_set, T, phase)
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
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, phase, 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, phase, Ice()),
) 0.998 * q_tot / ρ_v_triple / ρ - 1

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

0 comments on commit 6777935

Please sign in to comment.