-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 11/11/15 12:04, Buesing, Henrik wrote:
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).
[Buesing, Henrik] Yes, true. I mixed this up. I want to do
solve(F == 0, u, J=approximate symbolic Jacobian)
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.
[Buesing, Henrik] That's what I would like to do. In my multi-physics case (see attachement) the Jacobian would have a 2x2 block structure.
I'm unsure how to provide this... I tried to write sth. down for the blocks (see test.py), but this is obviously wrong.
It looks like you getting mixed up between symbolic and actual computation. You look like you want to do the finite differencing sort of by hand? For example here: delta = Constant(1e-8) tmp = pw eps = delta + delta*tmp eps = assemble(eps) pw = tmp + eps val1 = F pw = tmp - eps val2 = F pw = tmp tmp00 = Constant(0.5)*(val1-val2)/eps it looks like you want val1 to be F evaluated at tmp + eps and val2 to be F evaluated a tmp - eps, but in fact, this is just symbolic assignment so both val1 and val2 are just different names for F. To write your approximate symbolic jacobian, you need to write J in terms of functions of the coefficients and test and trial functions (just like you did F). Then it will have the appropriate block structure, I think. I don't quite understand what all the bits are doing, but it looks like, for example the dF/dpw block is just zero (since F doesn't depend on pw?) Lawrence -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (GNU/Linux) iQEcBAEBAgAGBQJWQzU2AAoJECOc1kQ8PEYvpFIIAL6fgCYZnDr6/utEN5ANbfbA jXLPikM9FvStXwryCQOBrdt7iXuOkrz/ACTqjKvGJtFpqfwdJR/MuVLSfB8+rofr Ic4tOQV+wXkWQQa7Z7kRdmH0hhFRia8zFKqXvBoGkOPQNjKfXMaHfMDsgPhu7ehV xsjZt9zsrBzuZQxuY9fOSoABvgrkVk3xSyLaBML+f0rYJTJZ4BLjUbcXuIl9fJEX 940PUx58ZO3mYqkLCwzQQt+vqchptuKZgaaf/Bg1kZVK+ImlfgeVZrXidlTCH8VA bvwLSl387se2z7lQQOeMGH/yW+NeM48biz+W/EPskkcjLE4QTtbu7JBqN7HxcVw= =PWld -----END PGP SIGNATURE-----