from fipy import CellVariable, Grid2D, DiffusionTerm
nx = 20 # grid size on coordinate axes
dx = 1 # grid spacing
ny = nx; dy = dx; L = dx*nx
mesh = Grid2D(dx=dx, dy=dy, nx=nx, ny=ny)
phi = CellVariable(name = "phi", mesh = mesh, value = 0.5)
eq = (0. == DiffusionTerm( coeff=1., var=phi))
valueTopLeft = 0.; valueBottomRight = 1.
phi.constrain(valueTopLeft, where = mesh.facesLeft)
phi.constrain(valueBottomRight, where = mesh.facesRight)
eq.solve(var=phi)
print (phi.value[:])
What's wrong with this code? Code produces zero solution, which is not correct.