Discrete-Time

class pathsim.blocks.discrete.SampleHold(T=1.0, tau=0.0)[source]

Bases: Block

Zero-order hold: samples the input periodically and holds it at the output.

\[y(t) = u(k T + \tau), \quad k T + \tau \leq t < (k+1) T + \tau\]

Note

Supports vector input — each channel is sampled independently.

Parameters:
  • T (float) – sampling period

  • tau (float) – delay before first sample

events

internal scheduled event for periodic sampling

Type:

list[Schedule]

property T
property tau
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)
pathsim.blocks.discrete.ZeroOrderHold

alias of SampleHold

class pathsim.blocks.discrete.FirstOrderHold(T=1.0, tau=0.0)[source]

Bases: Block

First-order hold reconstructor.

Reconstructs a continuous signal from periodic samples using linear extrapolation across one sampling interval. Causal (one-sample-lag) variant matching the Simulink First-Order Hold block.

Between two consecutive sample times \(t_{k-1}\) and \(t_k\), the output is

\[y(t) = u_{k-1} + \frac{u_{k-1} - u_{k-2}}{T} (t - t_{k-1})\]

During the very first interval (only one sample captured) the output is held at the most recent sample.

Note

Supports vector input — each channel is extrapolated independently.

Parameters:
  • T (float) – sampling period

  • tau (float) – delay before first sample

events

internal scheduled event for periodic sampling

Type:

list[Schedule]

property T
property tau
reset()[source]

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

update(t)[source]

The ‘update’ method is called iteratively for all blocks to evaluate the algebraic components of the global system ode from the DAG.

It is meant for instant time blocks (blocks that dont have a delay due to the timestep, such as Amplifier, etc.) and updates the ‘outputs’ of the block directly based on the ‘inputs’ and possibly internal states.

Note

The implementation of the ‘update’ method in the base ‘Block’ class is intended as a fallback and is not performance optimized. Special blocks might reimplement this method differently for higher performance, for example SISO or MISO blocks.

Parameters:

t (float) – evaluation time

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)
class pathsim.blocks.discrete.FIR(coeffs=[1.0], T=1.0, tau=0.0)[source]

Bases: Block

Discrete-time Finite-Impulse-Response (FIR) filter.

Applies an FIR filter to a periodically sampled input signal.

\[y[n] = b_0 x[n] + b_1 x[n-1] + \dots + b_N x[n-N]\]

where b are the filter coefficients and N is the filter order (number of coefficients minus one). The output is held constant between sample times.

Note

Supports vector input — the same coefficients are applied to each channel in parallel.

Parameters:
  • coeffs (array_like) – FIR filter coefficients [b0, b1, ..., bN]

  • T (float) – sampling period

  • tau (float) – delay before first sample

events

internal scheduled event for periodic filter evaluation

Type:

list[Schedule]

property coeffs
property T
property tau
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 FIR state including input buffer.

load_checkpoint(prefix, json_data, npz)[source]

Restore FIR state including input buffer.

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)
class pathsim.blocks.discrete.DiscreteIntegrator(T=1.0, tau=0.0, initial_value=0.0)[source]

Bases: Block

Discrete-time integrator (forward Euler).

\[y[k+1] = y[k] + T \, u[k]\]

The output at sample k is the accumulated sum of past inputs; the current input u[k] only enters the next sample.

Note

Supports vector input — each channel is integrated independently. Pass an array as initial_value to set per-channel initial values.

Parameters:
  • T (float) – sampling period

  • tau (float) – delay before first sample

  • initial_value (float, array_like) – initial integrator output y[0]

events

internal scheduled event for periodic update

Type:

list[Schedule]

property T
property tau
property initial_value
reset()[source]

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

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)
class pathsim.blocks.discrete.DiscreteDerivative(T=1.0, tau=0.0)[source]

Bases: Block

Discrete-time backward-difference derivative.

\[y[k] = \frac{u[k] - u[k-1]}{T}\]

Note

Supports vector input — each channel is differentiated independently.

Parameters:
  • T (float) – sampling period

  • tau (float) – delay before first sample

events

internal scheduled event for periodic update

Type:

list[Schedule]

property T
property tau
reset()[source]

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

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)
class pathsim.blocks.discrete.DiscreteStateSpace(A=0.0, B=1.0, C=1.0, D=0.0, T=1.0, tau=0.0, initial_value=None)[source]

Bases: Block

Discrete-time MIMO state space block.

\[\begin{split}\begin{align} x[k+1] &= \mathbf{A}\, x[k] + \mathbf{B}\, u[k] \\ y[k] &= \mathbf{C}\, x[k] + \mathbf{D}\, u[k] \end{align}\end{split}\]

Note

The output port reflects y[k] for the duration of the current sample interval (zero-order hold between updates). The direct feedthrough term D u[k] is computed at the sample event, so the block has no algebraic passthrough between updates.

Parameters:
  • A (array_like) – discrete state space matrices

  • B (array_like) – discrete state space matrices

  • C (array_like) – discrete state space matrices

  • D (array_like) – discrete state space matrices

  • T (float) – sampling period

  • tau (float) – delay before first sample

  • initial_value (array_like, None) – initial state x[0]

events

internal scheduled event for periodic update

Type:

list[Schedule]

property A
property B
property C
property D
property T
property tau
property initial_value
reset()[source]

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

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)
class pathsim.blocks.discrete.DiscreteTransferFunction(Num=[1.0], Den=[1.0, 0.0], T=1.0, tau=0.0)[source]

Bases: DiscreteStateSpace

Discrete-time SISO transfer function in numerator/denominator form.

\[H(z) = \frac{b_0 z^M + b_1 z^{M-1} + \dots + b_M}{a_0 z^N + a_1 z^{N-1} + \dots + a_N}\]

Realized internally as a DiscreteStateSpace via the controllable canonical form returned by scipy.signal.tf2ss.

Parameters:
  • Num (array_like) – numerator polynomial coefficients (highest power of z first)

  • Den (array_like) – denominator polynomial coefficients (highest power of z first)

  • T (float) – sampling period

  • tau (float) – delay before first sample

input_port_labels = {'in': 0}
output_port_labels = {'out': 0}
property Num
property Den
property T
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)
property tau
class pathsim.blocks.discrete.TappedDelay(N=2, T=1.0, tau=0.0)[source]

Bases: Block

Tapped delay line.

Outputs the current and N-1 past samples of the input as parallel signals. The block has N outputs:

\[y_i[k] = u[k - i], \quad i = 0, 1, \dots, N-1\]
Parameters:
  • N (int) – number of taps (output ports)

  • T (float) – sampling period

  • tau (float) – delay before first sample

events

internal scheduled event for periodic shift

Type:

list[Schedule]

property N
property T
property tau
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)
reset()[source]

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