Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change edmfx advection #2121

Merged
merged 1 commit into from
Sep 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 16 additions & 13 deletions config/model_configs/edmfx_adv_test_box.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
dt_save_to_disk: "100secs"
job_id: "edmfx_adv_test_box"
initial_condition: "MoistAdiabaticProfileEDMFX"
x_max: 10000.0
hyperdiff: "true"
z_elem: 45
dt: "10secs"
t_end: "1000secs"
y_max: 10000.0
y_elem: 2
advection_test: true
turbconv: "edmfx"
x_elem: 2
dz_bottom: 30.0
ode_algo: "SSP33ShuOsher"
edmfx_upwinding: "first_order"
config: "box"
advection_test: true
kappa_4: 1.0e8
job_id: "edmfx_adv_test_box"
moist: "equil"
hyperdiff: "true"
kappa_4: 1e8
x_max: 1e4
y_max: 1e4
z_max: 3e4
x_elem: 2
y_elem: 2
z_elem: 45
dz_bottom: 30.0
dt: "10secs"
t_end: "3600secs"
dt_save_to_disk: "100secs"
toml: [toml/edmfx_box_advection.toml]
30 changes: 20 additions & 10 deletions src/prognostic_equations/advection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,9 @@ NVTX.@annotate function explicit_vertical_advection_tendency!(Yₜ, Y, p, t)
(; ᶜh_totʲs) = n > 0 && is_total_energy ? p : all_nothing
(; ᶠu³⁰) = advect_tke ? p : all_nothing
ᶜρa⁰ = advect_tke ? (n > 0 ? p.ᶜρa⁰ : Y.c.ρ) : nothing
ᶜρ⁰ = advect_tke ? (n > 0 ? p.ᶜρ⁰ : Y.c.ρ) : nothing
ᶜtke⁰ = advect_tke ? (n > 0 ? p.ᶜspecific⁰.tke : p.ᶜtke⁰) : nothing
ᶜ1 = p.ᶜtemp_scalar
ᶜa_scalar = p.ᶜtemp_scalar
ᶜω³ = p.ᶜtemp_CT3
ᶠω¹² = p.ᶠtemp_CT12
ᶠω¹²ʲs = p.ᶠtemp_CT12ʲs
Expand Down Expand Up @@ -139,24 +140,28 @@ NVTX.@annotate function explicit_vertical_advection_tendency!(Yₜ, Y, p, t)

# TODO: Move this to implicit_vertical_advection_tendency!.
for j in 1:n
@. ᶜ1[colidx] = one(Y.c.ρ[colidx])
@. ᶜa_scalar[colidx] =
draft_area(Y.c.sgsʲs.:($$j).ρa[colidx], ᶜρʲs.:($$j)[colidx])
vertical_transport!(
Yₜ.c.sgsʲs.:($j).ρa[colidx],
ᶜJ[colidx],
Y.c.sgsʲs.:($j).ρa[colidx],
ᶜρʲs.:($j)[colidx],
ᶠu³ʲs.:($j)[colidx],
ᶜ1[colidx],
ᶜa_scalar[colidx],
dt,
edmfx_upwinding,
)

if :ρae_tot in propertynames(Yₜ.c.sgsʲs.:($j))
@. ᶜa_scalar[colidx] =
ᶜh_totʲs.:($$j)[colidx] *
draft_area(Y.c.sgsʲs.:($$j).ρa[colidx], ᶜρʲs.:($$j)[colidx])
vertical_transport!(
Yₜ.c.sgsʲs.:($j).ρae_tot[colidx],
ᶜJ[colidx],
Y.c.sgsʲs.:($j).ρa[colidx],
ᶜρʲs.:($j)[colidx],
ᶠu³ʲs.:($j)[colidx],
ᶜh_totʲs.:($j)[colidx],
ᶜa_scalar[colidx],
dt,
edmfx_upwinding,
)
Expand All @@ -165,12 +170,15 @@ NVTX.@annotate function explicit_vertical_advection_tendency!(Yₜ, Y, p, t)
for (ᶜρaχʲₜ, ᶜχʲ, χ_name) in
matching_subfields(Yₜ.c.sgsʲs.:($j), ᶜspecificʲs.:($j))
χ_name == :e_tot && continue
@. ᶜa_scalar[colidx] =
ᶜχʲ[colidx] *
draft_area(Y.c.sgsʲs.:($$j).ρa[colidx], ᶜρʲs.:($$j)[colidx])
vertical_transport!(
ᶜρaχʲₜ[colidx],
ᶜJ[colidx],
Y.c.sgsʲs.:($j).ρa[colidx],
ᶜρʲs.:($j)[colidx],
ᶠu³ʲs.:($j)[colidx],
ᶜχʲ[colidx],
ᶜa_scalar[colidx],
dt,
edmfx_upwinding,
)
Expand All @@ -179,12 +187,14 @@ NVTX.@annotate function explicit_vertical_advection_tendency!(Yₜ, Y, p, t)

# TODO: Move this to implicit_vertical_advection_tendency!.
if use_prognostic_tke(turbconv_model) # advect_tke triggers allocations
@. ᶜa_scalar[colidx] =
ᶜtke⁰[colidx] * draft_area(ᶜρa⁰[colidx], ᶜρ⁰[colidx])
vertical_transport!(
Yₜ.c.sgs⁰.ρatke[colidx],
ᶜJ[colidx],
ᶜρa⁰[colidx],
ᶜρ⁰[colidx],
ᶠu³⁰[colidx],
ᶜtke⁰[colidx],
ᶜa_scalar[colidx],
dt,
edmfx_upwinding,
)
Expand Down
6 changes: 6 additions & 0 deletions toml/edmfx_box.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,9 @@ type = "float"
alias = "surface_area"
value = 0.1
type = "float"

[EDMF_min_area]
alias = "min_area"
value = 1.0e-2
type = "float"
description = "Minimum area fraction per updraft. Parameter not described in the literature."
10 changes: 10 additions & 0 deletions toml/edmfx_box_advection.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[EDMF_surface_area]
alias = "surface_area"
value = 0
type = "float"

[EDMF_min_area]
alias = "min_area"
value = 1.0e-2
trontrytel marked this conversation as resolved.
Show resolved Hide resolved
type = "float"
description = "Minimum area fraction per updraft. Parameter not described in the literature."
Loading