Skip to content

Commit

Permalink
Merge pull request #3230 from CliMA/cc/sgs_quad_edmf_cloud
Browse files Browse the repository at this point in the history
Use sgs quadrature fields for cloud diagnostics
  • Loading branch information
costachris authored Aug 13, 2024
2 parents 66ad251 + 175f92c commit 41b8467
Show file tree
Hide file tree
Showing 30 changed files with 98 additions and 21 deletions.
2 changes: 1 addition & 1 deletion config/default_configs/default_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ precip_model:
help: "Precipitation model [`nothing` (default), `0M`]"
value: ~
cloud_model:
help: "Cloud model [`grid_scale`, `quadrature` (default), `diagnostic_edmfx`]"
help: "Cloud model [`grid_scale`, `quadrature` (default), `quadrature_sgs`]"
value: "quadrature"
perf_summary:
help: "Flag for collecting performance summary information"
Expand Down
2 changes: 1 addition & 1 deletion config/longrun_configs/amip_target_diagedmf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ z_elem: 63
dz_bottom: 30.0
dz_top: 3000.0
moist: "equil"
cloud_model: diagnostic_edmfx
cloud_model: "quadrature_sgs"
precip_model: "0M"
override_τ_precip: false
rad: "allskywithclear"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ dt: "120secs"
t_end: "240days"
dt_save_state_to_disk: "30days"
moist: "equil"
cloud_model: diagnostic_edmfx
cloud_model: "quadrature_sgs"
rad: "allskywithclear"
dt_rad: "1hours"
dt_cloud_fraction: "1hours"
Expand Down
2 changes: 1 addition & 1 deletion config/model_configs/aquaplanet_diagedmf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ edmfx_detr_model: "Generalized"
edmfx_nh_pressure: true
edmfx_sgs_mass_flux: true
edmfx_sgs_diffusive_flux: true
cloud_model: diagnostic_edmfx
cloud_model: "quadrature_sgs"
precip_model: 0M
dt: 90secs
t_end: 1days
Expand Down
2 changes: 1 addition & 1 deletion config/model_configs/diagnostic_edmfx_aquaplanet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ edmfx_nh_pressure: true
edmfx_sgs_mass_flux: true
edmfx_sgs_diffusive_flux: true
moist: equil
cloud_model: diagnostic_edmfx
cloud_model: "quadrature_sgs"
precip_model: 0M
override_τ_precip: false
dt: 100secs
Expand Down
2 changes: 1 addition & 1 deletion config/model_configs/diagnostic_edmfx_bomex_box.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ edmfx_nh_pressure: true
edmfx_sgs_mass_flux: true
edmfx_sgs_diffusive_flux: true
moist: "equil"
cloud_model: diagnostic_edmfx
cloud_model: "quadrature_sgs"
call_cloud_diagnostics_per_stage: true
config: "box"
x_max: 1e8
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ edmfx_nh_pressure: true
edmfx_sgs_mass_flux: true
edmfx_sgs_diffusive_flux: true
moist: "equil"
cloud_model: diagnostic_edmfx
cloud_model: "quadrature_sgs"
call_cloud_diagnostics_per_stage: true
config: "box"
x_max: 1e8
Expand Down
2 changes: 1 addition & 1 deletion config/model_configs/diagnostic_edmfx_dycoms_rf01_box.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ edmfx_nh_pressure: true
edmfx_sgs_mass_flux: true
edmfx_sgs_diffusive_flux: true
moist: equil
cloud_model: diagnostic_edmfx
cloud_model: "quadrature_sgs"
call_cloud_diagnostics_per_stage: true
config: box
x_max: 1e8
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ edmfx_nh_pressure: true
edmfx_sgs_mass_flux: true
edmfx_sgs_diffusive_flux: true
moist: equil
cloud_model: diagnostic_edmfx
cloud_model: "quadrature_sgs"
call_cloud_diagnostics_per_stage: true
config: box
x_max: 1e8
Expand Down
2 changes: 1 addition & 1 deletion config/model_configs/diagnostic_edmfx_dycoms_rf02_box.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ edmfx_nh_pressure: true
edmfx_sgs_mass_flux: true
edmfx_sgs_diffusive_flux: true
moist: equil
cloud_model: diagnostic_edmfx
cloud_model: "quadrature_sgs"
precip_model: "1M"
call_cloud_diagnostics_per_stage: true
config: box
Expand Down
2 changes: 1 addition & 1 deletion config/model_configs/diagnostic_edmfx_gabls_box.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ edmfx_nh_pressure: true
edmfx_sgs_mass_flux: true
edmfx_sgs_diffusive_flux: true
moist: equil
cloud_model: diagnostic_edmfx
cloud_model: "quadrature_sgs"
call_cloud_diagnostics_per_stage: true
config: box
x_max: 1e8
Expand Down
2 changes: 1 addition & 1 deletion config/model_configs/diagnostic_edmfx_rico_box.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ edmfx_nh_pressure: true
edmfx_sgs_mass_flux: true
edmfx_sgs_diffusive_flux: true
moist: equil
cloud_model: diagnostic_edmfx
cloud_model: "quadrature_sgs"
precip_model: "1M"
call_cloud_diagnostics_per_stage: true
config: box
Expand Down
2 changes: 1 addition & 1 deletion config/model_configs/diagnostic_edmfx_trmm_box.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ edmfx_nh_pressure: true
edmfx_sgs_mass_flux: true
edmfx_sgs_diffusive_flux: true
moist: equil
cloud_model: diagnostic_edmfx
cloud_model: "quadrature_sgs"
call_cloud_diagnostics_per_stage: true
apply_limiter: false
precip_model: "1M"
Expand Down
2 changes: 1 addition & 1 deletion config/model_configs/diagnostic_edmfx_trmm_box_0M.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ edmfx_nh_pressure: true
edmfx_sgs_mass_flux: true
edmfx_sgs_diffusive_flux: true
moist: equil
cloud_model: diagnostic_edmfx
cloud_model: "quadrature_sgs"
call_cloud_diagnostics_per_stage: true
precip_model: "0M"
override_τ_precip: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ edmfx_nh_pressure: true
edmfx_sgs_mass_flux: true
edmfx_sgs_diffusive_flux: true
moist: equil
cloud_model: diagnostic_edmfx
cloud_model: "quadrature_sgs"
call_cloud_diagnostics_per_stage: true
precip_model: "1M"
override_τ_precip: false
Expand Down
1 change: 1 addition & 0 deletions config/model_configs/prognostic_edmfx_aquaplanet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ edmfx_filter: true
edmfx_sgs_mass_flux: true
edmfx_sgs_diffusive_flux: true
moist: equil
cloud_model: "quadrature_sgs"
precip_model: 0M
dt: 10secs
t_end: 1hours
Expand Down
1 change: 1 addition & 0 deletions config/model_configs/prognostic_edmfx_bomex_box.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ edmfx_nh_pressure: true
edmfx_filter: true
prognostic_tke: true
moist: "equil"
cloud_model: "quadrature_sgs"
call_cloud_diagnostics_per_stage: true
config: "box"
x_max: 1e8
Expand Down
1 change: 1 addition & 0 deletions config/model_configs/prognostic_edmfx_bomex_column.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ edmfx_nh_pressure: true
edmfx_filter: true
prognostic_tke: true
moist: "equil"
cloud_model: "quadrature_sgs"
call_cloud_diagnostics_per_stage: true
config: "column"
z_max: 3e3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ edmfx_nh_pressure: true
edmfx_filter: true
prognostic_tke: false
moist: "equil"
cloud_model: "quadrature_sgs"
call_cloud_diagnostics_per_stage: true
config: "column"
z_max: 3e3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ edmfx_nh_pressure: true
edmfx_filter: true
prognostic_tke: true
moist: "equil"
cloud_model: "quadrature_sgs"
call_cloud_diagnostics_per_stage: true
config: "column"
z_max: 3e3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ edmfx_nh_pressure: true
edmfx_filter: true
prognostic_tke: true
moist: "equil"
cloud_model: "quadrature_sgs"
call_cloud_diagnostics_per_stage: true
config: "column"
hyperdiff: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ edmfx_nh_pressure: true
edmfx_filter: true
prognostic_tke: true
moist: equil
cloud_model: "quadrature_sgs"
call_cloud_diagnostics_per_stage: true
config: column
hyperdiff: false
Expand Down
1 change: 1 addition & 0 deletions config/model_configs/prognostic_edmfx_gcmdriven_column.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ perturb_initstate: false
dt: "10secs"
t_end: "6hours"
dt_save_state_to_disk: "6hours"
cloud_model: "quadrature_sgs"
call_cloud_diagnostics_per_stage : true
toml: [toml/prognostic_edmfx_gcmdriven.toml]
netcdf_output_at_levels: true
Expand Down
1 change: 1 addition & 0 deletions config/model_configs/prognostic_edmfx_rico_column.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ edmfx_nh_pressure: true
edmfx_filter: true
prognostic_tke: true
moist: "equil"
cloud_model: "quadrature_sgs"
call_cloud_diagnostics_per_stage: true
precip_model: "1M"
config: "column"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ edmfx_nh_pressure: true
edmfx_filter: true
prognostic_tke: false
moist: "equil"
cloud_model: "quadrature_sgs"
call_cloud_diagnostics_per_stage: true
config: "column"
z_max: 4e3
Expand Down
1 change: 1 addition & 0 deletions config/model_configs/prognostic_edmfx_trmm_column.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ edmfx_nh_pressure: true
edmfx_filter: true
prognostic_tke: true
moist: equil
cloud_model: "quadrature_sgs"
apply_limiter: false
precip_model: "1M"
call_cloud_diagnostics_per_stage: true
Expand Down
1 change: 1 addition & 0 deletions config/model_configs/prognostic_edmfx_trmm_column_0M.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ edmfx_nh_pressure: true
edmfx_filter: true
prognostic_tke: true
moist: equil
cloud_model: "quadrature_sgs"
apply_limiter: false
precip_model: "0M"
call_cloud_diagnostics_per_stage: true
Expand Down
71 changes: 68 additions & 3 deletions src/cache/cloud_fraction.jl
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ NVTX.@annotate function set_cloud_fraction!(
thermo_params = CAP.thermodynamics_params(params)
(; ᶜts, ᶜmixing_length, cloud_diagnostics_tuple) = p.precomputed
(; turbconv_model) = p.atmos

if isnothing(turbconv_model)
if p.atmos.call_cloud_diagnostics_per_stage isa
CallCloudDiagnosticsPerStage
Expand All @@ -94,11 +95,25 @@ NVTX.@annotate function set_cloud_fraction!(
thermo_params,
)
end

NVTX.@annotate function set_cloud_fraction!(
Y,
p,
moisture_model::Union{EquilMoistModel, NonEquilMoistModel},
cloud_model::SGSQuadratureCloud,
)

(; turbconv_model) = p.atmos
set_cloud_fraction!(Y, p, moisture_model, cloud_model, turbconv_model)
end


NVTX.@annotate function set_cloud_fraction!(
Y,
p,
::Union{EquilMoistModel, NonEquilMoistModel},
::DiagnosticEDMFCloud,
::SGSQuadratureCloud,
::DiagnosticEDMFX,
)
(; SG_quad, params) = p

Expand All @@ -109,10 +124,9 @@ NVTX.@annotate function set_cloud_fraction!(
(; turbconv_model) = p.atmos

# TODO - we should make this default when using diagnostic edmf
@assert turbconv_model isa DiagnosticEDMFX

# environment
coeff = FT(2.1) # TODO - move to parameters

@. cloud_diagnostics_tuple = quad_loop(
SG_quad,
ᶜts,
Expand All @@ -122,6 +136,7 @@ NVTX.@annotate function set_cloud_fraction!(
ᶜmixing_length,
thermo_params,
)

# updrafts
n = n_mass_flux_subdomains(turbconv_model)

Expand All @@ -140,6 +155,56 @@ NVTX.@annotate function set_cloud_fraction!(
),
)
end

end

NVTX.@annotate function set_cloud_fraction!(
Y,
p,
::Union{EquilMoistModel, NonEquilMoistModel},
::SGSQuadratureCloud,
::PrognosticEDMFX,
)
(; SG_quad, params) = p

FT = eltype(params)
thermo_params = CAP.thermodynamics_params(params)
(; ᶜts⁰, ᶜmixing_length, cloud_diagnostics_tuple) = p.precomputed
(; ᶜρʲs, ᶜtsʲs) = p.precomputed
(; turbconv_model) = p.atmos

# TODO - we should make this default when using diagnostic edmf
# environment
coeff = FT(2.1) # TODO - move to parameters

@. cloud_diagnostics_tuple = quad_loop(
SG_quad,
ᶜts⁰,
Geometry.WVector(p.precomputed.ᶜgradᵥ_q_tot⁰),
Geometry.WVector(p.precomputed.ᶜgradᵥ_θ_liq_ice⁰),
coeff,
ᶜmixing_length,
thermo_params,
)

# updrafts
n = n_mass_flux_subdomains(turbconv_model)

for j in 1:n
@. cloud_diagnostics_tuple += NamedTuple{(:cf, :q_liq, :q_ice)}(
tuple(
ifelse(
TD.has_condensate(thermo_params, ᶜtsʲs.:($$j)),
draft_area(Y.c.sgsʲs.:($$j).ρa, ᶜρʲs.:($$j)),
0,
),
draft_area(Y.c.sgsʲs.:($$j).ρa, ᶜρʲs.:($$j)) *
TD.PhasePartition(thermo_params, ᶜtsʲs.:($$j)).liq,
draft_area(Y.c.sgsʲs.:($$j).ρa, ᶜρʲs.:($$j)) *
TD.PhasePartition(thermo_params, ᶜtsʲs.:($$j)).ice,
),
)
end
end

"""
Expand Down
4 changes: 2 additions & 2 deletions src/solver/model_getters.jl
Original file line number Diff line number Diff line change
Expand Up @@ -286,8 +286,8 @@ function get_cloud_model(parsed_args)
GridScaleCloud()
elseif cloud_model == "quadrature"
QuadratureCloud()
elseif cloud_model == "diagnostic_edmfx"
DiagnosticEDMFCloud()
elseif cloud_model == "quadrature_sgs"
SGSQuadratureCloud()
else
error("Invalid cloud_model $(cloud_model)")
end
Expand Down
2 changes: 1 addition & 1 deletion src/solver/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ struct Microphysics1Moment <: AbstractPrecipitationModel end
abstract type AbstractCloudModel end
struct GridScaleCloud <: AbstractCloudModel end
struct QuadratureCloud <: AbstractCloudModel end
struct DiagnosticEDMFCloud <: AbstractCloudModel end
struct SGSQuadratureCloud <: AbstractCloudModel end

abstract type AbstractModelConfig end
struct SingleColumnModel <: AbstractModelConfig end
Expand Down

0 comments on commit 41b8467

Please sign in to comment.