I am trying to set up a model to solve the heat equation with temperature dependent terms.

It would look like this:

```
initial_T = Expression("Tini", Tini=298, degree=3) # initial temperature
T0 = interpolate(initial_T, Space)
T = Function(Space) # Temperature
V = TestFunction(Space) # Test Function
dT = TrialFunction(Space) # Temperature Derivative
q0 = Function(VectorSpace) # old heat flux
i = Index()
G = as_tensor(T.dx(i), (i)) #gradient of T
G0 = as_tensor(T0.dx(i), (i)) # old gradient of T
```

and the equations would be:

```
Laser = Expression('2*power_Q*(1-eta_s)*eta_l*exp(-pow((x[0] - (-Lx/2+2*r_b)-v_source*dt), 2)/(r_b*r_b)-pow((x[1]-0), 2)/(r_b*r_b))/3.1416/r_b/r_b', degree=3, power_Q=power_Q, eta_s=eta_s, eta_l=eta_l, r_b=r_b, Lx=Lx, Lz=Lz, v_source=source_vel, dt=t)
q = as_tensor(dtime/(dtime + tau_q) * (tau_q/dtime*q0[i] - kappa*(1+tau_T/dtime)*G[i] + kappa*tau_T/dtime*G0[i]),(i)) #heat
S= as_tensor(exp(-(((T-1100)/20)*((T-1100)/20)))/60000,(i)) #temperature dependent source
F = (rho*cp/dtime*(T-T0)*V-S[i]*V.dx(i) - q[i]*V.dx(i))* dv - rho*Laser*V*da(3)
Gain = derivative(F, T, dT) # Jacobian
```

where the dv and da are volume and area elements and the Neuman conditions are not included yet. The other parameters are model parameters.

The equations are solved as:

```
solve(F==0, T, bcs, J = Gain, solver_parameters={"newton_solver":{"linear_solver": "mumps", "relative_tolerance": 1e-3} })
q_tmp = project(q, VectorSpace)
q0.assign(q_tmp)
T0.assign(T)
```

However, I get 2 errors.

-The first one in the definition of S:

Traceback (most recent call last):

File “/scratch/snx3000/jfernnde/fenics/fenics-project/HeatFlowModel.py”, line 508, in

model.runModel()

File “/scratch/snx3000/jfernnde/fenics/fenics-project/HeatFlowModel.py”, line 452, in runModel

self._createModel(t)

File “/scratch/snx3000/jfernnde/fenics/fenics-project/HeatFlowModel.py”, line 269, in _createModel

self.S = as_tensor(exp(-(((self.T-1100)/20)*((self.T-1100)/20)))/60000,(self.i))

File “/users/jfernnde/bin/miniconda3/envs/fenics/lib/python3.9/site-packages/ufl/tensors.py”, line 272, in as_tensor

return ComponentTensor(expressions, indices)

File “/users/jfernnde/bin/miniconda3/envs/fenics/lib/python3.9/site-packages/ufl/tensors.py”, line 152, in **init**

fi, fid, sh = remove_indices(expression.ufl_free_indices,

File “/users/jfernnde/bin/miniconda3/envs/fenics/lib/python3.9/site-packages/ufl/index_combination_utils.py”, line 138, in remove_indices

assert None not in shape

AssertionError

-The second one, in the last 2 lines. It cannot assign the variable:

File “/scratch/snx3000/jfernnde/fenics/fenics-project/HeatFlowModel.py”, line 508, in

model.runModel()

File “/scratch/snx3000/jfernnde/fenics/fenics-project/HeatFlowModel.py”, line 483, in runModel

q_tmp = project(self.q, self.VectorSpace)

File “/users/jfernnde/bin/miniconda3/envs/fenics/lib/python3.9/site-packages/dolfin/fem/projection.py”, line 138, in project

cpp.la.solve(A, function.vector(), b, solver_type, preconditioner_type)

RuntimeError:

*** -------------------------------------------------------------------------

*** DOLFIN encountered an error. If you are not able to resolve this issue

*** using the information listed below, you can ask for help at

*** fenics-support@googlegroups.com

*** Remember to include the error message listed below and, if possible,

*** include a *minimal* running example to reproduce the error.

*** -------------------------------------------------------------------------

*** Error: Unable to successfully call PETSc function ‘KSPSolve’.

*** Reason: PETSc error code is: 76 (Error in external library).

*** Where: This error was encountered inside /home/conda/feedstock_root/build_artifacts/fenics-pkgs_1608660238187/work/dolfin/dolfin/la/PETScKrylovSolver.cpp.

*** Process: 0

*** DOLFIN version: 2019.1.0

*** Git changeset: 640ef70247ae212e16ae9f24fc9bc603b506f78a

Can anyone help?