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:02<?, ?it/s]
  0%|          | 0.007/20.0 [00:17<13:50:57, 2493.76s/it]
  0%|          | 0.01/20.0 [00:17<9:41:35, 1745.67s/it]
  1%|          | 0.186/20.0 [00:17<31:00, 93.88s/it]
 14%|█▎        | 2.731/20.0 [00:17<01:50,  6.42s/it]
 62%|██████▏   | 12.467/20.0 [00:17<00:10,  1.43s/it]
 62%|██████▏   | 12.467/20.0 [00:17<00:10,  1.44s/it]
100%|██████████| 20.0/20.0 [00:17<00:00,  1.11it/s]
100%|██████████| 20.0/20.0 [00:18<00:00,  1.11it/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 18.130 seconds)