Demo gives error

I installed Fenics and then tried to run the Poisson example code from here.

I get this error:
KeyError: ‘Must supply element or degree’.

The problem was solved upon changing:

f = Expression(“10exp(-(pow(x[0] - 0.5, 2) + pow(x[1] - 0.5, 2)) / 0.02)")
g = Expression("sin(5


f = Expression(“10exp(-(pow(x[0] - 0.5, 2) + pow(x[1] - 0.5, 2)) / 0.02)", degree = 1)
g = Expression("sin(5
x[0])”, degree = 1)

However, if I try run another demo from here, I get this error:

TypeError: unsupported operand type(s) for *: ‘FunctionSpace’ and ‘FunctionSpace’

Is there a difference between the current available Fenics and the documentation? It seems something in Fenics has changed but is not reflected in the documentation.

1 Like

the link you mentioned refer to version 1.3 of FEniCS which is extremely old so that a few things have changed in the API, in particular the definition of MixedFunctionSpace using the star operator. The current demos can be found here


Ironically, this link is now broken

Consider: Demos — DOLFIN documentation
or simply:

The first link lists demos, one of which has (I think) the same problem as before:

I am not sure which link you are referring to.
The link you have provided works. and I cannot see which link inside the reference I provided that you mean is incorrect

To be clear:

has a link to:

which doesn’t work

i.e., this link:

Demos — DOLFIN documentation

The latest link you are sending is directing me to a workin webpage, which has the following link:

This link sends me to the demo:

This link also sends me to the demo

The demo doesn’t work. That’s what I meant

What error do you obtain when running the demo?

Aha! I found the problem – at my end. I was running an out-of-date version of “”, not the one pointed to by that link. Apologies!

FWIW, and for those of us who are new here and haven’t seen the evolution of the Dolfin over time, this works:

BDM = FiniteElement("BDM", mesh.ufl_cell(), 1)
DG  = FiniteElement("DG", mesh.ufl_cell(), 0)
W = FunctionSpace(mesh, BDM * DG)

but this doesn’t (any more):

BDM = FunctionSpace(mesh, "BDM", 1)
DG = FunctionSpace(mesh, "DG", 0)
W = BDM * DG