NameError: name 'interactive' is not defined

3 months ago by
Dear All,

I am beginner who firstly use Fenics. Now I cannot start any fenics simulation as I got the following error:
"NameError: name 'interactive' is not defined"

Test File: i.e.

from fenics import *

# Create mesh and define function space
mesh = UnitSquareMesh(8, 8)
V = FunctionSpace(mesh, 'P', 1)

# Define boundary condition
u_D = Expression('1 + x[0]*x[0] + 2*x[1]*x[1]', degree=2)

def boundary(x, on_boundary):
    return on_boundary

bc = DirichletBC(V, u_D, boundary)

# Define variational problem
u = TrialFunction(V)
v = TestFunction(V)
f = Constant(-6.0)
a = dot(grad(u), grad(v))*dx
L = f*v*dx

# Compute solution
u = Function(V)
solve(a == L, u, bc)

# Plot solution and mesh

# Save solution to file in VTK format
vtkfile = File('poisson/solution.pvd')
vtkfile << u

# Compute error in L2 norm
error_L2 = errornorm(u_D, u, 'L2')

# Compute maximum error at vertices
vertex_values_u_D = u_D.compute_vertex_values( mesh)
vertex_values_u = u.compute_vertex_values(mesh)
import numpy as np
error_max = np.max(np.abs(vertex_values_u_ D - vertex_values_u))

# Print errors
print('error_L2  =', error_L2)
print('error_max =', error_max)

# Hold plot

i have no idea how to solve this problem in fenics...

Community: FEniCS Project

1 Answer

3 months ago by
It's the code for the older version. I had the same problem before. According to my experience, just remove this line and it should work.
It is solved, thanks!
written 3 months ago by EQWEQ  
Please login to add an answer/comment or follow this question.

Similar posts:
Search »