Skip to content

Commit d94fa7b

Browse files
authored
Merge pull request #4089 from CliMA/zs/assert
remove some assert and clean up some edmf code
2 parents 0e35f3d + 1e9e650 commit d94fa7b

File tree

7 files changed

+19
-29
lines changed

7 files changed

+19
-29
lines changed

src/cache/cloud_fraction.jl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,8 +309,6 @@ function quad_loop(
309309

310310
function f(x1_hat, x2_hat)
311311
FT = eltype(x1_hat)
312-
@assert(x1_hat >= FT(0))
313-
@assert(x2_hat >= FT(0))
314312
_ts = thermo_state(thermo_params; p = p_c, θ = x1_hat, q_tot = x2_hat)
315313
hc = TD.has_condensate(thermo_params, _ts)
316314

src/cache/precomputed_quantities.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,15 @@ function precomputed_quantities(Y, atmos)
8080
!(atmos.turbconv_model isa PrognosticEDMFX)
8181
@assert isnothing(atmos.turbconv_model) ||
8282
isnothing(atmos.vertical_diffusion)
83+
@assert !(atmos.moisture_model isa NonEquilMoistModel) ||
84+
!(atmos.microphysics_model isa Microphysics0Moment)
8385
TST = thermo_state_type(atmos.moisture_model, FT)
8486
SCT = SurfaceConditions.surface_conditions_type(atmos, FT)
8587
cspace = axes(Y.c)
8688
fspace = axes(Y.f)
8789
n = n_mass_flux_subdomains(atmos.turbconv_model)
90+
n_prog = n_prognostic_mass_flux_subdomains(atmos.turbconv_model)
91+
@assert !(atmos.turbconv_model isa PrognosticEDMFX) || n_prog == 1
8892
gs_quantities = (;
8993
ᶜwₜqₜ = similar(Y.c, Geometry.WVector{FT}),
9094
ᶜwₕhₜ = similar(Y.c, Geometry.WVector{FT}),

src/cache/prognostic_edmf_precomputed_quantities.jl

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ NVTX.@annotate function set_prognostic_edmf_precomputed_quantities_environment!(
1616
ᶠuₕ³,
1717
t,
1818
)
19-
@assert !(p.atmos.moisture_model isa DryModel)
2019

2120
thermo_params = CAP.thermodynamics_params(p.params)
2221
(; turbconv_model) = p.atmos
@@ -64,8 +63,7 @@ NVTX.@annotate function set_prognostic_edmf_precomputed_quantities_draft!(
6463
ᶠuₕ³,
6564
t,
6665
)
67-
(; moisture_model, turbconv_model) = p.atmos
68-
@assert !(moisture_model isa DryModel)
66+
(; moisture_model, turbconv_model, microphysics_model) = p.atmos
6967

7068
n = n_mass_flux_subdomains(turbconv_model)
7169
thermo_params = CAP.thermodynamics_params(p.params)
@@ -83,9 +81,9 @@ NVTX.@annotate function set_prognostic_edmf_precomputed_quantities_draft!(
8381
ᶜρʲ = ᶜρʲs.:($j)
8482
ᶜmseʲ = Y.c.sgsʲs.:($j).mse
8583
ᶜq_totʲ = Y.c.sgsʲs.:($j).q_tot
86-
if p.atmos.moisture_model isa NonEquilMoistModel && (
87-
p.atmos.microphysics_model isa Microphysics1Moment ||
88-
p.atmos.microphysics_model isa Microphysics2Moment
84+
if moisture_model isa NonEquilMoistModel && (
85+
microphysics_model isa Microphysics1Moment ||
86+
microphysics_model isa Microphysics2Moment
8987
)
9088
ᶜq_liqʲ = Y.c.sgsʲs.:($j).q_liq
9189
ᶜq_iceʲ = Y.c.sgsʲs.:($j).q_ice
@@ -95,9 +93,9 @@ NVTX.@annotate function set_prognostic_edmf_precomputed_quantities_draft!(
9593

9694
set_velocity_quantities!(ᶜuʲ, ᶠu³ʲ, ᶜKʲ, ᶠu₃ʲ, Y.c.uₕ, ᶠuₕ³)
9795
@. ᶠKᵥʲ = (adjoint(CT3(ᶠu₃ʲ)) * ᶠu₃ʲ) / 2
98-
if p.atmos.moisture_model isa NonEquilMoistModel && (
99-
p.atmos.microphysics_model isa Microphysics1Moment ||
100-
p.atmos.microphysics_model isa Microphysics2Moment
96+
if moisture_model isa NonEquilMoistModel && (
97+
microphysics_model isa Microphysics1Moment ||
98+
microphysics_model isa Microphysics2Moment
10199
)
102100
@. ᶜtsʲ = TD.PhaseNonEquil_phq(
103101
thermo_params,
@@ -127,8 +125,7 @@ NVTX.@annotate function set_prognostic_edmf_precomputed_quantities_bottom_bc!(
127125
p,
128126
t,
129127
)
130-
(; moisture_model, turbconv_model) = p.atmos
131-
@assert !(moisture_model isa DryModel)
128+
(; moisture_model, turbconv_model, microphysics_model) = p.atmos
132129

133130
FT = Spaces.undertype(axes(Y.c))
134131
n = n_mass_flux_subdomains(turbconv_model)
@@ -143,9 +140,9 @@ NVTX.@annotate function set_prognostic_edmf_precomputed_quantities_bottom_bc!(
143140
ᶜtsʲ = ᶜtsʲs.:($j)
144141
ᶜmseʲ = Y.c.sgsʲs.:($j).mse
145142
ᶜq_totʲ = Y.c.sgsʲs.:($j).q_tot
146-
if p.atmos.moisture_model isa NonEquilMoistModel && (
147-
p.atmos.microphysics_model isa Microphysics1Moment ||
148-
p.atmos.microphysics_model isa Microphysics2Moment
143+
if moisture_model isa NonEquilMoistModel && (
144+
microphysics_model isa Microphysics1Moment ||
145+
microphysics_model isa Microphysics2Moment
149146
)
150147
ᶜq_liqʲ = Y.c.sgsʲs.:($j).q_liq
151148
ᶜq_iceʲ = Y.c.sgsʲs.:($j).q_ice
@@ -224,9 +221,9 @@ NVTX.@annotate function set_prognostic_edmf_precomputed_quantities_bottom_bc!(
224221
# Then overwrite the prognostic variables at first inetrior point.
225222
ᶜΦ_int_val = Fields.field_values(Fields.level(ᶜΦ, 1))
226223
ᶜtsʲ_int_val = Fields.field_values(Fields.level(ᶜtsʲ, 1))
227-
if p.atmos.moisture_model isa NonEquilMoistModel && (
228-
p.atmos.microphysics_model isa Microphysics1Moment ||
229-
p.atmos.microphysics_model isa Microphysics2Moment
224+
if moisture_model isa NonEquilMoistModel && (
225+
microphysics_model isa Microphysics1Moment ||
226+
microphysics_model isa Microphysics2Moment
230227
)
231228
ᶜq_liqʲ_int_val = Fields.field_values(Fields.level(ᶜq_liqʲ, 1))
232229
ᶜq_iceʲ_int_val = Fields.field_values(Fields.level(ᶜq_iceʲ, 1))
@@ -273,8 +270,7 @@ NVTX.@annotate function set_prognostic_edmf_precomputed_quantities_implicit_clos
273270
t,
274271
)
275272

276-
(; moisture_model, turbconv_model) = p.atmos
277-
@assert !(moisture_model isa DryModel)
273+
(; turbconv_model) = p.atmos
278274

279275
(; params) = p
280276
n = n_mass_flux_subdomains(turbconv_model)
@@ -313,7 +309,6 @@ NVTX.@annotate function set_prognostic_edmf_precomputed_quantities_explicit_clos
313309
)
314310

315311
(; moisture_model, turbconv_model) = p.atmos
316-
@assert !(moisture_model isa DryModel)
317312

318313
(; params) = p
319314
(; dt) = p
@@ -485,7 +480,6 @@ NVTX.@annotate function set_prognostic_edmf_precomputed_quantities_precipitation
485480
p,
486481
::Microphysics0Moment,
487482
)
488-
@assert !(p.atmos.moisture_model isa DryModel)
489483

490484
(; params, dt) = p
491485
thp = CAP.thermodynamics_params(params)
@@ -513,7 +507,6 @@ NVTX.@annotate function set_prognostic_edmf_precomputed_quantities_precipitation
513507
p,
514508
::Microphysics1Moment,
515509
)
516-
@assert (p.atmos.moisture_model isa NonEquilMoistModel)
517510

518511
(; params, dt) = p
519512
thp = CAP.thermodynamics_params(params)

src/diagnostics/radiation_diagnostics.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ function compute_rsd!(
4545
cache.radiation.rrtmgp_model.face_sw_flux_dn,
4646
axes(state.f),
4747
)
48-
@assert !isnothing(out) "Output field 'out' must not be `nothing` in this branch"
4948
radiation_mode.deep_atmosphere &&
5049
apply_geometric_scaling!(out, z_lev, planet_radius, FT)
5150
end

src/prognostic_equations/edmfx_sgs_flux.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,6 @@ function edmfx_sgs_diffusive_flux_tendency!(
469469
p.atmos.microphysics_model isa Microphysics1Moment ||
470470
p.atmos.microphysics_model isa Microphysics2Moment
471471
)
472-
@assert n_prognostic_mass_flux_subdomains(turbconv_model) == 1
473472
α_precip = CAP.α_vert_diff_tracer(params)
474473
ᶜρχₜ_diffusion = p.scratch.ᶜtemp_scalar
475474
ᶜdivᵥ_ρq = Operators.DivergenceF2C(

src/prognostic_equations/implicit/manual_sparse_jacobian.jl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,6 @@ function jacobian_cache(alg::ManualSparseJacobian, Y, atmos)
211211
end
212212

213213
sgs_advection_blocks = if atmos.turbconv_model isa PrognosticEDMFX
214-
@assert n_prognostic_mass_flux_subdomains(atmos.turbconv_model) == 1
215214
if use_derivative(sgs_advection_flag)
216215
(
217216
MatrixFields.unrolled_map(
@@ -264,7 +263,6 @@ function jacobian_cache(alg::ManualSparseJacobian, Y, atmos)
264263
end
265264

266265
sgs_massflux_blocks = if atmos.turbconv_model isa PrognosticEDMFX
267-
@assert n_prognostic_mass_flux_subdomains(atmos.turbconv_model) == 1
268266
if use_derivative(sgs_mass_flux_flag)
269267
(
270268
MatrixFields.unrolled_map(

src/prognostic_equations/mass_flux_closures.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,6 @@ function edmfx_vertical_diffusion_tendency!(
180180
p.atmos.microphysics_model isa Microphysics1Moment ||
181181
p.atmos.microphysics_model isa Microphysics2Moment
182182
)
183-
@assert n_prognostic_mass_flux_subdomains(turbconv_model) == 1
184183
α_precip = CAP.α_vert_diff_tracer(params)
185184
ᶜρaʲ = Y.c.sgsʲs.:(1).ρa
186185
ᶜdivᵥ_q = Operators.DivergenceF2C(

0 commit comments

Comments
 (0)