4.7.3. pde.trackers.interrupts module

Module defining classes for time interrupts for trackers

The provided interrupt classes are:

FixedInterrupts

class representing a list of interrupt times

ConstantInterrupts

class representing equidistantly spaced time interrupts

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

dt: float

current time difference between interrupts

Type

float

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.

Return type

float

class FixedInterrupts(interrupts)[source]

Bases: InterruptsBase

class representing a list of interrupt times

Parameters

interrupts (Union[ndarray, Sequence[float]]) –

copy()[source]

return a copy of this instance

dt: float

current time difference between interrupts

Type

float

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.

Return type

float

class InterruptsBase[source]

Bases: object

base class for implementing interrupts

abstract copy()[source]
dt: float

current time difference between interrupts

Type

float

abstract initialize(t)[source]
Parameters

t (float) –

Return type

float

abstract next(t)[source]
Parameters

t (float) –

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.

dt: float

current time difference between interrupts

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.

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.

dt: float

current time difference between interrupts

Type

float

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.

Return type

float

interval_to_interrupts(data)[source]

create interrupt class from various data formats specifying time intervals

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 time intervals

Return type

InterruptsBase