Solving Laplace equation on a surface of 3D sphere

Hi there,

I would like to solve the Laplace equation on the surface of the sphere. But I am a bit lost and would like to consult your expertise.

From an internet search, I met this.

Below is my script:

sphere = Sphere(Point(0.0, 0.0, 0.0), 1.0)
vmesh = generate_mesh(sphere, 20)
mesh = BoundaryMesh(vmesh, “exterior”)
plot(mesh)

V = FunctionSpace(mesh, “CG”, 1)
u = TrialFunction(V)
v = TestFunction(V)
w = Function(V)

r = Expression(“x[0]”, degree=1)
phi = Expression(“x[1]”, degree=1)
theta = Expression(“x[2]”, degree=1)

f = Constant(0.0)
a = (Dx(u,0)Dx(v,0) + (Constant(1.)/r)**2Dx(u,1)Dx(v,1) + Constant(1.)/(rsin(phi))**2*Dx(u,2)*Dx(v,2))*dx
L = inner(f,v)*dx
solve(a == L, w)

With the above code I get the following error message at the weak formulation:
“TypeError: Expression.float returned non-float (type NotImplementedType)”

Additionally, I need to define some points from the sphere surface as a Dirichlet boundary condition, i.e. ask the diffusion PDE not to change them. Is there any suggestion to tackle this in Fenics?

Thank you in advance!