diff --git a/src/cache/diagnostic_edmf_precomputed_quantities.jl b/src/cache/diagnostic_edmf_precomputed_quantities.jl index e615d63920..a496a80bc0 100644 --- a/src/cache/diagnostic_edmf_precomputed_quantities.jl +++ b/src/cache/diagnostic_edmf_precomputed_quantities.jl @@ -361,7 +361,7 @@ function set_diagnostic_edmf_precomputed_quantities!(Y, p, t) p_prev_level, ρ_prev_level, buoyancy_flux_sfc_halflevel, - ρaʲ_prev_level / ρʲ_prev_level, + draft_area(ρaʲ_prev_level, ρʲ_prev_level), get_physical_w( u³ʲ_prev_halflevel, local_geometry_prev_halflevel, @@ -385,7 +385,7 @@ function set_diagnostic_edmf_precomputed_quantities!(Y, p, t) p_prev_level, ρ_prev_level, buoyancy_flux_sfc_halflevel, - ρaʲ_prev_level / ρʲ_prev_level, + draft_area(ρaʲ_prev_level, ρʲ_prev_level), get_physical_w( u³ʲ_prev_halflevel, local_geometry_prev_halflevel, diff --git a/src/cache/edmf_precomputed_quantities.jl b/src/cache/edmf_precomputed_quantities.jl index 4d1025f8ab..b4a517089a 100644 --- a/src/cache/edmf_precomputed_quantities.jl +++ b/src/cache/edmf_precomputed_quantities.jl @@ -169,7 +169,7 @@ function set_edmf_precomputed_quantities!(Y, p, ᶠuₕ³, t) ᶜp, Y.c.ρ, buoyancy_flux, - Y.c.sgsʲs.:($$j).ρa / ᶜρʲs.:($$j), + draft_area(Y.c.sgsʲs.:($$j).ρa, ᶜρʲs.:($$j)), get_physical_w(ᶜuʲs.:($$j), ᶜlg), TD.relative_humidity(thermo_params, ᶜtsʲs.:($$j)), ᶜphysical_buoyancy(params, ᶜρ_ref, ᶜρʲs.:($$j)), @@ -186,7 +186,7 @@ function set_edmf_precomputed_quantities!(Y, p, ᶠuₕ³, t) ᶜp, Y.c.ρ, buoyancy_flux, - Y.c.sgsʲs.:($$j).ρa / ᶜρʲs.:($$j), + draft_area(Y.c.sgsʲs.:($$j).ρa, ᶜρʲs.:($$j)), get_physical_w(ᶜuʲs.:($$j), ᶜlg), TD.relative_humidity(thermo_params, ᶜtsʲs.:($$j)), ᶜphysical_buoyancy(params, ᶜρ_ref, ᶜρʲs.:($$j)), diff --git a/src/cache/precomputed_quantities.jl b/src/cache/precomputed_quantities.jl index 39d9585750..88e8e95d0c 100644 --- a/src/cache/precomputed_quantities.jl +++ b/src/cache/precomputed_quantities.jl @@ -344,8 +344,8 @@ function output_sgs_quantities(Y, p, t) set_sgs_ᶠu₃!(u₃⁺, ᶠu₃⁺, Y, turbconv_model) set_velocity_quantities!(ᶜu⁺, ᶠu³⁺, ᶜK⁺, ᶠu₃⁺, Y.c.uₕ, ᶠuₕ³) ᶜts⁺ = @. ts_sgs(thermo_args..., ᶜspecific⁺, ᶜK⁺, ᶜΦ, ᶜp) - ᶜa⁺ = @. ρa⁺(Y.c) / TD.air_density(thermo_params, ᶜts⁺) - ᶜa⁰ = @. ᶜρa⁰ / ᶜρ⁰ + ᶜa⁺ = @. draft_area(ρa⁺(Y.c), TD.air_density(thermo_params, ᶜts⁺)) + ᶜa⁰ = @. draft_area(ᶜρa⁰, ᶜρ⁰) return (; ᶜspecific⁺, ᶠu₃⁺, ᶜu⁺, ᶠu³⁺, ᶜK⁺, ᶜts⁺, ᶜa⁺, ᶜa⁰) end @@ -361,6 +361,6 @@ function output_diagnostic_sgs_quantities(Y, p, t) ᶠu³⁺ = p.ᶠu³ʲs[1] ᶜu⁺ = @. (C123(Y.c.uₕ) + C123(ᶜinterp(ᶠu³⁺))) ᶜts⁺ = @. ᶜtsʲs[1] - ᶜa⁺ = @. ᶜρaʲs[1] / TD.air_density(thermo_params, ᶜts⁺) + ᶜa⁺ = @. draft_area(ᶜρaʲs[1], TD.air_density(thermo_params, ᶜts⁺)) return (; ᶜu⁺, ᶠu³⁺, ᶜts⁺, ᶜa⁺) end diff --git a/src/prognostic_equations/edmfx_closures.jl b/src/prognostic_equations/edmfx_closures.jl index a16220f4f5..f5f4fed8b8 100644 --- a/src/prognostic_equations/edmfx_closures.jl +++ b/src/prognostic_equations/edmfx_closures.jl @@ -6,6 +6,13 @@ import StaticArrays as SA import ClimaCore.Geometry as Geometry import ClimaCore.Fields as Fields +""" + Return draft area given ρa and ρ +""" +function draft_area(ρa::FT, ρ::FT) where {FT} + return ρa / ρ +end + """ Return buoyancy on cell centers. """ @@ -86,8 +93,10 @@ function edmfx_nh_pressure_tendency!(Yₜ, Y, p, t, colidx, turbconv_model::EDMF # look for updraft top updraft_top = FT(0) for level in 1:Spaces.nlevels(axes(ᶜz)) - if Spaces.level(Y.c.sgsʲs.:($j).ρa[colidx], level)[] / - Spaces.level(ᶜρʲs.:($j)[colidx], level)[] > a_min + if draft_area( + Spaces.level(Y.c.sgsʲs.:($j).ρa[colidx], level)[], + Spaces.level(ᶜρʲs.:($j)[colidx], level)[], + ) > a_min updraft_top = Spaces.level(ᶜz[colidx], level)[] end end