Skip to content

Commit fa06adf

Browse files
committed
up
1 parent 702777d commit fa06adf

File tree

1 file changed

+25
-24
lines changed

1 file changed

+25
-24
lines changed
Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,30 @@
1-
# Fetch pakages.
2-
using NonlinearSolve, DiffEqDevTools, Plots
3-
using Test
1+
# Fetch packages.
2+
using DiffEqDevTools, NonlinearSolve, Plots, Test
43

5-
# Prepares NonlinearProblem.
6-
f(u, p) = 3u .^3 .+ 2u .^2 .+ u + .- p
7-
u0 = [1.0, 6.0]
8-
p = [1.0, 3.0]
9-
static_prob = NonlinearProblem(f, u0, p)
10-
real_sol = solve(static_prob, NewtonRaphson(), reltol = 1e-15, abstol = 1e-15)
4+
let
5+
# Prepares NonlinearProblem.
6+
f(u, p) = 3u .^3 .+ 2u .^2 .+ u + .- p
7+
u0 = [1.0, 6.0]
8+
p = [1.0, 3.0]
9+
static_prob = NonlinearProblem(f, u0, p)
10+
real_sol = solve(static_prob, NewtonRaphson(), reltol = 1e-15, abstol = 1e-15)
1111

12-
# Sets WP input.
13-
abstols = 1.0 ./ 10.0 .^ (8:12)
14-
reltols = 1.0 ./ 10.0 .^ (8:12)
15-
setups = [Dict(:alg=>NewtonRaphson())
16-
Dict(:alg=>TrustRegion())]
17-
solnames = ["NewtonRaphson"; "TrustRegion"]
12+
# Sets WP input.
13+
abstols = 1.0 ./ 10.0 .^ (8:12)
14+
reltols = 1.0 ./ 10.0 .^ (8:12)
15+
setups = [Dict(:alg=>NewtonRaphson())
16+
Dict(:alg=>TrustRegion())]
17+
solnames = ["NewtonRaphson"; "TrustRegion"]
1818

19-
# Makes WP-diagram
20-
wp = WorkPrecisionSet(static_prob, abstols, reltols, setups; names=solnames, numruns=100, appxsol=real_sol, error_estimate=:l2)
19+
# Makes WP-diagram
20+
wp = WorkPrecisionSet(static_prob, abstols, reltols, setups; names=solnames, numruns=100, appxsol=real_sol, error_estimate=:l2)
2121

22-
# Checks that all errors are small (they definitely should be).
23-
@test all(vcat(getfield.(wp.wps, :errors)...) .< 10e-9)
24-
@test length(plot(wp).series_list) == 2
22+
# Checks that all errors are small (they definitely should be).
23+
@test all(vcat(getfield.(wp.wps, :errors)...) .< 10e-9)
24+
@test length(plot(wp).series_list) == 2
2525

26-
# Check without appxsol.
27-
wp = WorkPrecisionSet(static_prob, abstols, reltols, setups; names=solnames, numruns=100, error_estimate=:l2)
28-
@test all(vcat(getfield.(wp.wps, :errors)...) .< 10e-9)
29-
@test length(plot(wp).series_list) == 2
26+
# Check without appxsol.
27+
wp = WorkPrecisionSet(static_prob, abstols, reltols, setups; names=solnames, numruns=100, error_estimate=:l2)
28+
@test all(vcat(getfield.(wp.wps, :errors)...) .< 10e-9)
29+
@test length(plot(wp).series_list) == 2
30+
end

0 commit comments

Comments
 (0)