Skip to content

Commit

Permalink
Remove params from config, add TOMLs for overrides
Browse files Browse the repository at this point in the history
  • Loading branch information
nefrathenrici committed Aug 25, 2023
1 parent 8d111f7 commit d400692
Show file tree
Hide file tree
Showing 41 changed files with 179 additions and 66 deletions.
20 changes: 1 addition & 19 deletions config/default_configs/default_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -243,22 +243,4 @@ prognostic_tke:
prognostic_surface:
help: "Determines if surface temperature is prognostic [`false` (default), , `true`, `PrognosticSurfaceTemperature`, `PrescribedSurfaceTemperature`]"
value: "false"
# Will be moved to ClimaParameters.jl
C_E:
help: "Bulk transfer coefficient"
value: 0.0044
alpha_rayleigh_w:
help: "Rayleigh sponge coefficient for vertical velocity"
value: 1.0
alpha_rayleigh_uh:
help: "Rayleigh sponge coefficient for horizontal velocity"
value: 0.0
zd_viscous:
help: "Viscous sponge height"
value: 15000.0
zd_rayleigh:
help: "Rayleigh sponge height"
value: 15000.0
kappa_2_sponge:
help: "Viscous sponge coefficient"
value: 1.0e6

Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
rad: "clearsky"
dt_save_to_disk: "10days"
rayleigh_sponge: true
zd_rayleigh: 35000.0
z_elem: 50
dt: "150secs"
surface_setup: "DefaultMoninObukhov"
Expand All @@ -11,9 +10,9 @@ dz_bottom: 30.0
vert_diff: "true"
h_elem: 16
kappa_4: 1.0e16
alpha_rayleigh_w: 10.0
FLOAT_TYPE: "Float64"
z_max: 45000.0
precip_model: "0M"
job_id: "longrun_aquaplanet_rhoe_equil_clearsky_highres_hightop_rayleigh35e3_float64"
moist: "equil"
toml: toml/longrun_aquaplanet_rhoe_equil_clearsky_highres_hightop_rayleigh35e3_float64.toml
5 changes: 2 additions & 3 deletions config/longrun_configs/longrun_compressible_edmf_trmm.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

config: "column"
FLOAT_TYPE: "Float64"
hyperdiff: "false"
Expand All @@ -12,7 +11,7 @@ z_elem: 90
z_stretch: false
z_max: 17000
rayleigh_sponge: true
zd_rayleigh: 15000
job_id: "longrun_compressible_edmf_trmm"
dt: "0.2secs"
t_end: "3.8hours"
t_end: "3.8hours"
toml: longrun_compressible_edmf_trmm.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ kappa_4: 1.0e16
forcing: "held_suarez"
dt: "300secs"
rayleigh_sponge: true
zd_rayleigh: 35000.0
job_id: "longrun_hs_rhoe_equilmoist_nz63_0M_55km_rs35km"
toml: toml/longrun_hs_rhoe_equilmoist_nz63_0M_55km_rs35km.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
dt_save_to_disk: "10days"
rayleigh_sponge: true
zd_rayleigh: 30000.0
z_elem: 50
dt: "150secs"
t_end: "300days"
Expand All @@ -10,8 +9,8 @@ vert_diff: "true"
h_elem: 16
kappa_4: 1.0e16
forcing: "held_suarez"
alpha_rayleigh_w: 10.0
z_max: 45000.0
precip_model: "0M"
job_id: "longrun_hs_rhoe_equilmoist_highres_hightop_rayleigh30e3"
moist: "equil"
toml: toml/longrun_hs_rhoe_equilmoist_highres_hightop_rayleigh30e3.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ vert_diff: "true"
moist: "equil"
precip_model: "0M"
rayleigh_sponge: true
alpha_rayleigh_w: 10.0
zd_rayleigh: 35000.0
forcing: "held_suarez"
job_id: "longrun_hs_rhoe_equilmoist_nz64_0M_55km_rs35km"
toml: toml/longrun_hs_rhoe_equilmoist_nz64_0M_55km_rs35km.toml
2 changes: 1 addition & 1 deletion config/model_configs/bomex_box_rhoe.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ dt: "0.5secs"
surface_setup: "Bomex"
perturb_initstate: false
t_end: "600secs"
C_E: 0.044
y_max: 10000.0
z_stretch: false
vert_diff: "true"
Expand All @@ -17,3 +16,4 @@ z_max: 3000.0
ls_adv: "Bomex"
job_id: "bomex_box_rhoe"
moist: "equil"
toml: toml/bomex_box_rhoe.toml
2 changes: 1 addition & 1 deletion config/model_configs/edmf_trmm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ FLOAT_TYPE: "Float64"
z_max: 16400.0
precip_model: "1M"
regression_test: true
alpha_rayleigh_uh: 0.0001
dt_save_to_sol: "5mins"
job_id: "edmf_trmm"
rad: "TRMM_LBA"
toml: toml/edmf_trmm.toml
2 changes: 1 addition & 1 deletion config/model_configs/edmfx_bomex_box_v1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ surface_setup: "Bomex"
perturb_initstate: false
edmfx_entr_detr: true
t_end: "10800secs"
C_E: 0.044
y_max: 100000.0
y_elem: 2
turbconv: "edmfx"
Expand All @@ -24,3 +23,4 @@ z_max: 3000.0
ls_adv: "Bomex"
job_id: "edmfx_bomex_box_v1"
moist: "equil"
toml: toml/edmfx_bomex_box_v1.toml
2 changes: 1 addition & 1 deletion config/model_configs/edmfx_bomex_box_v2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ surface_setup: "Bomex"
perturb_initstate: false
edmfx_entr_detr: true
t_end: "10800secs"
C_E: 0.044
y_max: 100000.0
y_elem: 2
turbconv: "edmfx"
Expand All @@ -25,3 +24,4 @@ z_max: 3000.0
ls_adv: "Bomex"
job_id: "edmfx_bomex_box_v2"
moist: "equil"
toml: toml/edmfx_bomex_box_v2.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ dz_bottom: 200.0
use_reference_state: false
config: "plane"
kappa_4: 1.0e6
alpha_rayleigh_w: 0.1
z_max: 25000.0
topography: "Agnesi"
job_id: "plane_agnesi_mountain_test_stretched"
toml: toml/plane_agnesi_mountain_test_stretched.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ x_elem: 80
use_reference_state: false
config: "plane"
kappa_4: 1.0e6
alpha_rayleigh_w: 0.1
z_max: 25000.0
topography: "Agnesi"
job_id: "plane_agnesi_mountain_test_uniform"
toml: toml/plane_agnesi_mountain_test_uniform.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use_reference_state: false
ode_algo: "SSP33ShuOsher"
config: "plane"
kappa_4: 5.0e7
alpha_rayleigh_w: 0.1
z_max: 25000.0
topography: "Schar"
job_id: "plane_schar_mountain_test_stretched"
toml: toml/plane_schar_mountain_test_stretched.toml
2 changes: 1 addition & 1 deletion config/model_configs/plane_schar_mountain_test_uniform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use_reference_state: false
ode_algo: "SSP33ShuOsher"
config: "plane"
kappa_4: 5.0e7
alpha_rayleigh_w: 0.1
z_max: 25000.0
topography: "Schar"
job_id: "plane_schar_mountain_test_uniform"
toml: toml/plane_schar_mountain_test_uniform.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
rad: "allskywithclear"
dt_save_to_disk: "18hours"
rayleigh_sponge: true
zd_rayleigh: 30000.0
orographic_gravity_wave: "raw_topo"
z_elem: 25
dt: "400secs"
Expand All @@ -17,3 +16,4 @@ regression_test: true
surface_temperature: "ZonallyAsymmetric"
job_id: "sphere_aquaplanet_rhoe_equilmoist_allsky_gw_raw_zonallyasymmetric"
moist: "equil"
toml: toml/sphere_aquaplanet_rhoe_equilmoist_allsky_gw_raw_zonallyasymmetric.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
rad: "allskywithclear"
dt_save_to_disk: "18hours"
rayleigh_sponge: true
zd_rayleigh: 30000.0
orographic_gravity_wave: "gfdl_restart"
z_elem: 25
dt: "400secs"
Expand All @@ -16,3 +15,4 @@ precip_model: "0M"
regression_test: true
job_id: "sphere_aquaplanet_rhoe_equilmoist_allsky_gw_res"
moist: "equil"
toml: toml/sphere_aquaplanet_rhoe_equilmoist_allsky_gw_res.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
dt_save_to_disk: "4days"
rayleigh_sponge: true
zd_rayleigh: 30000.0
zd_viscous: 30000.0
dt: "450secs"
z_elem: 25
t_end: "4days"
Expand All @@ -14,3 +12,4 @@ regression_test: true
viscous_sponge: true
job_id: "sphere_held_suarez_rhoe_equilmoist_hightop_sponge"
moist: "equil"
toml: toml/sphere_held_suarez_rhoe_equilmoist_hightop_sponge.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
dt_save_to_disk: "3days"
rayleigh_sponge: true
zd_rayleigh: 30000.0
zd_viscous: 30000.0
dt: "300secs"
z_elem: 25
tracer_upwinding: first_order
Expand All @@ -17,3 +15,4 @@ viscous_sponge: true
job_id: "sphere_ssp_first_tracer_energy_upwind_held_suarez_rhoe_equilmoist_hightop_sponge"
moist: "equil"
apply_limiter: true
toml: toml/sphere_ssp_first_tracer_energy_upwind_held_suarez_rhoe_equilmoist_hightop_sponge.toml
2 changes: 1 addition & 1 deletion config/perf_configs/flame/perf_gw.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
rad: "allskywithclear"
rayleigh_sponge: true
zd_rayleigh: 30000.0
orographic_gravity_wave: "raw_topo"
z_elem: 25
dt: "1secs"
Expand All @@ -14,3 +13,4 @@ z_max: 45000.0
precip_model: "0M"
job_id: "flame_perf_gw"
moist: "equil"
toml: toml/flame_perf_gw.toml
17 changes: 16 additions & 1 deletion src/parameters/Parameters.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const ACAP = AbstractClimaAtmosParameters

Base.broadcastable(param_set::ACAP) = tuple(param_set)

Base.@kwdef struct ClimaAtmosParameters{FT, TP, RP, IP, MPP, SFP, TCP} <: ACAP
Base.@kwdef struct ClimaAtmosParameters{FT, TP, RP, IP, MPP, SFP, TCP, SP} <: ACAP
Omega::FT
f_plane_coriolis_frequency::FT
planet_radius::FT
Expand All @@ -26,11 +26,26 @@ Base.@kwdef struct ClimaAtmosParameters{FT, TP, RP, IP, MPP, SFP, TCP} <: ACAP
microphysics_params::MPP
surfacefluxes_params::SFP
turbconv_params::TCP
sponge_params::SP
entr_coeff::FT = 1
detr_coeff::FT = 0.001
# TODO: Figure out a better place for these held-suarez parameters
ΔT_y_dry::FT
ΔT_y_wet::FT
C_E::FT
end

"""
SpongeParameters{FT}
Parameters for both the viscous and rayleigh sponge.
"""
Base.@kwdef struct SpongeParameters{FT}
alpha_rayleigh_w::FT
alpha_rayleigh_uh::FT
zd_viscous::FT
zd_rayleigh::FT
kappa_2_sponge::FT
end

Base.eltype(::ClimaAtmosParameters{FT}) where {FT} = FT
Expand Down
16 changes: 13 additions & 3 deletions src/parameters/create_parameters.jl
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ function create_climaatmos_parameter_set(
aliases = setdiff(aliases, ["thermo_params"])
pairs = CP.get_parameter_values!(toml_dict, aliases, "CloudMicrophysics")
pairs = override_climaatmos_defaults((; pairs...), overrides)

microphys_params = CM.Parameters.CloudMicrophysicsParameters{FTD, TP}(;
pairs...,
thermo_params,
Expand Down Expand Up @@ -98,7 +99,13 @@ function create_climaatmos_parameter_set(

pairs = CP.get_parameter_values!(
toml_dict,
["Omega", "planet_radius", "astro_unit", "ΔT_y_dry", "ΔT_y_wet"],
["alpha_rayleigh_w", "alpha_rayleigh_uh", "zd_viscous", "zd_rayleigh", "kappa_2_sponge"],
)
sponge_params = CAP.SpongeParameters(; pairs...)

pairs = CP.get_parameter_values!(
toml_dict,
["Omega", "planet_radius", "astro_unit", "ΔT_y_dry", "ΔT_y_wet", "C_E"],
"ClimaAtmos",
)
pairs = (; pairs...) # convert to NamedTuple
Expand All @@ -121,8 +128,10 @@ function create_climaatmos_parameter_set(
turbconv_params = tc_params,
entr_coeff = FTD(parsed_args["entr_coeff"]),
detr_coeff = FTD(parsed_args["detr_coeff"]),
ΔT_y_dry = FTD(pairs.ΔT_y_dry),
ΔT_y_wet = FTD(pairs.ΔT_y_wet),
ΔT_y_dry = pairs.ΔT_y_dry,
ΔT_y_wet = pairs.ΔT_y_wet,
C_E = pairs.C_E,
sponge_params
)
# logfilepath = joinpath(@__DIR__, "logfilepath_$FT.toml")
# CP.log_parameter_information(toml_dict, logfilepath)
Expand All @@ -134,6 +143,7 @@ function create_parameter_set(config::AtmosConfig)
(; toml_dict, parsed_args) = config
FT = eltype(config)
dt = FT(CA.time_to_seconds(parsed_args["dt"]))

return if CA.is_column_edmf(parsed_args)
overrides = (; MSLP = 100000.0, τ_precip = dt)
create_climaatmos_parameter_set(toml_dict, parsed_args, overrides)
Expand Down
21 changes: 9 additions & 12 deletions src/solver/model_getters.jl
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ end
function get_vertical_diffusion_model(
diffuse_momentum,
parsed_args,
params,
::Type{FT},
) where {FT}
vert_diff_name = parsed_args["vert_diff"]
return if vert_diff_name in ("false", false, "none")
nothing
elseif vert_diff_name in ("true", true, "VerticalDiffusion")
C_E = FT(parsed_args["C_E"])
VerticalDiffusion{diffuse_momentum, FT}(; C_E)
VerticalDiffusion{diffuse_momentum, FT}(; C_E = params.C_E)
else
error("Uncaught diffusion model `$vert_diff_name`.")
end
Expand All @@ -76,30 +76,27 @@ function get_surface_model(parsed_args)
end
end

function get_viscous_sponge_model(parsed_args, ::Type{FT}) where {FT}
function get_viscous_sponge_model(parsed_args, sponge_params, ::Type{FT}) where {FT}
vs_name = parsed_args["viscous_sponge"]
return if vs_name in ("false", false, "none")
nothing
elseif vs_name in ("true", true, "ViscousSponge")
zd = parsed_args["zd_viscous"]
κ₂ = parsed_args["kappa_2_sponge"]
zd = sponge_params.zd_viscous
κ₂ = sponge_params.kappa_2_sponge
ViscousSponge{FT}(; zd, κ₂)
else
error("Uncaught viscous sponge model `$vs_name`.")
end
end

function get_rayleigh_sponge_model(parsed_args, ::Type{FT}) where {FT}
function get_rayleigh_sponge_model(parsed_args, sponge_params, ::Type{FT}) where {FT}
rs_name = parsed_args["rayleigh_sponge"]
return if rs_name in ("false", false)
nothing
elseif rs_name in ("true", true, "RayleighSponge")
zd = parsed_args["zd_rayleigh"]
α_uₕ = parsed_args["alpha_rayleigh_uh"]
α_w = parsed_args["alpha_rayleigh_w"]
isnothing(zd) && (zd = FT(15e3))
isnothing(α_uₕ) && (α_uₕ = FT(1e-4))
isnothing(α_w) && (α_w = FT(1))
zd = sponge_params.zd_rayleigh
α_uₕ = sponge_params.alpha_rayleigh_uh
α_w = sponge_params.alpha_rayleigh_w
RayleighSponge{FT}(; zd, α_uₕ, α_w)
else
error("Uncaught rayleigh sponge model `$rs_name`.")
Expand Down
Loading

0 comments on commit d400692

Please sign in to comment.