import sys
sys.path.append("../..") # add the pde package to the python path
import pde
# initialize the grid, an initial condition, and the PDE
grid = pde.UnitGrid([32, 32])
field = pde.ScalarField.random_uniform(grid, -1, 1)
eq = pde.DiffusionPDE()
# try our explicit solver
solver = pde.ExplicitSolver(eq)
controller = pde.Controller(solver, t_range=1)
sol1 = controller.run(field, dt=1e-3);
# try the standard scipy solver
solver = pde.ScipySolver(eq)
controller = pde.Controller(solver, t_range=1)
sol2 = controller.run(field);
# plot both fields and give the deviation as the title
title = f"Mean squared deviation: {((sol1 - sol2) ** 2).average:.2g}"
pde.FieldCollection([sol1, sol2]).plot(title=title)