Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
anastasia-popova committed Feb 20, 2024
1 parent c948c91 commit 19c96c8
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 55 deletions.
3 changes: 2 additions & 1 deletion src/P3Scheme.jl
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,8 @@ end
# q_rim = 0 and D_min = D_th, D_max = inf
function q_rz(p3::PSP3, N_0::FT, λ::FT, D_min::FT) where {FT}
x = DSD_μ(p3, λ) + p3.β_va + 1
return α_va_si(p3) * N_0 / λ^x * (Γ(x) + Γ(x, λ * D_min) - (x - 1) * Γ(x - 1))
return α_va_si(p3) * N_0 / λ^x *
(Γ(x) + Γ(x, λ * D_min) - (x - 1) * Γ(x - 1))
end
# q_rim > 0 and D_min = D_th and D_max = D_gr
function q_n(p3::PSP3, N_0::FT, λ::FT, D_min::FT, D_max::FT) where {FT}
Expand Down
107 changes: 53 additions & 54 deletions test/p3_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -156,57 +156,56 @@ function test_p3_shape_solver(FT)

TT.@testset "shape parameters (nonlinear solver function)" begin

# initialize test values:
ep = 1e3 * eps(FT)
N_test = (FT(1e8)) # N values
λ_test = (FT(15000)) #, FT(20000)) # test λ values in range
ρ_r_test = (FT(400)) #, FT(1)) #, FT(100)) # representative ρ_r values
F_r_test = (FT(0.5), FT(0.8), FT(0.95)) # representative F_r values

# check that the shape solution solves to give correct values
for N in N_test
for λ_ex in λ_test
for ρ_r in ρ_r_test
for F_r in F_r_test
# Compute the shape parameters that correspond to the
# input test values
μ_ex = P3.DSD_μ(p3, λ_ex)
N₀_ex = P3.DSD_N₀(p3, N, λ_ex)
# Find the P3 scheme thresholds
th = P3.thresholds(p3, ρ_r, F_r)
# Convert λ to ensure it remains positive
x = log(λ_ex)
# Compute mass density based on input shape parameters
q_calc = P3.q_gamma(p3, F_r, N, x, th)

# Solve for shape parameters
(λ, N₀) = P3.distribution_parameter_solver(
p3,
q_calc,
N,
ρ_r,
F_r,
)

# Compare solved values with the input expected values
TT.@test λ λ_ex rtol = ep
TT.@test N₀ N₀_ex rtol = ep
end
end
end
end
end
end

println("Testing Float32")
test_p3_thresholds(Float32)
test_p3_mass(Float32)
#TODO - only works for Float64 now. We should switch the units inside the solver
# from SI base to something more managable
test_p3_shape_solver(Float32)

println("Testing Float64")
test_p3_thresholds(Float64)
test_p3_mass(Float64)
test_p3_shape_solver(Float64)

# initialize test values:
ep = 1e3 * eps(FT)
N_test = (FT(1e8)) # N values
λ_test = (FT(15000)) #, FT(20000)) # test λ values in range
ρ_r_test = (FT(400)) #, FT(1)) #, FT(100)) # representative ρ_r values
F_r_test = (FT(0.5), FT(0.8), FT(0.95)) # representative F_r values

# check that the shape solution solves to give correct values
for N in N_test
for λ_ex in λ_test
for ρ_r in ρ_r_test
for F_r in F_r_test
# Compute the shape parameters that correspond to the
# input test values
μ_ex = P3.DSD_μ(p3, λ_ex)
N₀_ex = P3.DSD_N₀(p3, N, λ_ex)
# Find the P3 scheme thresholds
th = P3.thresholds(p3, ρ_r, F_r)
# Convert λ to ensure it remains positive
x = log(λ_ex)
# Compute mass density based on input shape parameters
q_calc = P3.q_gamma(p3, F_r, N, x, th)

# Solve for shape parameters
(λ, N₀) = P3.distribution_parameter_solver(
p3,
q_calc,
N,
ρ_r,
F_r,
)

# Compare solved values with the input expected values
TT.@test λ λ_ex rtol = ep
TT.@test N₀ N₀_ex rtol = ep
end
end
end
end
end
end

println("Testing Float32")
test_p3_thresholds(Float32)
test_p3_mass(Float32)
#TODO - only works for Float64 now. We should switch the units inside the solver
# from SI base to something more managable
test_p3_shape_solver(Float32)

println("Testing Float64")
test_p3_thresholds(Float64)
test_p3_mass(Float64)
test_p3_shape_solver(Float64)

0 comments on commit 19c96c8

Please sign in to comment.