1
1
# Fetch pakages.
2
2
using NonlinearSolve, DiffEqDevTools, Plots
3
+ using Test
3
4
4
5
# Prepares NonlinearProblem.
5
- let
6
- f (u, p) = u .- p
7
- u0 = [1.0 , 1.0 ]
8
- p = 2.0
9
- static_prob = NonlinearProblem (f, u0, p)
10
- real_sol = solve (static_prob, NewtonRaphson (), reltol = 1e-15 , abstol = 1e-15 )
6
+ f (u, p) = 3 u .^ 3 .+ 2 u .^ 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 )
11
11
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" ]
18
18
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 )
21
21
22
- # Checks that all errors are small (they definitely should be).
23
- @test all (vcat (getfield .(wp. wps, :errors )... ) .< 10e-9 )
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
24
25
25
- # Check without appxsol.
26
- wp = WorkPrecisionSet (static_prob, abstols, reltols, setups; names= solnames, numruns= 100 , error_estimate= :l2 )
27
- @test all (vcat (getfield .(wp. wps, :errors )... ) .< 10e-9 )
28
- end
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
0 commit comments