Skip to content

Commit

Permalink
revert tests
Browse files Browse the repository at this point in the history
  • Loading branch information
anastasia-popova committed Feb 20, 2024
1 parent 753a296 commit c0257f6
Showing 1 changed file with 54 additions and 59 deletions.
113 changes: 54 additions & 59 deletions test/p3_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -156,62 +156,57 @@ function test_p3_shape_solver(FT)

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

# initialize test values:
ep = 1e3 * eps(FT)
N_test = range(6, stop = 10, step = 1) # N values
coeffs = range(FT(5), stop = FT(9), step = FT(1))
λ_test = range(4, stop = 5, step = FT(1)) # test λ values in range
ρ_r_test = range(FT(200), stop = FT(800), step = FT(200)) # representative ρ_r values
F_r_test = (FT(0), 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_pow in N_test
for λ_pow in λ_test
for coeff in coeffs
for ρ_r in ρ_r_test
for F_r in F_r_test
N = FT(10^N_pow)
λ_ex = FT(coeff * 10^λ_pow)
# Compute the shape parameters that correspond to the
# input test values
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,
)

#println("N = ", N, " λ = ", λ_ex, " F_r = ", F_r, " ρ_r = ", ρ_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
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(200)) #, 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 c0257f6

Please sign in to comment.