LTI

class pathsim.blocks.lti.StateSpace(A=-1.0, B=1.0, C=-1.0, D=1.0, initial_value=None)[source]

Bases: Block

Linear time invariant (LTI) multi input multi output (MIMO) state space model.

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

where A, B, C and D are the state space matrices, x is the state, u the input and y the output vector.

Example

A SISO state space block with two internal states can be initialized like this:

S = StateSpace(
    A=-np.eye(2),
    B=np.ones((2, 1)),
    C=np.ones((1, 2)),
    D=1.0
    )

and a MIMO (2 in, 2 out) state space block with three internal states can be initialized like this:

S = StateSpace(
    A=-np.eye(3),
    B=np.ones((3, 2)),
    C=np.ones((2, 3)),
    D=np.ones((2, 2))
    )
Parameters:
  • A (array_like) – real valued state space matrices

  • B (array_like) – real valued state space matrices

  • C (array_like) – real valued state space matrices

  • D (array_like) – real valued state space matrices

  • initial_value (array_like, None) – initial state / initial condition

op_dyn

internal dynamic operator for state equation

Type:

DynamicOperator

op_alg

internal algebraic operator for mapping to outputs

Type:

DynamicOperator

solve(t, dt)[source]

advance solution of implicit update equation of the solver

Parameters:
  • t (float) – evaluation time

  • dt (float) – integration timestep

Returns:

error – solver residual norm

Return type:

float

step(t, dt)[source]

compute timestep update with integration engine

Parameters:
  • t (float) – evaluation time

  • dt (float) – integration timestep

Returns:

  • success (bool) – step was successful

  • error (float) – local truncation error from adaptive integrators

  • scale (float) – timestep rescale from adaptive integrators

class pathsim.blocks.lti.TransferFunctionPRC(Poles=[], Residues=[], Const=0.0)[source]

Bases: StateSpace

This block defines a LTI (MIMO for pole residue) transfer function.

The transfer function is defined in pole-residue-constant (PRC) form

\[\mathbf{H}(s) = \mathbf{C} + \sum_n^N \frac{\mathbf{R}_n}{s - p_n}\]

where ‘Poles’ are the scalar (possibly complex conjugate) poles of the transfer function and ‘Residues’ are the possibly matrix valued (in MIMO case) and complex conjugate residues of the transfer function. ‘Const’ has same shape as ‘Residues’.

Upon initialization, the state space realization of the transfer function is computed using a minimal gilbert realization.

The resulting state space model of the form

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

is handled the same as the ‘StateSpace’ block, where A, B, C and D are the state space matrices, x is the internal state, u the input and y the output vector.

Parameters:
  • Poles (array) – transfer function poles

  • Residues (array) – transfer function residues

  • Const (array, float) – constant term of transfer function

property Const
property Poles
property Residues
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.lti.TransferFunction(Poles=[], Residues=[], Const=0.0)[source]

Bases: TransferFunctionPRC

Alias for TransferFunctionPRC.

Deprecated since version 1.0.0: Use TransferFunctionPRC() instead.

class pathsim.blocks.lti.TransferFunctionZPG(Zeros=[], Poles=[-1], Gain=1.0)[source]

Bases: StateSpace

This block defines a LTI (SISO) transfer function.

The transfer function is defined in zeros-poles-gain (ZPG) form

\[\mathbf{H}(s) = k \frac{(s - z_1)(s - z_2)\cdots(s - z_m)}{(s - p_1)(s - p_2)\cdots(s - p_n)}\]

where Zeros are the scalar (possibly complex conjugate) zeros of the transfer function, and Poles are the poles (denominator zeros) of the transfer function. Gain is the scalar factor k.

Upon initialization, the state space realization of the transfer function is computed using scipy.signal.ZerosPolesGain(Zeros, Poles, Gain).to_ss().

The resulting state space model of the form

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

is handled the same as the ‘StateSpace’ block, where A, B, C and D are the state space matrices, x is the internal state, u the input and y the output vector.

Parameters:
  • Poles (array_like) – transfer function poles

  • Zeros (array_like) – transfer function zeros

  • Gain (float) – gain term of transfer function

input_port_labels = {'in': 0}
output_port_labels = {'out': 0}
property Zeros
property Poles
property Gain
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.lti.TransferFunctionNumDen(Num=[1], Den=[1, 1])[source]

Bases: StateSpace

This block defines a LTI (SISO) transfer function.

The transfer function is defined in polynomial (numerator-denominator) form

\[\mathbf{H}(s) = \frac{b_n + b_{n-1} s + \dots + b_{0} s^n}{a_m + a_{m-1} s + \dots + a_{0} s^m}\]

where Num is the list of numerator polynomial coefficients and Den the list of denominator coefficients.

Upon initialization, the state space realization of the transfer function is computed using scipy.signal.TransferFunction(Num, Den).to_ss().

The resulting state space model of the form

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

is handled the same as the ‘StateSpace’ block, where A, B, C and D are the state space matrices, x is the internal state, u the input and y the output vector.

Parameters:
  • Num (array_like) – numerator polynomial coefficients

  • Den (array_like) – denominator polynomial coefficients

input_port_labels = {'in': 0}
output_port_labels = {'out': 0}
property Num
property Den
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)