Skip to content

Commit 957af82

Browse files
authored
Merge pull request #567 from CliMA/aj/0M_updates
Add more interface options to 0M
2 parents 8591890 + 7f8828a commit 957af82

File tree

5 files changed

+29
-8
lines changed

5 files changed

+29
-8
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "CloudMicrophysics"
22
uuid = "6a9e3e04-43cd-43ba-94b9-e8782df3c71b"
33
authors = ["Climate Modeling Alliance"]
4-
version = "0.22.12"
4+
version = "0.22.13"
55

66
[deps]
77
ClimaParams = "5c42b081-d73a-476f-9059-fd94b934656c"

src/Microphysics0M.jl

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,29 +15,40 @@ import CloudMicrophysics.Parameters as CMP
1515
export remove_precipitation
1616

1717
"""
18+
remove_precipitation(params_0M, q_liq, q_ice; q_vap_sat)
1819
remove_precipitation(params_0M, q; q_vap_sat)
1920
2021
- `params_0M` - a struct with 0-moment parameters
21-
- `q` - current PhasePartition
22+
- `q` - current Thermodynamics.PhasePartition or `q_liq` and `q_ice` specific contents
2223
- `q_vap_sat` - specific humidity at saturation
2324
2425
Returns the `q_tot` tendency due to the removal of precipitation.
2526
The tendency is obtained assuming a relaxation with a constant timescale
2627
to a state with precipitable water removed.
2728
The threshold for when to remove `q_tot` is defined either by the
2829
condensate specific content or supersaturation.
29-
The thresholds and the relaxation timescale are defined in
30-
ClimaParams.
30+
The thresholds and the relaxation timescale are defined `Parameters0M` struct.
3131
"""
3232
remove_precipitation(
3333
(; τ_precip, qc_0)::CMP.Parameters0M,
34+
q_liq,
35+
q_ice,
36+
) = -max(0, (q_liq + q_ice - qc_0)) / τ_precip
37+
remove_precipitation(
38+
params::CMP.Parameters0M,
3439
q::TD.PhasePartition,
35-
) = -max(0, (q.liq + q.ice - qc_0)) / τ_precip
40+
) = remove_precipitation(params, q.liq, q.ice)
3641

3742
remove_precipitation(
3843
(; τ_precip, S_0)::CMP.Parameters0M,
44+
q_liq,
45+
q_ice,
46+
q_vap_sat,
47+
) = -max(0, (q_liq + q_ice - S_0 * q_vap_sat)) / τ_precip
48+
remove_precipitation(
49+
params::CMP.Parameters0M,
3950
q::TD.PhasePartition,
4051
q_vap_sat,
41-
) = -max(0, (q.liq + q.ice - S_0 * q_vap_sat)) / τ_precip
52+
) = remove_precipitation(params, q.liq, q.ice, q_vap_sat)
4253

4354
end #module Microphysics0M.jl

test/gpu_tests.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,8 @@ end
173173
q = TD.PhasePartition(FT(qt[i]), ql, qi)
174174

175175
output[1, i] = CM0.remove_precipitation(p0m, q)
176-
output[2, i] = -max(0, ql + qi - p0m.qc_0) / p0m.τ_precip
176+
output[2, i] = CM0.remove_precipitation(p0m, ql, qi)
177+
output[3, i] = -max(0, ql + qi - p0m.qc_0) / p0m.τ_precip
177178
end
178179
end
179180

@@ -890,7 +891,7 @@ function test_gpu(FT)
890891
end
891892

892893
@testset "0-moment microphysics kernels" begin
893-
dims = (3, 2)
894+
dims = (3, 3)
894895
(; output, ndrange) = setup_output(dims, FT)
895896

896897
liquid_frac = ArrayType([FT(0), FT(0.5), FT(1)])
@@ -902,6 +903,7 @@ function test_gpu(FT)
902903

903904
# test 0-moment rain removal is callable and returns a reasonable value
904905
@test all(isequal(Array(output)[1, :], Array(output)[2, :]))
906+
@test all(isequal(Array(output)[1, :], Array(output)[3, :]))
905907
end
906908

907909
@testset "1-moment microphysics kernels" begin

test/microphysics0M_tests.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ function test_microphysics0M(FT)
2121
# no rain if no cloud
2222
q = TD.PhasePartition(q_tot)
2323
TT.@test CM0.remove_precipitation(p0m, q) FT(0)
24+
TT.@test CM0.remove_precipitation(p0m, FT(0), FT(0)) FT(0)
2425
TT.@test CM0.remove_precipitation(p0m, q, q_vap_sat) FT(0)
26+
TT.@test CM0.remove_precipitation(p0m, FT(0), FT(0), q_vap_sat) FT(0)
27+
2528

2629
# rain based on qc threshold
2730
for lf in frac
@@ -32,6 +35,8 @@ function test_microphysics0M(FT)
3235

3336
TT.@test CM0.remove_precipitation(p0m, q)
3437
-max(0, q_liq + q_ice - qc_0) / τ_precip
38+
TT.@test CM0.remove_precipitation(p0m, q_liq, q_ice)
39+
-max(0, q_liq + q_ice - qc_0) / τ_precip
3540
end
3641

3742
# rain based on supersaturation threshold
@@ -43,6 +48,8 @@ function test_microphysics0M(FT)
4348

4449
TT.@test CM0.remove_precipitation(p0m, q, q_vap_sat)
4550
-max(0, q_liq + q_ice - S_0 * q_vap_sat) / τ_precip
51+
TT.@test CM0.remove_precipitation(p0m, q_liq, q_ice, q_vap_sat)
52+
-max(0, q_liq + q_ice - S_0 * q_vap_sat) / τ_precip
4653
end
4754
end
4855
end

test/performance_tests.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,7 @@ function benchmark_test(FT)
290290

291291
# 0-moment
292292
bench_press(FT, CM0.remove_precipitation, (p0m, q), 12)
293+
bench_press(FT, CM0.remove_precipitation, (p0m, q_liq, q_ice), 12)
293294

294295
# 1-moment
295296
bench_press(

0 commit comments

Comments
 (0)