Cannot determine geometric dimension from expression

Hello everyone, I am doing the diffusion problem of stress and concentration displacement, the general governing equation is as follows:


My minimum working code is as follows:

from fenics import *

L = 1
D = 1

T = 1
num_steps = 100
dt = T/num_steps

mesh = IntervalMesh(100, 0, L)
V = FunctionSpace(mesh, “P”, 1)

v = TestFunction(V)
u = TrialFunction(V)
u_n = Function(V)

sigma = Expression(‘10*exp(pow(x[0]-c,2))’, c=0.5, degree=2)

F = v*((u - u_n)/dt)dx - Ddot(grad(v), grad(u))dx - udot(grad(v), grad(sigma))*dx
u = Function(V)
solve(lhs(F) == rhs(F), u)

for n in range(num_steps):

solve(lhs(F) == rhs(F), u)
u_n.assign(u)  
plot(u)

But running the calculation is wrong: it Cannot determine geometric dimension from expression.

Sorry, I don’t know what the problem is, the multiplication * in the variational formula F doesn’t show up, but it doesn’t seem to affect the reading.

Please format your code as

```python
# add code here
```

Also, please search the forum for your error message, as there are many similar posts, including: Error while trying to find the derivative of user-defined expression ["ufl.log.UFLException: Cannot determine geometric dimension from expression."] - #2 by kamensky
which I believe has the solution to your problem.