# .Modelica_LinearSystems2.UsersGuide.GettingStarted.LinearSystemDataStructures

## Information

At the top level of the Modelica_LinearSystems2 library, data structures are provided as Modelica records defining different representations of linear, time invariant differential and difference equation systems. In the record definitions, functions are provided that operate on the corresponding data structure. Currently, the following linear system representations are available:

 record StateSpace Multi input, multi output, linear differential equation systems in state space form: ``` der(x) = A * x + B * u y = C * x + D * u ``` record TransferFunction Single input, single output, transfer functions defined via a numerator and a denominator polynomial n(s) and d(s) respectively: ``` n(s) 2*s+3 y = ------ * u, for example: y = ----------------- * u d(s) 4*s^2 + 5*s + 6 ``` record ZerosAndPoles Single input, single output, transfer function defined via the products of its zeros z and poles p, respectively; ``` product(s - z[i]) y = k*------------------- * u product(s - p[i]) ``` A description with zeros and poles is problematic: For example, a small change in the imaginary part of a conjugate complex pole pair, leads no longer to a transfer function with real coefficients. If the same zero or pole is present twice or more, then a diagonal state space form is no longer possible. This means that the structure is very sensitive if zeros or poles are close together. For this and other reasons, internally, this data structure stores the zeros and poles as first and second order polynomials with real coefficients: ``` product(s+n1[i]) * product(s^2+n2[i,1]*s+n2[i,2]) y = k*--------------------------------------------------- product(s+d1[i]) * product(s^2+d2[i,1]*s+d2[i,2]) ``` record DiscreteStateSpace Multi input, multi output, linear difference equation system in state space form: ``` x(Ts*(k+1)) = A * x(Ts*k) + B * u(Ts*k) y(Ts*k) = C * x(Ts*k) + D * u(Ts*k) x_continuous(Ts*k) = x(Ts*k) + B2 * u(Ts*k) ``` with Ts the sample time and k the index of the actual sample instance (k=0,1,2,3,...). x(t) is the discrete state vector and x_continuous(t) is the state vector of the continuous system from which the discrete block has been derived by a state transformation, in order to remove dependencies of past values of u.

It is planned to add linear system descriptions such as DiscreteTransferFunction, DiscreteFactorized, FrequencyResponse, and DiscreteFrequencyResponse, in the future. Furthermore, several useful functions are not yet available in the records above. They will also be added in the future.

Below, a typical session in the command window is shown: The last command (plotBode) results in the following frequency response: Note, the interesting frequency range is automatically determined (it can be fairly good deduced from the phase information of poles and zeros).

Transfer function tf3 can be transformed into a state space description with command ss=StateSpace(tf3) and an poles-and-zeros plot and print out is then available via StateSpace.Plot.polesAndZeros(ss) resulting in: It is also possible to linearize any Modelica model at the start time (after initialization has been performed). This is especially useful if the model is initialized in steady state. For example, the command StateSpace.Import.fromModel("xxx") results in: Also several filters are provided in. Typical frequency responses of implemented filters are shown in the next figure: The step responses of the same low pass filters are shown in the next figure, starting from a steady state initial filter with initial input = 0.2: Generated at 2020-11-23T01:59:39Z by OpenModelicaOpenModelica 1.17.0~dev-193-gd8931f2 using GenerateDoc.mos