Skip to content

Commit

Permalink
Add perf and GPU tests for Chen2022 terminal velocity
Browse files Browse the repository at this point in the history
  • Loading branch information
trontrytel committed Nov 22, 2024
1 parent ab82db5 commit d54e35c
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 0 deletions.
60 changes: 60 additions & 0 deletions test/gpu_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,32 @@ end
end
end

@kernel function test_chen2022_terminal_velocity_kernel!(
liquid,
ice,
rain,
snow,
Ch2022,
output::AbstractArray{FT},
ρₐ,
qₗ,
qᵢ,
qᵣ,
qₛ,
) where {FT}

i = @index(Group, Linear)

@inbounds begin
output[1, i] = CMN.terminal_velocity(liquid, Ch2022.rain, ρₐ[i], qₗ[i])
output[2, i] =
CMN.terminal_velocity(ice, Ch2022.small_ice, ρₐ[i], qᵢ[i])
output[3, i] = CM1.terminal_velocity(rain, Ch2022.rain, ρₐ[i], qᵣ[i])
output[4, i] =
CM1.terminal_velocity(snow, Ch2022.large_ice, ρₐ[i], qₛ[i])
end
end

@kernel function test_0_moment_micro_kernel!(
p0m,
output::AbstractArray{FT},
Expand Down Expand Up @@ -750,6 +776,7 @@ function test_gpu(FT)
# Terminal velocity
blk1mvel = CMP.Blk1MVelType(FT)
SB2006Vel = CMP.SB2006VelType(FT)
Ch2022 = CMP.Chen2022VelType(FT)

# 2-moment microphysics
SB2006 = CMP.SB2006(FT)
Expand Down Expand Up @@ -829,6 +856,39 @@ function test_gpu(FT)
@test Array(output)[2] FT(-1e-4)
end

@testset "Chen 2022 terminal velocity kernels" begin
dims = (4, 1)
(; output, ndrange) = setup_output(dims, FT)

ρ = ArrayType([FT(0.95)])
qₗ = ArrayType([FT(0.004)])
qᵢ = ArrayType([FT(0.003)])
qᵣ = ArrayType([FT(0.002)])
qₛ = ArrayType([FT(0.001)])

kernel! = test_chen2022_terminal_velocity_kernel!(backend, work_groups)
kernel!(
liquid,
ice,
rain,
snow,
Ch2022,
output,
ρ,
qₗ,
qᵢ,
qᵣ,
qₛ;
ndrange,
)

# test that terminal velocity is callable and returns a reasonable value
@test Array(output)[1] FT(0.00689286343412659)
@test Array(output)[2] FT(0.011493257177438487)
@test Array(output)[3] FT(4.274715870117866)
@test Array(output)[4] FT(0.5688979454130587)
end

@testset "0-moment microphysics kernels" begin
dims = (3, 2)
(; output, ndrange) = setup_output(dims, FT)
Expand Down
15 changes: 15 additions & 0 deletions test/performance_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ function benchmark_test(FT)
liquid = CMP.CloudLiquid(FT)
ice = CMP.CloudIce(FT)
rain = CMP.Rain(FT)
snow = CMP.Snow(FT)
ce = CMP.CollisionEff(FT)
# 2-moment microphysics
override_file = joinpath(
Expand Down Expand Up @@ -202,6 +203,20 @@ function benchmark_test(FT)
#bench_press(CMI_het.P3_deposition_N_i, (ip.p3, T_air_cold), 230)
#bench_press(CMI_het.P3_het_N_i, (ip.p3, T_air_cold, N_liq, V_liq, Δt), 230)

# Chen 2022 terminal velocity
bench_press(CMN.terminal_velocity, (liquid, ch2022.rain, ρ_air, q_liq), 350)
bench_press(
CMN.terminal_velocity,
(ice, ch2022.small_ice, ρ_air, q_ice),
350,
)
bench_press(CM1.terminal_velocity, (rain, ch2022.rain, ρ_air, q_rai), 650)
bench_press(
CM1.terminal_velocity,
(snow, ch2022.large_ice, ρ_air, q_sno),
650,
)

# aerosol activation
bench_press(
AA.total_N_activated,
Expand Down

0 comments on commit d54e35c

Please sign in to comment.