Skip to content

Commit 801b957

Browse files
committed
Remove ts from nonequilibrium cloud sources
1 parent 2c97b68 commit 801b957

File tree

3 files changed

+133
-60
lines changed

3 files changed

+133
-60
lines changed

src/cache/prognostic_edmf_precomputed_quantities.jl

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -653,17 +653,25 @@ NVTX.@annotate function set_prognostic_edmf_precomputed_quantities_precipitation
653653
@. ᶜSqₗᵖʲs.:($$j) += cloud_sources(
654654
cmc.liquid,
655655
thp,
656-
ᶜtsʲs.:($$j),
656+
Y.c.sgsʲs.:($$j).q_tot,
657+
Y.c.sgsʲs.:($$j).q_liq,
658+
Y.c.sgsʲs.:($$j).q_ice,
657659
Y.c.sgsʲs.:($$j).q_rai,
658660
Y.c.sgsʲs.:($$j).q_sno,
661+
ᶜρʲs.:($$j),
662+
TD.air_temperature(thp, ᶜtsʲs.:($$j)),
659663
dt,
660664
)
661665
@. ᶜSqᵢᵖʲs.:($$j) += cloud_sources(
662666
cmc.ice,
663667
thp,
664-
ᶜtsʲs.:($$j),
668+
Y.c.sgsʲs.:($$j).q_tot,
669+
Y.c.sgsʲs.:($$j).q_liq,
670+
Y.c.sgsʲs.:($$j).q_ice,
665671
Y.c.sgsʲs.:($$j).q_rai,
666672
Y.c.sgsʲs.:($$j).q_sno,
673+
ᶜρʲs.:($$j),
674+
TD.air_temperature(thp, ᶜtsʲs.:($$j)),
667675
dt,
668676
)
669677
end
@@ -703,7 +711,29 @@ NVTX.@annotate function set_prognostic_edmf_precomputed_quantities_precipitation
703711
thp,
704712
)
705713
# Cloud formation from the environment
706-
@. ᶜSqₗᵖ⁰ += cloud_sources(cmc.liquid, thp, ᶜts⁰, ᶜq_rai⁰, ᶜq_sno⁰, dt)
707-
@. ᶜSqᵢᵖ⁰ += cloud_sources(cmc.ice, thp, ᶜts⁰, ᶜq_rai⁰, ᶜq_sno⁰, dt)
714+
@. ᶜSqₗᵖ⁰ += cloud_sources(
715+
cmc.liquid,
716+
thp,
717+
ᶜq_tot⁰,
718+
ᶜq_liq⁰,
719+
ᶜq_ice⁰,
720+
ᶜq_rai⁰,
721+
ᶜq_sno⁰,
722+
ᶜρ⁰,
723+
TD.air_temperature(thp, ᶜts⁰),
724+
dt,
725+
)
726+
@. ᶜSqᵢᵖ⁰ += cloud_sources(
727+
cmc.ice,
728+
thp,
729+
ᶜq_tot⁰,
730+
ᶜq_liq⁰,
731+
ᶜq_ice⁰,
732+
ᶜq_rai⁰,
733+
ᶜq_sno⁰,
734+
ᶜρ⁰,
735+
TD.air_temperature(thp, ᶜts⁰),
736+
dt,
737+
)
708738
return nothing
709739
end

src/parameterized_tendencies/microphysics/cloud_condensate.jl

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,22 +33,32 @@ function cloud_condensate_tendency!(
3333
thp = CAP.thermodynamics_params(params)
3434
cmc = CAP.microphysics_cloud_params(params)
3535

36+
Tₐ = @. lazy(TD.air_temperature(thp, ᶜts))
37+
3638
@. Yₜ.c.ρq_liq +=
3739
Y.c.ρ * cloud_sources(
3840
cmc.liquid,
3941
thp,
40-
ᶜts,
42+
specific(Y.c.ρq_tot, Y.c.ρ),
43+
specific(Y.c.ρq_liq, Y.c.ρ),
44+
specific(Y.c.ρq_ice, Y.c.ρ),
4145
specific(Y.c.ρq_rai, Y.c.ρ),
4246
specific(Y.c.ρq_sno, Y.c.ρ),
47+
Y.c.ρ,
48+
Tₐ,
4349
dt,
4450
)
4551
@. Yₜ.c.ρq_ice +=
4652
Y.c.ρ * cloud_sources(
4753
cmc.ice,
4854
thp,
49-
ᶜts,
55+
specific(Y.c.ρq_tot, Y.c.ρ),
56+
specific(Y.c.ρq_liq, Y.c.ρ),
57+
specific(Y.c.ρq_ice, Y.c.ρ),
5058
specific(Y.c.ρq_rai, Y.c.ρ),
5159
specific(Y.c.ρq_sno, Y.c.ρ),
60+
Y.c.ρ,
61+
Tₐ,
5262
dt,
5363
)
5464
end
@@ -66,30 +76,44 @@ function cloud_condensate_tendency!(
6676
thp = CAP.thermodynamics_params(params)
6777
cmc = CAP.microphysics_cloud_params(params)
6878

79+
Tₐ = @. lazy(TD.air_temperature(thp, ᶜts))
80+
6981
@. Yₜ.c.ρq_liq +=
7082
Y.c.ρ * cloud_sources(
7183
cmc.liquid,
7284
thp,
73-
ᶜts,
85+
specific(Y.c.ρq_tot, Y.c.ρ),
86+
specific(Y.c.ρq_liq, Y.c.ρ),
87+
specific(Y.c.ρq_ice, Y.c.ρ),
7488
specific(Y.c.ρq_rai, Y.c.ρ),
7589
specific(Y.c.ρq_sno, Y.c.ρ),
90+
Y.c.ρ,
91+
Tₐ,
7692
dt,
7793
)
7894
@. Yₜ.c.ρq_ice +=
7995
Y.c.ρ * cloud_sources(
8096
cmc.ice,
8197
thp,
82-
ᶜts,
98+
specific(Y.c.ρq_tot, Y.c.ρ),
99+
specific(Y.c.ρq_liq, Y.c.ρ),
100+
specific(Y.c.ρq_ice, Y.c.ρ),
83101
specific(Y.c.ρq_rai, Y.c.ρ),
84102
specific(Y.c.ρq_sno, Y.c.ρ),
103+
Y.c.ρ,
104+
Tₐ,
85105
dt,
86106
)
87107

88108
@. Yₜ.c.ρn_liq +=
89109
Y.c.ρ * aerosol_activation_sources(
90110
cmc.liquid,
91111
thp,
92-
ᶜts,
112+
Y.c.ρ,
113+
Tₐ,
114+
specific(Y.c.ρq_tot, Y.c.ρ),
115+
specific(Y.c.ρq_liq, Y.c.ρ),
116+
specific(Y.c.ρq_ice, Y.c.ρ),
93117
specific(Y.c.ρq_rai, Y.c.ρ),
94118
specific(Y.c.ρq_sno, Y.c.ρ),
95119
specific(Y.c.ρn_liq, Y.c.ρ),

src/parameterized_tendencies/microphysics/microphysics_wrappers.jl

Lines changed: 70 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,11 @@ import CloudMicrophysics.Parameters as CMP
1111
const Tₐ = TD.air_temperature
1212
const PP = TD.PhasePartition
1313
const qᵥ = TD.vapor_specific_humidity
14-
qₜ(thp, ts) = TD.PhasePartition(thp, ts).tot
1514

16-
# Get q_liq and q_ice out of phase partition
17-
function qₗ(thp, ts, qᵣ)
18-
FT = eltype(ts)
19-
return max(FT(0), TD.PhasePartition(thp, ts).liq - qᵣ)
20-
end
21-
function qᵢ(thp, ts, qₛ)
22-
FT = eltype(ts)
23-
return max(FT(0), TD.PhasePartition(thp, ts).ice - qₛ)
24-
end
25-
26-
# Clip precipitation to avoid negative numbers
27-
function qₚ(q_rain_snow)
28-
FT = eltype(q_rain_snow)
29-
return max(FT(0), q_rain_snow)
15+
# Clip any specific humidity
16+
function clip(q)
17+
FT = eltype(q)
18+
return max(FT(0), q)
3019
end
3120

3221
# Helper function to compute the limit of the tendency in the traingle limiter.
@@ -64,13 +53,17 @@ function ml_N_cloud_liquid_droplets(cmc, c_dust, c_seasalt, c_SO4, q_liq)
6453
end
6554

6655
"""
67-
cloud_sources(cm_params, thp, ts, dt)
56+
cloud_sources(cm_params, thp, qₜ, qₗ, qᵢ, qᵣ, qₛ, ρ, Tₐ, dt)
6857
6958
- cm_params - CloudMicrophysics parameters struct for cloud water or ice condensate
7059
- thp - Thermodynamics parameters struct
71-
- ts - thermodynamics state
60+
- qₜ - total specific humidity
61+
- qₗ - liquid specific humidity
62+
- qᵢ - ice specific humidity
7263
- qᵣ - rain specific humidity
7364
- qₛ - snow specific humidity
65+
- ρ - air density
66+
- Tₐ - air temperature
7467
- dt - model time step
7568
7669
Returns the condensation/evaporation or deposition/sublimation rate for
@@ -79,57 +72,75 @@ non-equilibrium Morrison and Milbrandt 2015 cloud formation.
7972
function cloud_sources(
8073
cm_params::CMP.CloudLiquid{FT},
8174
thp,
82-
ts,
75+
qₜ,
76+
qₗ,
77+
qᵢ,
8378
qᵣ,
8479
qₛ,
80+
ρ,
81+
Tₐ,
8582
dt,
8683
) where {FT}
8784

88-
q = TD.PhasePartition(thp, ts)
89-
ρ = TD.air_density(thp, ts)
90-
91-
S = CMNe.conv_q_vap_to_q_liq_ice_MM2015(
92-
cm_params,
93-
thp,
94-
q,
95-
qᵣ,
96-
qₛ,
97-
ρ,
98-
Tₐ(thp, ts),
99-
)
85+
qᵥ = qₜ - qₗ - qᵢ - qᵣ - qₛ
86+
87+
if qᵥ + qₗ > FT(0)
88+
S = CMNe.conv_q_vap_to_q_liq_ice_MM2015(
89+
cm_params,
90+
thp,
91+
qₜ,
92+
qₗ,
93+
qᵢ,
94+
qᵣ,
95+
qₛ,
96+
ρ,
97+
Tₐ,
98+
)
99+
else
100+
S = FT(0)
101+
end
100102

101103
return ifelse(
102104
S > FT(0),
103-
triangle_inequality_limiter(S, limit(qᵥ(thp, ts), dt, 2)),
104-
-triangle_inequality_limiter(abs(S), limit(qₗ(thp, ts, qₚ(qᵣ)), dt, 2)),
105+
triangle_inequality_limiter(S, limit(clip(qᵥ), dt, 2)),
106+
-triangle_inequality_limiter(abs(S), limit(clip(qₗ), dt, 2)),
105107
)
106108
end
107109
function cloud_sources(
108110
cm_params::CMP.CloudIce{FT},
109111
thp,
110-
ts,
112+
qₜ,
113+
qₗ,
114+
qᵢ,
111115
qᵣ,
112116
qₛ,
117+
ρ,
118+
T,
113119
dt,
114120
) where {FT}
115121

116-
q = TD.PhasePartition(thp, ts)
117-
ρ = TD.air_density(thp, ts)
118-
119-
S = CMNe.conv_q_vap_to_q_liq_ice_MM2015(
120-
cm_params,
121-
thp,
122-
q,
123-
qᵣ,
124-
qₛ,
125-
ρ,
126-
Tₐ(thp, ts),
127-
)
122+
qᵥ = qₜ - qₗ - qᵢ - qᵣ - qₛ
123+
124+
if qᵥ + qᵢ > FT(0)
125+
S = CMNe.conv_q_vap_to_q_liq_ice_MM2015(
126+
cm_params,
127+
thp,
128+
qₜ,
129+
qₗ,
130+
qᵢ,
131+
qᵣ,
132+
qₛ,
133+
ρ,
134+
T,
135+
)
136+
else
137+
S = FT(0)
138+
end
128139

129140
return ifelse(
130141
S > FT(0),
131-
triangle_inequality_limiter(S, limit(qᵥ(thp, ts), dt, 2)),
132-
-triangle_inequality_limiter(abs(S), limit(qᵢ(thp, ts, qₚ(qₛ)), dt, 2)),
142+
triangle_inequality_limiter(S, limit(clip(qᵥ), dt, 2)),
143+
-triangle_inequality_limiter(abs(S), limit(clip(qᵢ), dt, 2)),
133144
)
134145
end
135146

@@ -362,11 +373,15 @@ end
362373
#####
363374

364375
"""
365-
aerosol_activation_sources(cm_params, thp, ts, qₚ, n_dp, n_dp_prescribed, dt)
376+
aerosol_activation_sources(cm_params, thp, ρ, Tₐ, qₜ, qₗ, qᵢ, qᵣ, qₛ, n_dp, n_dp_prescribed, dt)
366377
367378
- cm_params - CloudMicrophysics parameters struct for cloud water or ice condensate
368379
- thp - Thermodynamics parameters struct
369-
- ts - thermodynamics state
380+
- ρ - air density
381+
- Tₐ - air temperature
382+
- qₜ - total specific humidity
383+
- qₗ - liquid specific humidity
384+
- qᵢ - ice specific humidity
370385
- qᵣ - rain specific humidity
371386
- qₛ - snow specific humidity
372387
- n_dp - number concentration droplets (liquid or ice) per mass
@@ -379,7 +394,11 @@ based on mass rates and a prescribed droplet mass (no activation parameterizatio
379394
function aerosol_activation_sources(
380395
cm_params::CMP.CloudLiquid{FT},
381396
thp,
382-
ts,
397+
ρ,
398+
Tₐ,
399+
qₜ,
400+
qₗ,
401+
qᵢ,
383402
qᵣ,
384403
qₛ,
385404
n_dp,
@@ -388,7 +407,7 @@ function aerosol_activation_sources(
388407
) where {FT}
389408
r_dp = FT(2e-6) # 2 μm
390409
m_dp = 4 / 3 * FT(π) * r_dp^3 * cm_params.ρw
391-
Sn = cloud_sources(cm_params, thp, ts, qᵣ, qₛ, dt) / m_dp
410+
Sn = cloud_sources(cm_params, thp, qₜ, qₗ, qᵢ, qᵣ, qₛ, ρ, Tₐ, dt) / m_dp
392411

393412
return ifelse(
394413
Sn > FT(0),

0 commit comments

Comments
 (0)