@@ -24,26 +24,21 @@ function test_microphysics2M(FT)
24
24
25
25
# Seifert and Beheng 2006 parameters
26
26
override_file = joinpath (
27
- pkgdir (CM),
28
- " src" ,
29
- " parameters" ,
30
- " toml" ,
31
- " SB2006_limiters.toml" ,
27
+ pkgdir (CM), " src" , " parameters" , " toml" , " SB2006_limiters.toml" ,
32
28
)
33
29
toml_dict = CP. create_toml_dict (FT; override_file)
34
30
SB2006 = CMP. SB2006 (toml_dict)
35
31
SB2006_no_limiters = CMP. SB2006 (toml_dict, false )
36
32
37
33
# Thermodynamics and air properties parameters
38
34
aps = CMP. AirProperties (FT)
39
- wtr = CMP. WaterProperties (FT)
40
35
tps = TD. Parameters. ThermodynamicsParameters (FT)
41
36
42
37
# Terminal velocity parameters
43
38
SB2006Vel = CMP. SB2006VelType (FT)
44
39
Chen2022Vel = CMP. Chen2022VelTypeRain (FT)
45
40
46
- TT. @testset " 2M_microphysics - unit tests" begin
41
+ TT. @testset " 2M_microphysics - unit tests ( $FT ) " begin
47
42
48
43
ρ = FT (1 )
49
44
@@ -93,7 +88,7 @@ function test_microphysics2M(FT)
93
88
94
89
end
95
90
96
- TT. @testset " 2M_microphysics - compare with Wood_2005" begin
91
+ TT. @testset " 2M_microphysics - compare with Wood_2005 ( $FT ) " begin
97
92
98
93
ρ = FT (1 )
99
94
q_liq = FT (0.5e-3 )
@@ -149,7 +144,7 @@ function test_microphysics2M(FT)
149
144
end
150
145
151
146
# 2M_microphysics - Seifert and Beheng 2006 double moment scheme tests
152
- TT. @testset " limiting lambda_r and x_r - Seifert and Beheng 2006" begin
147
+ TT. @testset " limiting lambda_r and x_r - Seifert and Beheng 2006 ( $FT ) " begin
153
148
# setup
154
149
q_rai = [FT (0 ), FT (1e-3 ), FT (1e-4 ), FT (1e-2 )]
155
150
N_rai = [FT (1e1 ), FT (1e1 ), FT (1e3 ), FT (1e5 )]
@@ -170,7 +165,7 @@ function test_microphysics2M(FT)
170
165
171
166
end
172
167
173
- TT. @testset " 2M_microphysics - Seifert and Beheng 2006 autoconversion and liquid self-collection" begin
168
+ TT. @testset " 2M_microphysics - Seifert and Beheng 2006 autoconversion and liquid self-collection ( $FT ) " begin
174
169
# setup
175
170
ρ = FT (1 )
176
171
q_liq = FT (0.5e-3 )
@@ -260,7 +255,7 @@ function test_microphysics2M(FT)
260
255
end
261
256
end
262
257
263
- TT. @testset " 2M_microphysics - Seifert and Beheng 2006 accretion" begin
258
+ TT. @testset " 2M_microphysics - Seifert and Beheng 2006 accretion ( $FT ) " begin
264
259
# setup
265
260
ρ = FT (1.1 )
266
261
q_liq = FT (0.5e-3 )
@@ -303,29 +298,26 @@ function test_microphysics2M(FT)
303
298
end
304
299
end
305
300
306
- TT. @testset " 2M_microphysics - Seifert and Beheng 2006 rain self-collection and breakup" begin
307
- # setup
308
- ρ = FT (1.1 )
309
- q_rai = FT (1e-6 )
310
- N_rai = FT (1e4 )
301
+ for SB in [SB2006, SB2006_no_limiters]
302
+ sb_str = SB == SB2006 ? " with limiters" : " without limiters"
303
+ TT. @testset " 2M_microphysics - Seifert and Beheng 2006 rain self-collection and breakup ($sb_str ) ($FT )" begin
304
+ # Setup
305
+ ρ = FT (1.1 )
306
+ q_rai = FT (1e-6 )
307
+ N_rai = FT (1e4 )
311
308
312
- for SB in [SB2006, SB2006_no_limiters]
313
309
(; krr, κrr) = SB. self
314
310
(; Deq, kbr, κbr) = SB. brek
315
311
ρ0 = SB. pdf_r. ρ0
316
312
317
- # action
318
- sc_rai =
319
- CM2. rain_self_collection (SB. pdf_r, SB. self, q_rai, ρ, N_rai)
320
- br_rai =
321
- CM2. rain_breakup (SB. pdf_r, SB. brek, q_rai, ρ, N_rai, sc_rai)
322
- sc_br_rai =
323
- CM2. rain_self_collection_and_breakup (SB, q_rai, ρ, N_rai)
313
+ # Action
314
+ sc_rai = CM2. rain_self_collection (SB. pdf_r, SB. self, q_rai, ρ, N_rai)
315
+ br_rai = CM2. rain_breakup (SB. pdf_r, SB. brek, q_rai, ρ, N_rai, sc_rai)
316
+ sc_br_rai = CM2. rain_self_collection_and_breakup (SB, q_rai, ρ, N_rai)
324
317
325
318
λr = CM2. pdf_rain_parameters (SB. pdf_r, q_rai, ρ, N_rai). Br
326
319
327
- dNrdt_sc =
328
- - krr * N_rai * ρ * q_rai * (1 + κrr / λr)^- 5 * sqrt (ρ0 / ρ)
320
+ dNrdt_sc = - krr * N_rai * ρ * q_rai * (1 + κrr / λr)^- 5 * √ (ρ0 / ρ)
329
321
330
322
Dr =
331
323
(
@@ -339,14 +331,10 @@ function test_microphysics2M(FT)
339
331
340
332
dNrdt_br = - (ϕ_br + 1 ) * sc_rai
341
333
342
- # test
334
+ # Test
343
335
TT. @test sc_rai ≈ dNrdt_sc rtol = 1e-6
344
336
TT. @test CM2. rain_self_collection (
345
- SB. pdf_r,
346
- SB. self,
347
- FT (0 ),
348
- ρ,
349
- N_rai,
337
+ SB. pdf_r, SB. self, FT (0 ), ρ, N_rai,
350
338
) ≈ FT (0 ) atol = eps (FT)
351
339
TT. @test br_rai ≈ dNrdt_br rtol = 1e-6
352
340
TT. @test sc_br_rai isa NamedTuple
@@ -357,12 +345,9 @@ function test_microphysics2M(FT)
357
345
q_rai = FT (0 )
358
346
359
347
# action
360
- sc_rai =
361
- CM2. rain_self_collection (SB. pdf_r, SB. self, q_rai, ρ, N_rai)
362
- br_rai =
363
- CM2. rain_breakup (SB. pdf_r, SB. brek, q_rai, ρ, N_rai, sc_rai)
364
- sc_br_rai =
365
- CM2. rain_self_collection_and_breakup (SB, q_rai, ρ, N_rai)
348
+ sc_rai = CM2. rain_self_collection (SB. pdf_r, SB. self, q_rai, ρ, N_rai)
349
+ br_rai = CM2. rain_breakup (SB. pdf_r, SB. brek, q_rai, ρ, N_rai, sc_rai)
350
+ sc_br_rai = CM2. rain_self_collection_and_breakup (SB, q_rai, ρ, N_rai)
366
351
367
352
# test
368
353
TT. @test sc_rai ≈ FT (0 ) atol = eps (FT)
@@ -372,7 +357,7 @@ function test_microphysics2M(FT)
372
357
end
373
358
end
374
359
375
- TT. @testset " 2M_microphysics - Seifert and Beheng 2006 rain terminal velocity with limiters" begin
360
+ TT. @testset " 2M_microphysics - Seifert and Beheng 2006 rain terminal velocity with limiters ( $FT ) " begin
376
361
# setup
377
362
ρ = FT (1.1 )
378
363
q_rai = FT (1e-6 )
@@ -393,22 +378,14 @@ function test_microphysics2M(FT)
393
378
TT. @test vt_rai[2 ] ≈ vt1 rtol = 1e-6
394
379
395
380
TT. @test CM2. rain_terminal_velocity (
396
- SB2006,
397
- SB2006Vel,
398
- q_rai,
399
- ρ,
400
- FT (0 ),
381
+ SB2006, SB2006Vel, q_rai, ρ, FT (0 ),
401
382
)[1 ] ≈ 0 atol = eps (FT)
402
383
TT. @test CM2. rain_terminal_velocity (
403
- SB2006,
404
- SB2006Vel,
405
- FT (0 ),
406
- ρ,
407
- N_rai,
384
+ SB2006, SB2006Vel, FT (0 ), ρ, N_rai,
408
385
)[2 ] ≈ 0 atol = eps (FT)
409
386
end
410
387
411
- TT. @testset " 2M_microphysics - Seifert and Beheng 2006 modified rain terminal velocity without limiters" begin
388
+ TT. @testset " 2M_microphysics - Seifert and Beheng 2006 modified rain terminal velocity without limiters ( $FT ) " begin
412
389
# setup
413
390
ρ = FT (1.1 )
414
391
q_rai = FT (1e-6 )
@@ -418,11 +395,7 @@ function test_microphysics2M(FT)
418
395
419
396
# action
420
397
vt_rai = CM2. rain_terminal_velocity (
421
- SB2006_no_limiters,
422
- SB2006Vel,
423
- q_rai,
424
- ρ,
425
- N_rai,
398
+ SB2006_no_limiters, SB2006Vel, q_rai, ρ, N_rai,
426
399
)
427
400
428
401
λr =
@@ -448,60 +421,42 @@ function test_microphysics2M(FT)
448
421
TT. @test vt_rai[2 ] ≈ vt1 rtol = 1e-6
449
422
450
423
TT. @test CM2. rain_terminal_velocity (
451
- SB2006_no_limiters,
452
- SB2006Vel,
453
- q_rai,
454
- ρ,
455
- FT (0 ),
424
+ SB2006_no_limiters, SB2006Vel, q_rai, ρ, FT (0 ),
456
425
)[1 ] ≈ 0 atol = eps (FT)
457
426
TT. @test CM2. rain_terminal_velocity (
458
- SB2006_no_limiters,
459
- SB2006Vel,
460
- FT (0 ),
461
- ρ,
462
- N_rai,
427
+ SB2006_no_limiters, SB2006Vel, FT (0 ), ρ, N_rai,
463
428
)[2 ] ≈ 0 atol = eps (FT)
464
429
end
465
430
466
- TT. @testset " 2M_microphysics - Chen 2022 rain terminal velocity" begin
431
+ TT. @testset " 2M_microphysics - Chen 2022 rain terminal velocity ( $FT ) " begin
467
432
# setup
468
433
ρ = FT (1.1 )
469
434
q_rai = FT (5e-4 )
470
435
N_rai = FT (1e4 )
471
436
472
437
for SB in [SB2006, SB2006_no_limiters]
473
438
# action
474
- vt_rai =
475
- CM2. rain_terminal_velocity (SB, Chen2022Vel, q_rai, ρ, N_rai)
476
- v_bigger =
477
- CM2. rain_terminal_velocity (SB, Chen2022Vel, q_rai * 2 , ρ, N_rai)
439
+ vt_rai = CM2. rain_terminal_velocity (SB, Chen2022Vel, q_rai, ρ, N_rai)
440
+ v_bigger = CM2. rain_terminal_velocity (SB, Chen2022Vel, q_rai * 2 , ρ, N_rai)
478
441
479
442
# test
480
443
TT. @test vt_rai isa Tuple
481
444
TT. @test vt_rai[1 ] ≈ 1.0738503635546666 rtol = 1e-6
482
445
TT. @test vt_rai[2 ] ≈ 4.00592218028957 rtol = 1e-6
483
446
484
447
TT. @test CM2. rain_terminal_velocity (
485
- SB,
486
- Chen2022Vel,
487
- q_rai,
488
- ρ,
489
- FT (0 ),
448
+ SB, Chen2022Vel, q_rai, ρ, FT (0 ),
490
449
)[1 ] ≈ 0 atol = eps (FT)
491
450
TT. @test CM2. rain_terminal_velocity (
492
- SB,
493
- Chen2022Vel,
494
- FT (0 ),
495
- ρ,
496
- N_rai,
451
+ SB, Chen2022Vel, FT (0 ), ρ, N_rai,
497
452
)[2 ] ≈ 0 atol = eps (FT)
498
453
499
454
TT. @test v_bigger[1 ] > vt_rai[1 ]
500
455
TT. @test v_bigger[2 ] > vt_rai[2 ]
501
456
end
502
457
end
503
458
504
- TT. @testset " 2M_microphysics - Seifert and Beheng 2006 rain evaporation" begin
459
+ TT. @testset " 2M_microphysics - Seifert and Beheng 2006 rain evaporation ( $FT ) " begin
505
460
# setup
506
461
ρ = FT (1.1 )
507
462
q_rai = FT (1e-6 )
@@ -540,37 +495,16 @@ function test_microphysics2M(FT)
540
495
TT. @test evap. evap_rate_0 ≈ evap0 rtol = 1e-4
541
496
TT. @test evap. evap_rate_1 ≈ evap1 rtol = 1e-5
542
497
TT. @test CM2. rain_evaporation (
543
- SB,
544
- aps,
545
- tps,
546
- q,
547
- q_rai,
548
- ρ,
549
- FT (0 ),
550
- T,
498
+ SB, aps, tps, q, q_rai, ρ, FT (0 ), T,
551
499
). evap_rate_0 ≈ 0 atol = eps (FT)
552
500
TT. @test CM2. rain_evaporation (
553
- SB,
554
- aps,
555
- tps,
556
- q,
557
- FT (0 ),
558
- ρ,
559
- N_rai,
560
- T,
501
+ SB, aps, tps, q, FT (0 ), ρ, N_rai, T,
561
502
). evap_rate_1 ≈ 0 atol = eps (FT)
562
503
end
563
504
564
505
# test limit case: xr = 0 for SB with no limiters
565
506
TT. @test CM2. rain_evaporation (
566
- SB2006_no_limiters,
567
- aps,
568
- tps,
569
- q,
570
- FT (0 ),
571
- ρ,
572
- N_rai,
573
- T,
507
+ SB2006_no_limiters, aps, tps, q, FT (0 ), ρ, N_rai, T,
574
508
). evap_rate_0 ≈ 0 atol = eps (FT)
575
509
576
510
end
@@ -697,7 +631,7 @@ function test_microphysics2M(FT)
697
631
end
698
632
end
699
633
700
- TT. @testset " 2M_microphysics - Seifert and Beheng 2006 cloud distribution sanity checks" begin
634
+ TT. @testset " 2M_microphysics - Seifert and Beheng 2006 cloud distribution sanity checks ( $FT ) " begin
701
635
702
636
# example number concentration and specific content
703
637
Nₗ = FT (1e3 * 1e6 ) # 1000 1/cm3
0 commit comments