Skip to content

Commit 46e774f

Browse files
tapioscostachris
authored andcommitted
Added generic draft_sum (as comment for now)
Remove from ᶜρa⁰ Fixed syntax errors Removed ᶜρ⁰ from precomputed Remove ᶜq_tot⁰ (and fix forgotten ᶜρa⁰ Introduced helper functions to compute sums over draft, environmental volumetric variables, and specific env variables Use new helper functions to simplify calculation of ᶜq_tot⁰ Remove redundant draft sum functions Added specific_env_mse helper Removed ᶜmse⁰ from precomputed Remove ᶜq_liq⁰, ᶜq_ice⁰, ᶜq_rai⁰, ᶜq_sno⁰ from precomputed Remove redundant draft sum helper functions; docstrings Added TODO Renamed specific_gs to all_specific_gs; specific_sgs to all_specific_sgs; added docstrings Added new helper specific_sgs to cleanly extract specific SGS quantities; use it to get env TKE Change specific_sgs to use ClimaCore>MatrixFIelds for type stability Removed ᶜspecific (GS precomputed specific quantities); caveat lector [lots of changes] Correcting errors in previous commit removing gs precomputed quantities Removed a few more instances of ᶜspecific from precomputed quantities; removed ᶜtke⁰ Missing ᶜtke⁰ removal Another ᶜtke⁰ fix Introduced helper function for specific_tke and used it where needed Corrections of rebasing mistakes; updates to variable_manipulations for clarity. Removing some more ᶜspecific Added ᶜtke⁰ computations Removal of more specifics Remove h_tot Syntax corrections Fixes in cloud fraction Syntax error fix in jacobian Remove specific in precomputed_quantities; syntax error corrections
1 parent 5557f30 commit 46e774f

24 files changed

+704
-465
lines changed

src/ClimaAtmos.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import LazyBroadcast
88
import LazyBroadcast: lazy
99
import Thermodynamics as TD
1010
import Thermodynamics
11+
import ClimaCore.MatrixFields: @name
12+
1113

1214
include("compat.jl")
1315
include(joinpath("parameters", "Parameters.jl"))

src/cache/cloud_fraction.jl

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,16 @@ NVTX.@annotate function set_cloud_fraction!(
6262
TD.PhasePartition(thermo_params, ᶜts).ice,
6363
)
6464
else
65+
q_liq = @. lazy(specific(Y.c.ρq_liq, Y.c.ρ))
66+
q_ice = @. lazy(specific(Y.c.ρq_ice, Y.c.ρ))
6567
@. cloud_diagnostics_tuple = make_named_tuple(
6668
ifelse(
67-
specific(Y.c.ρq_liq, Y.c.ρ) + specific(Y.c.ρq_ice, Y.c.ρ) > 0,
69+
q_liq + q_ice > 0,
6870
1,
6971
0,
7072
),
71-
specific(Y.c.ρq_liq, Y.c.ρ),
72-
specific(Y.c.ρq_ice, Y.c.ρ),
73+
q_liq,
74+
q_ice,
7375
)
7476
end
7577
end
@@ -89,6 +91,16 @@ NVTX.@annotate function set_cloud_fraction!(
8991
(; turbconv_model) = p.atmos
9092

9193
if isnothing(turbconv_model)
94+
(;
95+
ᶜlinear_buoygrad,
96+
ᶜstrain_rate_norm,
97+
ᶠu³⁰,
98+
ᶠu³,
99+
ᶜentrʲs,
100+
ᶜdetrʲs,
101+
ᶠu³ʲs,
102+
) = p.precomputed
103+
ᶜρa⁰ = @.lazy(ρa⁰(Y.c))
92104
if p.atmos.call_cloud_diagnostics_per_stage isa
93105
CallCloudDiagnosticsPerStage
94106
(; ᶜgradᵥ_θ_virt, ᶜgradᵥ_q_tot, ᶜgradᵥ_θ_liq_ice) = p.precomputed
@@ -193,8 +205,9 @@ NVTX.@annotate function set_cloud_fraction!(
193205
FT = eltype(params)
194206
thermo_params = CAP.thermodynamics_params(params)
195207
(; ᶜts⁰, ᶜmixing_length, cloud_diagnostics_tuple) = p.precomputed
196-
(; ᶜρʲs, ᶜtsʲs, ᶜρa⁰, ᶜρ⁰) = p.precomputed
208+
(; ᶜρʲs, ᶜtsʲs) = p.precomputed
197209
(; turbconv_model) = p.atmos
210+
ᶜρa⁰ = @.lazy(ρa⁰(Y.c))
198211

199212
# TODO - we should make this default when using diagnostic edmf
200213
# environment
@@ -213,9 +226,9 @@ NVTX.@annotate function set_cloud_fraction!(
213226
# weight cloud diagnostics by environmental area
214227
@. cloud_diagnostics_tuple *= NamedTuple{(:cf, :q_liq, :q_ice)}(
215228
tuple(
216-
draft_area(ᶜρa⁰, ᶜρ⁰),
217-
draft_area(ᶜρa⁰, ᶜρ⁰),
218-
draft_area(ᶜρa⁰, ᶜρ⁰),
229+
draft_area(ᶜρa⁰, TD.air_density(thermo_params, ᶜts⁰)),
230+
draft_area(ᶜρa⁰, TD.air_density(thermo_params, ᶜts⁰)),
231+
draft_area(ᶜρa⁰, TD.air_density(thermo_params, ᶜts⁰)),
219232
),
220233
)
221234
# updrafts

src/cache/diagnostic_edmf_precomputed_quantities.jl

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ NVTX.@annotate function set_diagnostic_edmfx_env_quantities_level!(
6161
local_geometry_halflevel,
6262
turbconv_model,
6363
)
64-
@. u³⁰_halflevel = divide_by_ρa(
64+
@. u³⁰_halflevel = specific(
6565
ρ_level * u³_halflevel -
6666
unrolled_dotproduct(ρaʲs_level, u³ʲs_halflevel),
6767
ρ_level,
@@ -93,16 +93,20 @@ NVTX.@annotate function set_diagnostic_edmf_precomputed_quantities_bottom_bc!(
9393
FT = eltype(Y)
9494
n = n_mass_flux_subdomains(turbconv_model)
9595
(; ᶜΦ) = p.core
96-
(; ᶜp, ᶠu³, ᶜh_tot, ᶜK) = p.precomputed
97-
(; q_tot) = p.precomputed.ᶜspecific
96+
(; ᶜp, ᶠu³, ᶜK) = p.precomputed
9897
(; ustar, obukhov_length, buoyancy_flux, ρ_flux_h_tot, ρ_flux_q_tot) =
9998
p.precomputed.sfc_conditions
10099
(; ᶜρaʲs, ᶠu³ʲs, ᶜKʲs, ᶜmseʲs, ᶜq_totʲs, ᶜtsʲs, ᶜρʲs) = p.precomputed
101100
(; ᶠu³⁰, ᶜK⁰) = p.precomputed
102101

103102
(; params) = p
103+
104104
thermo_params = CAP.thermodynamics_params(params)
105105
turbconv_params = CAP.turbconv_params(params)
106+
ᶜts = p.precomputed.ᶜts #TODO replace
107+
108+
q_tot = specific(Y.c.ρq_tot, Y.c.ρ)
109+
ᶜh_tot = @. lazy(TD.total_specific_enthalpy(thermo_params, ᶜts, specific(Y.c.ρe_tot, Y.c.ρ)))
106110

107111
ρ_int_level = Fields.field_values(Fields.level(Y.c.ρ, 1))
108112
uₕ_int_level = Fields.field_values(Fields.level(Y.c.uₕ, 1))
@@ -305,8 +309,7 @@ NVTX.@annotate function set_diagnostic_edmf_precomputed_quantities_do_integral!(
305309
(; dt) = p
306310
dt = float(dt)
307311
(; ᶜΦ, ᶜgradᵥ_ᶠΦ) = p.core
308-
(; ᶜp, ᶠu³, ᶜts, ᶜh_tot, ᶜK) = p.precomputed
309-
(; q_tot) = p.precomputed.ᶜspecific
312+
(; ᶜp, ᶠu³, ᶜts, ᶜK) = p.precomputed
310313
(;
311314
ᶜρaʲs,
312315
ᶠu³ʲs,
@@ -324,10 +327,8 @@ NVTX.@annotate function set_diagnostic_edmf_precomputed_quantities_do_integral!(
324327
(; ᶠu³⁰, ᶜK⁰, ᶜtke⁰) = p.precomputed
325328

326329
if microphysics_model isa Microphysics1Moment
327-
ᶜq_liqʲs = p.precomputed.ᶜq_liqʲs
328-
ᶜq_iceʲs = p.precomputed.ᶜq_iceʲs
329-
q_rai = p.precomputed.ᶜqᵣ
330-
q_sno = p.precomputed.ᶜqₛ
330+
q_rai = @. lazy(specific(Y.c.ρq_rai, Y.c.ρ))
331+
q_sno = @. lazy(specific(Y.c.ρq_sno, Y.c.ρ))
331332
end
332333

333334
thermo_params = CAP.thermodynamics_params(params)
@@ -347,6 +348,7 @@ NVTX.@annotate function set_diagnostic_edmf_precomputed_quantities_do_integral!(
347348
Fields.field_values(Fields.level(Fields.coordinate_field(Y.f).z, half))
348349

349350
# integral
351+
q_tot = specific(Y.c.ρq_tot, Y.c.ρ)
350352
for i in 2:Spaces.nlevels(axes(Y.c))
351353
ρ_level = Fields.field_values(Fields.level(Y.c.ρ, i))
352354
uₕ_level = Fields.field_values(Fields.level(Y.c.uₕ, i))
@@ -965,7 +967,6 @@ NVTX.@annotate function set_diagnostic_edmf_precomputed_quantities_env_closures!
965967
(; dt) = p
966968
(; ᶜp, ᶜu, ᶜts) = p.precomputed
967969
(; ustar, obukhov_length) = p.precomputed.sfc_conditions
968-
(; ᶜtke⁰) = p.precomputed
969970
(;
970971
ᶜlinear_buoygrad,
971972
ᶜstrain_rate_norm,
@@ -1083,6 +1084,7 @@ NVTX.@annotate function set_diagnostic_edmf_precomputed_quantities_env_precipita
10831084
(; ᶜts, ᶜSqₜᵖ⁰) = p.precomputed
10841085

10851086
# Environment precipitation sources (to be applied to grid mean)
1087+
q_tot = @. lazy(specific(Y.c.ρq_tot, Y.c.ρ))
10861088
@. ᶜSqₜᵖ⁰ = q_tot_0M_precipitation_sources(
10871089
thermo_params,
10881090
microphys_0m_params,
@@ -1126,4 +1128,4 @@ NVTX.@annotate function set_diagnostic_edmf_precomputed_quantities_env_precipita
11261128
# thermo_params,
11271129
#)
11281130
return nothing
1129-
end
1131+
end

src/cache/precipitation_precomputed_quantities.jl

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,11 @@ function set_precipitation_velocities!(
112112
cm2p = CAP.microphysics_2m_params(p.params)
113113
thp = CAP.thermodynamics_params(p.params)
114114

115+
q_liq = @. lazy(specific(Y.c.ρq_liq, Y.c.ρ))
116+
q_ice = @. lazy(specific(Y.c.ρq_ice, Y.c.ρ))
117+
q_rai = @. lazy(specific(Y.c.ρq_rai, Y.c.ρ))
118+
q_sno = @. lazy(specific(Y.c.ρq_sno, Y.c.ρ))
119+
115120
# compute the precipitation terminal velocity [m/s]
116121
# TODO sedimentation of snow is based on the 1M scheme
117122
@. ᶜwnᵣ = getindex(
@@ -253,10 +258,11 @@ function set_precipitation_cache!(
253258
::PrognosticEDMFX,
254259
)
255260
(; ᶜΦ) = p.core
256-
(; ᶜSqₜᵖ⁰, ᶜSqₜᵖʲs, ᶜρa⁰) = p.precomputed
261+
(; ᶜSqₜᵖ⁰, ᶜSqₜᵖʲs) = p.precomputed
257262
(; ᶜS_ρq_tot, ᶜS_ρe_tot) = p.precomputed
258263
(; ᶜts⁰, ᶜtsʲs) = p.precomputed
259264
thermo_params = CAP.thermodynamics_params(p.params)
265+
ᶜρa⁰ = @.lazy(ρa⁰(Y.c))
260266

261267
n = n_mass_flux_subdomains(p.atmos.turbconv_model)
262268

@@ -283,7 +289,8 @@ function set_precipitation_cache!(Y, p, ::Microphysics1Moment, _)
283289
(; ᶜts, ᶜwᵣ, ᶜwₛ, ᶜu) = p.precomputed
284290
(; ᶜSqₗᵖ, ᶜSqᵢᵖ, ᶜSqᵣᵖ, ᶜSqₛᵖ) = p.precomputed
285291

286-
(; q_tot, q_liq, q_ice, q_rai, q_sno) = p.precomputed.ᶜspecific
292+
q_rai = specific(Y.c.ρq_rai, Y.c.ρ)
293+
q_sno = specific(Y.c.ρq_sno, Y.c.ρ)
287294

288295
ᶜSᵖ = p.scratch.ᶜtemp_scalar
289296
ᶜSᵖ_snow = p.scratch.ᶜtemp_scalar_2
@@ -357,6 +364,11 @@ function set_precipitation_cache!(Y, p, ::Microphysics2Moment, _)
357364
(; ᶜSqₗᵖ, ᶜSqᵢᵖ, ᶜSqᵣᵖ, ᶜSqₛᵖ) = p.precomputed
358365
(; ᶜSnₗᵖ, ᶜSnᵣᵖ) = p.precomputed
359366

367+
q_liq = specific(Y.c.ρq_liq, Y.c.ρ)
368+
q_rai = specific(Y.c.ρq_rai, Y.c.ρ)
369+
n_liq = specific(Y.c.ρn_liq, Y.c.ρ)
370+
n_rai = specific(Y.c.ρn_rai, Y.c.ρ)
371+
360372
ᶜSᵖ = p.scratch.ᶜtemp_scalar
361373
ᶜS₂ᵖ = p.scratch.ᶜtemp_scalar_2
362374

@@ -469,14 +481,26 @@ function set_precipitation_surface_fluxes!(
469481
sfc_ρ = @. lazy(int_ρ * int_J / sfc_J)
470482

471483
# Constant extrapolation to surface, consistent with simple downwinding
472-
sfc_wᵣ = sfc_lev(ᶜwᵣ)
473-
sfc_wₛ = sfc_lev(ᶜwₛ)
474-
sfc_wₗ = sfc_lev(ᶜwₗ)
475-
sfc_wᵢ = sfc_lev(ᶜwᵢ)
476-
sfc_qᵣ = lazy.(specific.(sfc_lev(Y.c.ρq_rai), sfc_ρ))
477-
sfc_qₛ = lazy.(specific.(sfc_lev(Y.c.ρq_sno), sfc_ρ))
478-
sfc_qₗ = lazy.(specific.(sfc_lev(Y.c.ρq_liq), sfc_ρ))
479-
sfc_qᵢ = lazy.(specific.(sfc_lev(Y.c.ρq_ice), sfc_ρ))
484+
sfc_qᵣ = Fields.Field(
485+
Fields.field_values(Fields.level(specific(Y.c.ρq_rai, Y.c.ρ), 1)),
486+
sfc_space,
487+
)
488+
sfc_qₛ = Fields.Field(
489+
Fields.field_values(Fields.level(specific(Y.c.ρq_sno, Y.c.ρ), 1)),
490+
sfc_space,
491+
)
492+
sfc_qₗ = Fields.Field(
493+
Fields.field_values(Fields.level(specific(Y.c.ρq_liq, Y.c.ρ), 1)),
494+
sfc_space,
495+
)
496+
sfc_qᵢ = Fields.Field(
497+
Fields.field_values(Fields.level(specific(Y.c.ρq_ice, Y.c.ρ), 1)),
498+
sfc_space,
499+
)
500+
sfc_wᵣ = Fields.Field(Fields.field_values(Fields.level(ᶜwᵣ, 1)), sfc_space)
501+
sfc_wₛ = Fields.Field(Fields.field_values(Fields.level(ᶜwₛ, 1)), sfc_space)
502+
sfc_wₗ = Fields.Field(Fields.field_values(Fields.level(ᶜwₗ, 1)), sfc_space)
503+
sfc_wᵢ = Fields.Field(Fields.field_values(Fields.level(ᶜwᵢ, 1)), sfc_space)
480504

481505
@. surface_rain_flux = sfc_ρ * (sfc_qᵣ * (-sfc_wᵣ) + sfc_qₗ * (-sfc_wₗ))
482506
@. surface_snow_flux = sfc_ρ * (sfc_qₛ * (-sfc_wₛ) + sfc_qᵢ * (-sfc_wᵢ))

src/cache/precomputed_quantities.jl

Lines changed: 22 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,20 @@ Allocates precomputed quantities that are treated implicitly (i.e., updated
1111
on each iteration of the implicit solver). This includes all quantities related
1212
to velocity and thermodynamics that are used in the implicit tendency.
1313
14-
The following grid-scale quantities are treated implicitly:
15-
- `ᶜspecific`: specific quantities on cell centers (for every prognostic
16-
quantity `ρχ`, there is a corresponding specific quantity `χ`)
14+
The following grid-scale quantities are treated implicitly and are precomputed:
1715
- `ᶜu`: covariant velocity on cell centers
1816
- `ᶠu`: contravariant velocity on cell faces
1917
- `ᶜK`: kinetic energy on cell centers
2018
- `ᶜts`: thermodynamic state on cell centers
2119
- `ᶜp`: air pressure on cell centers
22-
- `ᶜh_tot`: total enthalpy on cell centers
2320
If the `turbconv_model` is `PrognosticEDMFX`, there also two SGS versions of
2421
every quantity except for `ᶜp` (which is shared across all subdomains):
2522
- `_⁰`: value for the environment
2623
- `_ʲs`: a tuple of values for the mass-flux subdomains
2724
In addition, there are several other SGS quantities for `PrognosticEDMFX`:
28-
- `ᶜtke⁰`: turbulent kinetic energy of the environment on cell centers
29-
- `ᶜρa⁰`: area-weighted air density of the environment on cell centers
30-
- `ᶜmse⁰`: moist static energy of the environment on cell centers
31-
- `ᶜq_tot⁰`: total specific humidity of the environment on cell centers
32-
- `ᶜρ⁰`: air density of the environment on cell centers
3325
- `ᶜρʲs`: a tuple of the air densities of the mass-flux subdomains on cell
3426
centers
35-
For every other `AbstractEDMF`, only `ᶜtke⁰` is added as a precomputed quantity.
27+
3628
3729
TODO: Rename `ᶜK` to `ᶜκ`.
3830
"""
@@ -48,43 +40,25 @@ function implicit_precomputed_quantities(Y, atmos)
4840
ᶠu = similar(Y.f, CT123{FT}),
4941
ᶜK = similar(Y.c, FT),
5042
ᶜts = similar(Y.c, TST),
51-
ᶜp = similar(Y.c, FT),
52-
ᶜh_tot = similar(Y.c, FT),
43+
ᶜp = similar(Y.c, FT)
5344
)
5445
sgs_quantities =
55-
turbconv_model isa AbstractEDMF ? (; ᶜtke⁰ = similar(Y.c, FT)) : (;)
56-
moisture_sgs_quantities =
57-
(
58-
turbconv_model isa PrognosticEDMFX &&
59-
moisture_model isa NonEquilMoistModel &&
60-
microphysics_model isa Microphysics1Moment
61-
) ?
62-
(;
63-
ᶜq_liq⁰ = similar(Y.c, FT),
64-
ᶜq_ice⁰ = similar(Y.c, FT),
65-
ᶜq_rai⁰ = similar(Y.c, FT),
66-
ᶜq_sno⁰ = similar(Y.c, FT),
67-
) : (;)
46+
turbconv_model isa AbstractEDMF ? (;) : (;)
6847
prognostic_sgs_quantities =
6948
turbconv_model isa PrognosticEDMFX ?
7049
(;
71-
ᶜρa⁰ = similar(Y.c, FT),
72-
ᶜmse⁰ = similar(Y.c, FT),
73-
ᶜq_tot⁰ = similar(Y.c, FT),
7450
ᶠu₃⁰ = similar(Y.f, C3{FT}),
7551
ᶜu⁰ = similar(Y.c, C123{FT}),
7652
ᶠu³⁰ = similar(Y.f, CT3{FT}),
7753
ᶜK⁰ = similar(Y.c, FT),
7854
ᶜts⁰ = similar(Y.c, TST),
79-
ᶜρ⁰ = similar(Y.c, FT),
8055
ᶜuʲs = similar(Y.c, NTuple{n, C123{FT}}),
8156
ᶠu³ʲs = similar(Y.f, NTuple{n, CT3{FT}}),
8257
ᶜKʲs = similar(Y.c, NTuple{n, FT}),
8358
ᶠKᵥʲs = similar(Y.f, NTuple{n, FT}),
8459
ᶜtsʲs = similar(Y.c, NTuple{n, TST}),
8560
ᶜρʲs = similar(Y.c, NTuple{n, FT}),
8661
ᶠnh_pressure₃_dragʲs = similar(Y.f, NTuple{n, C3{FT}}),
87-
moisture_sgs_quantities...,
8862
) : (;)
8963
return (; gs_quantities..., sgs_quantities..., prognostic_sgs_quantities...)
9064
end
@@ -194,7 +168,6 @@ function precomputed_quantities(Y, atmos)
194168
atmos.turbconv_model isa EDOnlyEDMFX ?
195169
(;
196170
ᶜmixing_length_tuple = similar(Y.c, MixingLength{FT}),
197-
ᶜtke⁰ = similar(Y.c, FT),
198171
ᶜK_u = similar(Y.c, FT),
199172
ρatke_flux = similar(Fields.level(Y.f, half), C3{FT}),
200173
ᶜK_h = similar(Y.c, FT),
@@ -399,18 +372,23 @@ function thermo_state(
399372
return get_ts(ρ, p, θ, e_int, q_tot, q_pt)
400373
end
401374

402-
function thermo_vars(moisture_model, microphysics_model, ᶜY, K, Φ)
403-
energy_var = (; e_int = specific(ᶜY.ρe_tot, ᶜY.ρ) - K - Φ)
375+
function thermo_vars(moisture_model, microphysics_model, Y_c, K, Φ)
376+
# Compute specific quantities on-the-fly
377+
e_tot = @. lazy(specific(Y_c.ρe_tot, Y_c.ρ))
378+
energy_var = (; e_int = e_tot - K - Φ)
379+
404380
moisture_var = if moisture_model isa DryModel
405381
(;)
406382
elseif moisture_model isa EquilMoistModel
407-
(; q_tot = specific(ᶜY.ρq_tot, ᶜY.ρ))
383+
q_tot = @. lazy(specific(Y_c.ρq_tot, Y_c.ρ))
384+
(; q_tot)
408385
elseif moisture_model isa NonEquilMoistModel
409-
q_pt_args = (;
410-
q_tot = specific(ᶜY.ρq_tot, ᶜY.ρ),
411-
q_liq = specific(ᶜY.ρq_liq, ᶜY.ρ) + specific(ᶜY.ρq_rai, ᶜY.ρ),
412-
q_ice = specific(ᶜY.ρq_ice, ᶜY.ρ) + specific(ᶜY.ρq_sno, ᶜY.ρ),
413-
)
386+
q_tot = @. lazy(specific(Y_c.ρq_tot, Y_c.ρ))
387+
q_liq = @. lazy(specific(Y_c.ρq_liq, Y_c.ρ))
388+
q_ice = @. lazy(specific(Y_c.ρq_ice, Y_c.ρ))
389+
q_rai = @. lazy(specific(Y_c.ρq_rai, Y_c.ρ))
390+
q_sno = @. lazy(specific(Y_c.ρq_sno, Y_c.ρ))
391+
q_pt_args = (q_tot, q_liq + q_rai, q_ice + q_sno)
414392
(; q_pt = TD.PhasePartition(q_pt_args...))
415393
end
416394
return (; energy_var..., moisture_var...)
@@ -458,7 +436,7 @@ quantities are updated.
458436
NVTX.@annotate function set_implicit_precomputed_quantities!(Y, p, t)
459437
(; turbconv_model, moisture_model, microphysics_model) = p.atmos
460438
(; ᶜΦ) = p.core
461-
(; ᶜspecific, ᶜu, ᶠu³, ᶠu, ᶜK, ᶜts, ᶜp, ᶜh_tot) = p.precomputed
439+
(; ᶜu, ᶠu³, ᶠu, ᶜK, ᶜts, ᶜp) = p.precomputed
462440
ᶠuₕ³ = p.scratch.ᶠtemp_CT3
463441
n = n_mass_flux_subdomains(turbconv_model)
464442
thermo_params = CAP.thermodynamics_params(p.params)
@@ -492,19 +470,15 @@ NVTX.@annotate function set_implicit_precomputed_quantities!(Y, p, t)
492470
end
493471
@. ᶜts = ts_gs(thermo_args..., Y.c, ᶜK, ᶜΦ, Y.c.ρ)
494472
@. ᶜp = TD.air_pressure(thermo_params, ᶜts)
495-
@. ᶜh_tot = TD.total_specific_enthalpy(
496-
thermo_params,
497-
ᶜts,
498-
specific(Y.c.ρe_tot, Y.c.ρ),
499-
)
500473

501474
if turbconv_model isa PrognosticEDMFX
502475
set_prognostic_edmf_precomputed_quantities_draft!(Y, p, ᶠuₕ³, t)
503476
set_prognostic_edmf_precomputed_quantities_environment!(Y, p, ᶠuₕ³, t)
504477
set_prognostic_edmf_precomputed_quantities_implicit_closures!(Y, p, t)
505-
elseif turbconv_model isa AbstractEDMF
506-
(; ᶜtke⁰) = p.precomputed
507-
@. ᶜtke⁰ = Y.c.sgs⁰.ρatke / Y.c.ρ
478+
elseif turbconv_model isa DiagnosticEDMFX
479+
set_diagnostic_edmf_precomputed_quantities!(Y, p, t)
480+
elseif !(isnothing(turbconv_model))
481+
# Do nothing for other turbconv models for now
508482
end
509483
end
510484

0 commit comments

Comments
 (0)