# Error in implementing 2D time dependent heat equation

Hi dear Fenicsx users,

I am trying to implement the 2D time dependent heat equation of this tutorial https://jsdokken.com/dolfinx-tutorial/chapter2/heat_code.html.

However the following error occurs when I create the matrix and vector for the linear problem.
I am using DOLFINx version: 0.7.2.

Here is the code:

#We start by defining the temporal discretization parameters, along with the parameters

from petsc4py import PETSc
from mpi4py import MPI
import ufl
from dolfinx import mesh, fem
from dolfinx.fem.petsc import assemble_matrix, assemble_vector, apply_lifting, create_vector, set_bc
import numpy
t = 0  # Start time
T = 2  # End time
num_steps = 20  # Number of time steps
dt = (T - t) / num_steps  # Time step size
alpha = 3
beta = 1.2

#As for the previous problem, we define the mesh and appropriate function spaces.

nx, ny = 5, 5
domain = mesh.create_unit_square(MPI.COMM_WORLD, nx, ny, mesh.CellType.triangle)
V = fem.FunctionSpace(domain, ("Lagrange", 1))

#As in the membrane problem, we create a Python-class to resemble the exact solution

class exact_solution():
def __init__(self, alpha, beta, t):
self.alpha = alpha
self.beta = beta
self.t = t

def __call__(self, x):
return 1 + x[0]**2 + self.alpha * x[1]**2 + self.beta * self.t

u_exact = exact_solution(alpha, beta, t)

#As in the previous chapters, we define a Dirichlet boundary condition over the whole boundary

u_D = fem.Function(V)
u_D.interpolate(u_exact)
tdim = domain.topology.dim
fdim = tdim - 1
domain.topology.create_connectivity(fdim, tdim)
boundary_facets = mesh.exterior_facet_indices(domain.topology)
bc = fem.dirichletbc(u_D, fem.locate_dofs_topological(V, fdim, boundary_facets))

u_n = fem.Function(V)
u_n.interpolate(u_exact)

f = fem.Constant(domain, beta - 2 - 2 * alpha)

u, v = ufl.TrialFunction(V), ufl.TestFunction(V)
F = u * v * ufl.dx + dt * ufl.dot(ufl.grad(u), ufl.grad(v)) * ufl.dx - (u_n + dt * f) * v * ufl.dx

a = fem.form(ufl.lhs(F))
L = fem.form(ufl.rhs(F))

A = assemble_matrix(a, bcs=[bc])
A.assemble()
b = create_vector(L)
uh = fem.Function(V)

The error is :

x86_64-conda-linux-gnu-cc: error: unrecognized command-line option '-march'
Traceback (most recent call last):
File "/home/mamadou/anaconda3/envs/fenicsx/lib/python3.12/site-packages/setuptools/_distutils/unixccompiler.py", line 185, in _compile
self.spawn(compiler_so + cc_args + [src, '-o', obj] + extra_postargs)
File "/home/mamadou/anaconda3/envs/fenicsx/lib/python3.12/site-packages/setuptools/_distutils/ccompiler.py", line 1041, in spawn
spawn(cmd, dry_run=self.dry_run, **kwargs)
File "/home/mamadou/anaconda3/envs/fenicsx/lib/python3.12/site-packages/setuptools/_distutils/spawn.py", line 70, in spawn
raise DistutilsExecError(
distutils.errors.DistutilsExecError: command '/home/mamadou/anaconda3/envs/fenicsx/bin/x86_64-conda-linux-gnu-cc' failed with exit code 1

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/mamadou/anaconda3/envs/fenicsx/lib/python3.12/site-packages/cffi/ffiplatform.py", line 48, in _build
dist.run_command('build_ext')
File "/home/mamadou/anaconda3/envs/fenicsx/lib/python3.12/site-packages/setuptools/dist.py", line 989, in run_command
super().run_command(command)
File "/home/mamadou/anaconda3/envs/fenicsx/lib/python3.12/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
cmd_obj.run()
File "/home/mamadou/anaconda3/envs/fenicsx/lib/python3.12/site-packages/setuptools/command/build_ext.py", line 88, in run
_build_ext.run(self)
File "/home/mamadou/anaconda3/envs/fenicsx/lib/python3.12/site-packages/setuptools/_distutils/command/build_ext.py", line 345, in run
self.build_extensions()
File "/home/mamadou/anaconda3/envs/fenicsx/lib/python3.12/site-packages/setuptools/_distutils/command/build_ext.py", line 467, in build_extensions
self._build_extensions_serial()
File "/home/mamadou/anaconda3/envs/fenicsx/lib/python3.12/site-packages/setuptools/_distutils/command/build_ext.py", line 493, in _build_extensions_serial
self.build_extension(ext)
File "/home/mamadou/anaconda3/envs/fenicsx/lib/python3.12/site-packages/setuptools/command/build_ext.py", line 249, in build_extension
_build_ext.build_extension(self, ext)
File "/home/mamadou/anaconda3/envs/fenicsx/lib/python3.12/site-packages/setuptools/_distutils/command/build_ext.py", line 548, in build_extension
objects = self.compiler.compile(
^^^^^^^^^^^^^^^^^^^^^^
File "/home/mamadou/anaconda3/envs/fenicsx/lib/python3.12/site-packages/setuptools/_distutils/ccompiler.py", line 600, in compile
self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts)
File "/home/mamadou/anaconda3/envs/fenicsx/lib/python3.12/site-packages/setuptools/_distutils/unixccompiler.py", line 187, in _compile
raise CompileError(msg)
distutils.errors.CompileError: command '/home/mamadou/anaconda3/envs/fenicsx/bin/x86_64-conda-linux-gnu-cc' failed with exit code 1

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
a = fem.form(ufl.lhs(F))
^^^^^^^^^^^^^^^^^^^^
File "/home/mamadou/anaconda3/envs/fenicsx/lib/python3.12/site-packages/dolfinx/fem/forms.py", line 188, in form
return _create_form(form)
^^^^^^^^^^^^^^^^^^
File "/home/mamadou/anaconda3/envs/fenicsx/lib/python3.12/site-packages/dolfinx/fem/forms.py", line 183, in _create_form
return _form(form)
^^^^^^^^^^^
File "/home/mamadou/anaconda3/envs/fenicsx/lib/python3.12/site-packages/dolfinx/fem/forms.py", line 141, in _form
ufcx_form, module, code = jit.ffcx_jit(mesh.comm, form,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/mamadou/anaconda3/envs/fenicsx/lib/python3.12/site-packages/dolfinx/jit.py", line 56, in mpi_jit
return local_jit(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/mamadou/anaconda3/envs/fenicsx/lib/python3.12/site-packages/dolfinx/jit.py", line 204, in ffcx_jit
r = ffcx.codegeneration.jit.compile_forms([ufl_object], options=p_ffcx, **p_jit)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/mamadou/anaconda3/envs/fenicsx/lib/python3.12/site-packages/ffcx/codegeneration/jit.py", line 199, in compile_forms
raise e
File "/home/mamadou/anaconda3/envs/fenicsx/lib/python3.12/site-packages/ffcx/codegeneration/jit.py", line 190, in compile_forms
impl = _compile_objects(decl, forms, form_names, module_name, p, cache_dir,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/mamadou/anaconda3/envs/fenicsx/lib/python3.12/site-packages/ffcx/codegeneration/jit.py", line 284, in _compile_objects
ffibuilder.compile(tmpdir=cache_dir, verbose=True, debug=cffi_debug)
File "/home/mamadou/anaconda3/envs/fenicsx/lib/python3.12/site-packages/cffi/api.py", line 725, in compile
return recompile(self, module_name, source, tmpdir=tmpdir,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/mamadou/anaconda3/envs/fenicsx/lib/python3.12/site-packages/cffi/recompiler.py", line 1564, in recompile
outputfilename = ffiplatform.compile('.', ext,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/mamadou/anaconda3/envs/fenicsx/lib/python3.12/site-packages/cffi/ffiplatform.py", line 20, in compile
outputfilename = _build(tmpdir, ext, compiler_verbose, debug)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/mamadou/anaconda3/envs/fenicsx/lib/python3.12/site-packages/cffi/ffiplatform.py", line 54, in _build
raise VerificationError('%s: %s' % (e.__class__.__name__, e))
cffi.VerificationError: CompileError: command '/home/mamadou/anaconda3/envs/fenicsx/bin/x86_64-conda-linux-gnu-cc' failed with exit code 1

Hi.

I cannot reproduce your error in DOLFINx v0.7.2, nor DOLFINx v0.7.3. Both tested in conda and Docker environments. Please check mixed Python environments (I saw that you have (fenicsx) (base) in your terminal).

It’s odd that it doesn’t give a URL to the compiler’s log. Maybe it can’t find your C compiler? If you do \$ which mpicc do you see what you’d expect?

@ottarhellan at Simula also experienced this today. Maybe @minrk has an idea?

Thank you Jesus for your suggestions. I have chosen (fenicsx) (base) (fenicsx) (base) in my terminal because it is the recommended environment.