Problem with demo.py in Tutorial

Asked by Christine Tobler

More a remark than a question, as I've found a way around it:

When I entered the demo example from http://www.fenics.org/wiki/Tutorial, I got the error message

fenics-test$ python demo.py
Calling FFC just-in-time (JIT) compiler, this may take some time.
Traceback (most recent call last):
  File "demo.py", line 13, in <module>
    u0 = Constant(mesh, 0.0)
TypeError: __init__() takes exactly 2 arguments (3 given)

Looking at the demos in dolfin-docs, I found I needed to change

u0 = Constant(mesh, 0.0)
to
u0 = Constant(0.0)

and later

f = Function(V, "500.0 * exp(-(pow(x[0] - 0.5, 2) + pow(x[1] - 0.5, 2)) / 0.02)")
to
f = Expression("500.0 * exp(-(pow(x[0] - 0.5, 2) + pow(x[1] - 0.5, 2)) / 0.02)")

to get it to work. I just started with python and FEniCS, do you think the problem is with my installation?

Question information

Language:
English Edit question
Status:
Answered
For:
FEniCS Project Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Kristian B. Ølgaard (k.b.oelgaard) said :
#1

The problem is that the demo from http://www.fenics.org/wiki/Tutorial is outdated. What you did to fix it is correct.

Revision history for this message
Kristian B. Ølgaard (k.b.oelgaard) said :
#2

I've updated the demo with the correct syntax.

Can you help with this problem?

Provide an answer of your own, or ask Christine Tobler for more information if necessary.

To post a message you must log in.