scipy.optimize.root as a nonlinear solver
See original GitHub issue#118 referred to the translation of one of the FEniCS tutorial examples into scikit-fem https://github.com/gdmcbain/fenics-tuto-in-skfem/tree/master/05_poisson_nonlinear. As discussed there, it’s a nonlinear Poisson equation like docs/examples/ex10.py
.
In ex10, Newton iteration is coded from scratch. I wondered whether it would be possible to use a canned implementation such as scipy.optimize.root. This was done.
Actually in the scikit-fem translation, the optional Jacobian is not passed to root
; it solves in a reasonable time (4 seconds) without for this very small problem. It shouldn’t be that hard to add the Jacobian (by hand as suggested in #27 or perhaps using SymPy #118).
Would ex10 be better for using a canned nonlinear solver? I tend to prefer to encapsulate algorithms like Newton iteration than recode them each time.
SciPy is already a dependency.
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (6 by maintainers)
Top GitHub Comments
Assumed that scipy implements it in a reasonable fashion (with regards to the sparsity etc.), I don’t mind that the example is modified.
Following the (offline) discussion of the ‘action’ of a bilinear form (Kirby & Logg, ‘Finite element variational forms’) and then the tantalizing last paragraph of Hannukainen & Jantunen about the then planned future work on ‘matrix free implementation of the finite element assembly’ (did they ever get to that?), I was reminded of ‘Jacobian-free Newton–Krylov methods’ and took another look at this using
root
withmethod='krylov'
. It works quite nicely on ex10: just omit theBilinearForm
and replace thefor
-loop withComplete file: ex10_jfnk.py.txt