from dolfin import*
mesh = UnitSquareMesh(30,30)
V = FunctionSpace(mesh, "CG", 1)
def boundary(x):
return x[0] < DOLFIN_EPS or x[0] > 1.0 - DOLFIN_EPS
u0=Constant(0.0)
bc = DirichletBC(V,u0,boundary)
u=TrialFunction(V)
v=TestFunction(V)
f = Expression("10*exp(-pow(x[0]-0.5,2) + pow(x[1] - 0.5, 2))/0.02)", degree=2)
g= Expression("sin(5*x[0])", degree=2)
a = dot(grad(u), grad(v))*dx
L = f*v*dx + g*v*ds
u=function(V)
solve(a==L,u,bc)
file = File("poisson1.pvd")
file <<u
You have too few left brackets. Here you have 3x( but 4x)