Dear Amireh,
On 30 Oct 2018, at 17:04, Amireh Mousavi <amireh.mousavi@math.iut.ac.ir> wrote:
Dear Firedrake team,
I'm trying to solve Hamilton-Jacobi-Bellman equation. It is a fully nonlinear equation, so after linearization, in each iteration in first we need to determine a parameter which is obtained from solving nonlinear algebraic equation and after that we solve the linear PDE. How can I solve nonlinear algebraic equation in Firedrake?
Consider the simple example:
mesh = UnitSquareMesh(4, 4)
R = FunctionSpace(mesh, "R", 0)
Ralpha = Function(R)
alpha = variable(Ralpha)
A_alpha = as_tensor([[cos(alpha) , -sin(alpha)] , [sin(alpha) , cos(alpha)]])
A = Constant([[20 ,1] , [1 , 0.1]])
A_alphaA = inner(A_alpha , A)
#dA_alphaA = solve(diff(A_alphaA , alpha ), alpha)
How can I solve "diff(A_alphaA , alpha)=0" in Firedrake ?
If this is actually the thing you want to solve, that is, a single-variable nonlinear problem, I would be tempted to just write out the Jacobian for this problem "by hand" and then use one of the nonlinear iterations in scipy to minimise it. You could pose this as a variational problem over R, since I think in that case the directional derivative and the normal "diff" derivative match up. So you could say: solve(derivative(A_alphaA, alpha) == 0, alpha) But if you have to do this a lot, that won't be the most efficient way of inverting the 1x1 Jacobian. Does that help? Cheers, Lawrence