← Back to team overview

ufl team mailing list archive

Re: Automatic differentiation

 



Martin Sandve Alnæs wrote:
I'll take a look at improving the error message and checking,
but try this (if I understand what you're trying to do correctly):

kc = Function(mixed_element)
k1, c1 = split(kc)
dkc = TrialFunction(mixed_element)
dk, dc = split(dkc)

...
a1 = derivative(L1, kc, dkc)


Thanks. I managed to figure it out and it's now used in the DOLFIN Cahn-Hilliard demo.

Garth

Martin



On Sat, Jun 6, 2009 at 10:34 PM, Garth N. Wells<gnw20@xxxxxxxxx> wrote:
I've used the UFL automatic differentiation for a primal problem, and it
worked great. Now I'd like to try it for the Cahn-Hilliard demo which is
a mixed method. I'd like to do:

   a1 = derivative(L1, k1, dk) + derivative(L1, c1, dc)

but I get the below error. Is there are trick for mixed elements?

Garth



Traceback (most recent call last):
  File "/usr/local/bin/ffc", line 186, in <module>
    sys.exit(main(sys.argv[1:]))
  File "/usr/local/bin/ffc", line 130, in main
    execfile(script, {})
  File "CahnHilliard2D.py", line 68, in <module>
    a1 = derivative(L1, k1, dk) + derivative(L1, c1, dc)
  File "/usr/local/lib/python2.6/dist-packages/ufl/formoperators.py",
line 142, in derivative
    functions, basis_functions = _handle_derivative_arguments(function,
basis_function)
  File "/usr/local/lib/python2.6/dist-packages/ufl/formoperators.py",
line 128, in _handle_derivative_arguments
    functions       = Tuple(*functions)
UnboundLocalError: local variable 'functions' referenced before assignment
_______________________________________________
UFL-dev mailing list
UFL-dev@xxxxxxxxxx
http://fenics.org/mailman/listinfo/ufl-dev



Follow ups

References