4.7.3 pde.trackers.interrupts module

Module defining classes for time interrupts for trackers.

The provided interrupt classes are:

ConstantInterrupts

Class representing equidistantly spaced time interrupts.

FixedInterrupts

Class representing a list of interrupt times.

LogarithmicInterrupts

Class representing logarithmically spaced time interrupts.

RealtimeInterrupts

Class representing time interrupts spaced equidistantly in real time.

class ConstantInterrupts(dt=1, t_start=None)[source]

Bases: InterruptsBase

Class representing equidistantly spaced time interrupts.

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.

copy()[source]

Return a copy of this instance.

initialize(t)[source]

Initialize the interrupt class.

Parameters:

t (float) – The starting time of the simulation

Returns:

The first time the simulation needs to be interrupted

Return type:

float

next(t)[source]

Computes the next time point.

Parameters:

t (float) – The current time point of the simulation. The returned next time point lies later than this time, so interrupts might be skipped.

Returns:

The next time point

Return type:

float

class FixedInterrupts(interrupts)[source]

Bases: InterruptsBase

Class representing a list of interrupt times.

Parameters:

interrupts (np.ndarray | Sequence[float])

copy()[source]

Return a copy of this instance.

initialize(t)[source]

Initialize the interrupt class.

Parameters:

t (float) – The starting time of the simulation

Returns:

The first time the simulation needs to be interrupted

Return type:

float

next(t)[source]

Computes the next time point.

Parameters:

t (float) – The current time point of the simulation. The returned next time point lies later than this time, so interrupts might be skipped.

Returns:

The next time point

Return type:

float

class InterruptsBase[source]

Bases: object

Base class for implementing interrupts.

abstract copy()[source]

Return a copy of this instance.

Parameters:

self (TInterrupt)

Return type:

TInterrupt

dt: float

current time difference between interrupts

Type:

float

abstract initialize(t)[source]

Initialize the interrupt class.

Parameters:

t (float) – The starting time of the simulation

Returns:

The first time the simulation needs to be interrupted

Return type:

float

abstract next(t)[source]

Computes the next time point.

Parameters:

t (float) – The current time point of the simulation. The returned next time point lies later than this time, so interrupts might be skipped.

Returns:

The next time point

Return type:

float

class LogarithmicInterrupts(dt_initial=1, factor=1, t_start=None)[source]

Bases: ConstantInterrupts

Class representing logarithmically spaced time interrupts.

Parameters:
  • dt_initial (float) – The initial duration between subsequent interrupts. This is measured in simulation time units.

  • factor (float) – The factor by which the time between interrupts is increased every time. Values larger than one lead to time interrupts that are increasingly further apart.

  • 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.

next(t)[source]

Computes the next time point.

Parameters:

t (float) – The current time point of the simulation. The returned next time point lies later than this time, so interrupts might be skipped.

Returns:

The next time point

Return type:

float

class RealtimeInterrupts(duration, dt_initial=0.01)[source]

Bases: ConstantInterrupts

Class representing time interrupts 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.

initialize(t)[source]

Initialize the interrupt class.

Parameters:

t (float) – The starting time of the simulation

Returns:

The first time the simulation needs to be interrupted

Return type:

float

next(t)[source]

Computes the next time point.

Parameters:

t (float) – The current time point of the simulation. The returned next time point lies later than this time, so interrupts might be skipped.

Returns:

The next time point

Return type:

float

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 a InterruptsBase, it is simply returned, numbers imply ConstantInterrupts, a string is parsed as a time for RealtimeInterrupts, and lists are interpreted as FixedInterrupts.

Returns:

An instance that represents the interrupt

Return type:

InterruptsBase