Derivative Command Returns UFL-Form of Wrong Dimensions

Issue #684 new
Stephan Schmidt created an issue

Dear all,

It appears the dimensionality of the return value of the derivative function depends on the dimensionality of the evaluation point and not the dimensionality of the desired direction.

This results in inconsistent return values when I differentiate, e.g. (f2-f2)f3 with respect to f2 in comparison to differentiating just 0.0*f3 with respect to f2. Ideally, both should be a "zero" of the same UFL-type, but apparently they are not.

I attach a minimal example to illustrate this. In one case, the code works, in the other it doesn't. I am using version 1.7.0dev.

This makes automatically processing "derivative"-output very tedious, as I would need a check "did my integrand depend on f2 in the first place?" to catch the return value inconsistency and I have no idea how to do this :(

Comments (5)

  1. Stephan Schmidt reporter

    Thanks to Patrick and Simon, one workaround is to use ufl.algorithms.ad.expand_derivatives(), which will return <empty form> in case of the last test and something sensible in the first two

  2. Log in to comment