### FunctionSpace not working in Fenics 2018.1 Ubuntu (PPA)

157
views
5
10 days ago by
I just updated FEnicCS to 2018.1 on Ubuntu (using PPA).  I'm running Python 3.6.5.  Some elementary things seem to be broken that were working for me yesterday in 2017.2.  For instance, this very simple MWE:
from dolfin import *
mesh=UnitSquareMesh(8,8)
W = FunctionSpace(mesh, 'CG', 1)​
gives me the error message pasted below.  Is it just an issue of 2018.1 working out it's issues in a day or two?  If not, can anyone point me to the changes for 2018.1.  I cannot find anything for FunctionSpace.

      Calling FFC just-in-time (JIT) compiler, this may take some time.
Traceback (most recent call last):

File "<ipython-input-9-89cecb69e6b7>", line 1, in <module>
W = 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 "/home/kd/.local/lib/python3.6/site-packages/ffc/jitcompiler.py", line 217, in jit
module = jit_build(ufl_object, module_name, parameters)

File "/home/kd/.local/lib/python3.6/site-packages/ffc/jitcompiler.py", line 133, in jit_build
generate=jit_generate)

File "/home/kd/.local/lib/python3.6/site-packages/dijitso/jit.py", line 165, in jit
header, source, dependencies = generate(jitable, name, signature, params["generator"])

File "/home/kd/.local/lib/python3.6/site-packages/ffc/jitcompiler.py", line 66, in jit_generate
prefix=module_name, parameters=parameters, jit=True)

File "/home/kd/.local/lib/python3.6/site-packages/ffc/compiler.py", line 150, in compile_element
prefix, parameters, jit)

File "/home/kd/.local/lib/python3.6/site-packages/ffc/compiler.py", line 190, in compile_ufl_objects
ir = compute_ir(analysis, prefix, parameters, jit)

File "/home/kd/.local/lib/python3.6/site-packages/ffc/representation.py", line 168, in compute_ir
for e in elements]

File "/home/kd/.local/lib/python3.6/site-packages/ffc/representation.py", line 168, in <listcomp>
for e in elements]

File "/home/kd/.local/lib/python3.6/site-packages/ffc/representation.py", line 200, in _compute_element_ir
fiat_element = create_element(ufl_element)

File "/home/kd/.local/lib/python3.6/site-packages/ffc/fiatinterface.py", line 99, in create_element
element = _create_fiat_element(ufl_element)

File "/home/kd/.local/lib/python3.6/site-packages/ffc/fiatinterface.py", line 192, in _create_fiat_element
element = ElementClass(fiat_cell, degree)

File "/home/kd/.local/lib/python3.6/site-packages/FIAT/lagrange.py", line 54, in __init__
poly_set = polynomial_set.ONPolynomialSet(ref_el, degree)

File "/home/kd/.local/lib/python3.6/site-packages/FIAT/polynomial_set.py", line 174, in __init__
dv = expansion_set.tabulate_derivatives(degree, pts)

File "/home/kd/.local/lib/python3.6/site-packages/FIAT/expansions.py", line 260, in tabulate_derivatives
data = _tabulate_dpts(self._tabulate, 2, n, order, numpy.array(pts))

File "/home/kd/.local/lib/python3.6/site-packages/FIAT/expansions.py", line 102, in _tabulate_dpts
phi.append(form_derivative(phi[-1]))

File "/home/kd/.local/lib/python3.6/site-packages/FIAT/expansions.py", line 48, in form_derivative
out = [sympy.diff(F, X[j]) for j in range(D)]

File "/home/kd/.local/lib/python3.6/site-packages/FIAT/expansions.py", line 48, in <listcomp>
out = [sympy.diff(F, X[j]) for j in range(D)]

File "/home/kd/.local/lib/python3.6/site-packages/sympy/core/function.py", line 1993, in diff
return Derivative(f, *symbols, **kwargs)

File "/home/kd/.local/lib/python3.6/site-packages/sympy/core/function.py", line 1117, in __new__
it cannot be differentiated.''' % expr))

ValueError:
Since there are no variables in the expression [0, 0], it cannot be
differentiated.​
Community: FEniCS Project
1
It's likely something that needs to be fixed in the new PPA packages.

That error message looks like one we've seen elsewhere after sympy was upgraded to 1.2. The bug should have been fixed already so this may be a new one that needs to be fixed.
written 10 days ago by Drew Parsons
Yes, that's the error we got from FIAT with sympy 1.2.

Can you confirm your versions? dpkg -l python3-sympy python3-fiat

And check you have a patch applied: grep sympy.diff -C 1 /usr/lib/python3/dist-packages/FIAT/expansions.py
written 10 days ago by Drew Parsons

4
9 days ago by
Hi K.D., we noticed that your error message refers to /home/kd/.local/lib/python3.6.  That means you have a local user installation in place, you're not actually testing the PPA packages.  Please remove your local fenics installation.
Thanks Drew, this worked perfectly.  (I'm having other issues with my code -- changing Expression to UserExpression -- but I think there are already posts about that which may show me how to fix these).

PS.  Also I guess I started off my comment under the answer section, so I have no way to select your answer.  If you don't mind making a new answer, I can do that.
written 9 days ago by K D
Glad you've got it working. The UserExpression is easy to fix.  I've changed my comment to an answer.
written 9 days ago by Drew Parsons
0
10 days ago by

Thanks Drew.  I have pasted below the output though I have no idea what it all means and how to fix this issue (I ran apt update but nothing showed up).

A related question: would all these issue be avoided by using Docker?

kd@kd-ThinkPad-Edge-E430:~$dpkg -l python3-sympy python3-fiat Desired=Unknown/Install/Remove/Purge/Hold | Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend |/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad) ||/ Name Version Architecture Description +++-=============================-===================-===================-================================================================ ii python3-fiat 2018.1.0-5~ppa1~bio all tabulation of finite element function spaces (Python 3) ii python3-sympy 1.1.1-5 all Computer Algebra System (CAS) in Python (Python3) kd@kd-ThinkPad-Edge-E430:~$ grep sympy.diff -C 1 /usr/lib/python3/dist-packages/FIAT/expansions.py
try:
out = [sympy.diff(F, X[j]) for j in range(D)]
except (AttributeError, ValueError):

Still sympy 1.1 then. My guess is the sympy 1.2 patch breaks it.  I've updated fiat, please let me know if that fixes bionic FEniCS for you.

On Docker: sort of, yes.  Might introduce other complications.  The fiat update will be simpler if it works.
written 10 days ago by Drew Parsons
Hi Drew,
I ran apt update and it seemed to do something for FIAT, but unfortunately it doesn't fix the problem. Some possibly useful output below.

kd@kd-thinkpad-edge-e430:~$sudo apt upgrade Reading package lists... Done Building dependency tree  Reading state information... Done Calculating upgrade... Done The following packages will be upgraded:  python3-fiat 1 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. Need to get 54.0 kB of archives. After this operation, 0 B of additional disk space will be used. Do you want to continue? [Y/n] y Get:1 http://ppa.launchpad.net/fenics-packages/fenics/ubuntu bionic/main amd64 python3-fiat all 2018.1.0-5~ppa1~bionic2 [54.0 kB] Fetched 54.0 kB in 1s (106 kB/s)  (Reading database ... 225073 files and directories currently installed.) Preparing to unpack .../python3-fiat_2018.1.0-5~ppa1~bionic2_all.deb ... Unpacking python3-fiat (2018.1.0-5~ppa1~bionic2) over (2018.1.0-5~ppa1~bionic1) ... Setting up python3-fiat (2018.1.0-5~ppa1~bionic2) ... kd@kd-thinkpad-edge-e430:~$ dpkg -l python3-sympy python3-fiat
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-=============================-===================-===================-================================================================
ii python3-fiat 2018.1.0-5~ppa1~bio all tabulation of finite element function spaces (Python 3)
ii python3-sympy 1.1.1-5 all Computer Algebra System (CAS) in Python (Python3)

kd@kd-thinkpad-edge-e430:~$grep sympy.diff -C 1 /usr/lib/python3/dist-packages/FIAT/expansions.py  try:  out = [sympy.diff(F, X[j]) for j in range(D)]  except AttributeError: ​ written 9 days ago by K D Thanks K.D. Actually, dpkg -l chops the end of the version, so use "dpkg -l python3-sympy python3-fiat | cat" to double check the version. But if the update didn't help anyway then we'll need to dig deeper into the code. written 9 days ago by Drew Parsons 0 4 days ago by EDIT: Should've been a comment. I'm having the same problem with FEniCS 2018.1 after a fresh Arch Linux update. I have Python 3.7.0 and Sympy 1.2. From the shell: $ echo "element = FiniteElement('CG', tetrahedron, 1)" > test.ufl && ffc test.ufl
Traceback (most recent call last):
File "/usr/bin/ffc", line 11, in <module>
File "/usr/lib/python3.7/site-packages/ffc/main.py", line 215, in main
resultcode = _compile_files(args, parameters, enable_profile)
File "/usr/lib/python3.7/site-packages/ffc/main.py", line 254, in _compile_files
code_h, code_c = compile_ufl_data(ufd, prefix, parameters)
File "/usr/lib/python3.7/site-packages/ffc/main.py", line 100, in compile_ufl_data
parameters=parameters)
File "/usr/lib/python3.7/site-packages/ffc/compiler.py", line 150, in compile_element
prefix, parameters, jit)
File "/usr/lib/python3.7/site-packages/ffc/compiler.py", line 190, in compile_ufl_objects
ir = compute_ir(analysis, prefix, parameters, jit)
File "/usr/lib/python3.7/site-packages/ffc/representation.py", line 168, in compute_ir
for e in elements]
File "/usr/lib/python3.7/site-packages/ffc/representation.py", line 168, in <listcomp>
for e in elements]
File "/usr/lib/python3.7/site-packages/ffc/representation.py", line 200, in _compute_element_ir
fiat_element = create_element(ufl_element)
File "/usr/lib/python3.7/site-packages/ffc/fiatinterface.py", line 99, in create_element
element = _create_fiat_element(ufl_element)
File "/usr/lib/python3.7/site-packages/ffc/fiatinterface.py", line 192, in _create_fiat_element
element = ElementClass(fiat_cell, degree)
File "/usr/lib/python3.7/site-packages/FIAT/lagrange.py", line 54, in __init__
poly_set = polynomial_set.ONPolynomialSet(ref_el, degree)
File "/usr/lib/python3.7/site-packages/FIAT/polynomial_set.py", line 174, in __init__
dv = expansion_set.tabulate_derivatives(degree, pts)
File "/usr/lib/python3.7/site-packages/FIAT/expansions.py", line 373, in tabulate_derivatives
data = _tabulate_dpts(self._tabulate, D, n, order, numpy.array(pts))
File "/usr/lib/python3.7/site-packages/FIAT/expansions.py", line 102, in _tabulate_dpts
phi.append(form_derivative(phi[-1]))
File "/usr/lib/python3.7/site-packages/FIAT/expansions.py", line 48, in form_derivative
out = [sympy.diff(F, X[j]) for j in range(D)]
File "/usr/lib/python3.7/site-packages/FIAT/expansions.py", line 48, in <listcomp>
out = [sympy.diff(F, X[j]) for j in range(D)]
File "/usr/lib/python3.7/site-packages/sympy/core/function.py", line 1993, in diff
return Derivative(f, *symbols, **kwargs)
File "/usr/lib/python3.7/site-packages/sympy/core/function.py", line 1117, in __new__
it cannot be differentiated.''' % expr))
ValueError:
Since there are no variables in the expression [0, 0, 0], it cannot be
differentiated.
​
I had this exact version of FEniCS until yesterday - using the same install files - so it must be something else that's changed. Maybe the Python version? Maybe the Sympy version? I also tried installing FEniCS in an Anaconda environment (conda install -c conda-forge fenics), thinking that it should take care of using the right versions (it uses Python 3.6.6 and Sympy 1.2). The strange thing is that I get the same error there:

\$ echo "element = FiniteElement('CG', tetrahedron, 1)" > test.ufl && ffc test.ufl
Traceback (most recent call last):
File "/home/sigvald/.conda/envs/fenics/bin/ffc", line 11, in <module>
File "/home/sigvald/.conda/envs/fenics/lib/python3.6/site-packages/ffc/main.py", line 215, in main
resultcode = _compile_files(args, parameters, enable_profile)
File "/home/sigvald/.conda/envs/fenics/lib/python3.6/site-packages/ffc/main.py", line 254, in _compile_files
code_h, code_c = compile_ufl_data(ufd, prefix, parameters)
File "/home/sigvald/.conda/envs/fenics/lib/python3.6/site-packages/ffc/main.py", line 100, in compile_ufl_data
parameters=parameters)
File "/home/sigvald/.conda/envs/fenics/lib/python3.6/site-packages/ffc/compiler.py", line 150, in compile_element
prefix, parameters, jit)
File "/home/sigvald/.conda/envs/fenics/lib/python3.6/site-packages/ffc/compiler.py", line 190, in compile_ufl_objects
ir = compute_ir(analysis, prefix, parameters, jit)
File "/home/sigvald/.conda/envs/fenics/lib/python3.6/site-packages/ffc/representation.py", line 168, in compute_ir
for e in elements]
File "/home/sigvald/.conda/envs/fenics/lib/python3.6/site-packages/ffc/representation.py", line 168, in <listcomp>
for e in elements]
File "/home/sigvald/.conda/envs/fenics/lib/python3.6/site-packages/ffc/representation.py", line 200, in _compute_element_ir
fiat_element = create_element(ufl_element)
File "/home/sigvald/.conda/envs/fenics/lib/python3.6/site-packages/ffc/fiatinterface.py", line 99, in create_element
element = _create_fiat_element(ufl_element)
File "/home/sigvald/.conda/envs/fenics/lib/python3.6/site-packages/ffc/fiatinterface.py", line 192, in _create_fiat_element
element = ElementClass(fiat_cell, degree)
File "/home/sigvald/.conda/envs/fenics/lib/python3.6/site-packages/FIAT/lagrange.py", line 54, in __init__
poly_set = polynomial_set.ONPolynomialSet(ref_el, degree)
File "/home/sigvald/.conda/envs/fenics/lib/python3.6/site-packages/FIAT/polynomial_set.py", line 174, in __init__
dv = expansion_set.tabulate_derivatives(degree, pts)
File "/home/sigvald/.conda/envs/fenics/lib/python3.6/site-packages/FIAT/expansions.py", line 373, in tabulate_derivatives
data = _tabulate_dpts(self._tabulate, D, n, order, numpy.array(pts))
File "/home/sigvald/.conda/envs/fenics/lib/python3.6/site-packages/FIAT/expansions.py", line 102, in _tabulate_dpts
phi.append(form_derivative(phi[-1]))
File "/home/sigvald/.conda/envs/fenics/lib/python3.6/site-packages/FIAT/expansions.py", line 48, in form_derivative
out = [sympy.diff(F, X[j]) for j in range(D)]
File "/home/sigvald/.conda/envs/fenics/lib/python3.6/site-packages/FIAT/expansions.py", line 48, in <listcomp>
out = [sympy.diff(F, X[j]) for j in range(D)]
File "/home/sigvald/.conda/envs/fenics/lib/python3.6/site-packages/sympy/core/function.py", line 1993, in diff
return Derivative(f, *symbols, **kwargs)
File "/home/sigvald/.conda/envs/fenics/lib/python3.6/site-packages/sympy/core/function.py", line 1117, in __new__
it cannot be differentiated.''' % expr))
ValueError:
Since there are no variables in the expression [0, 0, 0], it cannot be
differentiated.
​

Any ideas?
1
I also tested the official Docker container, and it works. For Anaconda, eventhough it shipped with Sympy 1.2, I had to downgrade to Sympy 1.1.1 (conda install sympy=1.1.1). I will try to do the same on my system-wide Arch Linux install. Regarding the patch mentioned, I'm running FEniCS 2018.1. Are you sure the patch has been included in FEniCS 2018.1?
written 4 days ago by Sigvald Marholm
You're right Sigvald, the sympy patch was not in the upstream FIAT 2018.1.0 release.  In the Debian/Ubuntu version I applied the patch (Debian has a simple mechanism for managing patches) which is why the version from the PPA works.  If you're compiling for yourself from the upstream source, you might want to apply the patch manually.

https://bitbucket.org/fenics-project/fiat/commits/8ceb29a3b9b14668b9d387321a3f8f4126f9a159
written 3 days ago by Drew Parsons
0
6 hours ago by
I experienced this problem as well. I am a brand new user to FEniCS and the tutorials do not work. The error message is one from scipy--and is unhelpful.

My solution was to downgrade from scipy 1.2 to 1.1.1. I am running

• Ubuntu bionic 64 (DISTRIB_DESCRIPTION="Ubuntu 18.04 LTS")
• FEniCS 2018.1.0
• spicy 1.1.1
• Python 3.6.5

I think this answer/solution needs to be promoted. I searched long and hard to find this. Please figure out a way to let novice users know that they must downgrade scipy.

Moreover, searching this community board is only available to registered users. That is unusual and, I think, a poor decision that discourages new users. I had to join this community just to run the tutorial, which I was doing to see if this package is for me. I was very close to giving up on FEniCS and going elsewhere.