@@ -98,6 +98,76 @@ function set_precipitation_velocities!(
9898 return nothing
9999end
100100
101+ function compute_precip_velocities (ᶜY, ᶠY, p, t)
102+ cmc = CAP. microphysics_cloud_params (p. params)
103+ cmp = CAP. microphysics_1m_params (p. params)
104+
105+ # compute the precipitation terminal velocity [m/s]
106+ ᶜwᵣ = CM1. terminal_velocity (
107+ cmp. pr,
108+ cmp. tv. rain,
109+ ᶜY. ρ,
110+ max (zero (ᶜY. ρ), ᶜY. ρq_rai / ᶜY. ρ),
111+ )
112+ ᶜwₛ = CM1. terminal_velocity (
113+ cmp. ps,
114+ cmp. tv. snow,
115+ ᶜY. ρ,
116+ max (zero (ᶜY. ρ), ᶜY. ρq_sno / ᶜY. ρ),
117+ )
118+ # compute sedimentation velocity for cloud condensate [m/s]
119+ ᶜwₗ = CMNe. terminal_velocity (
120+ cmc. liquid,
121+ cmc. Ch2022. rain,
122+ ᶜY. ρ,
123+ max (zero (ᶜY. ρ), ᶜY. ρq_liq / ᶜY. ρ),
124+ )
125+ ᶜwᵢ = CMNe. terminal_velocity (
126+ cmc. ice,
127+ cmc. Ch2022. small_ice,
128+ ᶜY. ρ,
129+ max (zero (ᶜY. ρ), ᶜY. ρq_ice / ᶜY. ρ),
130+ )
131+ return (ᶜwᵣ, ᶜwₛ, ᶜwₗ, ᶜwᵢ)
132+ end
133+
134+
135+ compute_ᶜwₜqₜ (ᶜY, ᶠY, p, t) =
136+ compute_ᶜwₜqₜ (ᶜY, ᶠY, p, t, p. atmos. moisture_model, p. atmos. precip_model)
137+ compute_ᶜwₜqₜ (ᶜY, ᶠY, p, t, moisture_model, precip_model) = zero (ᶜY. ρ)
138+
139+ function compute_ᶜwₜqₜ (ᶜY, ᶠY, p, t,
140+ :: NonEquilMoistModel ,
141+ :: Microphysics1Moment ,
142+ )
143+ (ᶜwᵣ, ᶜwₛ, ᶜwₗ, ᶜwᵢ) = compute_precip_velocities (ᶜY, ᶠY, p, t)
144+ # compute their contributions to energy and total water advection
145+ return Geometry. WVector (
146+ ᶜwₗ * ᶜY. ρq_liq +
147+ ᶜwᵢ * ᶜY. ρq_ice +
148+ ᶜwᵣ * ᶜY. ρq_rai +
149+ ᶜwₛ * ᶜY. ρq_sno,
150+ ) / ᶜY. ρ
151+ end
152+
153+ compute_ᶜwₕhₜ (ᶜY, ᶠY, p, t) =
154+ compute_ᶜwₕhₜ (ᶜY, ᶠY, p, t, p. atmos. moisture_model, p. atmos. precip_model)
155+
156+ compute_ᶜwₕhₜ (ᶜY, ᶠY, p, t, moisture_model, precip_model) = zero (ᶜY. ρ)
157+
158+ function compute_ᶜwₕhₜ (ᶜY, ᶠY, p, t, :: NonEquilMoistModel , :: Microphysics1Moment )
159+ thp = CAP. thermodynamics_params (p. params)
160+ ᶜts = compute_ᶜts (ᶜY, ᶠY, p, t)
161+ (ᶜwᵣ, ᶜwₛ, ᶜwₗ, ᶜwᵢ) = compute_precip_velocities (ᶜY, ᶠY, p, t)
162+ # compute their contributions to energy and total water advection
163+ return @. lazy (Geometry. WVector (
164+ ᶜwₗ * ᶜY. ρq_liq * (Iₗ (thp, ᶜts) + ᶜΦ + $ (Kin (ᶜwₗ, ᶜY. ᶜu))) +
165+ ᶜwᵢ * ᶜY. ρq_ice * (Iᵢ (thp, ᶜts) + ᶜΦ + $ (Kin (ᶜwᵢ, ᶜY. ᶜu))) +
166+ ᶜwᵣ * ᶜY. ρq_rai * (Iₗ (thp, ᶜts) + ᶜΦ + $ (Kin (ᶜwᵣ, ᶜY. ᶜu))) +
167+ ᶜwₛ * ᶜY. ρq_sno * (Iᵢ (thp, ᶜts) + ᶜΦ + $ (Kin (ᶜwₛ, ᶜY. ᶜu))),
168+ ) / ᶜY. ρ)
169+ end
170+
101171"""
102172 set_precipitation_cache!(Y, p, precip_model, turbconv_model)
103173
0 commit comments