.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples_gallery/droplets_trackers.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_trackers.py: Trackers in active droplet simulations ====================================== This example shows how to analyze droplet trajectories. Note that the simulation requires the optional `numba-scipy` package! .. GENERATED FROM PYTHON SOURCE LINES 9-45 .. 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_trackers.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 import numpy as np 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(position=grid.get_random_point(), radius=np.random.uniform(0.1, 4)) 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 tracker = emulsim.DropletElementTracker("droplets", interrupts=10) simulation.run(t_range=1e3, tracker=tracker) # show droplet tracks tracker.droplet_tracks.plot() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.002 seconds) .. _sphx_glr_download_examples_gallery_droplets_trackers.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: droplets_trackers.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: droplets_trackers.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: droplets_trackers.zip `