Derivatives in 1D

Hi everyone,

I do have a problem with how to write a 1D derivative in fenics. I am a fenics newbie and thus wanted to solve an easy 1D linear elastic problem, but I get an UFLValueError in my variational formulation. I thought I had seen this usage of grad in the 1D case a few times, so I am wondering why it doesnt work for me. I installed fenics on ubuntu using the ppa fenics packages. I left out boundary conditions etc in the code since the error appears just using the code i copied.

I would like to solve the variational problem:

\int{ E(x)\frac{du}{dx}\frac{dv}{dx}}{dx} = \int{fv}{dx}

This code:

from fenics import *
mesh = UnitIntervalMesh(5)
V = FunctionSpace(mesh, 'P', 1)
u = TrialFunction(V)
v = TestFunctions(V)
E = Constant(1.0)
a = E*dot(grad(u), grad(v))*dx

gives me the error:

a = E*dot(grad(u), grad(v))*dx
  File "/usr/lib/python3/dist-packages/ufl/operators.py", line 369, in grad
    f = as_ufl(f)
  File "/usr/lib/python3/dist-packages/ufl/constantvalue.py", line 437, in as_ufl
    raise UFLValueError("Invalid type conversion: %s can not be converted"
ufl.log.UFLValueError: Invalid type conversion: (Argument(FunctionSpace(Mesh(VectorElement(FiniteElement('Lagrange', interval, 1), dim=1), 0), FiniteElement('Lagrange', interval, 1)), 0, None),) can not be converted to any UFL type.

The problem here is using TestFunctions (note the s at the end) with a scalar-valued FunctionSpace.

Okay, I never spotted that during the last two hours of error search :confused: thanks a lot