When I run this simple example of constructing a function space
from dolfin import *
mesh = UnitSquareMesh(8, 8)
V = FunctionSpace(mesh, "Lagrange", 1)
I get the following error
Calling FFC just-in-time (JIT) compiler, this may take some time.
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
/usr/lib/python3/dist-packages/sympy/core/compatibility.py in as_int(n, strict)
418 if strict and not isinstance(n, SYMPY_INTS + (Integer,)):
--> 419 raise TypeError
420 result = int(n)
TypeError:
During handling of the above exception, another exception occurred:
ValueError Traceback (most recent call last)
<ipython-input-2-6e0119016ad8> in <module>
3 # Create mesh and define function space
4 mesh = UnitSquareMesh(8, 8)
----> 5 V = FunctionSpace(mesh, "Lagrange", 1)
/usr/lib/petsc/lib/python3/dist-packages/dolfin/function/functionspace.py in __init__(self, *args, **kwargs)
31 self._init_from_ufl(*args, **kwargs)
32 else:
---> 33 self._init_convenience(*args, **kwargs)
34
35 def _init_from_ufl(self, mesh, element, constrained_domain=None):
/usr/lib/petsc/lib/python3/dist-packages/dolfin/function/functionspace.py in _init_convenience(self, mesh, family, degree, form_degree, constrained_domain, restriction)
98 form_degree=form_degree)
99
--> 100 self._init_from_ufl(mesh, element, constrained_domain=constrained_domain)
101
102 def dolfin_element(self):
/usr/lib/petsc/lib/python3/dist-packages/dolfin/function/functionspace.py in _init_from_ufl(self, mesh, element, constrained_domain)
40
41 # Compile dofmap and element
---> 42 ufc_element, ufc_dofmap = ffc_jit(element, form_compiler_parameters=None,
43 mpi_comm=mesh.mpi_comm())
44 ufc_element = cpp.fem.make_ufc_finite_element(ufc_element)
/usr/lib/petsc/lib/python3/dist-packages/dolfin/jit/jit.py in mpi_jit(*args, **kwargs)
48 # Just call JIT compiler when running in serial
49 if MPI.size(mpi_comm) == 1:
---> 50 return local_jit(*args, **kwargs)
51
52 # Default status (0 == ok, 1 == fail)
/usr/lib/petsc/lib/python3/dist-packages/dolfin/jit/jit.py in ffc_jit(ufl_form, form_compiler_parameters)
98 p.update(dict(parameters["form_compiler"]))
99 p.update(form_compiler_parameters or {})
--> 100 return ffc.jit(ufl_form, parameters=p)
101
102
/usr/lib/python3/dist-packages/ffc/jitcompiler.py in jit(ufl_object, parameters, indirect)
215
216 # Inspect cache and generate+build if necessary
--> 217 module = jit_build(ufl_object, module_name, parameters)
218
219 # Raise exception on failure to build or import module
/usr/lib/python3/dist-packages/ffc/jitcompiler.py in jit_build(ufl_object, module_name, parameters)
128
129 # Carry out jit compilation, calling jit_generate only if needed
--> 130 module, signature = dijitso.jit(jitable=ufl_object,
131 name=module_name,
132 params=params,
/usr/lib/python3/dist-packages/dijitso/jit.py in jit(jitable, name, params, generate, send, receive, wait)
163 elif generate:
164 # 1) Generate source code
--> 165 header, source, dependencies = generate(jitable, name, signature, params["generator"])
166 # Ensure we got unicode from generate
167 header = as_unicode(header)
/usr/lib/python3/dist-packages/ffc/jitcompiler.py in jit_generate(ufl_object, module_name, signature, parameters)
63 compile_object = compile_coordinate_mapping
64
---> 65 code_h, code_c, dependent_ufl_objects = compile_object(ufl_object,
66 prefix=module_name, parameters=parameters, jit=True)
67
/usr/lib/python3/dist-packages/ffc/compiler.py in compile_element(elements, object_names, prefix, parameters, jit)
147 prefix="Element", parameters=None, jit=False):
148 """This function generates UFC code for a given UFL element or list of UFL elements."""
--> 149 return compile_ufl_objects(elements, "element", object_names,
150 prefix, parameters, jit)
151
/usr/lib/python3/dist-packages/ffc/compiler.py in compile_ufl_objects(ufl_objects, kind, object_names, prefix, parameters, jit)
188 # Stage 2: intermediate representation
189 cpu_time = time()
--> 190 ir = compute_ir(analysis, prefix, parameters, jit)
191 _print_timing(2, time() - cpu_time)
192
/usr/lib/python3/dist-packages/ffc/representation.py in compute_ir(analysis, prefix, parameters, jit)
165 # Compute representation of elements
166 info("Computing representation of %d elements" % len(elements))
--> 167 ir_elements = [_compute_element_ir(e, element_numbers, classnames, parameters, jit)
168 for e in elements]
169
/usr/lib/python3/dist-packages/ffc/representation.py in <listcomp>(.0)
165 # Compute representation of elements
166 info("Computing representation of %d elements" % len(elements))
--> 167 ir_elements = [_compute_element_ir(e, element_numbers, classnames, parameters, jit)
168 for e in elements]
169
/usr/lib/python3/dist-packages/ffc/representation.py in _compute_element_ir(ufl_element, element_numbers, classnames, parameters, jit)
198
199 # Create FIAT element
--> 200 fiat_element = create_element(ufl_element)
201 cell = ufl_element.cell()
202 cellname = cell.cellname()
/usr/lib/python3/dist-packages/ffc/fiatinterface.py in create_element(ufl_element)
98 # Create regular FIAT finite element
99 if isinstance(ufl_element, ufl.FiniteElement):
--> 100 element = _create_fiat_element(ufl_element)
101
102 # Create mixed element (implemented by FFC)
/usr/lib/python3/dist-packages/ffc/fiatinterface.py in _create_fiat_element(ufl_element)
196 element = ElementClass(fiat_cell)
197 else:
--> 198 element = ElementClass(fiat_cell, degree)
199
200 # Consistency check between UFL and FIAT elements.
/usr/lib/python3/dist-packages/FIAT/lagrange.py in __init__(self, ref_el, degree)
41
42 def __init__(self, ref_el, degree):
---> 43 poly_set = polynomial_set.ONPolynomialSet(ref_el, degree)
44 dual = LagrangeDualSet(ref_el, degree)
45 formdegree = 0 # 0-form
/usr/lib/python3/dist-packages/FIAT/polynomial_set.py in __init__(self, ref_el, degree, shape)
166 vinv = numpy.linalg.inv(v)
167
--> 168 dv = expansion_set.tabulate_derivatives(degree, pts)
169 dtildes = [[[a[1][i] for a in dvrow] for dvrow in dv]
170 for i in range(sd)]
/usr/lib/python3/dist-packages/FIAT/expansions.py in tabulate_derivatives(self, n, pts)
275 def tabulate_derivatives(self, n, pts):
276 order = 1
--> 277 data = _tabulate_dpts(self._tabulate, 2, n, order, numpy.array(pts))
278 # Put data in the required data structure, i.e.,
279 # k-tuples which contain the value, and the k-1 derivatives
/usr/lib/python3/dist-packages/FIAT/expansions.py in _tabulate_dpts(tabulator, D, n, order, pts)
72
73 # Tabulate symbolically
---> 74 symbolic_tab = tabulator(n, X)
75 # Make sure that the entries of symbolic_tab are lists so we can
76 # append derivatives
/usr/lib/python3/dist-packages/FIAT/expansions.py in _tabulate(self, n, pts)
243 y = ref_pts[1]
244
--> 245 f1 = (1.0 + 2 * x + y) / 2.0
246 f2 = (1.0 - y) / 2.0
247 f3 = f2**2
/usr/lib/python3/dist-packages/sympy/core/decorators.py in __sympifyit_wrapper(a, b)
89 if not hasattr(b, '_op_priority'):
90 b = sympify(b, strict=True)
---> 91 return func(a, b)
92 except SympifyError:
93 return retval
/usr/lib/python3/dist-packages/sympy/core/decorators.py in binary_op_wrapper(self, other)
127 if f is not None:
128 return f(self)
--> 129 return func(self, other)
130 return binary_op_wrapper
131 return priority_decorator
/usr/lib/python3/dist-packages/sympy/core/expr.py in __rmul__(self, other)
199 @call_highest_priority('__mul__')
200 def __rmul__(self, other):
--> 201 return Mul(other, self)
202
203 @_sympifyit('other', NotImplemented)
/usr/lib/python3/dist-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
92 def wrapper(*args, **kwargs):
93 try:
---> 94 retval = cfunc(*args, **kwargs)
95 except TypeError:
96 retval = func(*args, **kwargs)
/usr/lib/python3/dist-packages/sympy/core/operations.py in __new__(cls, *args, **options)
45 return args[0]
46
---> 47 c_part, nc_part, order_symbols = cls.flatten(args)
48 is_commutative = not nc_part
49 obj = cls._from_args(c_part + nc_part, is_commutative)
/usr/lib/python3/dist-packages/sympy/core/mul.py in flatten(cls, seq)
205 elif global_distribute[0] and b.is_commutative:
206 r, b = b.as_coeff_Add()
--> 207 bargs = [_keep_coeff(a, bi) for bi in Add.make_args(b)]
208 _addsort(bargs)
209 ar = a*r
/usr/lib/python3/dist-packages/sympy/core/mul.py in <listcomp>(.0)
205 elif global_distribute[0] and b.is_commutative:
206 r, b = b.as_coeff_Add()
--> 207 bargs = [_keep_coeff(a, bi) for bi in Add.make_args(b)]
208 _addsort(bargs)
209 ar = a*r
/usr/lib/python3/dist-packages/sympy/core/mul.py in _keep_coeff(coeff, factors, clear, sign)
1895 if margs[0].is_Number:
1896 margs[0] *= coeff
-> 1897 if margs[0] == 1:
1898 margs.pop(0)
1899 else:
/usr/lib/python3/dist-packages/sympy/core/numbers.py in __eq__(self, other)
1404 return self._mpf_ == other._mpf_
1405 if other.is_Rational:
-> 1406 return other.__eq__(self)
1407 if other.is_Number:
1408 # numbers should compare at the same precision;
/usr/lib/python3/dist-packages/sympy/core/numbers.py in __eq__(self, other)
2246 elif isinstance(other, Integer):
2247 return (self.p == other.p)
-> 2248 return Rational.__eq__(self, other)
2249
2250 def __ne__(self, other):
/usr/lib/python3/dist-packages/sympy/core/numbers.py in __eq__(self, other)
1904 # does m*2**t == self.p
1905 return self.p and not self.p % m and \
-> 1906 integer_log(self.p//m, 2) == (t, True)
1907 # does non-integer s*m/2**-t = p/q?
1908 if self.is_Integer:
/usr/lib/python3/dist-packages/sympy/core/power.py in integer_log(y, x)
145 if x in (-2, 2):
146 x = int(x)
--> 147 y = as_int(y)
148 e = y.bit_length() - 1
149 return e, x**e == y
/usr/lib/python3/dist-packages/sympy/core/compatibility.py in as_int(n, strict)
423 return result
424 except TypeError:
--> 425 raise ValueError('%s is not an integer' % (n,))
426
427
ValueError: 1 is not an integer
I am using Ubuntu with Python 3.8.5. I installed FEniCS as instructed on the FEniCS website:
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:fenics-packages/fenics
sudo apt-get update
sudo apt-get install --no-install-recommends fenics