4.8.1 pde.trackers.base module
Base classes for trackers.
Base class for implementing trackers. |
|
List of trackers providing methods to handle them efficiently. |
|
Tracker that allows modifying incoming data. |
|
Exception for signaling that simulation finished successfully. |
- exception FinishedSimulation[source]
Bases:
StopIterationException for signaling that simulation finished successfully.
- add_note()
Exception.add_note(note) – add a note to the exception
- args
- value
generator return value
- with_traceback()
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- class TrackerBase(interrupts: InterruptsBase | int | float | str | Sequence[float] | ndarray[Any, dtype[number]] = 1)[source]
Bases:
objectBase class for implementing trackers.
- Parameters:
interrupts – 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 values is taken as explicit simulation time points. More fine- grained control is possible by passing an instance of classes defined in
interrupts.
- finalize(info: dict[str, Any] | None = None) None[source]
Finalize the tracker, supplying additional information.
- Parameters:
info (dict) – Extra information from the simulation
- classmethod from_data(data: TrackerBase | str, **kwargs) TrackerBase[source]
Create tracker class from given data.
- Parameters:
data (str or TrackerBase) – Data describing the tracker
**kwargs – Additional keyword arguments passed to the tracker constructor
- Returns:
An instance representing the tracker
- Return type:
- abstractmethod 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: list[TrackerBase] | None = None)[source]
Bases:
objectList of trackers providing methods to handle them efficiently.
- Parameters:
trackers – List of trackers that are to be handled.
- finalize(info: dict[str, Any] | None = None) None[source]
Finalize the tracker, supplying additional information.
- Parameters:
info (dict) – Extra information from the simulation
- classmethod from_data(data: Sequence[TrackerBase | str] | TrackerBase | str | None, **kwargs) TrackerCollection[source]
Create tracker collection from given data.
- Parameters:
data – Data describing the tracker collection
**kwargs – Additional keyword arguments passed to tracker constructors
- 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:
- class TransformedTrackerBase(interrupts: InterruptsBase | int | float | str | Sequence[float] | ndarray[Any, dtype[number]] = 1, *, transformation: Callable[[FieldBase, float], FieldBase] | None = None)[source]
Bases:
TrackerBaseTracker that allows modifying incoming data.
To support the transformations sub-classes need to call
self._transform(field, t)to obtain the transformed field.- Parameters:
interrupts – 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 values is taken as explicit simulation time points. More fine- grained control is possible by passing an instance of classes defined in
interrupts.transformation (callable, optional) – A function that transforms the current state into a new field or field collection, which is then used in the tracker. This allows to process derived quantities of the field during calculations. The argument needs to be a callable function taking 1 or 2 arguments. The first argument always is the current field, while the optional second argument is the associated time.
- finalize(info: dict[str, Any] | None = None) None
Finalize the tracker, supplying additional information.
- Parameters:
info (dict) – Extra information from the simulation
- classmethod from_data(data: TrackerBase | str, **kwargs) TrackerBase
Create tracker class from given data.
- Parameters:
data (str or TrackerBase) – Data describing the tracker
**kwargs – Additional keyword arguments passed to the tracker constructor
- Returns:
An instance representing the tracker
- Return type:
- abstractmethod handle(field: FieldBase, t: float) None
Handle data supplied to this tracker.
- Parameters:
field (
FieldBase) – The current state of the simulationt (float) – The associated time