emulsim.trackers module

Provides classes that track the state of the simulation.

TrajectoryTracker

Stores the state as a function of time during the simulation.

Trajectory

Reads trajectories of states written with TrajectoryTracker

DropletElementTracker

Stores information about droplets in a simulation.

FieldTracker

Wrapper to use py-pde trackers on fields.

class DropletElementTracker(element_name: str, interrupts: InterruptsBase | int | float | str | Sequence[float] | ndarray[Any, dtype[number]] = 1, *, store_emulsions: bool | str = True, store_droplet_tracks: bool | str = True, keep_vanished: bool = False)[source]

Bases: TrackerBase

Stores information about droplets in a simulation.

emulsions

An object describing the emulsion at the determined intervals

Type:

EmulsionTimeCourse

droplet_tracks

An object describing the time course of individual droplets.

Type:

DropletTrackList

The two attributes emulsions and droplet_tracks contain equivalent information, but their structure is different and either one might thus be used to analyze the simulation.

Parameters:
  • element_name (str) – The name of the element containing the droplets

  • interrupts – {ARG_TRACKER_INTERRUPTS}

  • store_emulsions (bool or str) – Determines whether to store data on emulsions in an instance of EmulsionTimeCourse. No data is stored when this is False. Otherwise, the data is available in the emulsions attributed of the tracker instance. The data is additionally written to a file when a path is supplied as a string.

  • store_droplet_tracks (bool or str) – Determines whether to store data on droplets in an instance of DropletTrackList. No data is stored when this is False. Otherwise, the data is available in the droplet_tracks attributed of the tracker instance. The data is additionally written to a file when a path is supplied as a string.

  • keep_vanished (bool) – Flag determining whether vanished droplets (with zero radius) are still stored. The default is to filter these droplets. Enable this flag if droplets disappearing and re-appearing should be combined in a single track.

finalize(info: dict[str, Any] | None = None) None[source]

Finalize the tracker, supplying additional information.

Parameters:

info (dict) – Extra information from the simulation

handle(state: State, t: float) None[source]

Handle data supplied to this tracker.

Parameters:
  • state (State) – The current state of the simulation

  • t (float) – The associated time

initialize(state: State, info: dict[str, Any] | None = None) float[source]
Parameters:
  • state (State) – The initial state of the simulation

  • info (dict) – Extra information for the simulation

class FieldTracker(element_name: str, tracker: TrackerBase)[source]

Bases: TrackerBase

Wrapper to use py-pde trackers on fields.

This acts as a wrapper around any of the trackers from pde.trackers, e.g., tracker = FieldTracker(‘background’, PlotTracker()).

Parameters:
  • element_name (str) – The name of the element of the field

  • tracker (TrackerBase) – The tracker that will receive the field

finalize(info: dict[str, Any] | None = None) None[source]

Finalize the tracker, supplying additional information.

Parameters:

info (dict) – Extra information from the simulation

handle(state: State, t: float) None[source]

Handle data supplied to this tracker.

Parameters:
  • state (State) – The current state of the simulation

  • t (float) – The associated time

initialize(state: State, info: dict[str, Any] | None = None) float[source]

Initialize the tracker with information about the simulation.

Parameters:
  • state (State) – An example of the data that will be analyzed by the tracker

  • info (dict) – Extra information from the simulation

Returns:

The first time the tracker needs to handle data

Return type:

float

class Trajectory(storage: StorageGroup, loc: None | str | Sequence[Location] = 'trajectory')[source]

Bases: Trajectory

Reads trajectories of states written with TrajectoryTracker

The class permits direct access to individual states using the square bracket notation. It is also possible to directly iterate over all states.

times

Time points at which data is available

Type:

ndarray

Parameters:
  • storage (MutableMapping or string) – Store or path to directory in file system or name of zip file.

  • loc (str or list of str) – The location in the storage where the trajectory data is read.

property info: dict[str, Any] | None

information that was stored with the trajectory

Type:

dict

class TrajectoryTracker(storage: None | str | Path | StorageGroup | StorageBase, interrupts: InterruptsBase | int | float | str | Sequence[float] | ndarray[Any, dtype[number]] = 1, *, mode: str | AccessMode | None = None, info: dict[str, Any] | None = None)[source]

Bases: TrackerBase

Stores the state as a function of time during the simulation.

Stored data can be read using Trajectory.

Parameters:
  • storage (MutableMapping or string) – Store or path to directory in file system

  • interrupts – {ARG_TRACKER_INTERRUPTS}

  • mode (str or AccessMode) – The file mode with which the storage is accessed. Determines allowed operations. The meaning of the special (default) value None depends on whether the file given by store already exists. If yes, a RuntimeError is raised, otherwise the choice corresponds to mode=”full” and thus creates a new trajectory. If the file exists, use mode=”truncate” to overwrite file or mode=”append” to insert new data into the file.

  • info (dict) – Additional information that are written to the trajectory storage. To document simulation parameters, simulation.info can be used here.

finalize(info: dict[str, Any] | None = None) None[source]

Finalize the tracker, supplying additional information.

Parameters:

info (dict) – Extra information from the simulation

handle(state: State, t: float) None[source]

Handle data supplied to this tracker.

Parameters:
  • state (State) – The current state of the simulation

  • t (float) – The associated time

initialize(state: State, info: dict[str, Any] | None = None) float[source]
Parameters:
  • state (State) – The initial state of the simulation

  • info (dict) – Extra information for the simulation