Skip to content

Commit

Permalink
Merge #2131
Browse files Browse the repository at this point in the history
2131: Remove unused fieldvector r=charleskawczynski a=charleskawczynski

Followup to #2130

Co-authored-by: Charles Kawczynski <kawczynski.charles@gmail.com>
  • Loading branch information
bors[bot] and charleskawczynski authored Sep 21, 2023
2 parents 16c2a66 + e604f1a commit a515e64
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 38 deletions.
1 change: 0 additions & 1 deletion src/cache/cache.jl
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ function default_cache(
test,
moisture_model = atmos.moisture_model,
model_config = atmos.model_config,
Yₜ = similar(Y), # only needed when using increment formulation
limiter,
ᶜΦ,
ᶠgradᵥ_ᶜΦ = ᶠgradᵥ.(ᶜΦ),
Expand Down
2 changes: 1 addition & 1 deletion src/callbacks/callbacks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ NVTX.@annotate function compute_diagnostics(integrator)
if p.atmos.precip_model isa Microphysics0Moment
(; ᶜS_ρq_tot, col_integrated_rain, col_integrated_snow) = p
Fields.bycolumn(axes(Y.c)) do colidx
precipitation_tendency!(p.Yₜ, Y, p, t, colidx, p.precip_model)
precipitation_tendency!(nothing, Y, p, t, colidx, p.precip_model)
end # TODO: Set the diagnostics without computing the tendency.
precip_diagnostic = (;
precipitation_removal = ᶜS_ρq_tot,
Expand Down
78 changes: 42 additions & 36 deletions src/parameterized_tendencies/microphysics/precipitation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,10 @@ function precipitation_tendency!(
thermo_params = CAP.thermodynamics_params(params)
cm_params = CAP.microphysics_params(params)
compute_precipitation_cache!(Y, p, colidx, precip_model, turbconv_model)
@. Yₜ.c.ρq_tot[colidx] += ᶜS_ρq_tot[colidx]
@. Yₜ.c.ρ[colidx] += ᶜS_ρq_tot[colidx]
if !isnothing(Yₜ)
@. Yₜ.c.ρq_tot[colidx] += ᶜS_ρq_tot[colidx]
@. Yₜ.c.ρ[colidx] += ᶜS_ρq_tot[colidx]
end
T_freeze = TD.Parameters.T_freeze(thermo_params)

# update precip in cache for coupler's use
Expand All @@ -131,7 +133,7 @@ function precipitation_tendency!(
if :ρe_tot in propertynames(Y.c)
#TODO - this is a hack right now. But it will be easier to clean up
# once we drop the support for the old EDMF code
if turbconv_model isa DiagnosticEDMFX
if turbconv_model isa DiagnosticEDMFX && !isnothing(Yₜ)
@. Yₜ.c.ρe_tot[colidx] +=
sum(
p.ᶜS_q_totʲs[colidx] *
Expand All @@ -145,7 +147,7 @@ function precipitation_tendency!(
ᶜts[colidx],
ᶜΦ[colidx],
)
else
elseif !isnothing(Yₜ)
@. Yₜ.c.ρe_tot[colidx] +=
ᶜS_ρq_tot[colidx] * e_tot_0M_precipitation_sources_helper(
thermo_params,
Expand Down Expand Up @@ -326,33 +328,35 @@ function precipitation_advection_tendency!(
# TODO: need to add horizontal advection + vertical velocity of air

# TODO: use correct advection operators
@. Yₜ.c.ρq_rai[colidx] += ᶜdivᵥ(
wvec(
RB(
ρq_rai * CM1.terminal_velocity(
microphys_params,
rain_type,
velo_type,
ρ_c,
ρq_rai / ρ_c,
if !isnothing(Yₜ)
@. Yₜ.c.ρq_rai[colidx] += ᶜdivᵥ(
wvec(
RB(
ρq_rai * CM1.terminal_velocity(
microphys_params,
rain_type,
velo_type,
ρ_c,
ρq_rai / ρ_c,
),
),
),
),
)
)

@. Yₜ.c.ρq_sno[colidx] += ᶜdivᵥ(
wvec(
RB(
ρq_sno * CM1.terminal_velocity(
microphys_params,
snow_type,
velo_type,
ρ_c,
ρq_sno / ρ_c,
@. Yₜ.c.ρq_sno[colidx] += ᶜdivᵥ(
wvec(
RB(
ρq_sno * CM1.terminal_velocity(
microphys_params,
snow_type,
velo_type,
ρ_c,
ρq_sno / ρ_c,
),
),
),
),
)
)
end
return nothing
end

Expand All @@ -373,17 +377,19 @@ function precipitation_tendency!(
p.atmos.turbconv_model,
)

@. Yₜ.c.ρ[colidx] += ᶜS_ρq_tot[colidx]
@. Yₜ.c.ρq_tot[colidx] += ᶜS_ρq_tot[colidx]
@. Yₜ.c.ρq_rai[colidx] += ᶜS_ρq_rai[colidx]
@. Yₜ.c.ρq_sno[colidx] += ᶜS_ρq_sno[colidx]
if !isnothing(Yₜ)
@. Yₜ.c.ρ[colidx] += ᶜS_ρq_tot[colidx]
@. Yₜ.c.ρq_tot[colidx] += ᶜS_ρq_tot[colidx]
@. Yₜ.c.ρq_rai[colidx] += ᶜS_ρq_rai[colidx]
@. Yₜ.c.ρq_sno[colidx] += ᶜS_ρq_sno[colidx]

if :ρe_tot in propertynames(Y.c)
@. Yₜ.c.ρe_tot[colidx] += ᶜS_ρe_tot[colidx]
else
error(
"1-moment microphysics can only be coupled to ρe_tot energy variable",
)
if :ρe_tot in propertynames(Y.c)
@. Yₜ.c.ρe_tot[colidx] += ᶜS_ρe_tot[colidx]
else
error(
"1-moment microphysics can only be coupled to ρe_tot energy variable",
)
end
end

precipitation_advection_tendency!(Yₜ, Y, p, colidx, precip_model)
Expand Down

0 comments on commit a515e64

Please sign in to comment.