The div
and grad
operators are ufl.operators
, and work on ufl objects. You are trying to use them inside a function that takes in numpy arrays (values and x), and therefore you see the error message.
I would suggest computing the div(grad(your_expression)) by hand, or use sympy to do it.
Please note that it is easier to do these things in DOLFINx, which is our new recommended software to use if you are just starting with DOLFINx,
see: The new DOLFINx solver is now recommended over DOLFIN
There I would create the expression with ufl:
from ufl import pow, exp, div, grad, as_vector
# Define mesh, V and u
# …
x = ufl.SpatialCoordinate(mesh)
v0 = exp(-(pow((x[0]-0.5),2)+pow((x[1]-0.5),2)))
v1 = 200*(exp(-(pow((x[0]-0.5),2)+pow((x[1]-0.5),2))))*(1-exp(-(pow((x[0]-0.5),2)+pow((x[1]-0.5),2))))*(1-2*exp(-(pow((x[0]-0.5),2)+pow((x[1]-0.5),2))))-lmbda*div(grad(exp(-(pow((x[0]-0.5),2)+pow((x[1]-0.5),2)))))
v = as_vector([v0,v1])
u_init = dolfinx.fem.Expression(v, V.element.interpolation_points)
u.interpolate(u_init)