.Modelica_LinearSystems2.TransferFunction.Conversion.toStateSpace

Information

Syntax

ss = TransferFunction.Conversion.toStateSpace(tf)

Description

Transforms a transfer function into state space representation. There are an infinite number of possible realizations. Here, the transfer function is transformed into controller canonical form, i.e. the transfer function

     b4*s^4 + b3*s^3 + b2*s^2 + b1*s + b0
y = -------------------------------------- * u
     a4*s^4 + a3*s^3 + a2*s^2 + a1*s + a0

is transformed into:

der(x) = A*x + B*u;
    y  = C*x + D*u;
   with
           A = [   0  ,    1  ,    0  ,    0;
                   0  ,    0  ,    1  ,    0:
                   0  ,    0  ,    0  ,    1;
                -a0/a4, -a1/a4, -a2/a4, -a3/a4];
            B = [  0;
                  0;
                  0;
                 1/a4];
           C = [b0-b4*a0/a4, b1-b4*a1/a4, b2-b4*a2/a4, b3-b4*a3/a4];
           D = [b4/a4];

If the numerator polynomial is 1, then the state vector x is built up of y and of all derivatives of y up to nx-1 (nx is the dimension of the state vector):

x = {y, dy/dt, d^2y/dt^2, ..., d^(n-1)y/dt^(n-1)};

Note, the state vector x of Modelica.Blocks.Continuous.TransferFunction is defined slightly differently.

Example

  TransferFunction s = Modelica_LinearSystems2.TransferFunction.s();
  Modelica_LinearSystems2.TransferFunction tf=(s+1)/(s^3 + s^2 + s +1);

algorithm
  ss := Modelica_LinearSystems2.TransferFunction.Conversion.toStateSpace(tf);
// ss.A = [0, 1, 0; 0, 0, 1; -1, -1, -1],
// ss.B = [0; 0; 1],
// ss.C = [1, 1, 0],
// ss.D = [0],

Interface

function toStateSpace
  import Modelica;
  import Modelica_LinearSystems2;
  import Modelica_LinearSystems2.TransferFunction;
  import Modelica.Math.Vectors;
  input Modelica_LinearSystems2.TransferFunction tf "Transfer function of a system";
  output Modelica_LinearSystems2.StateSpace ss(redeclare Real A[TransferFunction.Analysis.denominatorDegree(tf), TransferFunction.Analysis.denominatorDegree(tf)], redeclare Real B[TransferFunction.Analysis.denominatorDegree(tf), 1], redeclare Real C[1, TransferFunction.Analysis.denominatorDegree(tf)], redeclare Real D[1, 1]) "Transfer function in StateSpace form";
end toStateSpace;

Generated at 2024-11-22T19:25:38Z by OpenModelicaOpenModelica 1.24.2 using GenerateDoc.mos