pySimBlocks.blocks.systems.linear_state_space

class pySimBlocks.blocks.systems.linear_state_space.LinearStateSpace(name: str, A: ArrayLike, B: ArrayLike, C: ArrayLike, x0: TypeAliasForwardRef('ArrayLike') | None = None, sample_time: float | None = None)[source]

Bases: Block

Discrete-time linear state-space system block.

Implements a strictly proper discrete-time linear system:

x[k+1] = A x[k] + B u[k]

y[k] = C x[k]

The D matrix is intentionally not supported to avoid algebraic loops.

A

State transition matrix of shape (n, n).

B

Input matrix of shape (n, m).

C

Output matrix of shape (p, n).

direct_feedthrough = False

True if outputs depend directly on inputs.

initialize(t0: float) None[source]

Compute initial outputs from the initial state.

Parameters:

t0 – Initial simulation time in seconds.

output_update(t: float, dt: float) None[source]

Compute y and x outputs from the committed state.

Parameters:
  • t – Current simulation time in seconds.

  • dt – Current time step in seconds.

state_update(t: float, dt: float) None[source]

Compute the next state x[k+1] = A x[k] + B u[k].

Parameters:
  • t – Current simulation time in seconds.

  • dt – Current time step in seconds.

Raises:
  • RuntimeError – If input u is not connected.

  • ValueError – If input u has the wrong shape.