Unable to define linear variational problem

Hi, this is the error:

*** Error:   Unable to define linear variational problem a(u, v) = L(v) for all v.
*** Reason:  Expecting the right-hand side to be a linear form (not rank 2).
*** Where:   This error was encountered inside LinearVariationalProblem.cpp.
*** Process: 0

here is my code:

from dolfin import *

import matplotlib.pyplot as plt

# Mesh

mesh = UnitSquareMesh(32, 32)

# Finite Element

V = FunctionSpace(mesh, 'Lagrange', 1)

# Boundary

def boundary(x):

return x[0] < DOLFIN_EPS or x[0] > 1.0 - DOLFIN_EPS

# Condition

u10 = Constant(2.0)

bc = DirichletBC(V, u10, boundary)

#Problem

mixed1 = Constant(0.1)

dif1 = Constant(0.1)

u1 = TrialFunction(V)

v1 = TestFunction(V)

a = dif1*dot(grad(u1), grad(v1))*dx

f = mixed1*u1

L = f*v1*dx

# Solution

u = Function(V)

solve(a == L, u, bc)

# Save solution in VTK format

file = File("project1_minimized1.pvd")

file << u

# Plot solution

plot(u)

plt.show()

I read similar topics, and I guess my problem somehow related to f = mixed1*u1 (because when f = mixed1 there is no error).

How can I fix it?

You cannot have a TrialFunction on the right hand side.
What you can do is to move the term to the LHS, and add a zero term on the RHS

a = dif1*dot(grad(u1), grad(v1))*dx - f*v1*dx
L = Constant(0)*v1*dx 

Good that I learned that, thanks!