4.7.3 pde.trackers.interrupts module
Module defining classes for time interrupts for trackers.
The provided interrupt classes are:
Interrupts equidistantly spaced in time. |
|
Interrupts at fixed, predetermined times. |
|
Interrupts with successively increased spacing. |
|
Interrupts from the geometric sequence \(t_i = \Delta t f^i\) |
|
Interrupts spaced equidistantly in real time. |
|
Create interrupt class from various data formats. |
- class ConstantInterrupts(dt=1, t_start=None)[source]
Bases:
InterruptsBaseInterrupts equidistantly spaced in time.
- Parameters:
dt (float) – The duration between subsequent interrupts. This is measured in simulation time units.
t_start (float, optional) – The time after which the tracker becomes active. If omitted, the tracker starts recording right away. This argument can be used for an initial equilibration period during which no data is recorded.
- class FixedInterrupts(interrupts)[source]
Bases:
InterruptsBaseInterrupts at fixed, predetermined times.
- Parameters:
interrupts (np.ndarray | Sequence[float])
- class GeometricInterrupts(scale, factor)[source]
Bases:
InterruptsBaseInterrupts from the geometric sequence \(t_i = \Delta t f^i\)
In contrast to
LogarithmicInterrupts, this class ensures that time points lie on the geometric sequence given above. However, data points might be skipped if the simulations progress too quickly.
- class InterruptsBase[source]
Bases:
objectBase class for implementing interrupts.
- class LogarithmicInterrupts(dt_initial=1, factor=1, t_start=None)[source]
Bases:
ConstantInterruptsInterrupts with successively increased spacing.
The durations between interrupts increases by a constant factor \(f\):
\[t_{i+1} = t_i + \Delta t_i \qquad \text{with} \qquad \Delta t_{i+1} = f \Delta t_i\]starting with initial values \(t_0\) and \(\Delta t_0\). This results in exponentially spaced interrupts \(t_i = a + b f^i\), where \(a = t_0 - \Delta t_0 (f - 1)^{-1}\) and \(b = \Delta t_0 (f - 1)^{-1}\).
Note that the geometric sequence described above can be disrupted if other interrupts interfere. This class ensures ever increasing durations between its interrupts, at the cost of potentially oddly spaced times. If a geometric sequence is required, use
GeometricInterruptsinstead.- Parameters:
dt_initial (float) – The initial duration \(\Delta t_0\) between subsequent interrupts. This is measured in simulation time units.
factor (float) – The factor \(f\) by which the time between interrupts is increased after every interrupt. Values larger than one lead to time interrupts that are increasingly further apart.
t_start (float, optional) – The time \(t_0\) after which the tracker becomes active. If omitted, the tracker starts recording right away. This argument can be used for an initial equilibration period during which no data is recorded.
- class RealtimeInterrupts(duration, dt_initial=0.01)[source]
Bases:
ConstantInterruptsInterrupts spaced equidistantly in real time.
This spacing is only achieved approximately and depends on the initial value set by dt_initial and the actual variation in computation speed.
- Parameters:
duration (float or str) – The duration (in real seconds) that the interrupts should be spaced apart. The duration can also be given as a string, which is then parsed using the function
parse_duration().dt_initial (float) – The initial duration between subsequent interrupts. This is measured in simulation time units.
- parse_interrupt(data)[source]
Create interrupt class from various data formats.
- Parameters:
data (str or number or
InterruptsBase) – Data determining the interrupt class. If this is aInterruptsBase, it is simply returned, numbers implyConstantInterrupts, a string is generally parsed as a time forRealtimeInterrupts, and lists are interpreted asFixedInterrupts. Instance ofGeometricInterruptscan be constructed with the special string"geometric(SCALE, FACTOR)", specifying the scale and factor values directly as numbers.- Returns:
An instance that represents the interrupt
- Return type: