Note
Go to the end to download the full example code.
2.2.3 Simple diffusion equation
This example solves a simple diffusion equation in two dimensions.

0%| | 0/10.0 [00:00<?, ?it/s]
Initializing: 0%| | 0/10.0 [00:00<?, ?it/s]
0%| | 0/10.0 [00:03<?, ?it/s]
0%| | 0.006/10.0 [00:03<1:40:42, 604.57s/it]
3%|▎ | 0.296/10.0 [00:03<01:59, 12.27s/it]
47%|████▋ | 4.707/10.0 [00:03<00:04, 1.27it/s]
47%|████▋ | 4.707/10.0 [00:03<00:04, 1.25it/s]
100%|██████████| 10.0/10.0 [00:03<00:00, 2.65it/s]
100%|██████████| 10.0/10.0 [00:03<00:00, 2.65it/s]
from pde import DiffusionPDE, ScalarField, UnitGrid
grid = UnitGrid([64, 64]) # generate grid
state = ScalarField.random_uniform(grid, 0.2, 0.3) # generate initial condition
eq = DiffusionPDE(diffusivity=0.1) # define the pde
result = eq.solve(state, t_range=10)
result.plot()
Total running time of the script: (0 minutes 3.851 seconds)