From 59201853581e81cd0293b9330583c5939e26a006 Mon Sep 17 00:00:00 2001 From: Anna Jaruga Date: Tue, 5 Sep 2023 22:23:44 -0700 Subject: [PATCH 1/2] Change supersaturation definition --- src/relations.jl | 18 +++++++++--------- test/relations.jl | 14 ++++++++++++++ 2 files changed, 23 insertions(+), 9 deletions(-) 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..6115e45a 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, 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, Ice()), + ) ≈ 0.998 * q_tot / ρ_v_triple / ρ - 1 # energy functions and inverse (temperature) T = FT(300) From e3477bebc86134c3109aac003aa1f4e559fe0f0c Mon Sep 17 00:00:00 2001 From: Charles Kawczynski Date: Wed, 6 Sep 2023 14:43:05 -0700 Subject: [PATCH 2/2] chain calls --- src/relations.jl | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/relations.jl b/src/relations.jl index 486e8451..7a1855ad 100644 --- a/src/relations.jl +++ b/src/relations.jl @@ -1164,10 +1164,9 @@ function supersaturation( phase::Phase, ) where {FT <: Real} - p_v_sat::FT = saturation_vapor_pressure(param_set, T, phase) - p_v::FT = vapor_specific_humidity(q) * (ρ * TP.R_v(param_set) * T) + p_v_sat = saturation_vapor_pressure(param_set, T, phase) - return p_v / p_v_sat - FT(1) + return supersaturation(param_set, q, ρ, T, p_v_sat) end function supersaturation( param_set::APS,