Skip to content

Commit

Permalink
fix Float32 tests
Browse files Browse the repository at this point in the history
  • Loading branch information
trontrytel committed Aug 14, 2023
1 parent cc7d57b commit d235293
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/P3Scheme.jl
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ function thresholds(

p = Nothing # (no parameters)
prob_obj = NLS.NonlinearProblem(f, u0, p)
sol = NLS.solve(prob_obj, NLS.NewtonRaphson(), reltol = 1e-9)
sol = NLS.solve(prob_obj, NLS.NewtonRaphson(), abstol = eps(FT))
D_cr, D_gr, ρ_g, ρ_d = exp.(sol) # shift back into desired domain space
return [D_cr, D_gr, ρ_g, ρ_d]
end
Expand Down
15 changes: 7 additions & 8 deletions test/p3_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,14 @@ function test_p3_thresholds(FT)
vals = P3.thresholds(ρ_r, F_r)
output = f(vals, p)
for result in output
TT.@test abs(result) < FT(1.5e-6)
TT.@test abs(result) FT(0) atol = 1.1e3 * eps(FT)
end
end
end

# Define diff function for comparisons
function diff(test, gold, delta = 1e-2)
test_delta = abs(test - gold)
TT.@test test_delta < delta
function diff(test, gold, delta = 2e-2)
TT.@test test gold rtol = delta
end

# Check that D_cr returned by P3.thresholds() matches the value
Expand Down Expand Up @@ -130,7 +129,7 @@ function test_p3_thresholds(FT)

# Similarly, check that D_cr, D_gr returned by P3.thresholds()
# matches the value displayed in Fig. 1b of MM2015 within 1% error
# D_cr:
# D_cr:
diff(
FT(P3.thresholds(ρ_r_good[1], F_r_good[3])[1] * 1e3),
FT(6.152144691917768),
Expand Down Expand Up @@ -161,8 +160,8 @@ function test_p3_thresholds(FT)
end
end

println("Testing Float32")
test_p3_thresholds(Float32)

println("Testing Float64")
test_p3_thresholds(Float64)

# println("Testing Float32")
# test_p3_thresholds(Float32)

0 comments on commit d235293

Please sign in to comment.