deepmodeling / jax-fem

Differentiable Finite Element Method with JAX
GNU General Public License v3.0
290 stars 45 forks source link

module 'basix' has no attribute 'ElementFamily' #44

Closed akarsai closed 2 hours ago

akarsai commented 2 hours ago

hello,

i ran pip install jax-fem and then tried to run the example code provided in the readme. i encountered multiple "module not found" errors, which is why i installed every unfound module using pip, namely

pip install pyfiglet
pip install meshio
pip install gmsh
pip install basix
pip install petsc4py

now, there is no "module not found" error anymore, but i get the error

[11-19 10:28:46][DEBUG] jax_fem: Computing shape function values, gradients, etc.
Traceback (most recent call last):
  File "/Users/username/Desktop/jax_fem_test.py", line 59, in <module>
    problem = Poisson(mesh=mesh, vec=1, dim=2, ele_type=ele_type, dirichlet_bc_info=dirichlet_bc_info)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<string>", line 11, in __init__
  File "/Users/username/.pyenv/versions/jax/lib/python3.11/site-packages/jax_fem/problem.py", line 37, in __post_init__
    self.fes = [FiniteElement(mesh=self.mesh[i], 
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/username/.pyenv/versions/jax/lib/python3.11/site-packages/jax_fem/problem.py", line 37, in <listcomp>
    self.fes = [FiniteElement(mesh=self.mesh[i], 
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<string>", line 10, in __init__
  File "/Users/username/.pyenv/versions/jax/lib/python3.11/site-packages/jax_fem/fe.py", line 72, in __post_init__
    self.shape_vals, self.shape_grads_ref, self.quad_weights = get_shape_vals_and_grads(self.ele_type, self.gauss_order)
                                                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/username/.pyenv/versions/jax/lib/python3.11/site-packages/jax_fem/basis.py", line 116, in get_shape_vals_and_grads
    element_family, basix_ele, basix_face_ele, gauss_order_default, degree, re_order = get_elements(ele_type)
                                                                                       ^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/username/.pyenv/versions/jax/lib/python3.11/site-packages/jax_fem/basis.py", line 30, in get_elements
    element_family = basix.ElementFamily.P
                     ^^^^^^^^^^^^^^^^^^^
AttributeError: module 'basix' has no attribute 'ElementFamily'
akarsai commented 2 hours ago

i found my mistake:

the correct way to install basix is

pip install fenics-basix