Skip to content

Commit

Permalink
Merge pull request #2607 from CliMA/zs/dy/progedmf_implicit_diffusion
Browse files Browse the repository at this point in the history
Make diffusion and advection implicit in prognostic edmf
  • Loading branch information
szy21 authored Mar 21, 2024
2 parents 9771c16 + 6c29cf0 commit e7074c0
Show file tree
Hide file tree
Showing 18 changed files with 361 additions and 43 deletions.
2 changes: 1 addition & 1 deletion config/gpu_configs/gpu_prognostic_edmfx_aquaplanet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ turbconv: prognostic_edmfx
prognostic_tke: true
edmfx_upwinding: first_order
edmfx_entr_model: "Generalized"
edmfx_detr_model: "ConstantArea"
edmfx_detr_model: "Generalized"
edmfx_nh_pressure: true
edmfx_velocity_relaxation: true
edmfx_sgs_mass_flux: true
Expand Down
2 changes: 1 addition & 1 deletion config/model_configs/prognostic_edmfx_aquaplanet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ turbconv: prognostic_edmfx
prognostic_tke: true
edmfx_upwinding: first_order
edmfx_entr_model: "Generalized"
edmfx_detr_model: "ConstantArea"
edmfx_detr_model: "Generalized"
edmfx_nh_pressure: true
edmfx_velocity_relaxation: true
edmfx_sgs_mass_flux: true
Expand Down
6 changes: 5 additions & 1 deletion config/model_configs/prognostic_edmfx_bomex_box.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,16 @@ edmf_coriolis: "Bomex"
ls_adv: "Bomex"
surface_setup: "Bomex"
turbconv: "prognostic_edmfx"
implicit_diffusion: true
approximate_linear_solve_iters: 2
max_newton_iters_ode: 3
edmfx_upwinding: first_order
edmfx_entr_model: "Generalized"
edmfx_detr_model: "Generalized"
edmfx_sgs_mass_flux: true
edmfx_sgs_diffusive_flux: true
edmfx_nh_pressure: true
edmfx_velocity_relaxation: true
prognostic_tke: true
moist: "equil"
config: "box"
Expand All @@ -23,7 +27,7 @@ y_elem: 2
z_elem: 60
z_stretch: false
perturb_initstate: false
dt: "10secs"
dt: "50secs"
t_end: "6hours"
dt_save_state_to_disk: "30mins"
toml: [toml/prognostic_edmfx_bomex_box.toml]
Expand Down
6 changes: 5 additions & 1 deletion config/model_configs/prognostic_edmfx_dycoms_rf01_box.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,17 @@ edmf_coriolis: DYCOMS_RF01
rad: DYCOMS_RF01
surface_setup: DYCOMS_RF01
turbconv: prognostic_edmfx
implicit_diffusion: true
approximate_linear_solve_iters: 2
max_newton_iters_ode: 3
edmfx_upwinding: first_order
edmfx_sgsflux_upwinding: first_order
edmfx_entr_model: "Generalized"
edmfx_detr_model: "Generalized"
edmfx_sgs_mass_flux: true
edmfx_sgs_diffusive_flux: true
edmfx_nh_pressure: true
edmfx_velocity_relaxation: true
prognostic_tke: true
moist: equil
config: box
Expand All @@ -23,7 +27,7 @@ x_elem: 2
y_elem: 2
z_elem: 30
z_stretch: false
dt: 10secs
dt: 40secs
t_end: 4hours
dt_save_state_to_disk: 10mins
toml: [toml/prognostic_edmfx_dycoms_rf01_box.toml]
Expand Down
8 changes: 6 additions & 2 deletions config/model_configs/prognostic_edmfx_gabls_box.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@ initial_condition: GABLS
edmf_coriolis: GABLS
surface_setup: GABLS
turbconv: "prognostic_edmfx"
implicit_diffusion: true
approximate_linear_solve_iters: 2
max_newton_iters_ode: 3
edmfx_upwinding: "first_order"
edmfx_entr_model: "Generalized"
edmfx_detr_model: "ConstantArea"
edmfx_detr_model: "Generalized"
edmfx_sgs_mass_flux: true
edmfx_sgs_diffusive_flux: true
edmfx_nh_pressure: true
edmfx_velocity_relaxation: true
prognostic_tke: true
moist: "equil"
config: "box"
Expand All @@ -20,7 +24,7 @@ x_elem: 2
y_elem: 2
z_elem: 8
z_stretch: false
dt: "100secs"
dt: "60secs"
t_end: "9hours"
dt_save_state_to_disk: "30mins"
perturb_initstate: false
Expand Down
11 changes: 7 additions & 4 deletions config/model_configs/prognostic_edmfx_simpleplume_column.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,25 @@ job_id: "prognostic_edmfx_simpleplume_column"
initial_condition: "SimplePlume"
surface_setup: "SimplePlume"
turbconv: "prognostic_edmfx"
implicit_diffusion: true
approximate_linear_solve_iters: 2
max_newton_iters_ode: 3
gs_tendency: false
edmfx_upwinding: first_order
edmfx_entr_model: "Generalized"
edmfx_detr_model: "Generalized"
edmfx_sgs_mass_flux: true
edmfx_sgs_diffusive_flux: true
edmfx_sgs_mass_flux: false
edmfx_sgs_diffusive_flux: false
edmfx_nh_pressure: true
edmfx_velocity_relaxation: true
prognostic_tke: true
prognostic_tke: false
moist: "equil"
config: "column"
z_max: 4e3
z_elem: 80
z_stretch: false
perturb_initstate: false
dt: "1secs"
dt: 20secs"
t_end: "12hours"
dt_save_to_disk: "10mins"
toml: [toml/prognostic_edmfx_simpleplume.toml]
Expand Down
3 changes: 2 additions & 1 deletion config/model_configs/prognostic_edmfx_trmm_column.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ surface_setup: TRMM_LBA
turbconv: prognostic_edmfx
edmfx_upwinding: first_order
edmfx_entr_model: "Generalized"
edmfx_detr_model: "ConstantArea"
edmfx_detr_model: "Generalized"
edmfx_sgs_mass_flux: true
edmfx_sgs_diffusive_flux: true
edmfx_nh_pressure: true
edmfx_velocity_relaxation: true
prognostic_tke: true
moist: equil
apply_limiter: false
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
job_id: flame_perf_target_prognostic_edmfx_aquaplanet
surface_setup: DefaultExchangeCoefficients
surface_setup: DefaultExchangeCoefficients
rad: gray
vert_diff: "false"
turbconv: prognostic_edmfx
implicit_diffusion: false
prognostic_tke: true
edmfx_upwinding: first_order
edmfx_entr_model: "Generalized"
edmfx_detr_model: "ConstantArea"
edmfx_detr_model: "Generalized"
edmfx_nh_pressure: true
edmfx_sgs_mass_flux: true
edmfx_sgs_diffusive_flux: true
Expand Down
2 changes: 2 additions & 0 deletions src/cache/cache.jl
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ function build_cache(Y, atmos, params, surface_setup, sim_info)
ᶠcoord = Fields.local_geometry_field(Y.f).coordinates
grav = FT(CAP.grav(params))
ᶜΦ = grav .* ᶜcoord.z
ᶠΦ = grav .* ᶠcoord.z

if atmos.numerics.use_reference_state
R_d = FT(CAP.R_d(params))
Expand Down Expand Up @@ -186,6 +187,7 @@ function build_cache(Y, atmos, params, surface_setup, sim_info)
core = (
ᶜΦ,
ᶠgradᵥ_ᶜΦ = ᶠgradᵥ.(ᶜΦ),
ᶜgradᵥ_ᶠΦ = ᶜgradᵥ.(ᶠΦ),
ᶜρ_ref,
ᶜp_ref,
ᶜT = similar(Y.c, FT),
Expand Down
6 changes: 2 additions & 4 deletions src/prognostic_equations/advection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -217,15 +217,13 @@ function edmfx_sgs_vertical_advection_tendency!(
ᶜa_scalar = p.scratch.ᶜtemp_scalar
ᶜu₃ʲ = p.scratch.ᶜtemp_C3
ᶜKᵥʲ = p.scratch.ᶜtemp_scalar_2
ᶜinterp_lb = Operators.LeftBiasedF2C()
ᶜinterp_rb = Operators.RightBiasedF2C()
for j in 1:n
# TODO: Add a biased GradientF2F operator in ClimaCore
@. ᶜu₃ʲ[colidx] = ᶜinterp(Y.f.sgsʲs.:($$j).u₃[colidx])
@. ᶜKᵥʲ[colidx] = ifelse(
ᶜu₃ʲ[colidx].components.data.:1 > 0,
ᶜinterp_lb(ᶠKᵥʲs.:($$j)[colidx]),
ᶜinterp_rb(ᶠKᵥʲs.:($$j)[colidx]),
ᶜleft_bias(ᶠKᵥʲs.:($$j)[colidx]),
ᶜright_bias(ᶠKᵥʲs.:($$j)[colidx]),
)
# For the updraft u_3 equation, we assume the grid-mean to be hydrostatic
# and calcuate the buoyancy term relative to the grid-mean density.
Expand Down
Loading

0 comments on commit e7074c0

Please sign in to comment.