Skip to content

Commit

Permalink
Add an empty 1-moment precipitation tendency
Browse files Browse the repository at this point in the history
  • Loading branch information
trontrytel committed Nov 17, 2023
1 parent e5dcb33 commit 257bc19
Show file tree
Hide file tree
Showing 19 changed files with 522 additions and 31 deletions.
24 changes: 16 additions & 8 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,14 @@ steps:
command: "julia --color=yes --project=examples test/orographic_gravity_wave/ogwd_3d.jl"
artifact_paths: "orographic_gravity_wave_test_3d/*"

- group: "Precipitation"
steps:
- label: ":umbrella: 1-moment precipitation sanity test single column"
command: >
julia --color=yes --project=examples examples/hybrid/driver.jl
--config_file $CONFIG_PATH/single_column_precipitation_test.yml
artifact_paths: "single_column_precipitation_test/*"

- group: "Column Examples"
steps:

Expand Down Expand Up @@ -240,7 +248,7 @@ steps:
--job_id sphere_baroclinic_wave_rhoe_equilmoist
--out_dir sphere_baroclinic_wave_rhoe_equilmoist
artifact_paths: "sphere_baroclinic_wave_rhoe_equilmoist/*"

- label: ":computer: no lim ARS baroclinic wave (ρe) equilmoist explicit vertdiff"
command: >
julia --color=yes --project=examples examples/hybrid/driver.jl
Expand Down Expand Up @@ -314,7 +322,7 @@ steps:
- group: "Sphere Examples (Aquaplanet)"
steps:

- label: ":computer: aquaplanet (ρe_tot) equilmoist allsky radiation monin_obukhov varying insolation gravity wave (gfdl_restart) high top"
- label: ":computer: aquaplanet (ρe_tot) equilmoist allsky radiation monin_obukhov varying insolation gravity wave (gfdl_restart) high top with 1-moment micro"
command: >
julia --color=yes --project=examples examples/hybrid/driver.jl
--config_file $CONFIG_PATH/sphere_aquaplanet_rhoe_equilmoist_allsky_gw_res.yml
Expand Down Expand Up @@ -576,7 +584,7 @@ steps:
artifact_paths: "diagnostic_edmfx_trmm_box/*"
agents:
slurm_mem: 20GB

- label: ":genie: Diagnostic EDMFX TRMM stretched grid in a box"
command: >
julia --color=yes --project=examples examples/hybrid/driver.jl
Expand Down Expand Up @@ -619,15 +627,15 @@ steps:
artifact_paths: "prognostic_edmfx_bomex_fixtke_box/*"
agents:
slurm_mem: 20GB

- label: ":genie: Prognostic EDMFX Bomex in a box"
command: >
julia --color=yes --project=examples examples/hybrid/driver.jl
--config_file $CONFIG_PATH/prognostic_edmfx_bomex_box.yml
artifact_paths: "prognostic_edmfx_bomex_box/*"
agents:
slurm_mem: 20GB

- label: ":genie: Prognostic EDMFX Bomex stretched grid in a box"
command: >
julia --color=yes --project=examples examples/hybrid/driver.jl
Expand All @@ -643,7 +651,7 @@ steps:
artifact_paths: "prognostic_edmfx_dycoms_rf01_box/*"
agents:
slurm_mem: 20GB

- label: ":genie: Prognostic EDMFX Rico in a column"
command: >
julia --color=yes --project=examples examples/hybrid/driver.jl
Expand All @@ -659,7 +667,7 @@ steps:
artifact_paths: "prognostic_edmfx_trmm_column/*"
agents:
slurm_mem: 20GB

- label: ":genie: Prognostic EDMFX aquaplanet"
command: >
julia --color=yes --project=examples examples/hybrid/driver.jl
Expand Down Expand Up @@ -750,7 +758,7 @@ steps:
- label: "GPU: gpu_aquaplanet_dyamond"
command:
- mkdir -p gpu_aquaplanet_dyamond
- >
- >
julia --color=yes --project=examples examples/hybrid/driver.jl
--config_file ${GPU_CONFIG_PATH}gpu_aquaplanet_dyamond.yml
artifact_paths: "gpu_aquaplanet_dyamond/*"
Expand Down
6 changes: 6 additions & 0 deletions config/default_configs/default_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,9 @@ density_upwinding:
tracer_upwinding:
help: "Tracer upwinding mode [`none` (default), `first_order` , `third_order`, `boris_book`, `zalesak`]"
value: none
precip_upwinding:
help: "Precipitation upwinding mode [`none` (default), `first_order` , `third_order`]"
value: none
energy_upwinding:
help: "Energy upwinding mode [`none` (default), `first_order` , `third_order`, `boris_book`, `zalesak`]"
value: none
Expand All @@ -219,6 +222,9 @@ regression_test:
check_conservation:
help: "Check conservation of mass and energy [`false` (default), `true`]"
value: false
check_precipitation:
help: "Sanity checks for 1-moment precipitation [`false` (default), `true`]"
value: false
ls_adv:
help: "Large-scale advection [`nothing` (default), `Bomex`, `LifeCycleTan2018`, `Rico`, `ARM_SGP`, `GATE_III`]"
value: ~
Expand Down
32 changes: 32 additions & 0 deletions config/model_configs/single_column_precipitation_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
config: "column"
initial_condition: "PrecipitatingColumn"
surface_setup: "DefaultExchangeCoefficients"
z_elem: 200
z_max: 10000.0
z_stretch: false
dt: "10secs"
t_end: "1500secs"
dt_save_to_disk: "500secs"
moist: "nonequil"
precip_model: "1M"
precip_upwinding: "first_order"
hyperdiff: "false"
regression_test: false
check_precipitation: true
job_id: "single_column_precipitation_test"
toml: [toml/single_column_precipitation_test.toml]
diagnostics:
- short_name: hus
period: 500secs
- short_name: clw
period: 500secs
- short_name: cli
period: 500secs
- short_name: husra
period: 500secs
- short_name: hussn
period: 500secs
- short_name: ta
period: 500secs
- short_name: wa
period: 500secs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ dz_bottom: 300.0
vert_diff: "true"
idealized_insolation: false
z_max: 45000.0
precip_model: "0M"
precip_model: "1M"
precip_upwinding: "first_order"
job_id: "sphere_aquaplanet_rhoe_equilmoist_allsky_gw_res"
moist: "equil"
toml: [toml/sphere_aquaplanet_rhoe_equilmoist_allsky_gw_res.toml]
53 changes: 53 additions & 0 deletions examples/hybrid/driver.jl
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ include(joinpath(pkgdir(CA), "post_processing", "post_processing_funcs.jl"))
include(
joinpath(pkgdir(CA), "post_processing", "define_tc_quicklook_profiles.jl"),
)
include(joinpath(pkgdir(CA), "post_processing", "plot_single_column_precip.jl"))

ref_job_id = config.parsed_args["reference_job_id"]
reference_job_id = isnothing(ref_job_id) ? simulation.job_id : ref_job_id
Expand Down Expand Up @@ -123,3 +124,55 @@ if config.parsed_args["check_conservation"]
(p.net_energy_flux_sfc[][] - p.net_energy_flux_toa[][])
sum(sol.u[end].c.ρe_tot) rtol = 100 * eps(FT)
end

if config.parsed_args["check_precipitation"]

# plot results of the single column precipitation test
plot_single_column_precip(simulation.output_dir, reference_job_id)

# run some simple tests based on the output
FT = Spaces.undertype(axes(sol.u[end].c.ρ))
Yₜ = similar(sol.u[end])

Yₜ_ρ = similar(Yₜ.c.ρq_rai)
Yₜ_ρqₚ = similar(Yₜ.c.ρq_rai)
Yₜ_ρqₜ = similar(Yₜ.c.ρq_rai)

CA.remaining_tendency!(Yₜ, sol.u[end], sol.prob.p, sol.t[end])

@. Yₜ_ρqₚ = -Yₜ.c.ρq_rai - Yₜ.c.ρq_sno
@. Yₜ_ρqₜ = Yₜ.c.ρq_tot
@. Yₜ_ρ = Yₜ.c.ρ

Fields.bycolumn(axes(sol.u[end].c.ρ)) do colidx

# no nans
@assert !any(isnan, Yₜ.c.ρ[colidx])
@assert !any(isnan, Yₜ.c.ρq_tot[colidx])
@assert !any(isnan, Yₜ.c.ρe_tot[colidx])
@assert !any(isnan, Yₜ.c.ρq_rai[colidx])
@assert !any(isnan, Yₜ.c.ρq_sno[colidx])
@assert !any(isnan, sol.prob.p.precipitation.ᶜwᵣ[colidx])
@assert !any(isnan, sol.prob.p.precipitation.ᶜwₛ[colidx])

# treminal velocity is positive
@test minimum(sol.prob.p.precipitation.ᶜwᵣ[colidx]) >= FT(0)
@test minimum(sol.prob.p.precipitation.ᶜwₛ[colidx]) >= FT(0)

# checking for water budget conservation
# in the presence of precipitation sinks
# (This test only works without surface flux of q_tot)
@test all(
ClimaCore.isapprox(
Yₜ_ρqₜ[colidx],
Yₜ_ρqₚ[colidx],
rtol = 1e2 * eps(FT),
),
)

# mass budget consistency
@test all(
ClimaCore.isapprox(Yₜ_ρ[colidx], Yₜ_ρqₜ[colidx], rtol = eps(FT)),
)
end
end
110 changes: 110 additions & 0 deletions post_processing/plot_single_column_precip.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
import ClimaAtmos as CA
import ClimaCore as CO
import CairoMakie as MK

function plot_single_column_precip(output_dir, job_id)

fig = MK.Figure(resolution = (1200, 600))
ax1 = MK.Axis(fig[1, 1], ylabel = "z [km]", xlabel = "q_tot [g/kg]")
ax4 = MK.Axis(fig[2, 1], ylabel = "z [km]", xlabel = "T [K]")
ax2 = MK.Axis(fig[1, 2], xlabel = "q_liq [g/kg]")
ax3 = MK.Axis(fig[1, 3], xlabel = "q_ice [g/kg]")
ax5 = MK.Axis(fig[2, 2], xlabel = "q_rai [g/kg]")
ax6 = MK.Axis(fig[2, 3], xlabel = "q_sno [g/kg]")

path = joinpath(pkgdir(CA), output_dir)

col = Dict(
"0" => :navy,
"500" => :blue2,
"1000" => :royalblue,
"1500" => :skyblue1,
)

for time in ["0", "500", "1000", "1500"]

fqₜ = CO.InputOutput.HDF5Reader(
joinpath(path, "hus_inst_" * time * ".0.h5"),
)
fqₗ = CO.InputOutput.HDF5Reader(
joinpath(path, "clw_inst_" * time * ".0.h5"),
)
fqᵢ = CO.InputOutput.HDF5Reader(
joinpath(path, "cli_inst_" * time * ".0.h5"),
)
fqᵣ = CO.InputOutput.HDF5Reader(
joinpath(path, "husra_inst_" * time * ".0.h5"),
)
fqₛ = CO.InputOutput.HDF5Reader(
joinpath(path, "hussn_inst_" * time * ".0.h5"),
)
fTₐ = CO.InputOutput.HDF5Reader(
joinpath(path, "ta_inst_" * time * ".0.h5"),
)
fwₐ = CO.InputOutput.HDF5Reader(
joinpath(path, "wa_inst_" * time * ".0.h5"),
)

qₜ = CO.InputOutput.read_field(fqₜ, "hus_inst")
qₗ = CO.InputOutput.read_field(fqₗ, "clw_inst")
qᵢ = CO.InputOutput.read_field(fqᵢ, "cli_inst")
qᵣ = CO.InputOutput.read_field(fqᵣ, "husra_inst")
qₛ = CO.InputOutput.read_field(fqₛ, "hussn_inst")
Tₐ = CO.InputOutput.read_field(fTₐ, "ta_inst")
wₐ = CO.InputOutput.read_field(fwₐ, "wa_inst")

qₜ_col = CO.Fields.column(qₜ, 1, 1, 1)
qₗ_col = CO.Fields.column(qₗ, 1, 1, 1)
qᵢ_col = CO.Fields.column(qᵢ, 1, 1, 1)
qᵣ_col = CO.Fields.column(qᵣ, 1, 1, 1)
qₛ_col = CO.Fields.column(qₛ, 1, 1, 1)
Tₐ_col = CO.Fields.column(Tₐ, 1, 1, 1)
wₐ_col = CO.Fields.column(wₐ, 1, 1, 1)
z = CO.Fields.coordinate_field(qₜ_col).z

MK.lines!(
ax1,
vec(parent(qₜ_col)) .* 1e3,
vec(parent(z)) ./ 1e3,
color = col[time],
)
MK.lines!(
ax2,
vec(parent(qₗ_col)) .* 1e3,
vec(parent(z)) ./ 1e3,
color = col[time],
)
MK.lines!(
ax3,
vec(parent(qᵢ_col)) .* 1e3,
vec(parent(z)) ./ 1e3,
color = col[time],
)
MK.lines!(
ax4,
vec(parent(Tₐ_col)),
vec(parent(z)) ./ 1e3,
color = col[time],
)
MK.lines!(
ax5,
vec(parent(qᵣ_col)) .* 1e3,
vec(parent(z)) ./ 1e3,
color = col[time],
)
MK.lines!(
ax6,
vec(parent(qₛ_col)) .* 1e3,
vec(parent(z)) ./ 1e3,
color = col[time],
)

for fid in [fqₜ, fqₗ, fqᵢ, fqᵣ, fqₛ, fTₐ, fwₐ]
close(fid)
end
end

@info("Saving precipitation plots to " * path)

MK.save(joinpath(path, "single_column_precipitation.png"), fig)
end
2 changes: 1 addition & 1 deletion src/cache/precomputed_quantities.jl
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ function thermo_state(
eltype(thermo_params)(0.003),
)
get_ts::Real, ::Nothing, ::Nothing, e_int::Real, ::Nothing, q_pt) =
TD.PhaseNonEquil_ρeq(thermo_params, ρ, e_int, q_pt)
TD.PhaseNonEquil(thermo_params, e_int, ρ, q_pt)
get_ts(::Nothing, p::Real, θ::Real, ::Nothing, ::Nothing, ::Nothing) =
TD.PhaseDry_pθ(thermo_params, p, θ)
get_ts(::Nothing, p::Real, θ::Real, ::Nothing, q_tot::Real, ::Nothing) =
Expand Down
1 change: 1 addition & 0 deletions src/diagnostics/Diagnostics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import ..NonEquilMoistModel

# precip_model
import ..Microphysics0Moment
import ..Microphysics1Moment

# radiation
import ClimaAtmos.RRTMGPInterface as RRTMGPI
Expand Down
Loading

0 comments on commit 257bc19

Please sign in to comment.