Skip to content

Commit

Permalink
Merge pull request #3481 from CliMA/ne/params
Browse files Browse the repository at this point in the history
Add float-type constructor for ClimaAtmosParameters
  • Loading branch information
nefrathenrici authored Dec 19, 2024
2 parents 17e4eb2 + c2d164d commit 8f383d0
Show file tree
Hide file tree
Showing 18 changed files with 188 additions and 185 deletions.
2 changes: 1 addition & 1 deletion calibration/experiments/gcm_driven_scm/helper_funcs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ CLIMADIAGNOSTICS_LES_NAME_MAP =

"""Get z cell centers coordinates for CA run, given config. """
function get_z_grid(atmos_config; z_max = nothing)
params = CA.create_parameter_set(atmos_config)
params = CA.ClimaAtmosParameters(atmos_config)
spaces =
CA.get_spaces(atmos_config.parsed_args, params, atmos_config.comms_ctx)
coord = CA.Fields.coordinate_field(spaces.center_space)
Expand Down
3 changes: 0 additions & 3 deletions config/default_configs/default_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -259,9 +259,6 @@ implicit_diffusion:
approximate_linear_solve_iters:
help: "Number of iterations for the approximate linear solve (used when `implicit_diffusion` is true)"
value: 1
override_precip_timescale:
help: "If true, sets τ_precip to dt. Otherwise, τ_precip is set to the value in the toml dictionary"
value: true
output_default_diagnostics:
help: "Output the default diagnostics associated to the selected atmospheric model"
value: true
Expand Down
1 change: 0 additions & 1 deletion config/longrun_configs/amip_target_diagedmf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ dt_save_state_to_disk: "20days"
moist: "equil"
cloud_model: "quadrature_sgs"
precip_model: "0M"
override_precip_timescale: false
rad: "allskywithclear"
dt_rad: "1hours"
dt_cloud_fraction: "1hours"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,4 @@ edmfx_nh_pressure: true
edmfx_sgs_mass_flux: true
edmfx_sgs_diffusive_flux: true
precip_model: "0M"
override_precip_timescale: false
toml: [toml/longrun_aquaplanet_diagedmf.toml]
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,4 @@ edmfx_filter: true
edmfx_sgs_mass_flux: false
edmfx_sgs_diffusive_flux: true
precip_model: "0M"
override_precip_timescale: false
toml: [toml/longrun_aquaplanet_progedmf.toml]
1 change: 0 additions & 1 deletion config/model_configs/diagnostic_edmfx_trmm_box_0M.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ moist: equil
cloud_model: "quadrature_sgs"
call_cloud_diagnostics_per_stage: true
precip_model: "0M"
override_precip_timescale: false
config: box
x_max: 1e8
y_max: 1e8
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ moist: equil
cloud_model: "quadrature_sgs"
call_cloud_diagnostics_per_stage: true
precip_model: "1M"
override_precip_timescale: false
config: box
x_max: 1e8
y_max: 1e8
Expand Down
1 change: 0 additions & 1 deletion config/model_configs/rcemipii_box_diagnostic_edmfx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ edmfx_sgs_diffusive_flux: true
rayleigh_sponge: true
moist: equil
precip_model: 0M
override_precip_timescale: false
dt: 30secs
t_end: 3600secs
dt_save_state_to_disk: 12hours
Expand Down
1 change: 0 additions & 1 deletion config/model_configs/rcemipii_sphere_diagnostic_edmfx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ edmfx_sgs_diffusive_flux: true
rayleigh_sponge: true
moist: equil
precip_model: 0M
override_precip_timescale: false
dt: 100secs
t_end: 12hours
dt_save_state_to_disk: 12hours
Expand Down
15 changes: 8 additions & 7 deletions src/cache/diagnostic_edmf_precomputed_quantities.jl
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,8 @@ NVTX.@annotate function set_diagnostic_edmf_precomputed_quantities_do_integral!(
end

thermo_params = CAP.thermodynamics_params(params)
microphys_params = CAP.microphysics_precipitation_params(params)
microphys_0m_params = CAP.microphysics_0m_params(params)
microphys_1m_params = CAP.microphysics_1m_params(params)
turbconv_params = CAP.turbconv_params(params)

ᶠΦ = p.scratch.ᶠtemp_scalar
Expand Down Expand Up @@ -541,7 +542,7 @@ NVTX.@annotate function set_diagnostic_edmf_precomputed_quantities_do_integral!(
@. S_q_totʲ_prev_level = q_tot_precipitation_sources(
precip_model,
thermo_params,
microphys_params,
microphys_0m_params,
dt,
q_totʲ_prev_level,
tsʲ_prev_level,
Expand All @@ -560,7 +561,7 @@ NVTX.@annotate function set_diagnostic_edmf_precomputed_quantities_do_integral!(
tsʲ_prev_level,
Φ_prev_level,
dt,
microphys_params,
microphys_1m_params,
thermo_params,
)
end
Expand Down Expand Up @@ -1032,7 +1033,7 @@ NVTX.@annotate function set_diagnostic_edmf_precomputed_quantities_env_precipita
precip_model::Microphysics0Moment,
)
thermo_params = CAP.thermodynamics_params(p.params)
microphys_params = CAP.microphysics_precipitation_params(p.params)
microphys_0m_params = CAP.microphysics_0m_params(p.params)
(; dt) = p
(; ᶜts, ᶜSqₜᵖ⁰) = p.precomputed
(; q_tot) = p.precomputed.ᶜspecific
Expand All @@ -1041,7 +1042,7 @@ NVTX.@annotate function set_diagnostic_edmf_precomputed_quantities_env_precipita
@. ᶜSqₜᵖ⁰ = q_tot_precipitation_sources(
precip_model,
thermo_params,
microphys_params,
microphys_0m_params,
dt,
q_tot,
ᶜts,
Expand All @@ -1055,7 +1056,7 @@ NVTX.@annotate function set_diagnostic_edmf_precomputed_quantities_env_precipita
precip_model::Microphysics1Moment,
)
thermo_params = CAP.thermodynamics_params(p.params)
microphys_params = CAP.microphysics_precipitation_params(p.params)
microphys_1m_params = CAP.microphysics_1m_params(p.params)

(; ᶜts, ᶜSqₜᵖ⁰, ᶜSeₜᵖ⁰, ᶜSqᵣᵖ⁰, ᶜSqₛᵖ⁰) = p.precomputed
(; q_tot) = p.precomputed.ᶜspecific
Expand All @@ -1078,7 +1079,7 @@ NVTX.@annotate function set_diagnostic_edmf_precomputed_quantities_env_precipita
ᶜts,
p.core.ᶜΦ,
p.dt,
microphys_params,
microphys_1m_params,
thermo_params,
)
return nothing
Expand Down
2 changes: 1 addition & 1 deletion src/cache/precipitation_precomputed_quantities.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function set_precipitation_precomputed_quantities!(Y, p, t)

(; ᶜwᵣ, ᶜwₛ, ᶜqᵣ, ᶜqₛ) = p.precomputed

cmp = CAP.microphysics_precipitation_params(p.params)
cmp = CAP.microphysics_1m_params(p.params)

# compute the precipitation specific humidities
@. ᶜqᵣ = qₚ(Y.c.ρq_rai, Y.c.ρ)
Expand Down
4 changes: 2 additions & 2 deletions src/cache/prognostic_edmf_precomputed_quantities.jl
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ NVTX.@annotate function set_prognostic_edmf_precomputed_quantities_precipitation

(; params, dt) = p
thp = CAP.thermodynamics_params(params)
cmp = CAP.microphysics_precipitation_params(params)
cmp = CAP.microphysics_0m_params(params)
(; ᶜts⁰, ᶜq_tot⁰, ᶜtsʲs, ᶜSqₜᵖʲs, ᶜSqₜᵖ⁰) = p.precomputed

# Sources from the updrafts
Expand Down Expand Up @@ -426,7 +426,7 @@ NVTX.@annotate function set_prognostic_edmf_precomputed_quantities_precipitation
(; params, dt) = p
(; ᶜΦ,) = p.core
thp = CAP.thermodynamics_params(params)
cmp = CAP.microphysics_precipitation_params(params)
cmp = CAP.microphysics_1m_params(params)

(; ᶜSeₜᵖʲs, ᶜSqₜᵖʲs, ᶜSqᵣᵖʲs, ᶜSqₛᵖʲs, ᶜρʲs, ᶜtsʲs) = p.precomputed
(; ᶜSeₜᵖ⁰, ᶜSqₜᵖ⁰, ᶜSqᵣᵖ⁰, ᶜSqₛᵖ⁰, ᶜρ⁰, ᶜts⁰) = p.precomputed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ end
function q_tot_precipitation_sources(
::Microphysics0Moment,
thp,
cmp,
cmp::CMP.Parameters0M,
dt,
qₜ,
ts,
Expand Down
6 changes: 3 additions & 3 deletions src/parameterized_tendencies/microphysics/precipitation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ function compute_precipitation_cache!(Y, p, ::Microphysics0Moment, _)
(; ᶜts) = p.precomputed
(; ᶜS_ρq_tot, ᶜS_ρe_tot) = p.precipitation
(; ᶜΦ) = p.core
cm_params = CAP.microphysics_precipitation_params(params)
cm_params = CAP.microphysics_0m_params(params)
thermo_params = CAP.thermodynamics_params(params)
@. ᶜS_ρq_tot =
Y.c.ρ * q_tot_precipitation_sources(
Expand Down Expand Up @@ -206,7 +206,7 @@ function compute_precipitation_cache!(Y, p, ::Microphysics1Moment, _)

# get thermodynamics and 1-moment microphysics params
(; params) = p
cmp = CAP.microphysics_precipitation_params(params)
cmp = CAP.microphysics_1m_params(params)
thp = CAP.thermodynamics_params(params)

# compute precipitation source terms on the grid mean
Expand Down Expand Up @@ -265,7 +265,7 @@ function compute_precipitation_cache!(

# get thermodynamics and 1-moment microphysics params
(; params) = p
cmp = CAP.microphysics_precipitation_params(params)
cmp = CAP.microphysics_1m_params(params)
thp = CAP.thermodynamics_params(params)

# zero out the helper source terms
Expand Down
12 changes: 4 additions & 8 deletions src/parameters/Parameters.jl
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ Base.@kwdef struct ClimaAtmosParameters{
RP,
IP,
MPC,
MPP,
WP,
MP0M,
MP1M,
SFP,
TCP,
STP,
Expand All @@ -75,8 +75,8 @@ Base.@kwdef struct ClimaAtmosParameters{
rrtmgp_params::RP
insolation_params::IP
microphysics_cloud_params::MPC
microphysics_precipitation_params::MPP
water_params::WP
microphysics_0m_params::MP0M
microphysics_1m_params::MP1M
surface_fluxes_params::SFP
turbconv_params::TCP
surface_temp_params::STP
Expand Down Expand Up @@ -128,10 +128,6 @@ for var in [:molmass_ratio, :R_d, :R_v, :e_int_v0, :cp_d, :cv_v, :cv_l, :cv_d]
@eval $var(ps::ACAP) = TD.Parameters.$var(thermodynamics_params(ps))
end

# Forwarding CloudMicrophysics parameters
ρ_cloud_liq(ps::ACAP) = ps.water_params.ρw
ρ_cloud_ice(ps::ACAP) = ps.water_params.ρi

# Forwarding SurfaceFluxes parameters
von_karman_const(ps::ACAP) =
SF.Parameters.von_karman_const(surface_fluxes_params(ps))
Expand Down
Loading

0 comments on commit 8f383d0

Please sign in to comment.