Skip to content

Commit 7365926

Browse files
committed
review comments
1 parent d4ae75d commit 7365926

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
@@ -321,11 +321,12 @@ end
321321

322322
function add_sgs_ᶜK!(ᶜK, Y, ᶜρa⁰_vals, ᶠu₃⁰, turbconv_model)
323323
@. ᶜK +=
324-
ᶜρa⁰_vals * ᶜinterp(dot(ᶠu₃⁰ - Yf.u₃, CT3(ᶠu₃⁰ - Yf.u₃))) / 2 / Yc.ρ
324+
ᶜρa⁰_vals * ᶜinterp(dot(ᶠu₃⁰ - Y.f.u₃, CT3(ᶠu₃⁰ - Y.f.u₃))) / 2 / Y.c.ρ
325325
for j in 1:n_mass_flux_subdomains(turbconv_model)
326326
ᶜρaʲ = Y.c.sgsʲs.:($j).ρa
327327
ᶠu₃ʲ = Y.f.sgsʲs.:($j).u₃
328-
@. ᶜK += ᶜρaʲ * ᶜinterp(dot(ᶠu₃ʲ - Yf.u₃, CT3(ᶠu₃ʲ - Yf.u₃))) / 2 / Yc.ρ
328+
@. ᶜK +=
329+
ᶜρaʲ * ᶜinterp(dot(ᶠu₃ʲ - Y.f.u₃, CT3(ᶠu₃ʲ - Y.f.u₃))) / 2 / Y.c.ρ
329330
end
330331
return nothing
331332
end
@@ -384,56 +385,133 @@ function ᶜthermo_state(
384385
q_pt = nothing,
385386
)
386387

387-
get_ts::T, ::Nothing, θ::T, ::Nothing, ::Nothing, ::Nothing) where {T <: FieldOrValue} =
388-
TD.PhaseDry_ρθ(thermo_params, ρ, θ)
389-
get_ts::T, ::Nothing, θ::T, ::Nothing, q_tot::T, ::Nothing) where {T <: FieldOrValue} =
390-
TD.PhaseEquil_ρθq(thermo_params, ρ, θ, q_tot)
391-
get_ts::T, ::Nothing, θ::T, ::Nothing, ::Nothing, q_pt) where {T <: FieldOrValue} =
388+
get_ts(
389+
ρ::T,
390+
::Nothing,
391+
θ::T,
392+
::Nothing,
393+
::Nothing,
394+
::Nothing,
395+
) where {T <: FieldOrValue} = TD.PhaseDry_ρθ(thermo_params, ρ, θ)
396+
get_ts(
397+
ρ::T,
398+
::Nothing,
399+
θ::T,
400+
::Nothing,
401+
q_tot::T,
402+
::Nothing,
403+
) where {T <: FieldOrValue} = TD.PhaseEquil_ρθq(thermo_params, ρ, θ, q_tot)
404+
get_ts(
405+
ρ::T,
406+
::Nothing,
407+
θ::T,
408+
::Nothing,
409+
::Nothing,
410+
q_pt,
411+
) where {T <: FieldOrValue} =
392412
TD.PhaseNonEquil_ρθq(thermo_params, ρ, θ, q_pt)
393-
get_ts::T, ::Nothing, ::Nothing, e_int::T, ::Nothing, ::Nothing) where {T <: FieldOrValue} =
394-
TD.PhaseDry_ρe(thermo_params, ρ, e_int)
395-
get_ts::T, ::Nothing, ::Nothing, e_int::T, q_tot::T, ::Nothing) where {T <: FieldOrValue} =
396-
TD.PhaseEquil_ρeq(
397-
thermo_params,
398-
ρ,
399-
e_int,
400-
q_tot,
401-
3,
402-
eltype(thermo_params)(0.003),
403-
)
404-
get_ts::T, ::Nothing, ::Nothing, e_int::T, ::Nothing, q_pt) where {T <: FieldOrValue} =
413+
get_ts(
414+
ρ::T,
415+
::Nothing,
416+
::Nothing,
417+
e_int::T,
418+
::Nothing,
419+
::Nothing,
420+
) where {T <: FieldOrValue} = TD.PhaseDry_ρe(thermo_params, ρ, e_int)
421+
get_ts(
422+
ρ::T,
423+
::Nothing,
424+
::Nothing,
425+
e_int::T,
426+
q_tot::T,
427+
::Nothing,
428+
) where {T <: FieldOrValue} = TD.PhaseEquil_ρeq(
429+
thermo_params,
430+
ρ,
431+
e_int,
432+
q_tot,
433+
3,
434+
eltype(thermo_params)(0.003),
435+
)
436+
get_ts(
437+
ρ::T,
438+
::Nothing,
439+
::Nothing,
440+
e_int::T,
441+
::Nothing,
442+
q_pt,
443+
) where {T <: FieldOrValue} =
405444
TD.PhaseNonEquil(thermo_params, e_int, ρ, q_pt)
406-
get_ts(::Nothing, p::T, θ::T, ::Nothing, ::Nothing, ::Nothing) where {T <: FieldOrValue} =
407-
TD.PhaseDry_pθ(thermo_params, p, θ)
408-
get_ts(::Nothing, p::T, θ::T, ::Nothing, q_tot::T, ::Nothing) where {T <: FieldOrValue} =
409-
TD.PhaseEquil_pθq(thermo_params, p, θ, q_tot)
410-
get_ts(::Nothing, p::T, θ::T, ::Nothing, ::Nothing, q_pt) where {T <: FieldOrValue} =
445+
get_ts(
446+
::Nothing,
447+
p::T,
448+
θ::T,
449+
::Nothing,
450+
::Nothing,
451+
::Nothing,
452+
) where {T <: FieldOrValue} = TD.PhaseDry_pθ(thermo_params, p, θ)
453+
get_ts(
454+
::Nothing,
455+
p::T,
456+
θ::T,
457+
::Nothing,
458+
q_tot::T,
459+
::Nothing,
460+
) where {T <: FieldOrValue} = TD.PhaseEquil_pθq(thermo_params, p, θ, q_tot)
461+
get_ts(
462+
::Nothing,
463+
p::T,
464+
θ::T,
465+
::Nothing,
466+
::Nothing,
467+
q_pt,
468+
) where {T <: FieldOrValue} =
411469
TD.PhaseNonEquil_pθq(thermo_params, p, θ, q_pt)
412-
get_ts(::Nothing, p::T, ::Nothing, e_int::T, ::Nothing, ::Nothing) where {T <: FieldOrValue} =
413-
TD.PhaseDry_pe(thermo_params, p, e_int)
414-
get_ts(::Nothing, p::T, ::Nothing, e_int::T, q_tot::T, ::Nothing) where {T <: FieldOrValue} =
470+
get_ts(
471+
::Nothing,
472+
p::T,
473+
::Nothing,
474+
e_int::T,
475+
::Nothing,
476+
::Nothing,
477+
) where {T <: FieldOrValue} = TD.PhaseDry_pe(thermo_params, p, e_int)
478+
get_ts(
479+
::Nothing,
480+
p::T,
481+
::Nothing,
482+
e_int::T,
483+
q_tot::T,
484+
::Nothing,
485+
) where {T <: FieldOrValue} =
415486
TD.PhaseEquil_peq(thermo_params, p, e_int, q_tot)
416-
get_ts(::Nothing, p::T, ::Nothing, e_int::T, ::Nothing, q_pt) where {T <: FieldOrValue} =
487+
get_ts(
488+
::Nothing,
489+
p::T,
490+
::Nothing,
491+
e_int::T,
492+
::Nothing,
493+
q_pt,
494+
) where {T <: FieldOrValue} =
417495
TD.PhaseNonEquil_peq(thermo_params, p, e_int, q_pt)
418496

419497
return @. lazy(get_ts(ρ, p, θ, e_int, q_tot, q_pt))
420498
end
421499

422-
function thermo_vars(moisture_model, microphysics_model, Y_c, K, Φ)
423-
e_tot = ᶜspecific(Y_c.ρe_tot, Y_c.ρ)
500+
function thermo_vars(moisture_model, microphysics_model, ᶜY, K, Φ)
501+
e_tot = ᶜspecific(ᶜY.ρe_tot, ᶜY.ρ)
424502
energy_var = (; e_int = @. lazy(e_tot - K - Φ))
425503

426504
moisture_var = if moisture_model isa DryModel
427505
(;)
428506
elseif moisture_model isa EquilMoistModel
429-
q_tot = ᶜspecific(Y_c.ρq_tot, Y_c.ρ)
507+
q_tot = ᶜspecific(ᶜY.ρq_tot, ᶜY.ρ)
430508
(; q_tot)
431509
elseif moisture_model isa NonEquilMoistModel
432-
q_tot = ᶜspecific(Y_c.ρq_tot, Y_c.ρ)
433-
q_liq = ᶜspecific(Y_c.ρq_liq, Y_c.ρ)
434-
q_ice = ᶜspecific(Y_c.ρq_ice, Y_c.ρ)
435-
q_rai = ᶜspecific(Y_c.ρq_rai, Y_c.ρ)
436-
q_sno = ᶜspecific(Y_c.ρq_sno, Y_c.ρ)
510+
q_tot = ᶜspecific(ᶜY.ρq_tot, ᶜY.ρ)
511+
q_liq = ᶜspecific(ᶜY.ρq_liq, ᶜY.ρ)
512+
q_ice = ᶜspecific(ᶜY.ρq_ice, ᶜY.ρ)
513+
q_rai = ᶜspecific(ᶜY.ρq_rai, ᶜY.ρ)
514+
q_sno = ᶜspecific(ᶜY.ρq_sno, ᶜY.ρ)
437515
(;
438516
q_pt = @. lazy(
439517
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)