pathsim.blocks.lti module

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

Bases: Block

This block integrates a LTI MIMO state space model with the structure

\[\begin{split}\begin{eqnarray} \dot{x} &= \mathbf{A} x + \mathbf{B} u \\ y &= \mathbf{C} x + \mathbf{D} u \end{eqnarray}\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) – state space matrices

  • B (array_like) – state space matrices

  • C (array_like) – state space matrices

  • D (array_like) – 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

set_solver(Solver, **solver_args)[source]

set the internal numerical integrator

Parameters:
  • Solver (Solver) – numerical integration solver class

  • solver_args (dict) – parameters for solver initialization

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

Bases: StateSpace

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

The transfer function is defined in pole-residue form

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

where ‘Poles’ are the scalar poles of the transfer function and ‘Residues’ are the possibly matrix valued (in MIMO case) 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 statespace model of the form

\[\begin{split}\begin{eqnarray} \dot{x} &= \mathbf{A} x + \mathbf{B} u \\ y &= \mathbf{C} x + \mathbf{D} u \end{eqnarray}\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