[firedrake] Pass approximate Jacobian to derivative() call
Lawrence Mitchell
lawrence.mitchell at imperial.ac.uk
Wed Nov 11 09:52:56 GMT 2015
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 11/11/15 07:33, Buesing, Henrik wrote:
> Dear all,
>
>
>
> is it possible to just pass the approximate Jacobian to the
> derivative call? Since it’s so complicated in my case to get the
> exact Jacobian I would like to do sth. like
>
>
>
> du = [(F(u + h) – F(u - h))/(2*h)]
So you can't do this by passing something to derivative (which instead
computes the jacobian for you given a residual). However, you can ask
PETSc to compute a finite difference approximation to your Jacobian
using colouring, it, however, uses one-sided, rather than centred
differences:
J = (F(u + h) - F(u))/h
if you pass:
solver_parameters={'snes_fd_color': True}
Then PETSc will compute the Jacobian using finite differencing with
colouring. This requires an additional Ncolours residual computations
per Newton iteration, where Ncolours depends on the sparsity structure
of the matrix: for 3D it will typically be around 20.
You can instead of course build an approximate, symbolic, Jacobian "by
hand" and provide that to the solver: you'll then end up doing
quasi-newton, rather than newton.
Cheers,
Lawrence
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.22 (GNU/Linux)
iQEcBAEBAgAGBQJWQw/4AAoJECOc1kQ8PEYvF1AH/3XxCtckj5TIP5BPdhnX+IFz
G9fXIniTnTa3Jy6jR1gDLhQf/1YTRCt9j9tfTAvCLBQ9yPpLRd6FNpTNHyOsx3dN
GX0DWmYzmswDZUe+Awz1CSaxUuu4vn3uPpCcDL6WBS+XcKSdVgfSQ3kI+BRXUYtC
VNH0E0842dK0NdBXNFKR+c88QOp2MkdldCtRqgzS9LfAdYUYWYpB7xp+MSURo5QB
f1ewh0dk9umagssaIEDLXygh6a+VOG8MuaPXjvRzHK/hRAWsHQppj4f5G/VpPkrv
0sLQeptGQVP1Ob8fWMTIPD754OcGdIpv0bguJr8gECGnR8kL2IsUBzcEUCexngk=
=izop
-----END PGP SIGNATURE-----
More information about the firedrake
mailing list