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(interval: Union[ConstantIntervals, float, int, str] = 1)[source]¶
Bases:
object
base class for implementing trackers
- Parameters
interval – Determines how often the tracker interrupts the simulation. Simple numbers are interpreted as durations measured in the simulation time variable. Alternatively, a string using the format ‘hh:mm:ss’ can be used to give durations in real time. Finally, instances of the classes defined in
intervals
can be given for more control.
- finalize(info: Optional[Dict[str, Any]] = None) None [source]¶
finalize the tracker, supplying additional information
- Parameters
info (dict) – Extra information from the simulation
- classmethod from_data(data: Union[TrackerBase, str], **kwargs) TrackerBase [source]¶
create tracker class from given data
- Parameters
data (str or TrackerBase) – Data describing the tracker
- Returns
An instance representing the tracker
- Return type
- abstract handle(field: FieldBase, t: float) None [source]¶
handle data supplied to this tracker
- Parameters
field (
FieldBase
) – The current state of the simulationt (float) – The associated time
- class TrackerCollection(trackers: Optional[List[TrackerBase]] = None)[source]¶
Bases:
object
List of trackers providing methods to handle them efficiently
- Parameters
trackers – List of trackers that are to be handled.
- finalize(info: Optional[Dict[str, Any]] = None) None [source]¶
finalize the tracker, supplying additional information
- Parameters
info (dict) – Extra information from the simulation
- classmethod from_data(data: Optional[Union[Sequence[Union[TrackerBase, str]], TrackerBase, str]], **kwargs) TrackerCollection [source]¶
create tracker collection from given data
- Parameters
data – Data describing the tracker collection
- Returns
An instance representing the tracker collection
- Return type
- handle(state: FieldBase, t: float, atol: float = 1e-08) float [source]¶
handle all trackers
- Parameters
state (
FieldBase
) – The current state of the simulationt (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
- get_named_trackers() Dict[str, Type[TrackerBase]] [source]¶
returns all named trackers
- Returns
a mapping of names to the actual tracker classes.
- Return type