4.7.1 pde.trackers.base module

Base classes for trackers

exception FinishedSimulation[source]

Bases: StopIteration

exception for signaling that simulation finished successfully

class TrackerBase(interrupts=1, *, interval=None)[source]

Bases: object

base class for implementing trackers

Parameters:

interrupts (InterruptData) – Determines when the tracker interrupts the simulation. A single numbers determines an interval (measured in the simulation time unit) of regular interruption. A string is interpreted as a duration in real time assuming the format ‘hh:mm:ss’. A list of numbers is taken as explicit simulation time points. More fine- grained contol is possible by passing an instance of classes defined in interrupts.

finalize(info=None)[source]

finalize the tracker, supplying additional information

Parameters:

info (dict) – Extra information from the simulation

Return type:

None

classmethod from_data(data, **kwargs)[source]

create tracker class from given data

Parameters:

data (str or TrackerBase) – Data describing the tracker

Returns:

An instance representing the tracker

Return type:

TrackerBase

abstract handle(field, t)[source]

handle data supplied to this tracker

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

  • t (float) – The associated time

Return type:

None

initialize(field, info=None)[source]

initialize the tracker with information about the simulation

Parameters:
  • field (FieldBase) – 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 TrackerCollection(trackers=None)[source]

Bases: object

List of trackers providing methods to handle them efficiently

trackers

List of the trackers in the collection

Type:

list

Parameters:

trackers (list[TrackerBase] | None) – List of trackers that are to be handled.

finalize(info=None)[source]

finalize the tracker, supplying additional information

Parameters:

info (dict) – Extra information from the simulation

Return type:

None

classmethod from_data(data, **kwargs)[source]

create tracker collection from given data

Parameters:

data (Sequence[TrackerBase | str] | TrackerBase | str | None) – Data describing the tracker collection

Returns:

An instance representing the tracker collection

Return type:

TrackerCollection

handle(state, t, atol=1e-08)[source]

handle all trackers

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

  • t (float) – The associated time

  • atol (float) – An absolute tolerance that is used to determine whether a tracker should be called now or whether the simulation should be carried on more timesteps. This is basically used to predict the next time to decided which one is closer.

Returns:

The next time the simulation needs to be interrupted to handle a tracker.

Return type:

float

initialize(field, info=None)[source]

initialize the tracker with information about the simulation

Parameters:
  • field (FieldBase) – 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

time_next_action: float

The time of the next interrupt of the simulation

Type:

float

tracker_action_times: list[float]

Times at which the trackers need to be handled next

Type:

list

get_named_trackers()[source]

returns all named trackers

Returns:

a mapping of names to the actual tracker classes.

Return type:

dict