Delay

class pathsim.blocks.delay.Delay(tau=0.001, sampling_period=None)[source]

Bases: Block

Delays the input signal by a time constant ‘tau’ in seconds.

Supports two modes of operation:

Continuous mode (default, sampling_period=None): Uses an adaptive interpolating buffer for continuous-time delay.

\[\begin{split}y(t) = \begin{cases} x(t - \tau) & , t \geq \tau \\ 0 & , t < \tau \end{cases}\end{split}\]

Discrete mode (sampling_period provided): Uses a ring buffer with scheduled sampling events for N-sample delay, where N = round(tau / sampling_period).

\[y[k] = x[k - N]\]

Note

In continuous mode, the internal adaptive buffer uses interpolation for the evaluation. This is required to be compatible with variable step solvers. It has a drawback however. The order of the ode solver used will degrade when this block is used, due to the interpolation.

Note

This block supports vector input, meaning we can have multiple parallel delay paths through this block.

Example

Continuous-time delay:

#5 time units delay
D = Delay(tau=5)

Discrete-time N-sample delay (10 samples):

D = Delay(tau=0.01, sampling_period=0.001)
Parameters:
  • tau (float) – delay time constant in seconds

  • sampling_period (float, None) – sampling period for discrete mode, default is continuous mode

_buffer

internal interpolatable adaptive rolling buffer (continuous mode)

Type:

AdaptiveBuffer

_ring

internal ring buffer for N-sample delay (discrete mode)

Type:

deque

property tau
property sampling_period
reset()[source]

Reset the blocks inputs and outputs and also its internal solver, if the block has a solver instance.

to_checkpoint(prefix, recordings=False)[source]

Serialize Delay state including buffer data.

load_checkpoint(prefix, json_data, npz)[source]

Restore Delay state including buffer data.

update(t)[source]

Evaluation of the buffer at different times via interpolation (continuous) or ring buffer lookup (discrete).

Parameters:

t (float) – evaluation time

sample(t, dt)[source]

Sample input values and time of sampling and add them to the buffer.

Parameters:
  • t (float) – evaluation time for sampling

  • dt (float) – integration timestep

set(**kwargs)

Set multiple parameters and reinitialize once.

Parameters:

kwargs (dict) – parameter names and their new values

Example

block.set(K=5.0, T=0.3)