Skip to content

Commit d713f1b

Browse files
committed
new convergence tests
to be build up in a later pr
1 parent 5143f5c commit d713f1b

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

test/convergencetests.jl

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
using NonlinearSolve
2+
using StaticArrays
3+
using BenchmarkTools
4+
using Test
5+
6+
using SciMLNLSolve
7+
8+
###-----Trust Region tests-----###
9+
10+
# some simple functions #
11+
function f_oop(u, p)
12+
u .* u .- p
13+
end
14+
15+
function f_iip(du, u, p)
16+
du .= u .* u .- p
17+
end
18+
19+
function f_scalar(u, p)
20+
u * u - p
21+
end
22+
23+
u0 = [1.0, 1.0]
24+
csu0 = 1.0
25+
p = [2.0, 2.0]
26+
radius_update_scheme = RadiusUpdateSchemes.Simple
27+
tol = 1e-9
28+
29+
function convergence_test_oop(f, u0, p, radius_update_scheme)
30+
prob = NonlinearProblem{false}(f, oftype(p, u0), p)
31+
cache = init(prob, TrustRegion(radius_update_scheme=radius_update_scheme), abstol = 1e-9)
32+
sol = solve!(cache)
33+
return cache.internalnorm(cache.u_prev - cache.u), cache.iter, sol.retcode
34+
end
35+
36+
residual, iterations, return_code = convergence_test_oop(f_oop, u0, p, radius_update_scheme)
37+
@test return_code === ReturnCode.Success
38+
@test residual tol

0 commit comments

Comments
 (0)