Hello,
My name is Athul Shaji, a researcher from India. I have the following problem while using FEniCS.
I had installed FEniCS in Ubuntu 18.04.1. The laptop has 8GB RAM and Core i3 7100 processor. I am getting error messages the demo codes provided the FEniCS webpage is run. The IDE used is Spyder. I am not using Anaconda package. The different packages like Spyder, Numpy, Scipy, and Matplotlib are installed using pip. I have installed FEniCS project 2018.1.0.
The code which I tried to run is as follows:
import matplotlib.pyplot as plt
from fenics import *
class DirichletBoundary(SubDomain):
def inside(self, x, on_boundary):
return abs(x[0] - 1.0) < DOLFIN_EPS and on_boundary
mesh = UnitSquareMesh(32, 32)
File("mesh.pvd") << mesh
V = FunctionSpace(mesh, "CG", 1)
g = Constant(1.0)
bc = DirichletBC(V, g, DirichletBoundary())
u = Function(V)
v = TestFunction(V)
f = Expression("x[0]*sin(x[1])", degree=2)
F = inner((1 + u**2)*grad(u), grad(v))*dx - f*v*dx
solve(F == 0, u, bc,
solver_parameters={"newton_solver":{"relative_tolerance":1e-6}})
plt.figure()
plot(u, title="Solution")
plt.figure()
plot(grad(u), title="Solution gradient")
plt.show()
file = File("nonlinear_poisson.pvd")
file << u
The error message obtained when I ran the program is as follows:
athul@athul-X510UA:~/Desktop$ python3 nonlinearpoisson.py
Calling FFC just-in-time (JIT) compiler, this may take some time.
Traceback (most recent call last):
File "nonlinearpoisson.py", line 134, in <module>
V = FunctionSpace(mesh, "CG", 1)
File "/usr/lib/python3/dist-packages/dolfin/function/functionspace.py", line 33, in __init__
self._init_convenience(*args, **kwargs)
File "/usr/lib/python3/dist-packages/dolfin/function/functionspace.py", line 100, in _init_convenience
self._init_from_ufl(mesh, element, constrained_domain=constrained_domain)
File "/usr/lib/python3/dist-packages/dolfin/function/functionspace.py", line 43, in _init_from_ufl
mpi_comm=mesh.mpi_comm())
File "/usr/lib/python3/dist-packages/dolfin/jit/jit.py", line 47, in mpi_jit
return local_jit(*args, **kwargs)
File "/usr/lib/python3/dist-packages/dolfin/jit/jit.py", line 97, in ffc_jit
return ffc.jit(ufl_form, parameters=p)
File "/usr/lib/python3/dist-packages/ffc/jitcompiler.py", line 217, in jit
module = jit_build(ufl_object, module_name, parameters)
File "/usr/lib/python3/dist-packages/ffc/jitcompiler.py", line 133, in jit_build
generate=jit_generate)
File "/usr/lib/python3/dist-packages/dijitso/jit.py", line 165, in jit
header, source, dependencies = generate(jitable, name, signature, params["generator"])
File "/usr/lib/python3/dist-packages/ffc/jitcompiler.py", line 66, in jit_generate
prefix=module_name, parameters=parameters, jit=True)
File "/usr/lib/python3/dist-packages/ffc/compiler.py", line 150, in compile_element
prefix, parameters, jit)
File "/usr/lib/python3/dist-packages/ffc/compiler.py", line 190, in compile_ufl_objects
ir = compute_ir(analysis, prefix, parameters, jit)
File "/usr/lib/python3/dist-packages/ffc/representation.py", line 168, in compute_ir
for e in elements]
File "/usr/lib/python3/dist-packages/ffc/representation.py", line 168, in <listcomp>
for e in elements]
File "/usr/lib/python3/dist-packages/ffc/representation.py", line 200, in _compute_element_ir
fiat_element = create_element(ufl_element)
File "/usr/lib/python3/dist-packages/ffc/fiatinterface.py", line 99, in create_element
element = _create_fiat_element(ufl_element)
File "/usr/lib/python3/dist-packages/ffc/fiatinterface.py", line 192, in _create_fiat_element
element = ElementClass(fiat_cell, degree)
File "/usr/lib/python3/dist-packages/FIAT/lagrange.py", line 54, in __init__
poly_set = polynomial_set.ONPolynomialSet(ref_el, degree)
File "/usr/lib/python3/dist-packages/FIAT/polynomial_set.py", line 174, in __init__
dv = expansion_set.tabulate_derivatives(degree, pts)
File "/usr/lib/python3/dist-packages/FIAT/expansions.py", line 260, in tabulate_derivatives
data = _tabulate_dpts(self._tabulate, 2, n, order, numpy.array(pts))
File "/usr/lib/python3/dist-packages/FIAT/expansions.py", line 102, in _tabulate_dpts
phi.append(form_derivative(phi[-1]))
File "/usr/lib/python3/dist-packages/FIAT/expansions.py", line 48, in form_derivative
out = [sympy.diff(F, X[j]) for j in range(D)]
File "/usr/lib/python3/dist-packages/FIAT/expansions.py", line 48, in <listcomp>
out = [sympy.diff(F, X[j]) for j in range(D)]
File "/home/athul/.local/lib/python3.6/site-packages/sympy/core/function.py", line 1979, in diff
return Derivative(f, *symbols, **kwargs)
File "/home/athul/.local/lib/python3.6/site-packages/sympy/core/function.py", line 1121, in __new__
it cannot be differentiated.''' % expr))
ValueError:
Since there are no variables in the expression [0, 0], it cannot be
differentiated.
Please help me with this error. Thank you.
Athul Shaji