-
Notifications
You must be signed in to change notification settings - Fork 29
/
convection.jl
47 lines (40 loc) · 2.21 KB
/
convection.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
@testset "Parametrization: convection" begin
@testset "diagnose_convection!" begin
@testset for NF in (Float32, Float64)
_, diagn, model = SpeedyWeather.initialize_speedy(NF, model = :primitive)
nlev = diagn.nlev
pres_thresh_cnv = model.constants.pres_thresh_cnv
column = ColumnVariables{NF}(nlev = nlev)
column.humid .= 0 .+ 50 * rand(NF, nlev) # Typical values between 0-50 g/kg
column.pres = pres_thresh_cnv + 0.1 # Normalised pressure above threshold for convection
column.sat_humid .= 0 .+ 50 * rand(NF, nlev) # Typical values between 0-50 g/kg
column.dry_static_energy .= rand(NF, nlev)
column.moist_static_energy .= rand(NF, nlev)
column.sat_moist_static_energy .= rand(NF, nlev)
column.sat_moist_static_energy_half .= rand(NF, nlev)
SpeedyWeather.diagnose_convection!(column, model)
@test isfinite(column.excess_humidity)
@test column.excess_humidity >= 0
end
end
@testset "convection!" begin
@testset for NF in (Float32, Float64)
_, diagn, model = SpeedyWeather.initialize_speedy(NF, model = :primitive)
nlev = diagn.nlev
pres_thresh_cnv = model.constants.pres_thresh_cnv
column = ColumnVariables{NF}(nlev = nlev)
column.humid .= 0 .+ 50 * rand(NF, nlev) # Typical values between 0-50 g/kg
column.pres = pres_thresh_cnv + 0.1 # Normalised pressure above threshold for convection
column.sat_humid .= 0 .+ 50 * rand(NF, nlev) # Typical values between 0-50 g/kg
column.dry_static_energy .= rand(NF, nlev)
column.moist_static_energy .= rand(NF, nlev)
column.sat_moist_static_energy .= rand(NF, nlev)
column.sat_moist_static_energy_half .= rand(NF, nlev)
SpeedyWeather.convection!(column, model)
@test isfinite(column.cloud_base_mass_flux)
@test isfinite(column.precip_convection)
@test all(isfinite.(column.net_flux_humid))
@test all(isfinite.(column.net_flux_dry_static_energy))
end
end
end