diff --git a/config/default_configs/default_config.yml b/config/default_configs/default_config.yml index bf88fd23947..b7315b73633 100644 --- a/config/default_configs/default_config.yml +++ b/config/default_configs/default_config.yml @@ -217,9 +217,6 @@ 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: ~ diff --git a/config/model_configs/single_column_precipitation_test.yml b/config/model_configs/single_column_precipitation_test.yml index 679f148edcc..f105d951d02 100644 --- a/config/model_configs/single_column_precipitation_test.yml +++ b/config/model_configs/single_column_precipitation_test.yml @@ -14,7 +14,6 @@ vert_diff: "FriersonDiffusion" implicit_diffusion: true approximate_linear_solve_iters: 2 regression_test: false -check_precipitation: true toml: [toml/single_column_precipitation_test.toml] diagnostics: - short_name: [hus, clw, cli, husra, hussn, ta, wa] diff --git a/examples/hybrid/driver.jl b/examples/hybrid/driver.jl index c572b34bbcb..1ffe7c3cfa5 100644 --- a/examples/hybrid/driver.jl +++ b/examples/hybrid/driver.jl @@ -167,57 +167,6 @@ if config.parsed_args["check_conservation"] end end -# Precipitation characteristic checks -if config.parsed_args["check_precipitation"] - # run some simple tests based on the output - FT = Spaces.undertype(axes(sol.u[end].c.ρ)) - Yₜ = similar(sol.u[end]) - @. Yₜ = 0 - - Yₜ_ρ = similar(Yₜ.c.ρq_rai) - Yₜ_ρqₚ = similar(Yₜ.c.ρq_rai) - Yₜ_ρqₜ = similar(Yₜ.c.ρq_rai) - - - CA.precipitation_tendency!( - Yₜ, - sol.u[end], - sol.prob.p, - sol.t[end], - sol.prob.p.atmos.precip_model, - sol.prob.p.atmos.turbconv_model, - ) - @. Yₜ_ρqₚ = -Yₜ.c.ρq_rai - Yₜ.c.ρq_sno - @. Yₜ_ρqₜ = Yₜ.c.ρq_tot - @. Yₜ_ρ = Yₜ.c.ρ - - # no nans - @assert !any(isnan, Yₜ.c.ρ) - @assert !any(isnan, Yₜ.c.ρq_tot) - @assert !any(isnan, Yₜ.c.ρe_tot) - @assert !any(isnan, Yₜ.c.ρq_rai) - @assert !any(isnan, Yₜ.c.ρq_sno) - @assert !any(isnan, sol.prob.p.precomputed.ᶜwᵣ) - @assert !any(isnan, sol.prob.p.precomputed.ᶜwₛ) - - # treminal velocity is positive - @test minimum(sol.prob.p.precomputed.ᶜwᵣ) >= FT(0) - @test minimum(sol.prob.p.precomputed.ᶜwₛ) >= 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ₜ, Yₜ_ρqₚ, rtol = 1e2 * eps(FT))) - - # mass budget consistency - @test all(ClimaCore.isapprox(Yₜ_ρ, Yₜ_ρqₜ, rtol = eps(FT))) - - # cloud fraction diagnostics - @assert !any(isnan, sol.prob.p.precomputed.cloud_diagnostics_tuple.cf) - @test minimum(sol.prob.p.precomputed.cloud_diagnostics_tuple.cf) >= FT(0) - @test maximum(sol.prob.p.precomputed.cloud_diagnostics_tuple.cf) <= FT(1) -end - # Visualize the solution if ClimaComms.iamroot(config.comms_ctx) include( diff --git a/test/parameterized_tendencies/microphysics/precipitation.jl b/test/parameterized_tendencies/microphysics/precipitation.jl index 9363de99a3a..b69207f4fc7 100644 --- a/test/parameterized_tendencies/microphysics/precipitation.jl +++ b/test/parameterized_tendencies/microphysics/precipitation.jl @@ -73,10 +73,35 @@ include("../../test_helpers.jl") for var_name in test_varnames @test var_name ∈ propertynames(precip_cache) end + + # test helper functions @test CA.qₚ(FT(10), FT(2)) == FT(5) @test CA.qₚ(FT(-10), FT(2)) == FT(0) @test CA.limit(FT(10), FT(2), 5) == FT(1) + + # compute source terms based on the last model state CA.precipitation_tendency!(ᶜYₜ, Y, p, FT(0), precip_model, turbconv_model) + + # check for nans + @assert !any(isnan, ᶜYₜ.c.ρ) + @assert !any(isnan, ᶜYₜ.c.ρq_tot) + @assert !any(isnan, ᶜYₜ.c.ρe_tot) + @assert !any(isnan, ᶜYₜ.c.ρq_rai) + @assert !any(isnan, ᶜYₜ.c.ρq_sno) + @assert !any(isnan, p.precomputed.ᶜwᵣ) + @assert !any(isnan, p.precomputed.ᶜwₛ) + + # test water budget @test ᶜYₜ.c.ρ == ᶜYₜ.c.ρq_tot @test ᶜYₜ.c.ρ == Y.c.ρ .* p.precipitation.ᶜSqₜᵖ + @test p.precipitation.ᶜSqₜᵖ == .- p.precipitation.ᶜSqᵣᵖ .- p.precipitation.ᶜSqₛᵖ + + # test if terminal velocity is positive + @test minimum(p.precomputed.ᶜwᵣ) >= FT(0) + @test minimum(p.precomputed.ᶜwₛ) >= FT(0) + + # test if cloud fraction diagnostics make sense + @assert !any(isnan, p.precomputed.cloud_diagnostics_tuple.cf) + @test minimum(p.precomputed.cloud_diagnostics_tuple.cf) >= FT(0) + @test maximum(p.precomputed.cloud_diagnostics_tuple.cf) <= FT(1) end