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:09<?, ?it/s]
0%| | 0.00316/10.0 [00:09<8:46:44, 3161.46s/it]
2%|▏ | 0.16998/10.0 [00:09<09:37, 58.77s/it]
2%|▏ | 0.16998/10.0 [00:09<09:37, 58.78s/it]
100%|██████████| 10.0/10.0 [00:09<00:00, 1.00it/s]
100%|██████████| 10.0/10.0 [00:09<00:00, 1.00it/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 10.061 seconds)