Discrete-Time¶
- class pathsim.blocks.discrete.SampleHold(T=1.0, tau=0.0)[source]¶
Bases:
BlockZero-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.
- property T¶
- property tau¶
- pathsim.blocks.discrete.ZeroOrderHold¶
alias of
SampleHold
- class pathsim.blocks.discrete.FirstOrderHold(T=1.0, tau=0.0)[source]¶
Bases:
BlockFirst-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 Holdblock.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.
- 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
- class pathsim.blocks.discrete.FIR(coeffs=[1.0], T=1.0, tau=0.0)[source]¶
Bases:
BlockDiscrete-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
bare the filter coefficients andNis 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:
- property coeffs¶
- property T¶
- property tau¶
- class pathsim.blocks.discrete.DiscreteIntegrator(T=1.0, tau=0.0, initial_value=0.0)[source]¶
Bases:
BlockDiscrete-time integrator (forward Euler).
\[y[k+1] = y[k] + T \, u[k]\]The output at sample
kis the accumulated sum of past inputs; the current inputu[k]only enters the next sample.Note
Supports vector input — each channel is integrated independently. Pass an array as
initial_valueto set per-channel initial values.- Parameters:
- property T¶
- property tau¶
- property initial_value¶
- class pathsim.blocks.discrete.DiscreteDerivative(T=1.0, tau=0.0)[source]¶
Bases:
BlockDiscrete-time backward-difference derivative.
\[y[k] = \frac{u[k] - u[k-1]}{T}\]Note
Supports vector input — each channel is differentiated independently.
- property T¶
- property tau¶
- 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:
BlockDiscrete-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 termD 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]
- property A¶
- property B¶
- property C¶
- property D¶
- property T¶
- property tau¶
- property initial_value¶
- class pathsim.blocks.discrete.DiscreteTransferFunction(Num=[1.0], Den=[1.0, 0.0], T=1.0, tau=0.0)[source]¶
Bases:
DiscreteStateSpaceDiscrete-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
DiscreteStateSpacevia the controllable canonical form returned byscipy.signal.tf2ss.- Parameters:
- 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:
BlockTapped delay line.
Outputs the current and
N-1past samples of the input as parallel signals. The block hasNoutputs:\[y_i[k] = u[k - i], \quad i = 0, 1, \dots, N-1\]- Parameters:
- input_port_labels = {'in': 0}¶
- property N¶
- property T¶
- property tau¶