Mathematical FormulationΒΆ

SimuPy assumes systems have no direct feedthrough between inputs and outputs; this discpline avoids algebraic loops. You can simulate a system model that includes a feedthrough by augmenting the system. Augment the system using the input by including input components in the state and using derivatives of those signals in the control input. You can augment the system using the output by including the original output components in the state and using integrals of those signals in the system output. However, there is no requirement for the system to have a state, so

\[\begin{split}x'(t) &= f(t,x(t),u(t)) \\ y(t) &= h(t,x(t))\end{split}\]

and

\[y(t) = h(t,u(t))\]

are both valid formulations. Here, \(t\) is the time variable, \(x\) is the system state, \(u\) is the system input, and \(y\) is the sytem output. We call \(f\) the state equation and \(h\) the output equation. SimuPy can also handle discrete-time systems with sample period \(\Delta t\) of the form

\[\begin{split}x[k+1] &= f([k],x[k],u(k)]) \\ y[k+1] &= h([k],x[k+1])\end{split}\]

and

\[y[k+1] = h([k], u(k))\]

where \([k]\) indicates signal values over the half-open interval \((k\, \Delta t, (k+1) \Delta t]\) which are updated at time \(t=k\, \Delta t\) for discrete-time systems and \((k)\) indicates a zero-order hold sample of the signal at time \(k \, \Delta t\) for continuous-time systems. This formulation gives the expected results for models with only discrete-time sub-systems of the same update rate \(\Delta t\) which can be combined into a single system of the form

\[\begin{split}x[k+1] &= f([k], x[k], u[k]) \\ y[k] &= h([k], x[k])\end{split}\]

and makes sense in general for hybrid-time simulation.

This formulation is also consistent with common linear, time-invariant (LTI) system algebras and transformations. For example, the dynamics of the LTI system

\[\begin{split}x'(t) &= A \, x(t) + B \, u(t), \\ y(t) &= I \, x(t),\end{split}\]

with state-feedback

\[u(t) = -K\, x(t),\]

are the same as the autonomous system

\[\begin{split}x'(t) &= (A - B\,K) \, x(t), \\ y(t) &= I \, x(t).\end{split}\]

Similarly, timing transformations are consistent. The discrete-time equivalent of the continuous-time LTI system above,

\[\begin{split}x[k+1] &= \Phi\, x[k] + \Gamma\, u[k], \\ y[k] &= I \, x[k],\end{split}\]

will travel through the same state trajectory at times \(k\, \Delta t\) if both are subject to the same piecewise constant inputs and the state and input matrices are related by the zero-order hold transformation

\[\begin{split}\Phi &= e^{A\, \Delta t}, \\ \Gamma &= \int_{0}^{\Delta t} e^{A\, \tau} \, d \tau B.\end{split}\]

The accuracy of these algebras and transformations are demonstrated in the discrete_lti.py example and are incorporated into the test_block_diagram.py tests.