Multiple coupled PDEs

Demonstrates how multiple PDEs can be coupled.

pde collection
  0%|          | 0/20.0 [00:00<?, ?it/s]
Initializing:   0%|          | 0/20.0 [00:00<?, ?it/s]
  0%|          | 0/20.0 [00:01<?, ?it/s]
  0%|          | 0.008/20.0 [00:15<10:41:38, 1925.72s/it]
  0%|          | 0.01/20.0 [00:15<8:33:16, 1540.60s/it]
  1%|          | 0.235/20.0 [00:15<21:36, 65.58s/it]
 17%|█▋        | 3.414/20.0 [00:15<01:15,  4.53s/it]
 78%|███████▊  | 15.518/20.0 [00:15<00:04,  1.01s/it]
 78%|███████▊  | 15.518/20.0 [00:15<00:04,  1.02s/it]
100%|██████████| 20.0/20.0 [00:15<00:00,  1.26it/s]
100%|██████████| 20.0/20.0 [00:15<00:00,  1.26it/s]

from pde import PDE, FieldCollection, ScalarField, UnitGrid

import emulsim

# parameters
a, b = 1, 3
d0, d1 = 1, 0.1

# set up state
grid = UnitGrid([64, 64])
u = ScalarField(grid, a, label="Field $u$")
v = b / a + 0.1 * ScalarField.random_normal(grid, label="Field $v$")
field = FieldCollection([u, v])
element = emulsim.FieldCollectionElement.from_fields(field)
state = emulsim.State({"field": element})

# set up simulation
simulation = emulsim.Simulation(state)
eq = PDE(  # Brusselator equations
    {
        "u": f"{d0} * laplace(u) + {a} - ({b} + 1) * u + u**2 * v",
        "v": f"{d1} * laplace(v) + {b} * u - u**2 * v",
    }
)
simulation.add_actor("field", emulsim.CollectionPDEActor(eq))

# run simulation
result = simulation.run(t_range=20, dt=1e-3)

result.plot()

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