diff --git a/src/relations.jl b/src/relations.jl index 7d4c214c..486e8451 100644 --- a/src/relations.jl +++ b/src/relations.jl @@ -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, diff --git a/test/relations.jl b/test/relations.jl index fe615244..2b603a08 100644 --- a/test/relations.jl +++ b/test/relations.jl @@ -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, @@ -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)