How do I use split() on a function without having too few values to unpack?

I’m trying to use split() to create two coupled functions for solving a coupled heat equation. I’m getting an error about not having enough values to unpack. I’ve installed fenics through Anaconda, and I’m using Python 3.9.4.

n_shells = 1000
r_total = 0.8e-2

mesh = IntervalMesh(n_shells, 0, r_total)
V = FunctionSpace(mesh, 'P', 2)
vU = TestFunction(V)
vH = TestFunction(V)
u = Function(V)
uU, uH = split(u)

The error I’m getting is:

line 50, in <module>
    uU, uH = split(u)
ValueError: not enough values to unpack (expected 2, got 1)

Would someone mind helping me out?

Your FunctionSpace does not support more than one variable, e.g:

from dolfin import *

n_shells = 1000
r_total = 0.8e-2

mesh = IntervalMesh(n_shells, 0, r_total)
Ve = FiniteElement("CG", mesh.ufl_cell(), 2)
n_vars = 2
V = FunctionSpace(mesh, MixedElement([Ve]*n_vars))
vU = TestFunction(V)
vH = TestFunction(V)
u = Function(V)
uU, uH = split(u)
1 Like

Thank you so, so much!!