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:08<?, ?it/s]
0%| | 0.00334/10.0 [00:08<7:26:46, 2681.53s/it]
2%|▏ | 0.17025/10.0 [00:08<08:37, 52.61s/it]
2%|▏ | 0.17025/10.0 [00:08<08:37, 52.61s/it]
100%|██████████| 10.0/10.0 [00:08<00:00, 1.12it/s]
100%|██████████| 10.0/10.0 [00:08<00:00, 1.12it/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 9.019 seconds)