Skip to content

Commit 7bd5fab

Browse files
committed
review comments
1 parent 5379b0a commit 7bd5fab

File tree

3 files changed

+116
-48
lines changed

3 files changed

+116
-48
lines changed

src/cache/precipitation_precomputed_quantities.jl

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

115-
q_liq = ᶜspecific(Y.c.ρq_liq, Y.c.ρ)
116-
q_ice = ᶜspecific(Y.c.ρq_ice, Y.c.ρ)
117-
q_rai = ᶜspecific(Y.c.ρq_rai, Y.c.ρ)
118-
q_sno = ᶜspecific(Y.c.ρq_sno, Y.c.ρ)
119-
120115
# compute the precipitation terminal velocity [m/s]
121116
# TODO sedimentation of snow is based on the 1M scheme
122117
@. ᶜwnᵣ = getindex(
@@ -367,11 +362,6 @@ function set_precipitation_cache!(Y, p, ::Microphysics2Moment, _)
367362
(; ᶜSqₗᵖ, ᶜSqᵢᵖ, ᶜSqᵣᵖ, ᶜSqₛᵖ) = p.precomputed
368363
(; ᶜSnₗᵖ, ᶜSnᵣᵖ) = p.precomputed
369364

370-
q_liq = ᶜspecific(Y.c.ρq_liq, Y.c.ρ)
371-
q_rai = ᶜspecific(Y.c.ρq_rai, Y.c.ρ)
372-
n_liq = ᶜspecific(Y.c.ρn_liq, Y.c.ρ)
373-
n_rai = ᶜspecific(Y.c.ρn_rai, Y.c.ρ)
374-
375365
ᶜSᵖ = p.scratch.ᶜtemp_scalar
376366
ᶜS₂ᵖ = p.scratch.ᶜtemp_scalar_2
377367

src/cache/precomputed_quantities.jl

Lines changed: 114 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -302,11 +302,12 @@ end
302302

303303
function add_sgs_ᶜK!(ᶜK, Y, ᶜρa⁰_vals, ᶠu₃⁰, turbconv_model)
304304
@. ᶜK +=
305-
ᶜρa⁰_vals * ᶜinterp(dot(ᶠu₃⁰ - Yf.u₃, CT3(ᶠu₃⁰ - Yf.u₃))) / 2 / Yc.ρ
305+
ᶜρa⁰_vals * ᶜinterp(dot(ᶠu₃⁰ - Y.f.u₃, CT3(ᶠu₃⁰ - Y.f.u₃))) / 2 / Y.c.ρ
306306
for j in 1:n_mass_flux_subdomains(turbconv_model)
307307
ᶜρaʲ = Y.c.sgsʲs.:($j).ρa
308308
ᶠu₃ʲ = Y.f.sgsʲs.:($j).u₃
309-
@. ᶜK += ᶜρaʲ * ᶜinterp(dot(ᶠu₃ʲ - Yf.u₃, CT3(ᶠu₃ʲ - Yf.u₃))) / 2 / Yc.ρ
309+
@. ᶜK +=
310+
ᶜρaʲ * ᶜinterp(dot(ᶠu₃ʲ - Y.f.u₃, CT3(ᶠu₃ʲ - Y.f.u₃))) / 2 / Y.c.ρ
310311
end
311312
return nothing
312313
end
@@ -365,56 +366,133 @@ function ᶜthermo_state(
365366
q_pt = nothing,
366367
)
367368

368-
get_ts::T, ::Nothing, θ::T, ::Nothing, ::Nothing, ::Nothing) where {T <: FieldOrValue} =
369-
TD.PhaseDry_ρθ(thermo_params, ρ, θ)
370-
get_ts::T, ::Nothing, θ::T, ::Nothing, q_tot::T, ::Nothing) where {T <: FieldOrValue} =
371-
TD.PhaseEquil_ρθq(thermo_params, ρ, θ, q_tot)
372-
get_ts::T, ::Nothing, θ::T, ::Nothing, ::Nothing, q_pt) where {T <: FieldOrValue} =
369+
get_ts(
370+
ρ::T,
371+
::Nothing,
372+
θ::T,
373+
::Nothing,
374+
::Nothing,
375+
::Nothing,
376+
) where {T <: FieldOrValue} = TD.PhaseDry_ρθ(thermo_params, ρ, θ)
377+
get_ts(
378+
ρ::T,
379+
::Nothing,
380+
θ::T,
381+
::Nothing,
382+
q_tot::T,
383+
::Nothing,
384+
) where {T <: FieldOrValue} = TD.PhaseEquil_ρθq(thermo_params, ρ, θ, q_tot)
385+
get_ts(
386+
ρ::T,
387+
::Nothing,
388+
θ::T,
389+
::Nothing,
390+
::Nothing,
391+
q_pt,
392+
) where {T <: FieldOrValue} =
373393
TD.PhaseNonEquil_ρθq(thermo_params, ρ, θ, q_pt)
374-
get_ts::T, ::Nothing, ::Nothing, e_int::T, ::Nothing, ::Nothing) where {T <: FieldOrValue} =
375-
TD.PhaseDry_ρe(thermo_params, ρ, e_int)
376-
get_ts::T, ::Nothing, ::Nothing, e_int::T, q_tot::T, ::Nothing) where {T <: FieldOrValue} =
377-
TD.PhaseEquil_ρeq(
378-
thermo_params,
379-
ρ,
380-
e_int,
381-
q_tot,
382-
3,
383-
eltype(thermo_params)(0.003),
384-
)
385-
get_ts::T, ::Nothing, ::Nothing, e_int::T, ::Nothing, q_pt) where {T <: FieldOrValue} =
394+
get_ts(
395+
ρ::T,
396+
::Nothing,
397+
::Nothing,
398+
e_int::T,
399+
::Nothing,
400+
::Nothing,
401+
) where {T <: FieldOrValue} = TD.PhaseDry_ρe(thermo_params, ρ, e_int)
402+
get_ts(
403+
ρ::T,
404+
::Nothing,
405+
::Nothing,
406+
e_int::T,
407+
q_tot::T,
408+
::Nothing,
409+
) where {T <: FieldOrValue} = TD.PhaseEquil_ρeq(
410+
thermo_params,
411+
ρ,
412+
e_int,
413+
q_tot,
414+
3,
415+
eltype(thermo_params)(0.003),
416+
)
417+
get_ts(
418+
ρ::T,
419+
::Nothing,
420+
::Nothing,
421+
e_int::T,
422+
::Nothing,
423+
q_pt,
424+
) where {T <: FieldOrValue} =
386425
TD.PhaseNonEquil(thermo_params, e_int, ρ, q_pt)
387-
get_ts(::Nothing, p::T, θ::T, ::Nothing, ::Nothing, ::Nothing) where {T <: FieldOrValue} =
388-
TD.PhaseDry_pθ(thermo_params, p, θ)
389-
get_ts(::Nothing, p::T, θ::T, ::Nothing, q_tot::T, ::Nothing) where {T <: FieldOrValue} =
390-
TD.PhaseEquil_pθq(thermo_params, p, θ, q_tot)
391-
get_ts(::Nothing, p::T, θ::T, ::Nothing, ::Nothing, q_pt) where {T <: FieldOrValue} =
426+
get_ts(
427+
::Nothing,
428+
p::T,
429+
θ::T,
430+
::Nothing,
431+
::Nothing,
432+
::Nothing,
433+
) where {T <: FieldOrValue} = TD.PhaseDry_pθ(thermo_params, p, θ)
434+
get_ts(
435+
::Nothing,
436+
p::T,
437+
θ::T,
438+
::Nothing,
439+
q_tot::T,
440+
::Nothing,
441+
) where {T <: FieldOrValue} = TD.PhaseEquil_pθq(thermo_params, p, θ, q_tot)
442+
get_ts(
443+
::Nothing,
444+
p::T,
445+
θ::T,
446+
::Nothing,
447+
::Nothing,
448+
q_pt,
449+
) where {T <: FieldOrValue} =
392450
TD.PhaseNonEquil_pθq(thermo_params, p, θ, q_pt)
393-
get_ts(::Nothing, p::T, ::Nothing, e_int::T, ::Nothing, ::Nothing) where {T <: FieldOrValue} =
394-
TD.PhaseDry_pe(thermo_params, p, e_int)
395-
get_ts(::Nothing, p::T, ::Nothing, e_int::T, q_tot::T, ::Nothing) where {T <: FieldOrValue} =
451+
get_ts(
452+
::Nothing,
453+
p::T,
454+
::Nothing,
455+
e_int::T,
456+
::Nothing,
457+
::Nothing,
458+
) where {T <: FieldOrValue} = TD.PhaseDry_pe(thermo_params, p, e_int)
459+
get_ts(
460+
::Nothing,
461+
p::T,
462+
::Nothing,
463+
e_int::T,
464+
q_tot::T,
465+
::Nothing,
466+
) where {T <: FieldOrValue} =
396467
TD.PhaseEquil_peq(thermo_params, p, e_int, q_tot)
397-
get_ts(::Nothing, p::T, ::Nothing, e_int::T, ::Nothing, q_pt) where {T <: FieldOrValue} =
468+
get_ts(
469+
::Nothing,
470+
p::T,
471+
::Nothing,
472+
e_int::T,
473+
::Nothing,
474+
q_pt,
475+
) where {T <: FieldOrValue} =
398476
TD.PhaseNonEquil_peq(thermo_params, p, e_int, q_pt)
399477

400478
return @. lazy(get_ts(ρ, p, θ, e_int, q_tot, q_pt))
401479
end
402480

403-
function thermo_vars(moisture_model, microphysics_model, Y_c, K, Φ)
404-
e_tot = ᶜspecific(Y_c.ρe_tot, Y_c.ρ)
481+
function thermo_vars(moisture_model, microphysics_model, ᶜY, K, Φ)
482+
e_tot = ᶜspecific(ᶜY.ρe_tot, ᶜY.ρ)
405483
energy_var = (; e_int = @. lazy(e_tot - K - Φ))
406484

407485
moisture_var = if moisture_model isa DryModel
408486
(;)
409487
elseif moisture_model isa EquilMoistModel
410-
q_tot = ᶜspecific(Y_c.ρq_tot, Y_c.ρ)
488+
q_tot = ᶜspecific(ᶜY.ρq_tot, ᶜY.ρ)
411489
(; q_tot)
412490
elseif moisture_model isa NonEquilMoistModel
413-
q_tot = ᶜspecific(Y_c.ρq_tot, Y_c.ρ)
414-
q_liq = ᶜspecific(Y_c.ρq_liq, Y_c.ρ)
415-
q_ice = ᶜspecific(Y_c.ρq_ice, Y_c.ρ)
416-
q_rai = ᶜspecific(Y_c.ρq_rai, Y_c.ρ)
417-
q_sno = ᶜspecific(Y_c.ρq_sno, Y_c.ρ)
491+
q_tot = ᶜspecific(ᶜY.ρq_tot, ᶜY.ρ)
492+
q_liq = ᶜspecific(ᶜY.ρq_liq, ᶜY.ρ)
493+
q_ice = ᶜspecific(ᶜY.ρq_ice, ᶜY.ρ)
494+
q_rai = ᶜspecific(ᶜY.ρq_rai, ᶜY.ρ)
495+
q_sno = ᶜspecific(ᶜY.ρq_sno, ᶜY.ρ)
418496
(;
419497
q_pt = @. lazy(
420498
TD.PhasePartition(q_tot, q_liq + q_rai, q_ice + q_sno),

src/utils/variable_manipulations.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,8 +249,8 @@ draft_sum(f, sgsʲs) = mapreduce_with_init(f, +, sgsʲs)
249249
ᶜenv_value(grid_scale_value, f_draft, gs, turbconv_model)
250250
251251
Computes the value of a quantity `ρaχ` in the environment subdomain by subtracting
252-
the sum of its values in all draft subdomains from the grid-scale value. Only available
253-
for environmental area (ᶜρa⁰) for DiagnosticEDMFX.
252+
the sum of its values in all draft subdomains from the grid-scale value. Available
253+
for general variables in PrognosticEDMFX and environmental area (ᶜρa⁰) in DiagnosticEDMFX.
254254
255255
This is based on the domain decomposition principle for density-area weighted
256256
quantities: `GridMean(ρχ) = Env(ρaχ) + Sum(Drafts(ρaχ))`.

0 commit comments

Comments
 (0)