22
33import Thermodynamics as TD
44import CloudMicrophysics. Microphysics0M as CM0
5+ import CloudMicrophysics. Microphysics1M as CM1
6+ import CloudMicrophysics. MicrophysicsNonEq as CMNe
7+ import CloudMicrophysics. Parameters as CMP
58
69# define some aliases and functions to make the code more readable
710const Iₗ = TD. internal_energy_liquid
@@ -10,12 +13,64 @@ const Lf = TD.latent_heat_fusion
1013const Tₐ = TD. air_temperature
1114const PP = TD. PhasePartition
1215const qᵥ = TD. vapor_specific_humidity
16+ qₜ (thp, ts) = TD. PhasePartition (thp, ts). tot
1317qₗ (thp, ts) = TD. PhasePartition (thp, ts). liq
1418qᵢ (thp, ts) = TD. PhasePartition (thp, ts). ice
1519
1620# helper function to limit the tendency
17- function limit (q:: FT , dt:: FT ) where {FT}
18- return q / dt / 5
21+ function limit (q:: FT , dt:: FT , n:: Int ) where {FT}
22+ return q / dt / n
23+ end
24+
25+ """
26+ cloud_sources(cm_params, thp, ts, dt)
27+
28+ - cm_params - CloudMicrophysics parameters struct for cloud water or ice condensate
29+ - thp - Thermodynamics parameters struct
30+ - ts - thermodynamics state
31+ - dt - model time step
32+
33+ Returns the condensation/evaporation or deposition/sublimation rate for
34+ non-equilibrium cloud formation.
35+ """
36+ function cloud_sources (cm_params:: CMP.CloudLiquid{FT} , thp, ts, dt) where {FT}
37+
38+ λ = TD. liquid_fraction (thp, Tₐ (thp, ts), TD. PhaseEquil)
39+ qᵥ_ex_liquid = λ * (qₜ (thp, ts) - TD. q_vap_saturation_liquid (thp, ts))
40+
41+ # Ideally the logic whether to apply this source term, and what relaxation
42+ # timescale to use, should be based on the availability of CCNs and INPs.
43+ # We need a 2-moment microphysics scheme for that.
44+
45+ # Additionally, to approximate the partitioning between the condensation/evaporation
46+ # and deposition/sublimation, we are scaling down the excess q by the liquid fraction.
47+ # This needs more thought.
48+ S = CMNe. conv_q_vap_to_q_liq_ice (
49+ cm_params,
50+ PP (FT (0 ), qᵥ_ex_liquid, FT (0 )),
51+ PP (thp, ts),
52+ )
53+ return ifelse (
54+ S > FT (0 ),
55+ min (S, limit (qᵥ (thp, ts), dt, 2 )),
56+ - min (abs (S), limit (qₗ (thp, ts), dt, 2 )),
57+ )
58+ end
59+ function cloud_sources (cm_params:: CMP.CloudIce{FT} , thp, ts, dt) where {FT}
60+
61+ λ = TD. liquid_fraction (thp, Tₐ (thp, ts), TD. PhaseEquil)
62+ qᵥ_ex_ice = (1 - λ) * (qₜ (thp, ts) - TD. q_vap_saturation_ice (thp, ts))
63+
64+ S = CMNe. conv_q_vap_to_q_liq_ice (
65+ cm_params,
66+ PP (FT (0 ), FT (0 ), qᵥ_ex_ice),
67+ PP (thp, ts),
68+ )
69+ return ifelse (
70+ S > FT (0 ),
71+ min (S, limit (qᵥ (thp, ts), dt, 2 )),
72+ - min (abs (S), limit (qᵢ (thp, ts), dt, 2 )),
73+ )
1974end
2075
2176"""
@@ -114,7 +169,7 @@ function compute_precipitation_sources!(
114169 # ! format: off
115170 # rain autoconversion: q_liq -> q_rain
116171 @. Sᵖ = min (
117- limit (qₗ (thp, ts), dt),
172+ limit (qₗ (thp, ts), dt, 5 ),
118173 CM1. conv_q_liq_to_q_rai (mp. pr. acnv1M, qₗ (thp, ts), true ),
119174 )
120175 @. Sqₜᵖ -= Sᵖ
@@ -123,7 +178,7 @@ function compute_precipitation_sources!(
123178
124179 # snow autoconversion assuming no supersaturation: q_ice -> q_snow
125180 @. Sᵖ = min (
126- limit (qᵢ (thp, ts), dt),
181+ limit (qᵢ (thp, ts), dt, 5 ),
127182 CM1. conv_q_ice_to_q_sno_no_supersat (mp. ps. acnv1M, qᵢ (thp, ts), true ),
128183 )
129184 @. Sqₜᵖ -= Sᵖ
@@ -132,7 +187,7 @@ function compute_precipitation_sources!(
132187
133188 # accretion: q_liq + q_rain -> q_rain
134189 @. Sᵖ = min (
135- limit (qₗ (thp, ts), dt),
190+ limit (qₗ (thp, ts), dt, 5 ),
136191 CM1. accretion (mp. cl, mp. pr, mp. tv. rain, mp. ce, qₗ (thp, ts), qᵣ, ρ),
137192 )
138193 @. Sqₜᵖ -= Sᵖ
@@ -141,7 +196,7 @@ function compute_precipitation_sources!(
141196
142197 # accretion: q_ice + q_snow -> q_snow
143198 @. Sᵖ = min (
144- limit (qᵢ (thp, ts), dt),
199+ limit (qᵢ (thp, ts), dt, 5 ),
145200 CM1. accretion (mp. ci, mp. ps, mp. tv. snow, mp. ce, qᵢ (thp, ts), qₛ, ρ),
146201 )
147202 @. Sqₜᵖ -= Sᵖ
@@ -151,7 +206,7 @@ function compute_precipitation_sources!(
151206 # accretion: q_liq + q_sno -> q_sno or q_rai
152207 # sink of cloud water via accretion cloud water + snow
153208 @. Sᵖ = min (
154- limit (qₗ (thp, ts), dt),
209+ limit (qₗ (thp, ts), dt, 5 ),
155210 CM1. accretion (mp. cl, mp. ps, mp. tv. snow, mp. ce, qₗ (thp, ts), qₛ, ρ),
156211 )
157212 # if T < T_freeze cloud droplets freeze to become snow
@@ -160,7 +215,7 @@ function compute_precipitation_sources!(
160215 @. Sᵖ_snow = ifelse (
161216 Tₐ (thp, ts) < mp. ps. T_freeze,
162217 Sᵖ,
163- FT (- 1 ) * min (Sᵖ * α (thp, ts), limit (qₛ, dt)),
218+ FT (- 1 ) * min (Sᵖ * α (thp, ts), limit (qₛ, dt, 5 )),
164219 )
165220 @. Sqₛᵖ += Sᵖ_snow
166221 @. Sqₜᵖ -= Sᵖ
@@ -173,15 +228,15 @@ function compute_precipitation_sources!(
173228
174229 # accretion: q_ice + q_rai -> q_sno
175230 @. Sᵖ = min (
176- limit (qᵢ (thp, ts), dt),
231+ limit (qᵢ (thp, ts), dt, 5 ),
177232 CM1. accretion (mp. ci, mp. pr, mp. tv. rain, mp. ce, qᵢ (thp, ts), qᵣ, ρ),
178233 )
179234 @. Sqₜᵖ -= Sᵖ
180235 @. Sqₛᵖ += Sᵖ
181236 @. Seₜᵖ -= Sᵖ * (Iᵢ (thp, ts) + Φ)
182237 # sink of rain via accretion cloud ice - rain
183238 @. Sᵖ = min (
184- limit (qᵣ, dt),
239+ limit (qᵣ, dt, 5 ),
185240 CM1. accretion_rain_sink (mp. pr, mp. ci, mp. tv. rain, mp. ce, qᵢ (thp, ts), qᵣ, ρ),
186241 )
187242 @. Sqᵣᵖ -= Sᵖ
@@ -192,11 +247,11 @@ function compute_precipitation_sources!(
192247 @. Sᵖ = ifelse (
193248 Tₐ (thp, ts) < mp. ps. T_freeze,
194249 min (
195- limit (qᵣ, dt),
250+ limit (qᵣ, dt, 5 ),
196251 CM1. accretion_snow_rain (mp. ps, mp. pr, mp. tv. rain, mp. tv. snow, mp. ce, qₛ, qᵣ, ρ),
197252 ),
198253 - min (
199- limit (qₛ, dt),
254+ limit (qₛ, dt, 5 ),
200255 CM1. accretion_snow_rain (mp. pr, mp. ps, mp. tv. snow, mp. tv. rain, mp. ce, qᵣ, qₛ, ρ),
201256 ),
202257 )
@@ -245,7 +300,7 @@ function compute_precipitation_sinks!(
245300 # ! format: off
246301 # evaporation: q_rai -> q_vap
247302 @. Sᵖ = - min (
248- limit (qᵣ, dt),
303+ limit (qᵣ, dt, 5 ),
249304 - CM1. evaporation_sublimation (rps... , PP (thp, ts), qᵣ, ρ, Tₐ (thp, ts)),
250305 )
251306 @. Sqₜᵖ -= Sᵖ
@@ -254,7 +309,7 @@ function compute_precipitation_sinks!(
254309
255310 # melting: q_sno -> q_rai
256311 @. Sᵖ = min (
257- limit (qₛ, dt),
312+ limit (qₛ, dt, 5 ),
258313 CM1. snow_melt (sps... , qₛ, ρ, Tₐ (thp, ts)),
259314 )
260315 @. Sqᵣᵖ += Sᵖ
@@ -265,8 +320,8 @@ function compute_precipitation_sinks!(
265320 @. Sᵖ = CM1. evaporation_sublimation (sps... , PP (thp, ts), qₛ, ρ, Tₐ (thp, ts))
266321 @. Sᵖ = ifelse (
267322 Sᵖ > FT (0 ),
268- min (limit (qᵥ (thp, ts), dt), Sᵖ),
269- - min (limit (qₛ, dt), FT (- 1 ) * Sᵖ),
323+ min (limit (qᵥ (thp, ts), dt, 5 ), Sᵖ),
324+ - min (limit (qₛ, dt, 5 ), FT (- 1 ) * Sᵖ),
270325 )
271326 @. Sqₜᵖ -= Sᵖ
272327 @. Sqₛᵖ += Sᵖ
0 commit comments