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:11<?, ?it/s]
0%| | 0.00316/10.0 [00:11<9:50:41, 3545.27s/it]
2%|▏ | 0.15606/10.0 [00:11<11:46, 71.79s/it]
86%|████████▋ | 8.625/10.0 [00:11<00:01, 1.30s/it]
86%|████████▋ | 8.625/10.0 [00:11<00:01, 1.30s/it]
100%|██████████| 10.0/10.0 [00:11<00:00, 1.12s/it]
100%|██████████| 10.0/10.0 [00:11<00:00, 1.12s/it]
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 11.302 seconds)