Skip to content

Commit

Permalink
Merge pull request #3126 from CliMA/aj/updrafts_for_clouds
Browse files Browse the repository at this point in the history
Add cloud diagnostics for diagnostic edmf
  • Loading branch information
trontrytel authored Jun 24, 2024
2 parents 9ab25e2 + be3f66f commit 44915b1
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 2 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 @@ -191,7 +191,7 @@ precip_model:
help: "Precipitation model [`nothing` (default), `0M`]"
value: ~
cloud_model:
help: "Cloud model [`grid_scale`, `quadrature` (default)]"
help: "Cloud model [`grid_scale`, `quadrature` (default), `diagnostic_edmfx`]"
value: "quadrature"
perf_summary:
help: "Flag for collecting performance summary information"
Expand Down
1 change: 1 addition & 0 deletions config/model_configs/diagnostic_edmfx_bomex_box.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ edmfx_sgs_diffusive_flux: true
moist: "equil"
call_cloud_diagnostics_per_stage: true
config: "box"
cloud_model: "diagnostic_edmfx"
x_max: 1e8
y_max: 1e8
x_elem: 2
Expand Down
49 changes: 48 additions & 1 deletion src/cache/cloud_fraction.jl
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ NVTX.@annotate function set_cloud_fraction!(

FT = eltype(params)
thermo_params = CAP.thermodynamics_params(params)
(; ᶜts, ᶜp, ᶜmixing_length, cloud_diagnostics_tuple) = p.precomputed
(; ᶜ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
Expand Down Expand Up @@ -94,6 +94,53 @@ NVTX.@annotate function set_cloud_fraction!(
thermo_params,
)
end
NVTX.@annotate function set_cloud_fraction!(
Y,
p,
::Union{EquilMoistModel, NonEquilMoistModel},
::DiagnosticEDMFCloud,
)
(; SG_quad, params) = p

FT = eltype(params)
thermo_params = CAP.thermodynamics_params(params)
(; ᶜts, ᶜmixing_length, cloud_diagnostics_tuple) = p.precomputed
(; ᶜρaʲs, ᶜρʲs, ᶜtsʲs) = p.precomputed
(; 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,
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(ᶜρaʲs.:($$j), ᶜρʲs.:($$j)),
0,
),
draft_area(ᶜρaʲs.:($$j), ᶜρʲs.:($$j)) *
TD.PhasePartition(thermo_params, ᶜtsʲs.:($$j)).liq,
draft_area(ᶜρaʲs.:($$j), ᶜρʲs.:($$j)) *
TD.PhasePartition(thermo_params, ᶜtsʲs.:($$j)).ice,
),
)
end
end

"""
function quad_loop(SG_quad, ts, ᶜ∇q, ᶜ∇θ,
Expand Down
2 changes: 2 additions & 0 deletions src/solver/model_getters.jl
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,8 @@ function get_cloud_model(parsed_args)
GridScaleCloud()
elseif cloud_model == "quadrature"
QuadratureCloud()
elseif cloud_model == "diagnostic_edmfx"
DiagnosticEDMFCloud()
else
error("Invalid cloud_model $(cloud_model)")
end
Expand Down
1 change: 1 addition & 0 deletions src/solver/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ struct Microphysics1Moment <: AbstractPrecipitationModel end
abstract type AbstractCloudModel end
struct GridScaleCloud <: AbstractCloudModel end
struct QuadratureCloud <: AbstractCloudModel end
struct DiagnosticEDMFCloud <: AbstractCloudModel end

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

0 comments on commit 44915b1

Please sign in to comment.