This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

derivative of a nonlinear form

+3 votes

Hallo,
I have a form a=inner(q(u)*grad(u),grad(v))
with u Trialfunction and v Testfunction. Now I want to calculate the derivative of a with respect to u.
In a second step I want to evaluate this function at a function u_k (from an iterativ solve).
Is this possible with fenics?
Thanks for you help!

asked May 20, 2014 by cecilly FEniCS Novice (230 points)

Please could you use the proper formatting?

1 Answer

+1 vote

Yes, but u should be a Function rather than a TrialFunction.

So (untested) suggestion:

u = Function(V)
v = TestFunction(V)
F = inner(q(u)*grad(u),grad(v))*dx
a = derivative(F, u)
u_k = Function(V)
b = replace(a, {u: u_k})
answered May 20, 2014 by Marie E. Rognes FEniCS User (5,380 points)
...