Skip to content

Commit

Permalink
Merge #2127
Browse files Browse the repository at this point in the history
2127: add a function to get draft area r=trontrytel a=trontrytel



Co-authored-by: Anna Jaruga <ajaruga@caltech.edu>
  • Loading branch information
bors[bot] and trontrytel authored Sep 20, 2023
2 parents 5f855e5 + 00c4572 commit ed3e76a
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/cache/diagnostic_edmf_precomputed_quantities.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions src/cache/edmf_precomputed_quantities.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
Expand All @@ -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)),
Expand Down
6 changes: 3 additions & 3 deletions src/cache/precomputed_quantities.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
13 changes: 11 additions & 2 deletions src/prognostic_equations/edmfx_closures.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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.
"""
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit ed3e76a

Please sign in to comment.