-
-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #191 from yash2798/ys/bastin_new
Bastin's radius update scheme
- Loading branch information
Showing
3 changed files
with
159 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using NonlinearSolve | ||
using StaticArrays | ||
using BenchmarkTools | ||
using Test | ||
|
||
using SciMLNLSolve | ||
|
||
###-----Trust Region tests-----### | ||
|
||
# some simple functions # | ||
function f_oop(u, p) | ||
u .* u .- p | ||
end | ||
|
||
function f_iip(du, u, p) | ||
du .= u .* u .- p | ||
end | ||
|
||
function f_scalar(u, p) | ||
u * u - p | ||
end | ||
|
||
u0 = [1.0, 1.0] | ||
csu0 = 1.0 | ||
p = [2.0, 2.0] | ||
radius_update_scheme = RadiusUpdateSchemes.Simple | ||
tol = 1e-9 | ||
|
||
function convergence_test_oop(f, u0, p, radius_update_scheme) | ||
prob = NonlinearProblem{false}(f, oftype(p, u0), p) | ||
cache = init(prob, | ||
TrustRegion(radius_update_scheme = radius_update_scheme), | ||
abstol = 1e-9) | ||
sol = solve!(cache) | ||
return cache.internalnorm(cache.u_prev - cache.u), cache.iter, sol.retcode | ||
end | ||
|
||
residual, iterations, return_code = convergence_test_oop(f_oop, u0, p, radius_update_scheme) | ||
@test return_code === ReturnCode.Success | ||
@test residual ≈ tol |