Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wip on adding cloud condensate sedimentation #3442

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/cache/precomputed_quantities.jl
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,12 @@ function precomputed_quantities(Y, atmos)
else
(;)
end
sedimentation_quantities =
atmos.moisture_model isa NonEquilMoistModel ?
(;
ᶜwₗ = similar(Y.c, FT),
ᶜwᵢ = similar(Y.c, FT),
) : (;)
precipitation_quantities =
atmos.precip_model isa Microphysics1Moment ?
(;
Expand All @@ -162,6 +168,7 @@ function precomputed_quantities(Y, atmos)
advective_sgs_quantities...,
diagnostic_sgs_quantities...,
vert_diff_quantities...,
sedimentation_quantities...,
precipitation_quantities...,
cloud_diagnostics_tuple,
)
Expand Down
38 changes: 38 additions & 0 deletions src/cache/sedimentation_precomputed_quantities.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#####
##### Precomputed quantities
#####
import CloudMicrophysics.MicrophysicsNonEq as CMNe

# TODO - duplicated with precip, should be moved to some common helper module
# helper function to safely get precipitation from state
function q_cc(ρq::FT, ρ::FT) where {FT}
return max(FT(0), ρq / ρ)
end

"""
set_sedimentation_precomputed_quantities!(Y, p, t)

Updates the sedimentation terminal velocity stored in `p`
for the non-equilibrium microphysics scheme
"""
function set_sedimentation_precomputed_quantities!(Y, p, t)
@assert (p.atmos.moisture_model isa MicrophysicsNonEq)

(; ᶜwₗ, ᶜwᵢ) = p.precomputed
cmc = CAP.microphysics_cloud_params(p.params)

# compute the precipitation terminal velocity [m/s]
@. ᶜwₗ = CMNe.terminal_velocity(
cmc.liquid,
cmc.Ch2022.rain,
Y.c.ρ,
q_cc(Y.c.ρq_liq, Y.c.ρ),
)
@. ᶜwᵢ = CMNe.terminal_velocity(
cmc.ice,
cmc.Ch2022.small_ice,
Y.c.ρ,
q_cc(Y.c.ρq_ice, Y.c.ρ),
)
return nothing
end
1 change: 1 addition & 0 deletions src/parameters/create_parameters.jl
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ function create_parameter_set(config::AtmosConfig)
(;
liquid = CM.Parameters.CloudLiquid(toml_dict),
ice = CM.Parameters.CloudIce(toml_dict),
Ch2022 = CM.Parameters.Chen2022VelType(toml_dict),
)
else
nothing
Expand Down
12 changes: 10 additions & 2 deletions src/prognostic_equations/implicit/implicit_solver.jl
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,10 @@ NVTX.@annotate function Wfact!(A, Y, p, dtγ, t)
p.precomputed.ᶜK,
p.precomputed.ᶜts,
p.precomputed.ᶜp,
(
p.atmos.moisture_model isa NonEquilMoistModel ?
(; p.precomputed.ᶜwₗ, p.precomputed.ᶜwᵢ) : (;)
)...,
(
p.atmos.precip_model isa Microphysics1Moment ?
(; p.precomputed.ᶜwᵣ, p.precomputed.ᶜwₛ) : (;)
Expand Down Expand Up @@ -679,8 +683,12 @@ function update_implicit_equation_jacobian!(A, Y, p, dtγ)
end

ᶠlg = Fields.local_geometry_field(Y.f)
precip_info =
((@name(c.ρq_rai), @name(ᶜwᵣ)), (@name(c.ρq_sno), @name(ᶜwₛ)))
precip_info = (
(@name(c.ρq_liq), @name(ᶜwₗ)),
(@name(c.ρq_ice), @name(ᶜwᵢ)),
(@name(c.ρq_rai), @name(ᶜwᵣ)),
(@name(c.ρq_sno), @name(ᶜwₛ)),
)
MatrixFields.unrolled_foreach(precip_info) do (ρqₚ_name, wₚ_name)
MatrixFields.has_field(Y, ρqₚ_name) || return
∂ᶜρqₚ_err_∂ᶜρqₚ = matrix[ρqₚ_name, ρqₚ_name]
Expand Down
20 changes: 16 additions & 4 deletions src/prognostic_equations/implicit/implicit_tendency.jl
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,23 @@ function implicit_vertical_advection_tendency!(Yₜ, Y, p, t)
)
end

# Advection of cloud condensate and precipitation with the mean flow
# is done with other passive tracers in the explicit tendency.
# Here we add the advection with cloud condensate and precipitation
# terminal velocity using downward biasing
# and free outflow bottom boundary condition
if moisture_model isa NonEquilMoistModel
(; ᶜwₗ, ᶜwᵢ) = p.precomputed
@. Yₜ.c.ρq_liq -= ᶜprecipdivᵥ(
ᶠwinterp(ᶜJ, Y.c.ρ) *
ᶠright_bias(Geometry.WVector(-(ᶜwₗ)) * ᶜspecific.q_liq),
)
@. Yₜ.c.ρq_ice -= ᶜprecipdivᵥ(
ᶠwinterp(ᶜJ, Y.c.ρ) *
ᶠright_bias(Geometry.WVector(-(ᶜwᵢ)) * ᶜspecific.q_ice),
)
end
if precip_model isa Microphysics1Moment
# Advection of precipitation with the mean flow
# is done with other passive tracers in the explicit tendency.
# Here we add the advection with precipitation terminal velocity
# using downward biasing and free outflow bottom boundary condition
(; ᶜwᵣ, ᶜwₛ) = p.precomputed
@. Yₜ.c.ρq_rai -= ᶜprecipdivᵥ(
ᶠwinterp(ᶜJ, Y.c.ρ) *
Expand Down
Loading