← Back to team overview

fenics team mailing list archive

Does the derivative function work for multi functionspaces

 

Now the weak form is for coupled function spaces and I want to get the
Gateaux derivative of the form by 'derivative' function.
Code:

from dolfin import *
mesh = UnitSquare(10,10)

V1 = FunctionSpace(mesh, 'CG', 1)
V2 = FunctionSpace(mesh, 'CG', 1)
V = V1+V2
(v1,v2) = TestFunctions(V)
def q(u):
    return (1+u)**2


u1=Function(V1)
u2=Function(V2)
L = dot(q(u2)*grad(u1),grad(v1))*dx+
dot(q(u1)*grad(u2),grad(v2))*dx+(u1*v1+u2*v2)*dx

(du1,du2)=TrialFunctions(V)

a1=derivative(L,u1,du1)              #due to u1+\epsilon * du1
a2=derivative(L,u2,du2)             #due to u2+\epsilon*du2
a=a1+a2

But it raise error message below:
UFLException: Expecting Argument instance, not <class
'ufl.indexed.Indexed'>.

I don't know how to modify the problem, but I hope it can work as it will be
very convenient for problems
where differentiating the form by hand implies lengthy calculations. Thanks!

--Hongtao

Follow ups