Skip to content

Commit be0e044

Browse files
committed
Add warm-rain 2-moment microphysics on grid mean
1 parent 756dcf6 commit be0e044

25 files changed

+776
-42
lines changed

.buildkite/pipeline.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,13 @@ steps:
8686
--config_file $CONFIG_PATH/single_column_precipitation_test.yml
8787
--job_id single_column_precipitation_test
8888
artifact_paths: "single_column_precipitation_test/output_active/*"
89+
90+
- label: ":umbrella: 2-moment precipitation sanity test single column"
91+
command: >
92+
julia --color=yes --project=.buildkite .buildkite/ci_driver.jl
93+
--config_file $CONFIG_PATH/single_column_precipitation_2M_test.yml
94+
--job_id single_column_precipitation_2M_test
95+
artifact_paths: "single_column_precipitation_2M_test/output_active/*"
8996

9097
- group: "Gravity wave"
9198
steps:
@@ -367,6 +374,20 @@ steps:
367374
slurm_mem: 20GB
368375
slurm_constraint: icelake|cascadelake|skylake|epyc
369376

377+
- label: ":umbrella: aquaplanet nonequil allsky monin_obukhov varying insol gravity wave (gfdl_restart) high top 2-moment"
378+
command: >
379+
julia --color=yes --project=.buildkite .buildkite/ci_driver.jl
380+
--config_file $CONFIG_PATH/aquaplanet_nonequil_allsky_gw_res_2M.yml
381+
--job_id aquaplanet_nonequil_allsky_gw_res_2M
382+
383+
julia --color=yes --project=.buildkite reproducibility_tests/test_mse.jl
384+
--job_id aquaplanet_nonequil_allsky_gw_res_2M
385+
--out_dir aquaplanet_nonequil_allsky_gw_res_2M/output_active
386+
artifact_paths: "aquaplanet_nonequil_allsky_gw_res_2M/output_active/*"
387+
agents:
388+
slurm_mem: 20GB
389+
slurm_constraint: icelake|cascadelake|skylake|epyc
390+
370391
- label: ":computer: aquaplanet equil allsky monin_obukhov varying insol gravity wave (raw_topo) high top zonally asymmetric"
371392
command: >
372393
julia --color=yes --project=.buildkite .buildkite/ci_driver.jl
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
z_max: 60000.0
2+
z_elem: 31
3+
dz_bottom: 50.0
4+
rayleigh_sponge: true
5+
dt: "360secs"
6+
t_end: "1days"
7+
dt_save_state_to_disk: "24hours"
8+
vert_diff: "DecayWithHeightDiffusion"
9+
implicit_diffusion: true
10+
approximate_linear_solve_iters: 2
11+
moist: "nonequil"
12+
precip_model: "2M"
13+
rad: "allskywithclear"
14+
aerosol_radiation: true
15+
prescribe_clouds_in_radiation: true
16+
radiation_reset_rng_seed: true
17+
insolation: "timevarying"
18+
non_orographic_gravity_wave: true
19+
orographic_gravity_wave: "gfdl_restart"
20+
surface_setup: "DefaultMoninObukhov"
21+
prescribe_ozone: true
22+
reproducibility_test: true
23+
prescribed_aerosols: ["SO4", "CB1", "OC1", "DST01", "SSLT01"]
24+
diagnostics:
25+
- short_name: [edt, evu, mmrso4, mmrbcpo, mmrocpo, mmrdust, mmrss, loadss, o3, od550aer, odsc550aer]
26+
reduction_time: average
27+
period: 1days
28+
- short_name: [hus, clw, cli, husra, hussn, cdnc, ncra]
29+
reduction_time: average
30+
period: 1days
31+
- short_name: [reffclw, reffcli]
32+
period: 6hours
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
config: "column"
2+
initial_condition: "PrecipitatingColumn"
3+
surface_setup: "DefaultMoninObukhov"
4+
z_elem: 200
5+
z_max: 10000.0
6+
z_stretch: false
7+
dt: "10secs"
8+
t_end: "1500secs"
9+
dt_save_state_to_disk: "500secs"
10+
dt_cloud_fraction: "60secs"
11+
cloud_model: "grid_scale"
12+
moist: "nonequil"
13+
precip_model: "2M"
14+
vert_diff: "DecayWithHeightDiffusion"
15+
implicit_diffusion: true
16+
approximate_linear_solve_iters: 2
17+
reproducibility_test: false
18+
diagnostics:
19+
- short_name: [hus, clw, cli, husra, hussn, cdnc, ncra, ta, wa]
20+
period: 500secs
21+
- short_name: [pr]
22+
period: 10secs

post_processing/ci_plots.jl

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -621,23 +621,36 @@ function make_plots(
621621
end
622622

623623
function make_plots(
624-
::Val{:single_column_precipitation_test},
624+
sim_type::Union{
625+
Val{:single_column_precipitation_test},
626+
Val{:single_column_precipitation_2M_test},
627+
},
625628
output_paths::Vector{<:AbstractString},
626629
)
627630
simdirs = SimDir.(output_paths)
628631

629632
# TODO: Move this plotting code into the same framework as the other ones
630633
simdir = simdirs[1]
631634

632-
short_names = ["hus", "clw", "cli", "husra", "hussn", "ta"]
635+
if sim_type isa Val{:single_column_precipitation_test}
636+
short_names = ["hus", "clw", "cli", "husra", "hussn", "ta"]
637+
figsize = (1200, 600)
638+
pr_row = 3
639+
else
640+
short_names =
641+
["hus", "clw", "cli", "husra", "hussn", "ta", "cdnc", "ncra"]
642+
figsize = (1200, 800)
643+
pr_row = 4
644+
end
645+
633646
vars = [
634647
slice(get(simdir; short_name), x = 0.0, y = 0.0) for
635648
short_name in short_names
636649
]
637650

638651
# We first prepare the axes with all the nice labels with ClimaAnalysis, then we use
639652
# CairoMakie to add the additional lines.
640-
fig = CairoMakie.Figure(; size = (1200, 600))
653+
fig = CairoMakie.Figure(; size = figsize)
641654

642655
p_loc = [1, 1]
643656

@@ -677,7 +690,7 @@ function make_plots(
677690
viz.line_plot1D!(
678691
fig,
679692
slice(surface_precip, x = 0.0, y = 0.0);
680-
p_loc = [3, 1:3],
693+
p_loc = [pr_row, 1:3],
681694
)
682695

683696
file_path = joinpath(output_paths[1], "summary.pdf")
@@ -1130,6 +1143,7 @@ AquaplanetPlots = Union{
11301143
Val{:edonly_edmfx_aquaplanet},
11311144
Val{:mpi_sphere_aquaplanet_rhoe_equil_clearsky},
11321145
Val{:aquaplanet_nonequil_allsky_gw_res},
1146+
Val{:aquaplanet_nonequil_allsky_gw_res_2M},
11331147
Val{:rcemipii_sphere_diagnostic_edmfx},
11341148
Val{:longrun_aquaplanet_allsky_0M},
11351149
Val{:longrun_aquaplanet_allsky_diagedmf_0M},
@@ -1141,11 +1155,17 @@ AquaplanetPlots = Union{
11411155
Val{:amip_target_edonly},
11421156
}
11431157

1144-
function make_plots(::AquaplanetPlots, output_paths::Vector{<:AbstractString})
1158+
function make_plots(
1159+
sim_type::AquaplanetPlots,
1160+
output_paths::Vector{<:AbstractString},
1161+
)
11451162
simdirs = SimDir.(output_paths)
11461163

11471164
reduction = "average"
1148-
short_names_3D = ["ua", "ta", "hus"]
1165+
short_names_3D =
1166+
sim_type isa Val{:aquaplanet_nonequil_allsky_gw_res_2M} ?
1167+
["ua", "ta", "hus", "clw", "cli", "husra", "hussn", "cdnc", "ncra"] :
1168+
["ua", "ta", "hus"]
11491169
short_names_2D = [
11501170
"rsdt",
11511171
"rsds",

reproducibility_tests/ref_counter.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
243
1+
244
22

33
# **README**
44
#
@@ -20,6 +20,9 @@
2020

2121

2222
#=
23+
244
24+
- Add a new test case: aquaplanet with 2M microphysics
25+
2326
243
2427
- Consolidate eddy diffusivity logic in eddy_diffusion_closures.jl and mass flux
2528
logic in mass_flux_closures.jl, update buoyancy calculations to be consistent throughout

src/cache/precipitation_precomputed_quantities.jl

Lines changed: 114 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import CloudMicrophysics.MicrophysicsNonEq as CMNe
66
import CloudMicrophysics.Microphysics1M as CM1
7+
import CloudMicrophysics.Microphysics2M as CM2
78

89
import Thermodynamics as TD
910
import ClimaCore.Operators as Operators
@@ -97,6 +98,59 @@ function set_precipitation_velocities!(
9798
) / Y.c.ρ
9899
return nothing
99100
end
101+
function set_precipitation_velocities!(
102+
Y,
103+
p,
104+
moisture_model::NonEquilMoistModel,
105+
precip_model::Microphysics2Moment,
106+
)
107+
(; ᶜwₗ, ᶜwᵢ, ᶜwᵣ, ᶜwₛ, ᶜwnₗ, ᶜwnᵣ, ᶜwₜqₜ, ᶜwₕhₜ, ᶜts, ᶜu) = p.precomputed
108+
(; q_liq, q_ice, q_rai, q_sno) = p.precomputed.ᶜspecific
109+
(; ᶜΦ) = p.core
110+
111+
cm1c = CAP.microphysics_cloud_params(p.params)
112+
cm1p = CAP.microphysics_1m_params(p.params)
113+
cm2p = CAP.microphysics_2m_params(p.params)
114+
thp = CAP.thermodynamics_params(p.params)
115+
116+
# compute the precipitation terminal velocity [m/s]
117+
# TODO sedimentation of snow is based on the 1M scheme
118+
@. ᶜwnᵣ = getindex(
119+
CM2.rain_terminal_velocity(cm2p.sb, cm2p.tv, q_rai, Y.c.ρ, Y.c.ρn_rai),
120+
1,
121+
)
122+
@. ᶜwᵣ = getindex(
123+
CM2.rain_terminal_velocity(cm2p.sb, cm2p.tv, q_rai, Y.c.ρ, Y.c.ρn_rai),
124+
2,
125+
)
126+
@. ᶜwₛ = CM1.terminal_velocity(cm1p.ps, cm1p.tv.snow, Y.c.ρ, q_sno)
127+
# compute sedimentation velocity for cloud condensate [m/s]
128+
# TODO sedimentation velocities of cloud condensates are based
129+
# on the 1M scheme. Sedimentation velocity of cloud number concentration
130+
# is equal to that of the mass.
131+
@. ᶜwnₗ =
132+
CMNe.terminal_velocity(cm1c.liquid, cm1c.Ch2022.rain, Y.c.ρ, q_liq)
133+
@. ᶜwₗ = CMNe.terminal_velocity(cm1c.liquid, cm1c.Ch2022.rain, Y.c.ρ, q_liq)
134+
@. ᶜwᵢ =
135+
CMNe.terminal_velocity(cm1c.ice, cm1c.Ch2022.small_ice, Y.c.ρ, q_ice)
136+
137+
# compute their contributions to energy and total water advection
138+
@. ᶜwₜqₜ =
139+
Geometry.WVector(
140+
ᶜwₗ * Y.c.ρq_liq +
141+
ᶜwᵢ * Y.c.ρq_ice +
142+
ᶜwᵣ * Y.c.ρq_rai +
143+
ᶜwₛ * Y.c.ρq_sno,
144+
) / Y.c.ρ
145+
@. ᶜwₕhₜ =
146+
Geometry.WVector(
147+
ᶜwₗ * Y.c.ρq_liq * (Iₗ(thp, ᶜts) + ᶜΦ + $(Kin(ᶜwₗ, ᶜu))) +
148+
ᶜwᵢ * Y.c.ρq_ice * (Iᵢ(thp, ᶜts) + ᶜΦ + $(Kin(ᶜwᵢ, ᶜu))) +
149+
ᶜwᵣ * Y.c.ρq_rai * (Iₗ(thp, ᶜts) + ᶜΦ + $(Kin(ᶜwᵣ, ᶜu))) +
150+
ᶜwₛ * Y.c.ρq_sno * (Iᵢ(thp, ᶜts) + ᶜΦ + $(Kin(ᶜwₛ, ᶜu))),
151+
) / Y.c.ρ
152+
return nothing
153+
end
100154

101155
"""
102156
set_precipitation_cache!(Y, p, precip_model, turbconv_model)
@@ -262,6 +316,65 @@ function set_precipitation_cache!(
262316
# in edmf sub-domains.
263317
return nothing
264318
end
319+
function set_precipitation_cache!(Y, p, ::Microphysics2Moment, _)
320+
(; dt) = p
321+
(; ᶜts) = p.precomputed
322+
(; ᶜSqₗᵖ, ᶜSqᵢᵖ, ᶜSqᵣᵖ, ᶜSqₛᵖ) = p.precomputed
323+
(; ᶜSnₗᵖ, ᶜSnᵣᵖ) = p.precomputed
324+
325+
(; q_liq, q_rai, n_liq, n_rai) = p.precomputed.ᶜspecific
326+
327+
ᶜSᵖ = p.scratch.ᶜtemp_scalar
328+
ᶜS₂ᵖ = p.scratch.ᶜtemp_scalar_2
329+
330+
# get thermodynamics and microphysics params
331+
(; params) = p
332+
cmp = CAP.microphysics_2m_params(params)
333+
thp = CAP.thermodynamics_params(params)
334+
335+
# compute warm precipitation sources on the grid mean (based on SB2006 2M scheme)
336+
compute_warm_precipitation_sources_2M!(
337+
ᶜSᵖ,
338+
ᶜS₂ᵖ,
339+
ᶜSnₗᵖ,
340+
ᶜSnᵣᵖ,
341+
ᶜSqₗᵖ,
342+
ᶜSqᵣᵖ,
343+
Y.c.ρ,
344+
n_liq,
345+
n_rai,
346+
q_liq,
347+
q_rai,
348+
ᶜts,
349+
dt,
350+
cmp,
351+
thp,
352+
)
353+
354+
#TODO - implement 2M cold processes!
355+
@. ᶜSqᵢᵖ = 0
356+
@. ᶜSqₛᵖ = 0
357+
358+
return nothing
359+
end
360+
function set_precipitation_cache!(
361+
Y,
362+
p,
363+
::Microphysics2Moment,
364+
::DiagnosticEDMFX,
365+
)
366+
error("Not implemented yet")
367+
return nothing
368+
end
369+
function set_precipitation_cache!(
370+
Y,
371+
p,
372+
::Microphysics2Moment,
373+
::PrognosticEDMFX,
374+
)
375+
error("Not implemented yet")
376+
return nothing
377+
end
265378

266379
"""
267380
set_precipitation_surface_fluxes!(Y, p, precipitation model)
@@ -301,7 +414,7 @@ end
301414
function set_precipitation_surface_fluxes!(
302415
Y,
303416
p,
304-
precip_model::Microphysics1Moment,
417+
precip_model::Union{Microphysics1Moment, Microphysics2Moment},
305418
)
306419
(; surface_rain_flux, surface_snow_flux) = p.precomputed
307420
(; col_integrated_precip_energy_tendency,) = p.conservation_check

src/cache/precomputed_quantities.jl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,19 @@ function precomputed_quantities(Y, atmos)
139139
ᶜSqᵣᵖ = similar(Y.c, FT),
140140
ᶜSqₛᵖ = similar(Y.c, FT),
141141
)
142+
elseif atmos.precip_model isa Microphysics2Moment
143+
precipitation_quantities = (;
144+
ᶜwᵣ = similar(Y.c, FT),
145+
ᶜwₛ = similar(Y.c, FT),
146+
ᶜSqₗᵖ = similar(Y.c, FT),
147+
ᶜSqᵢᵖ = similar(Y.c, FT),
148+
ᶜSqᵣᵖ = similar(Y.c, FT),
149+
ᶜSqₛᵖ = similar(Y.c, FT),
150+
ᶜwnₗ = similar(Y.c, FT),
151+
ᶜwnᵣ = similar(Y.c, FT),
152+
ᶜSnₗᵖ = similar(Y.c, FT),
153+
ᶜSnᵣᵖ = similar(Y.c, FT),
154+
)
142155
else
143156
precipitation_quantities = (;)
144157
end

src/diagnostics/Diagnostics.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import ..NonEquilMoistModel
3131
import ..NoPrecipitation
3232
import ..Microphysics0Moment
3333
import ..Microphysics1Moment
34+
import ..Microphysics2Moment
3435

3536
# radiation
3637
import ClimaAtmos.RRTMGPInterface as RRTMGPI

0 commit comments

Comments
 (0)