@@ -11,7 +11,6 @@ const Iₗ = TD.internal_energy_liquid
11
11
const Iᵢ = TD. internal_energy_ice
12
12
const Lf = TD. latent_heat_fusion
13
13
const Tₐ = TD. air_temperature
14
- const PP = TD. PhasePartition
15
14
const qᵥ = TD. vapor_specific_humidity
16
15
qₜ (thp, ts) = TD. PhasePartition (thp, ts). tot
17
16
qₗ (thp, ts) = TD. PhasePartition (thp, ts). liq
@@ -266,6 +265,7 @@ function compute_precipitation_sources!(
266
265
end
267
266
function compute_precipitation_sources2M! (
268
267
Sᵖ,
268
+ N_act,
269
269
Sqₜᵖ,
270
270
Sqᵣᵖ,
271
271
SNᵣᵖ,
@@ -277,6 +277,8 @@ function compute_precipitation_sources2M!(
277
277
Nₗ,
278
278
ts,
279
279
Φ,
280
+ p,
281
+ w,
280
282
dt,
281
283
mp,
282
284
thp,
@@ -291,68 +293,76 @@ function compute_precipitation_sources2M!(
291
293
@. Seₜᵖ = ρ * FT (0 )
292
294
293
295
# ! format: off
294
- # rain autoconversion: q_liq -> q_rain
296
+
297
+ # TODO - only do activation at cloud base
298
+ @. Sᵖ = TD. supersaturation (thp, PP (thp, ts), ρ, Tₐ (thp, ts), TD. Liquid ())
299
+ # TODO - pass in background aerosol as parameters
300
+ r_dry = FT (0.1 * 1e-6 )
301
+ std_dry = FT (1.1 )
302
+ κ = FT (1.2 )
303
+ N_aer = FT (1000 * 1e6 )
304
+ @. N_act = CMAA. total_N_activated (
305
+ activation_params,
306
+ CMAM. AerosolDistribution (
307
+ (CMAM. Mode_κ (r_dry, std_dry, N_aer, (FT (1 ),), (FT (1 ),), (FT (0 ),), (κ,)),)
308
+ )
309
+ mp. aps,
310
+ thp,
311
+ Tₐ (thp, ts),
312
+ p,
313
+ w,
314
+ PP (thp, ts),
315
+ )
316
+ # Convert the total activated number to tendency
317
+ @. SNₗᵖ = ifelse (Sᵖ < 0 || isnan (N_act), FT (0 ), max (FT (0 ), N_act - Nₗ) / dt)
318
+
319
+ # autoconversion liquid to rain (mass)
295
320
@. Sᵖ = min (
296
321
limit (qₗ (thp, ts), dt, 5 ),
297
- CM1 . conv_q_liq_to_q_rai (mp. pr . acnv1M , qₗ (thp, ts), true ) ,
322
+ CM2 . autoconversion (mp. sb2006 . acnv , qₗ (thp, ts), qᵣ, ρ, Nₗ) . dq_rai_dt ,
298
323
)
299
324
@. Sqₜᵖ -= Sᵖ
300
325
@. Sqᵣᵖ += Sᵖ
301
326
@. Seₜᵖ -= Sᵖ * (Iₗ (thp, ts) + Φ)
302
327
303
- # TODO - add sources
304
- # # autoconversion liquid to rain (mass)
305
- # @. S₁ = limit(q_liq, dt, CM2.autoconversion(sb2006.acnv, q_liq, q_rai, ρ, N_liq).dq_rai_dt)
306
- # @. aux.precip_sources += to_sources(-S₁, -S₁, S₁, 0, 0, 0)
307
-
308
-
309
-
310
- # TODO - only do activation at cloud base
311
- # FT = eltype(q_tot)
312
- # S_Nl::FT = FT(0)
313
-
314
- # q = TD.PhasePartition(q_tot, q_liq, q_ice)
315
- # S::FT = TD.supersaturation(thermo_params, q, ρ, T, TD.Liquid())
316
-
317
- # (; r_dry, std_dry, κ) = kid_params
318
- # w = ρw / ρ
319
-
320
- # aerosol_distribution =
321
- # CMAM.AerosolDistribution((CMAM.Mode_κ(r_dry, std_dry, N_aer, (FT(1),), (FT(1),), (FT(0),), (κ,)),))
322
- # N_act = CMAA.total_N_activated(activation_params, aerosol_distribution, air_params, thermo_params, T, p, w, q)
323
-
324
- # # Convert the total activated number to tendency
325
- # S_Nl = ifelse(S < 0 || isnan(N_act), FT(0), max(FT(0), N_act - N_liq) / dt)
326
-
327
-
328
-
329
-
330
- # # autoconversion liquid to rain (number)
331
- # @. S₂ = limit(N_liq, dt, CM2.autoconversion(sb2006.acnv, q_liq, q_rai, ρ, N_liq).dN_rai_dt, 2)
332
- # @. aux.precip_sources += to_sources(0, 0, 0, 0, -2 * S₂, S₂)
333
- # # liquid self_collection
334
- # @. S₁ = -limit(N_liq, dt, -CM2.liquid_self_collection(sb2006.acnv, q_liq, ρ, -2 * S₂))
335
- # @. aux.precip_sources += to_sources(0, 0, 0, 0, S₁, 0)
336
-
337
- # # rain self_collection
338
- # @. S₁ = CM2.rain_self_collection(sb2006.pdf_r, sb2006.self, q_rai, ρ, N_rai)
339
- # @. aux.precip_sources += to_sources(0, 0, 0, 0, 0, -limit(N_rai, dt, -S₁))
340
- # # rain breakup
341
- # @. aux.precip_sources += to_sources(
342
- # 0,
343
- # 0,
344
- # 0,
345
- # 0,
346
- # 0,
347
- # limit(N_rai, dt, CM2.rain_breakup(sb2006.pdf_r, sb2006.brek, q_rai, ρ, N_rai, S₁)),
348
- # )
349
-
350
- # # accretion cloud water + rain
351
- # @. S₁ = limit(q_liq, dt, CM2.accretion(sb2006, q_liq, q_rai, ρ, N_liq).dq_rai_dt)
352
- # @. S₂ = -limit(N_liq, dt, -CM2.accretion(sb2006, q_liq, q_rai, ρ, N_liq).dN_liq_dt)
353
- # @. aux.precip_sources += to_sources(-S₁, -S₁, S₁, 0, S₂, 0)
328
+ # autoconversion liquid to rain (number)
329
+ @. Sᵖ = min (
330
+ limit (Nₗ, dt, 5 ),
331
+ CM2. autoconversion (mp. sb2006. acnv, qₗ (thp, ts), qᵣ, ρ, Nₗ). dN_rai_dt,
332
+ )
333
+ @. SNₗᵖ -= 2 * Sᵖ
334
+ @. SNᵣᵖ += Sᵖ
335
+ # liquid self_collection
336
+ @. SNₗᵖ -= min (
337
+ limit (Nₗ, dt, 5 ),
338
+ - CM2. liquid_self_collection (mp. sb2006. acnv, qₗ, ρ, - 2 * Sᵖ),
339
+ )
354
340
341
+ # rain self_collection
342
+ @. Sᵖ = - min (
343
+ limit (Nᵣ, dt, 5 ),
344
+ - CM2. rain_self_collection (mp. sb2006. pdf_r, mp. sb2006. self, qᵣ, ρ, Nᵣ),
345
+ )
346
+ @. SNᵣᵖ += Sᵖ
347
+ # rain breakup
348
+ @. SNᵣᵖ += min (
349
+ limit (Nᵣ, dt, 5 ),
350
+ CM2. rain_breakup (mp. sb2006. pdf_r, mp. sb2006. brek, qᵣ, ρ, Nᵣ, Sᵖ),
351
+ )
355
352
353
+ # accretion cloud water + rain
354
+ @. Sᵖ = min (
355
+ limit (qₗ (thp, ts), dt, 5 ),
356
+ CM2. accretion (mp. sb2006, qₗ (thp, ts), qᵣ, ρ, Nₗ). dq_rai_dt
357
+ )
358
+ @. Sqₜᵖ -= Sᵖ
359
+ @. Sqᵣᵖ += Sᵖ
360
+ @. Seₜᵖ -= Sᵖ * (Iₗ (thp, ts) + Φ)
361
+ @. Sᵖ = - min (
362
+ limit (Nₗ, dt, 5 ),
363
+ - CM2. accretion (mp. sb2006, qₗ (thp, ts), qᵣ, ρ, Nₗ). dN_liq_dt,
364
+ )
365
+ @. SNₗᵖ += Sᵖ
356
366
end
357
367
358
368
"""
@@ -517,7 +527,7 @@ function compute_precipitation_sinks2M!(
517
527
# evaporation: q_rai -> q_vap (mass)
518
528
@. Sᵖ = - min (
519
529
limit (qᵣ, dt, 5 ),
520
- - CM2. rain_evaporation (rps... , PP (thp, ts), qᵣ, ρ, Nᵣ, Tₐ (thp. ts)). evap_rate_1,
530
+ - CM2. rain_evaporation (rps... , PP (thp, ts), qᵣ, ρ, Nᵣ, Tₐ (thp, ts)). evap_rate_1,
521
531
)
522
532
@. Sqₜᵖ -= Sᵖ
523
533
@. Sqᵣᵖ += Sᵖ
@@ -526,7 +536,7 @@ function compute_precipitation_sinks2M!(
526
536
# evaporation: q_rai -> q_vap (number)
527
537
@. Sᵖ = - min (
528
538
limit (Nᵣ, dt, 5 ),
529
- - CM2. rain_evaporation (rps... , PP (thp, ts), qᵣ, ρ, Nᵣ, Tₐ (thp. ts)). evap_rate_0,
539
+ - CM2. rain_evaporation (rps... , PP (thp, ts), qᵣ, ρ, Nᵣ, Tₐ (thp, ts)). evap_rate_0,
530
540
)
531
541
@. SNᵣᵖ += Sᵖ
532
542
# ! format: on
0 commit comments