jorgensd / dolfinx-tutorial

A reimplementation of the Springer book: https://github.com/hplgit/fenics-tutorial/, covering new topics as well as transitioning from dolfin to dolfinx
https://jorgensd.github.io/dolfinx-tutorial/
110 stars 63 forks source link

Issue on page /chapter1/membrane_code.html #204

Closed bigsword2064 closed 2 months ago

bigsword2064 commented 2 months ago

Hi @jorgensd ,

When I try to run the code in https://jsdokken.com/dolfinx-tutorial/chapter1/membrane_code.html, the error jumps out saying 'ufl.algorithms.check_arities.ArityMismatch: Failure to conjugate test function in complex Form'. Do you come across the same issue here? By the way, I successfully ran the code for 'The Poisson problem with complex numbers'.

I am running this program on Ubuntu, with FEniCSx 0.8 installed. The detailed error is as follows:

Traceback (most recent call last): File "/home/jz482/programs/pythonProject1/membrane.py", line 48, in problem = LinearProblem(a, L, bcs=[bc], petsc_options={"ksp_type": "preonly", "pc_type": "lu"}) File "/home/jz482/anaconda3/envs/env3-10-complex/lib/python3.10/site-packages/dolfinx/fem/petsc.py", line 762, in init self._a = _create_form( File "/home/jz482/anaconda3/envs/env3-10-complex/lib/python3.10/site-packages/dolfinx/fem/forms.py", line 249, in form return _create_form(form) File "/home/jz482/anaconda3/envs/env3-10-complex/lib/python3.10/site-packages/dolfinx/fem/forms.py", line 244, in _create_form return _form(form) File "/home/jz482/anaconda3/envs/env3-10-complex/lib/python3.10/site-packages/dolfinx/fem/forms.py", line 186, in _form ufcx_form, module, code = jit.ffcx_jit( File "/home/jz482/anaconda3/envs/env3-10-complex/lib/python3.10/site-packages/dolfinx/jit.py", line 51, in mpi_jit return local_jit(*args, kwargs) File "/home/jz482/anaconda3/envs/env3-10-complex/lib/python3.10/site-packages/dolfinx/jit.py", line 201, in ffcx_jit r = ffcx.codegeneration.jit.compile_forms([ufl_object], options=p_ffcx, p_jit) File "/home/jz482/anaconda3/envs/env3-10-complex/lib/python3.10/site-packages/ffcx/codegeneration/jit.py", line 256, in compile_forms impl = _compile_objects( File "/home/jz482/anaconda3/envs/env3-10-complex/lib/python3.10/site-packages/ffcx/codegeneration/jit.py", line 383, in _compileobjects , code_body = ffcx.compiler.compile_ufl_objects( File "/home/jz482/anaconda3/envs/env3-10-complex/lib/python3.10/site-packages/ffcx/compiler.py", line 108, in compile_ufl_objects analysis = analyze_ufl_objects(ufl_objects, options["scalar_type"]) # type: ignore File "/home/jz482/anaconda3/envs/env3-10-complex/lib/python3.10/site-packages/ffcx/analysis.py", line 94, in analyze_ufl_objects form_data = tuple(_analyze_form(form, scalar_type) for form in forms) File "/home/jz482/anaconda3/envs/env3-10-complex/lib/python3.10/site-packages/ffcx/analysis.py", line 94, in form_data = tuple(_analyze_form(form, scalar_type) for form in forms) File "/home/jz482/anaconda3/envs/env3-10-complex/lib/python3.10/site-packages/ffcx/analysis.py", line 180, in _analyze_form form_data = ufl.algorithms.compute_form_data( File "/home/jz482/anaconda3/envs/env3-10-complex/lib/python3.10/site-packages/ufl/algorithms/compute_form_data.py", line 427, in compute_form_data check_form_arity(preprocessed_form, self.original_form.arguments(), complex_mode) File "/home/jz482/anaconda3/envs/env3-10-complex/lib/python3.10/site-packages/ufl/algorithms/check_arities.py", line 211, in check_form_arity check_integrand_arity(itg.integrand(), arguments, complex_mode) File "/home/jz482/anaconda3/envs/env3-10-complex/lib/python3.10/site-packages/ufl/algorithms/check_arities.py", line 203, in check_integrand_arity raise ArityMismatch("Failure to conjugate test function in complex Form") ufl.algorithms.check_arities.ArityMismatch: Failure to conjugate test function in complex Form Exception ignored in: <function LinearProblem.del at 0x7f3932b91990> Traceback (most recent call last): File "/home/jz482/anaconda3/envs/env3-10-complex/lib/python3.10/site-packages/dolfinx/fem/petsc.py", line 805, in del self._solver.destroy() AttributeError: 'LinearProblem' object has no attribute '_solver'

If this isn't a common issue, I’d really appreciate your advice on how to resolve it. Many thanks!

jorgensd commented 2 months ago

You are running DOLFINx with complex mode PETSc activated. Then some adjustments are needed, see https://jsdokken.com/dolfinx-tutorial/chapter1/complex_mode.html#inner-products-and-derivatives for details on what modifications that are needed

bigsword2064 commented 2 months ago

You are running DOLFINx with complex mode PETSc activated. Then some adjustments are needed, see https://jsdokken.com/dolfinx-tutorial/chapter1/complex_mode.html#inner-products-and-derivatives for details on what modifications that are needed

Thanks! Yes you are right, I solved it by simply switching to the real mode DOLFINx.