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

derivative(form, u) vs. derivative(form, u, du)

+3 votes

The third argument du in the derivative(...) method is optional, cf.
http://fenicsproject.org/documentation/dolfin/dev/python/programmers-reference/fem/formmanipulations/derivative.html.

What's the actual difference between

J = derivative(form, u)

and

J = derivative(form, u, du)

if both return the Jacobian?

In the Cahn-Hilliard demo, du is used somewhat strangely in that neither of dc, dmu = split(du) is used in the code,

asked Jan 7, 2014 by nschloe FEniCS User (7,120 points)
edited Jan 7, 2014 by nschloe

The link to the doc of derivative is broken.

Fixed. (In preview the link was alright, but the final representation decided to include the full stop at the end of the sentence to the URL.)

1 Answer

+4 votes

The direction of derivative becomes a new argument of a resulting form - TrialFunction, TestFunction or another argument according to the rank of the original form by default. You can override this logic by supplying a new argument, du here. The Cahn-Hilliard demo would work also without specifying this.

answered Jan 9, 2014 by Jan Blechta FEniCS Expert (51,420 points)
...