Skip to content

Commit

Permalink
add an option to turn off tendencies
Browse files Browse the repository at this point in the history
  • Loading branch information
szy21 committed Apr 1, 2024
1 parent d541e0a commit e0aee8b
Show file tree
Hide file tree
Showing 13 changed files with 157 additions and 34 deletions.
12 changes: 12 additions & 0 deletions .buildkite/longruns/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,21 @@ steps:
artifact_paths: "$$JOB_NAME/*"
agents:
slurm_ntasks: 32
slurm_nodes: 2
slurm_time: 24:00:00
env:
JOB_NAME: "longrun_ssp_bw_rhoe_equil_highres"

- label: ":computer: aquaplanet equilmoist clearsky radiation + prognostic edmf diffusion only + 0M microphysics"
command:
- srun julia --project=examples examples/hybrid/driver.jl --config_file $CONFIG_PATH/$$JOB_NAME.yml
artifact_paths: "$$JOB_NAME/*"
agents:
slurm_ntasks: 64
slurm_nodes: 4
slurm_time: 24:00:00
env:
JOB_NAME: "longrun_aquaplanet_rhoe_equil_55km_nz63_clearsky_progedmf_diffonly_0M"

- group: "Low resolution long runs"

Expand Down
6 changes: 3 additions & 3 deletions config/default_configs/default_edmf_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ turbconv:
advection_test:
help: "Switches off all grid-scale and subgrid-scale momentum tendencies [`false` (default), `true`]"
value: false
gs_tendency:
help: "Turns on all grid-scale tendencies [`true` (default), `false`]"
value: true
zero_tendency:
help: "Turns off tendencies [`nothing` (default), `grid_scale`, `subgrid_scale`]"
value: ~
implicit_sgs_advection:
help: "Whether to treat the subgrid-scale vertical advection tendency implicitly [`false` (default), `true`]"
value: false
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
h_elem: 16
z_max: 55000.0
z_elem: 63
dz_bottom: 30.0
dz_top: 3000.0
moist: "equil"
precip_model: "0M"
override_τ_precip: false
rad: "clearsky"
dt_rad: "6hours"
surface_setup: "DefaultMoninObukhov"
turbconv: "prognostic_edmfx"
implicit_diffusion: true
approximate_linear_solve_iters: 2
max_newton_iters_ode: 3
zero_tendency: "subgrid_scale"
prognostic_tke: true
edmfx_upwinding: "first_order"
edmfx_entr_model: "Generalized"
edmfx_detr_model: "Generalized"
edmfx_nh_pressure: false
edmfx_velocity_relaxation: true
edmfx_sgs_mass_flux: false
edmfx_sgs_diffusive_flux: true
rayleigh_sponge: true
dt_save_state_to_disk: "10days"
dt: "100secs"
t_end: "30days"
job_id: "longrun_aquaplanet_rhoe_equil_55km_nz63_clearsky_progedmf_diffonly_0M"
toml: [toml/longrun_aquaplanet_rhoe_equil_55km_nz63_clearsky_progedmf_0M.toml]
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ implicit_diffusion: true
implicit_sgs_advection: true
approximate_linear_solve_iters: 2
max_newton_iters_ode: 3
gs_tendency: false
zero_tendency: "grid_scale"
edmfx_upwinding: first_order
edmfx_entr_model: "Generalized"
edmfx_detr_model: "Generalized"
Expand Down
2 changes: 1 addition & 1 deletion src/ClimaAtmos.jl
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ include(joinpath("utils", "discrete_hydrostatic_balance.jl"))

include(joinpath("prognostic_equations", "pressure_work.jl"))
include(joinpath("prognostic_equations", "zero_velocity.jl"))
include(joinpath("prognostic_equations", "zero_gridscale_tendency.jl"))
include(joinpath("prognostic_equations", "zero_tendency.jl"))

include(joinpath("prognostic_equations", "implicit", "implicit_tendency.jl"))
include(joinpath("prognostic_equations", "implicit", "implicit_solver.jl"))
Expand Down
6 changes: 3 additions & 3 deletions src/prognostic_equations/implicit/implicit_tendency.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ NVTX.@annotate function implicit_tendency!(Yₜ, Y, p, t)
# please DO NOT add additional velocity tendencies after this function
zero_velocity_tendency!(Yₜ, Y, p, t, colidx)

# NOTE: This will zero out all grid-scale tendencies in the simple edmfx test
# please DO NOT add additional grid-scale tendencies after this function
zero_gridscale_tendency!(Yₜ, Y, p, t, colidx)
end
# NOTE: This will zero out all tendencies
# please DO NOT add additional tendencies after this function
zero_tendency!(Yₜ, Y, p, t, p.atmos.tendency_model, p.atmos.turbconv_model)
return nothing
end

Expand Down
6 changes: 3 additions & 3 deletions src/prognostic_equations/remaining_tendency.jl
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,6 @@ NVTX.@annotate function additional_tendency!(Yₜ, Y, p, t)
# please DO NOT add additional velocity tendencies after this function
zero_velocity_tendency!(Yₜ, Y, p, t, colidx)

# NOTE: This will zero out all grid-scale tendencies in the simple edmfx test
# please DO NOT add additional grid-scale tendencies after this function
zero_gridscale_tendency!(Yₜ, Y, p, t, colidx)
end
# TODO: make bycolumn-able
non_orographic_gravity_wave_tendency!(
Expand All @@ -122,4 +119,7 @@ NVTX.@annotate function additional_tendency!(Yₜ, Y, p, t)
t,
p.atmos.orographic_gravity_wave,
)
# NOTE: This will zero out all tendencies
# please DO NOT add additional tendencies after this function
zero_tendency!(Yₜ, Y, p, t, p.atmos.tendency_model, p.atmos.turbconv_model)
end
17 changes: 0 additions & 17 deletions src/prognostic_equations/zero_gridscale_tendency.jl

This file was deleted.

36 changes: 36 additions & 0 deletions src/prognostic_equations/zero_tendency.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
###
### Zero grid-scale or subgrid-scale tendencies
###

zero_tendency!(Yₜ, Y, p, t, _, _) = nothing

function zero_tendency!(Yₜ, Y, p, t, ::NoGridScaleTendency, _)
# turn off all grid-scale tendencies
@. Yₜ.c.ρ = 0
@. Yₜ.c.uₕ = C12(0, 0)
@. Yₜ.f.u₃ = C3(0)
@. Yₜ.c.ρe_tot = 0
for ρχ_name in filter(is_tracer_var, propertynames(Y.c))
@. Yₜ.c.:($$ρχ_name) = 0
end
return nothing
end

function zero_tendency!(
Yₜ,
Y,
p,
t,
::NoSubgridScaleTendency,
::PrognosticEDMFX,
)
# turn off all subgrid-scale tendencies
n = n_prognostic_mass_flux_subdomains(p.atmos.turbconv_model)
for j in 1:n
@. Yₜ.c.sgsʲs.:($$j).ρa = 0
@. Yₜ.f.sgsʲs.:($$j).u₃ = C3(0)
@. Yₜ.c.sgsʲs.:($$j).mse = 0
@. Yₜ.c.sgsʲs.:($$j).q_tot = 0
end
return nothing
end
12 changes: 12 additions & 0 deletions src/solver/model_getters.jl
Original file line number Diff line number Diff line change
Expand Up @@ -438,3 +438,15 @@ function get_tracers(parsed_args)
aerosol_names = Tuple(parsed_args["prescribed_aerosols"])
return (; aerosol_names)
end

function get_tendency_model(parsed_args)
zero_tendency_name = parsed_args["zero_tendency"]
@assert zero_tendency_name in (nothing, "grid_scale", "subgrid_scale")
return if zero_tendency_name == "grid_scale"
NoGridScaleTendency()
elseif zero_tendency_name == "subgrid_scale"
NoSubgridScaleTendency()
elseif isnothing(zero_tendency_name)
UseAllTendency()
end
end
5 changes: 1 addition & 4 deletions src/solver/type_getters.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ function get_atmos(config::AtmosConfig, params)
advection_test = parsed_args["advection_test"]
@assert advection_test in (false, true)

gs_tendency = parsed_args["gs_tendency"]
@assert gs_tendency in (false, true)

edmfx_entr_model = get_entrainment_model(parsed_args)
edmfx_detr_model = get_detrainment_model(parsed_args)

Expand Down Expand Up @@ -62,7 +59,7 @@ function get_atmos(config::AtmosConfig, params)
ls_adv = get_large_scale_advection_model(parsed_args, FT),
edmf_coriolis = get_edmf_coriolis(parsed_args, FT),
advection_test,
gs_tendency,
tendency_model = get_tendency_model(parsed_args),
edmfx_entr_model,
edmfx_detr_model,
edmfx_sgs_mass_flux,
Expand Down
10 changes: 8 additions & 2 deletions src/solver/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,11 @@ quad_type(::SGSQuadrature{N}) where {N} = N #TODO - this seems wrong?
abstract type AbstractSurfaceThermoState end
struct GCMSurfaceThermoState <: AbstractSurfaceThermoState end

abstract type AbstractTendencyModel end
struct UseAllTendency <: AbstractTendencyModel end
struct NoGridScaleTendency <: AbstractTendencyModel end
struct NoSubgridScaleTendency <: AbstractTendencyModel end

# Define broadcasting for types
Base.broadcastable(x::AbstractSurfaceThermoState) = tuple(x)
Base.broadcastable(x::AbstractMoistureModel) = tuple(x)
Expand All @@ -237,6 +242,7 @@ Base.broadcastable(x::DiagnosticEDMFX) = tuple(x)
Base.broadcastable(x::AbstractEntrainmentModel) = tuple(x)
Base.broadcastable(x::AbstractDetrainmentModel) = tuple(x)
Base.broadcastable(x::AbstractSGSamplingType) = tuple(x)
Base.broadcastable(x::AbstractTendencyModel) = tuple(x)

Base.@kwdef struct RadiationDYCOMS_RF01{FT}
"Large-scale divergence"
Expand Down Expand Up @@ -327,7 +333,7 @@ Base.@kwdef struct AtmosModel{
LA,
EC,
AT,
GT,
TM,
EEM,
EDM,
ESMF,
Expand Down Expand Up @@ -359,7 +365,7 @@ Base.@kwdef struct AtmosModel{
ls_adv::LA = nothing
edmf_coriolis::EC = nothing
advection_test::AT = nothing
gs_tendency::GT = nothing
tendency_model::TM = nothing
edmfx_entr_model::EEM = nothing
edmfx_detr_model::EDM = nothing
edmfx_sgs_mass_flux::ESMF = nothing
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
[zd_rayleigh]
value = 35000.0

[alpha_rayleigh_uh]
value = 0.0

[precipitation_timescale]
value = 600

[EDMF_surface_area]
value = 0

[EDMF_min_area]
value = 1.0e-5

[EDMF_max_area]
value = 0.7

[entr_inv_tau]
value = 0.0002

[entr_coeff]
value = 0.2

[min_area_limiter_scale]
value = 0

[min_area_limiter_power]
value = 100

[detr_inv_tau]
value = 0

[detr_coeff]
value = 0

[detr_buoy_coeff]
value = 0

[detr_vertdiv_coeff]
value = 0

[detr_massflux_vertdiv_coeff]
value = 1

[pressure_normalmode_drag_coeff]
value = 40.0

0 comments on commit e0aee8b

Please sign in to comment.