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

Remove unused fieldvector #2131

Merged
merged 2 commits into from
Sep 21, 2023
Merged
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
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
Loading