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

Correct way to formulate two coupled nonlinear PDEs

+1 vote

I have two coupled nonlinear PDEs that I wish to solve. I try the following (following roughly the tutorial for mixed poisson equation):

c = Function(W)
(u,v) = TestFunction(W)
(T,xi) = Function(W)

F = dx*(v*(T*Dx(xi,1)+3*T**2*Dx(xi,0)**2+Dx(T,0)*Dx(xi,0))+Dx(v,0)*T*Dx(xi,0) + \
    u*(T*Dx(T,1))+Dx(u,0)*(T*Dx(T,0)-2*T**3 *Dx(xi,0)))-Constant(0.)*v*dx-Constant(0.)*u*dx
solve(F == 0, c, [bc,bc2,bc3,bc4], solver_parameters={"newton_solver":
                                    {"relative_tolerance": 1e-6}})

Here W is a product function space that I define as:

V = FunctionSpace(mesh,"Lagrange",1)
U = FunctionSpace(mesh,"Lagrange",1)
W = V*U

This gives me an error:

TypeError: unsupported operand type(s) for *: 'Measure' and 'Sum'

This probably has to do with the fact that, defined this way, type of my u,v,T and xi is ufl.indexed.Indexed instead of dolfin.functions.function.Argument, but I can't figure out how else I can define them. I also tried defining T and xi as TrialFunctions instead of Functions, but it didn't help. What is the correct way to do this?

asked May 31, 2014 by Ech FEniCS Novice (570 points)

1 Answer

+2 votes
 
Best answer

Try moving the first 'dx' (the measure) to the end of the term. That usually does it for me.

F = (v(TDx(xi,1)+3T2*Dx(xi,0)2+Dx(T,0)Dx(xi,0))+Dx(v,0)TDx(xi,0) + \
u(TDx(T,1))+Dx(u,0)(TDx(T,0)-2*T**3 *Dx(xi,0)))*dx-Constant(0.)*v*dx-Constant(0.)*u*dx
....................................................................................^

answered Jun 2, 2014 by mwelland FEniCS User (8,410 points)
selected Jun 3, 2014 by Ech

This works. Thank you! It didn't occur to me that the ordering of the terms in the expression would matter.

...