https://github.com/avik-pal/robustnonlinearsolvers.jl
Testing out Nonlinear Solvers that Automatically Switch between Discrete and Continuous Variants
https://github.com/avik-pal/robustnonlinearsolvers.jl
Last synced: about 1 month ago
JSON representation
Testing out Nonlinear Solvers that Automatically Switch between Discrete and Continuous Variants
- Host: GitHub
- URL: https://github.com/avik-pal/robustnonlinearsolvers.jl
- Owner: avik-pal
- Created: 2023-11-02T21:11:25.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-11-07T18:56:54.000Z (over 1 year ago)
- Last Synced: 2025-01-21T04:41:57.794Z (3 months ago)
- Language: Julia
- Size: 5.86 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# RobustNonlinearSolvers
Provides an auto-switching algorithm that switches between a continuous and discrete solver
to balance between robustness and speed for solving nonlinear equations.## Usage Example
```julia
using RobustNonlinearSolvers, NonlinearSolve, OrdinaryDiffEqfunction newton_fails(u, p)
return 0.010000000000000002 .+
10.000000000000002 ./ (1 .+
(0.21640425613334457 .+
216.40425613334457 ./ (1 .+
(0.21640425613334457 .+
216.40425613334457 ./
(1 .+ 0.0006250000000000001(u .^ 2.0))) .^ 2.0)) .^ 2.0) .-
0.0011552453009332421u .- p
endp = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
u0 = [-10.0, -1.0, 1.0, 2.0, 3.0, 4.0, 10.0]
prob = NonlinearProblem{false}(newton_fails, u0, p)# Fails
sol1 = solve(prob, NewtonRaphson())
sol1.retcode
sol1.resid
sol1.stats# Fails
sol2 = solve(prob, PseudoTransient())
sol2.retcode
sol2.resid
sol2.stats# Tune and Pass
sol3 = solve(prob, PseudoTransient(; alpha_initial = 1.0))
sol3.retcode
sol3.resid
sol3.stats# Continuous Solver: Adaptive Time Stepping
sol4 = solve(prob, ContinuousNonlinearSolveAlgorithm(ImplicitEuler()))
sol4.retcode
sol4.resid
sol4.stats# Continuous Solver: Fixed Time Stepping -- fails
sol5 = solve(prob, ContinuousNonlinearSolveAlgorithm(Euler()); dt = 1.0)
sol5.retcode
sol5.resid
sol5.stats# Auto Switching
sol6 = solve(prob, CompositeNonlinearSolveAlgorithm())
sol6.retcode
sol6.resid
sol6.stats
```