.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples_gallery/droplets_active.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_examples_gallery_droplets_active.py: Simulation of active droplets in 2D =================================== This example shows how to simulate droplets with a simple linear reaction. Note that the simulation requires the optional `numba-scipy` package! .. GENERATED FROM PYTHON SOURCE LINES 9-39 .. rst-class:: sphx-glr-script-out .. code-block:: pytb Traceback (most recent call last): File "/home/docs/checkouts/readthedocs.org/user_builds/emulsim/checkouts/latest/examples/droplets_active.py", line 10, in import numba_scipy # raises an error if the module is not available ^^^^^^^^^^^^^^^^^^ ModuleNotFoundError: No module named 'numba_scipy' | .. code-block:: Python import numba_scipy # raises an error if the module is not available from droplets import SphericalDroplet from pde import ScalarField, UnitGrid import emulsim # set up state grid = UnitGrid([32, 32], periodic=True) background = emulsim.ScalarFieldElement.from_field(ScalarField(grid, 0.005)) droplet_data = [SphericalDroplet(grid.get_random_point(), 0.1) for _ in range(10)] droplets = emulsim.SphericalDropletsElement.from_droplets(droplet_data) state = emulsim.State({"background": background, "droplets": droplets}) # set up simulation reaction_flux = "0.001 - 0.01 * c" simulation = emulsim.Simulation(state) simulation.add_actor( "background", emulsim.ReactionDiffusionActor({"reaction_flux": reaction_flux}) ) droplet_actor = emulsim.SphericalDropletActor( {"mean_reaction_inside": -0.01, "reaction_outside": reaction_flux} ) simulation.add_actor(("droplets", "background"), droplet_actor) # run simulation result = simulation.run(t_range=10) result.plot() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.002 seconds) .. _sphx_glr_download_examples_gallery_droplets_active.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: droplets_active.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: droplets_active.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: droplets_active.zip `