Bulk-boundary coupling

Demonstrates coupling of bulk and boundary fields.

bulk boundary coupling
  0%|          | 0/100.0 [00:00<?, ?it/s]
Initializing:   0%|          | 0/100.0 [00:00<?, ?it/s]
  0%|          | 0/100.0 [00:09<?, ?it/s]
  0%|          | 0.1/100.0 [00:13<3:36:40, 130.14s/it]
  0%|          | 0.2/100.0 [00:13<1:48:13, 65.07s/it]
  0%|          | 0.3/100.0 [00:13<1:12:04, 43.38s/it]
 14%|█▎        | 13.7/100.0 [00:13<01:21,  1.05it/s]
 14%|█▎        | 13.7/100.0 [00:13<01:22,  1.05it/s]
100%|██████████| 100.0/100.0 [00:13<00:00,  7.68it/s]
100%|██████████| 100.0/100.0 [00:13<00:00,  7.68it/s]

import numpy as np

import pde

import emulsim

# set up a 2d cytosol with a 1d boundary membrane
grid = pde.UnitGrid([32, 8], periodic=[True, False])
cytosol = emulsim.ScalarFieldElement.from_field(pde.ScalarField(grid, 0.001))
membrane = emulsim.ScalarBoundaryFieldElement.from_bulk_grid(
    grid, axis=1, upper=True, data=np.random.uniform(-1, 1, 32)
)
state = emulsim.State({"cytosol": cytosol, "membrane": membrane})

# set up simulation of phase separation in membrane and diffusion in cytosol
simulation = emulsim.Simulation(state)
simulation.add_actor("cytosol", emulsim.DiffusionActor())
simulation.add_actor("membrane", emulsim.ScalarPDEActor(pde.CahnHilliardPDE()))
# couple both domains using an exchange flux
boundary_coupling = emulsim.FieldBoundaryExchangeActor(
    {"exchange_flux": "0.1 * (bulk - boundary)"}
)
simulation.add_actor(("cytosol", "membrane"), boundary_coupling)

# run the simulation
result = simulation.run(t_range=100)
result.plot(vmin=-0.2, vmax=0.2)

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