2.11. Setting boundary conditions

This example shows how different boundary conditions can be specified.

boundary conditions

Out:

  0%|          | 0/10.0 [00:00<?, ?it/s]
Initializing:   0%|          | 0/10.0 [00:00<?, ?it/s]
  0%|          | 0/10.0 [00:07<?, ?it/s]
  0%|          | 0.005/10.0 [00:08<4:31:22, 1629.02s/it]
  0%|          | 0.01/10.0 [00:09<2:31:46, 911.52s/it]
  0%|          | 0.015/10.0 [00:09<1:41:07, 607.70s/it]
  2%|2         | 0.25/10.0 [00:09<05:55, 36.46s/it]
  2%|2         | 0.25/10.0 [00:09<05:56, 36.52s/it]
100%|##########| 10.0/10.0 [00:09<00:00,  1.10it/s]
100%|##########| 10.0/10.0 [00:09<00:00,  1.10it/s]

from pde import DiffusionPDE, ScalarField, UnitGrid

grid = UnitGrid([32, 32], periodic=[False, True])  # generate grid
state = ScalarField.random_uniform(grid, 0.2, 0.3)  # generate initial condition

# set boundary conditions `bc` for all axes
bc_x_left = {"derivative": 0.1}
bc_x_right = {"value": "sin(y / 2)"}
bc_x = [bc_x_left, bc_x_right]
bc_y = "periodic"
eq = DiffusionPDE(bc=[bc_x, bc_y])

result = eq.solve(state, t_range=10, dt=0.005)
result.plot()

Total running time of the script: ( 0 minutes 9.269 seconds)

Gallery generated by Sphinx-Gallery