PDE system simple example

Thanks very much! I updated my code:

from fenics import *

mesh = UnitIntervalMesh(4)
el_scalar = FiniteElement("Lagrange", mesh.ufl_cell(), 2)  # use quadratic temperature triangle
el_vector = VectorElement("Lagrange", mesh.ufl_cell(), 1)  # use linear flux
el = MixedElement([el_scalar, el_vector])
Vmixed = FunctionSpace(mesh, el)
vs, vv = TestFunctions(Vmixed)
T, q   = TrialFunctions(Vmixed)

Vscalar = Vmixed.sub(0)
Vvector = Vmixed.sub(1)

k = Constant(1.0)
f = Constant(2.0)
F = dot(k*grad(T) + q, vv) * dx + dot(q, grad(vs)) * dx - f * vs * dx

bc = DirichletBC(Vscalar, Constant(0.0), "on_boundary")

u = Function(Vmixed)

solve(lhs(F) == rhs(F), u, bc)

T, q = u.split()

import numpy as np
np.asarray(T.vector())
array([  0.00000000e+00,             -inf,  -5.00000000e-01,
                    inf,  -1.00000000e+00,             -inf,
         1.15849359e-16,              inf,             -inf,
         5.00000000e-01,              inf,   0.00000000e+00,
                    inf,   1.00000000e+00])

I have a couple of follow up questions:

  • The solution contains inf and is nonsense. Is there maybe an issue with the boundary condition?
  • If I change the solve into solve(F == 0, u, bc) I get an error:
ArityMismatch: Adding expressions with non-matching form arguments ('v_0',) vs ('v_0', 'v_1').

why?

Edit: I opened a new question about the ArityMismatch.