@@ -71,7 +71,7 @@ function set_precipitation_velocities!(Y, p, ::NonEquilMoistModel, ::Microphysic
7171 ᶜwᵪ = get_field(p. precomputed, get_ᶜwᵪ_name_from_qᵪ_name(qᵪ_name))
7272 ᶜqᵪ = ᶜspecific_gs_tracer(Y, qᵪ_name)
7373 wᵪ = terminal_velocity_func_1M(cmc, cmp, qᵪ_name)
74- calc_hₜ = total_energy_func (qᵪ_name)
74+ calc_hₜ = total_energy_fn (qᵪ_name)
7575 @. ᶜwᵪ = wᵪ(Y. c. ρ, clip(ᶜqᵪ))
7676 @. ᶜwₜqₜ += WVec(ᶜwᵪ * ᶜqᵪ)
7777 @. ᶜwₕhₜ += WVec(ᶜwᵪ * ᶜqᵪ * calc_hₜ(thp, ᶜts, ᶜΦ, ᶜwᵪ, ᶜu_uvw))
@@ -83,7 +83,7 @@ function set_precipitation_velocities!(Y, p,
8383)
8484 (; ᶜΦ) = p. core
8585 (; ᶜwₜqₜ, ᶜwₕhₜ) = p. precomputed
86- (; ᶜts⁰, ᶜtsʲs, ᶜρʲs ) = p. precomputed
86+ (; ᶜts⁰, ᶜtsʲs) = p. precomputed
8787 ᶜsgsʲs = Y. c. sgsʲs
8888 ᶜρ = Y. c. ρ
8989 cmc = CAP. microphysics_cloud_params(p. params)
@@ -125,8 +125,8 @@ function set_precipitation_velocities!(Y, p,
125125 @. ᶜwᵪ = ρξw_div_ρξ_bounded(ᶜρaqwᵪ⁰ + draft_sum(ρaqwʲ_clip, ᶜsgsʲs, ᶜtsʲs), ᶜρqᵪ)
126126
127127 # implied environment mass flux: ρqᵪ⋅wᵪ (gm) - ∑ⱼ ρaʲ⋅qᵪʲ⋅wᵪʲ (drafts)
128- ᶜρqᵪ_gm = get_field(Y. c, get_ᶜρqᵪ_name_from_qᵪ_name (qᵪ_name)) # gm
129- ᶜρaqwᵪ⁰_implied = @. lazy(ᶜρqᵪ_gm * ᶜwᵪ) - draft_sum(ρaqwʲ, ᶜsgsʲs, ᶜtsʲs) # not clipped
128+ ᶜρqᵪ_gm = get_field(Y. c, get_ρχ_name (qᵪ_name)) # gm
129+ ᶜρaqwᵪ⁰_implied = @. lazy(ᶜρqᵪ_gm * ᶜwᵪ - draft_sum(ρaqwʲ, ᶜsgsʲs, ᶜtsʲs) ) # not clipped
130130
131131 # Calculate contribution of tracer `q` to total water and energy advection
132132 ρaqwₕhₜʲ(Φ) = (ᶜsgsʲ, ᶜtsʲ) -> ρaqwʲ(ᶜsgsʲ, ᶜtsʲ) * calc_hₜ(thp, ᶜtsʲ, Φ)
@@ -154,7 +154,7 @@ function set_precipitation_velocities!(Y, p, ::NonEquilMoistModel, ::Microphysic
154154 ᶜwₙᵪ = get_field(p. precomputed, get_ᶜwₙᵪ_name_from_qᵪ_name(qᵪ_name))
155155 wᵪ_func = terminal_velocity_mass_func_2M(cm2p, cmc, cm1p, qᵪ_name)
156156 wₙᵪ_func = terminal_velocity_number_func_2M(cm2p, cmc, cm1p, qᵪ_name)
157- calc_hₜ = total_energy_func (qᵪ_name)
157+ calc_hₜ = total_energy_fn (qᵪ_name)
158158 # Get tracer fields
159159 ᶜqᵪ = ᶜspecific_gs_tracer(Y, qᵪ_name)
160160 ρnᵪ_name = get_ρnᵪ_name_from_qᵪ_name(qᵪ_name)
@@ -300,9 +300,9 @@ function set_precipitation_velocities!(
300300
301301 # compute their contributions to energy and total water advection
302302 @. ᶜwₜqₜ = WVec(ᶜwₗ * ρq_liq + ᶜwᵢ * ρq_ice + ᶜwᵣ * ρq_rai) / ρ
303- calc_hₗ = total_energy_func (@name(q_liq))
304- calc_hᵢ = total_energy_func (@name(q_ice))
305- calc_hᵣ = total_energy_func (@name(q_rai))
303+ calc_hₗ = total_energy_fn (@name(q_liq))
304+ calc_hᵢ = total_energy_fn (@name(q_ice))
305+ calc_hᵣ = total_energy_fn (@name(q_rai))
306306 @. ᶜwₕhₜ =
307307 WVec(
308308 ᶜwₗ * ρq_liq * (calc_hₗ(thp, ᶜts, ᶜΦ, ᶜwₗ, UVW(ᶜu))) +
@@ -336,24 +336,26 @@ function set_precipitation_cache!(Y, p, ::Microphysics0Moment, _)
336336 return nothing
337337end
338338function set_precipitation_cache!(Y, p,
339- :: Microphysics0Moment , turbconv :: Union{DiagnosticEDMFX, PrognosticEDMFX} ,
339+ :: Microphysics0Moment , turbconv_model :: Union{DiagnosticEDMFX, PrognosticEDMFX} ,
340340)
341341 (; ᶜΦ) = p. core
342342 (; ᶜSqₜᵖ⁰, ᶜSqₜᵖʲs) = p. precomputed
343343 (; ᶜS_ρq_tot, ᶜS_ρe_tot) = p. precomputed
344344 (; ᶜtsʲs) = p. precomputed
345345 thp = CAP. thermodynamics_params(p. params)
346346 ᶜρ = Y. c. ρ
347+ is_pedmf = turbconv_model isa PrognosticEDMFX
347348
348349 # Draft and environment area-weighted densities
349- ᶜsgs_ρaʲs = ᶜρaʲs_list(Y, p, turbconv)
350+ ᶜsgs_ρaʲs = is_pedmf ? Y . c . sgsʲs : p . precomputed . ᶜρaʲs # used to extract env ρa
350351 # # For environment we multiply by grid mean `ρ` and not by `ᶜρa⁰`, assuming `a⁰ = 1`
351- ᶜρa⁰ = turbconv isa PrognosticEDMFX ? (@. lazy(ρa⁰(ᶜρ, Y. c. sgsʲs, turbconv ))) : ᶜρ
352- ᶜts⁰ = turbconv isa PrognosticEDMFX ? p. precomputed. ᶜts⁰ : p. precomputed. ᶜts
352+ ᶜρa⁰ = is_pedmf ? (@. lazy(ρa⁰(ᶜρ, Y. c. sgsʲs, turbconv_model ))) : ᶜρ
353+ ᶜts⁰ = is_pedmf ? p. precomputed. ᶜts⁰ : p. precomputed. ᶜts
353354
354355 e_tot_src(Sqₜ, ρ, ts, Φ) = Sqₜ * ρ * e_tot_0M_precipitation_sources_helper(thp, ts, Φ)
355- e_tot_srcʲ(Φ) = (Sqₜ, ρ, ts) -> e_tot_src(Sqₜ, ρ, ts, Φ)
356- @. ᶜS_ρq_tot = ᶜSqₜᵖ⁰ * ᶜρa⁰ + draft_sum((S, ρ) -> S * ρ, ᶜSqₜᵖʲs, ᶜsgs_ρaʲs)
356+ e_tot_srcʲ(Φ) = (Sqₜ, sgs_ρʲ, ts) -> e_tot_src(Sqₜ, ρaʲ(sgs_ρʲ, turbconv_model), ts, Φ)
357+ Sqₜρʲ(Sqₜ, sgs_ρʲ) = Sqₜ * ρaʲ(sgs_ρʲ, turbconv_model)
358+ @. ᶜS_ρq_tot = ᶜSqₜᵖ⁰ * ᶜρa⁰ + draft_sum(Sqₜρʲ, ᶜSqₜᵖʲs, ᶜsgs_ρaʲs)
357359 ᶜS_ρe_tot⁰ = @. lazy(e_tot_src(ᶜSqₜᵖ⁰, ᶜρa⁰, ᶜts⁰, ᶜΦ))
358360 @. ᶜS_ρe_tot = ᶜS_ρe_tot⁰ + draft_sum(e_tot_srcʲ(ᶜΦ), ᶜSqₜᵖʲs, ᶜsgs_ρaʲs, ᶜtsʲs)
359361 return nothing
0 commit comments