Modelica_LinearSystems2

Modelica_LinearSystems2 - Analysis, Synthesis and Modeling of Continuous and Discrete Linear Systems

Information


Library Modelica_LinearSystems2 is a Modelica package providing different representations of linear, time invariant differential and difference equation systems. For example, record StateSpace defines a linear time invariant differential equation system in state space form:

    der(x) = A * x + B * u
        y  = C * x + D * u

Operators are overloaded to work conveniently with these system descriptions in an interactive environment, e.g., to multiply transfer functions or to operate on complex numbers. About 180 functions are provided to operate on these data structures, e.g., to compute eigen values, zeros, step responses, to design pole-placement and LQG controllers, to plot step responses, frequency responses, eigen values, to convert between different description forms, or to generate a linear system description by linearization of a Modelica model.

Furthermore, in sublibrary Controller about 20 input/output blocks of linear systems are provided that are based on the different representation forms, e.g., PID, StateSpace, Filter blocks. A unique feature of these blocks is that it is very convenient to quickly switch between a continuous and a discrete block representation. Also, templates are provide to quickly built-up

For an introduction, have especially a look at:

It is planned to include this library in a future version of the Modelica Standard Library. Note, the library is not backwards compatible to the previous beta version 0.95, called "Modelica_LinearSystems", which was shipped with previous versions of Dymola. Since the differences are too large, no conversion scripts are provided, but different library names are used.

Licensed by DLR under the Modelica License 2
           Copyright © 2005-2009, DLR Institute of Robotics and Mechatronics

This Modelica package is free software and the use is completely at your own risk; it can be redistributed and/or modified under the terms of the Modelica license 2, see the license conditions (including the disclaimer of warranty) here or at http://www.Modelica.org/licenses/ModelicaLicense2.

Package Content

NameDescription
Modelica_LinearSystems2.UsersGuide UsersGuide Users Guide
DataDir=classDirectory() + "Extras/Data/"Absolute path to directory containing utilitiy files for this package
Modelica_LinearSystems2.Examples Examples Examples demonstrating the usage of this package
Modelica_LinearSystems2.StateSpace StateSpace Continuous state space description of a linear, time invariant differential equation system (data + operations)
Modelica_LinearSystems2.TransferFunction TransferFunction Continuous transfer function description of a single input, single output system (data + operations)
Modelica_LinearSystems2.ZerosAndPoles ZerosAndPoles Continuous zeros and poles description of a single input, single output system (data + operations)
Modelica_LinearSystems2.DiscreteStateSpace DiscreteStateSpace Discrete state space description of a linear, time invariant difference equation system (data + operations)
Modelica_LinearSystems2.Controller Controller Continuous and discrete input/output blocks. Easy to switch from continuous to discrete representation.
Modelica_LinearSystems2.Math Math Additional functions for Modelica.Math
Modelica_LinearSystems2.Utilities Utilities Functions that shall be included in Modelica.Utilities
Modelica_LinearSystems2.Types Types Constants and types with choices, especially to build menus

Modelica_LinearSystems2.StateSpace Modelica_LinearSystems2.StateSpace

Continuous state space description of a linear, time invariant differential equation system (data + operations)

Information


This record defines a linear time invariant differential equation system in state space form:

    der(x) = A * x + B * u
        y  = C * x + D * u

with

Extends from Modelica.Icons.Record (Icon for a record).

Parameters

NameDescription
der(x) = A*x + B*u; y = C*x + D*u
A[:, size(A, 1)] 
B[size(A, 1), :] 
C[:, size(A, 1)] 
D[size(C, 1), size(B, 2)] 
Signal names
yNames[size(C, 1)]Names of the output signals
xNames[size(A, 1)]Names of the states
uNames[size(B, 2)]Names of the input signals

Modelica_LinearSystems2.TransferFunction Modelica_LinearSystems2.TransferFunction

Continuous transfer function description of a single input, single output system (data + operations)

Information


This record defines the transfer function between the input signal u and the output signal y by the coefficients of the numerator and denominator polynomials n(s) and d(s) respectively:

        n(s)
   y = ------ * u
        d(s)

The order of the numerator polynomial can be larger as the order of the denominator polynomial (in such a case, the transfer function can not be transformed to a StateSpace system, but other operations are possible).

Example: The transfer function

             2*s+3
   y = ----------------- * u
        4*s^2 + 5*s + 6

is transformed in the following way in a TransferFunction record:

   import Modelica_LinearSystems2.TransferFunction;
   import Modelica.Utilities.Streams;
   TransferFunction tf(n={2,3}, d={4,5,6});
   print("y = " + TransferFunction.'String'(tf) + " * u");
   // prints the following string to the output window:
   //   y = (2*s + 3) / (4*s^2 + 5*s + 6) * u

Extends from Modelica.Icons.Record (Icon for a record).

Parameters

NameDescription
y = n*{s^m, ... , s, 1} / (d*{s^r, ... , s, 1}) * u
n[:]Coefficients of numerator polynomial (in descending order)
d[:]Coefficients of denominator polynomial (in descending order)
Signal names
uNameName of input signal
yNameName of output signal

Modelica_LinearSystems2.ZerosAndPoles Modelica_LinearSystems2.ZerosAndPoles

Continuous zeros and poles description of a single input, single output system (data + operations)

Information


This record defines a transfer function by its zeros, poles and a gain:

         product(p - z[i])
  y = k*------------------- * u
         product(p - n[i])

where z[:] is a Complex vector of zeros, n[:] is a Complex vector of poles and k is an additional multiplicative factor. The elements of the two Complex vectors must either be real numbers or conjugate complex pairs (in order that their product results in a polynomial with Real coefficients).

In the record, the zeros and poles are transformed into a product of first and second order polynomials. The data structure is especially useful in applications where first and second order polynomials are naturally occuring, e.g., as for filters. In fact, via function ZerosAndPoles.Design.filter, a ZeroAndPole transfer function is generated from low and high pass analog filters (CriticalDamping, Bessel, Butterworth, Chebyshev). The filters are available in normalized (default) and non-normalized form. In the normalized form, the amplitude of the filter transfer function at the cutoff frequency is 1/sqrt(2) (= 3 dB).

A ZeroAndPole transfer function is internally stored by the coefficients of first and second order polynomials, and by an additional multiplicative factor k:

         product(s + n1[i]) * product(p^2 + n2[i,1]*p + n2[i,2])
  y = k*---------------------------------------------------------
         product(p + d1[i]) * product(p^2 + d2[i,1]*p + d2[i,2])

Note, the degrees of the numerator and denominator polynomials are given as:

   degree of numerator   = size(n1,1) + 2*size(n2,1);
   degree of denominator = size(d1,1) + 2*size(d2,1);

Example:

                          (p+1)
  zp = 4* -------------------------------------
           (p - 1)*(p - (2+j*3))*(p - (2-j*3))

with j=sqrt(-1), is defined as

 
   import Modelica_LinearSystems2.Math.Complex; 
   import Modelica_LinearSystems2.ZerosAndPoles;
   
   zp = ZerosAndPoles(z = {Complex(-1,0)},
                      p = {Complex(1,0),
                           Complex(2,3),
                           Complex(2,-3)}, 
                           k=4);

Extends from Modelica.Icons.Record (Icon for a record).

Parameters

NameDescription
y = k*(product(p+n1[i]) * product(p^2+n2[i,1]*p+n2[i,2])) / (product(p+d1[i])*product(p^2+d2[i,1]*p+d2[i,2])) *u
kMultiplicative factor of transfer function
n1[:][p^0] coefficients of 1st order numerator polynomials
n2[:, 2][p,p^0] coefficients of 2nd order numerator polynomials
d1[:][p^0] coefficients of 1st order denominator polynomials
d2[:, 2][p,p^0] coefficients of 2nd order denominator polynomials
Signal names
uNameName of input signal
yNameName of output signal

Modelica_LinearSystems2.DiscreteStateSpace Modelica_LinearSystems2.DiscreteStateSpace

Discrete state space description of a linear, time invariant difference equation system (data + operations)

Information


This record defines a linear time invariant 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

A discrete system is usually derived by discretization from a continuous block, e.g., by function LinearSystems.DiscreteStateSpace.fromStateSpace. If the discretization method, e.g., the trapezoidal method, accesses actual and past values of the input u (e.g. u(Ts*k), u(Ts*(k-1), u(Ts*(k-2))), a state transformation is needed to get the difference equation above where only the actual value u(Ts*k) is accessed.

If the original continuous state vector should be computed from the sampled data system above, the matrices of this transformation have to be known. For simplicity and efficiency, here only the specific transformation used by function LinearSystems.DiscreteStateSpace.fromStateSpace is stored in the data record of the discrete system via matrix B2. Therefore, the state vector of the underlying continuous system can be calculated by adding the term B2*u to the state vector of the discretized system.

In Modelica notation, the difference equation above can be implemented as:

     when {initial(), sample(Ts,Ts)} then
        new_x = A * x + B * u;
            y = C * x + D * u;
            x = pre(new_x);
        x_continuous = x + B2 * u;
     end when;

Since no "next value" operator is available in Modelica, an auxiliary variable new_x stores the value of x for the next sampling instant. The relationship between new_x and x is defined via equation "x = pre(new_x)".

The body of the when-clause is active during initialization and at the next sample instant t=Ts. Note, the when-equation is not active after the initialization at t=0 (due to sample(Ts,Ts)), since the state x of the initialization has to be used also at t=0.

In library Blocks.Controller additional equations are added for the initialization to uniquely compute the initial vector x:

  initial equation 
     if init == InitialState then
        x = x_start;
     elseif init == SteadyState then
        x = new_x;
     end if;

Optionally, x is set to a given start vector x_start. As default initialization, the equation "x = new_x" is added that defines steady state initialization for the discrete system. As a consequence, the output y(Ts*k), k=0,1,2,.., remains constant after this initialization, provided the input vector u(Ts*k) remains constant.

Extends from Modelica.Icons.Record (Icon for a record).

Parameters

NameDescription
new_x = A*x + B*u; y = C*x + D*u; x_cont = x + B2*u
A[:, size(A, 1)] 
B[size(A, 1), :] 
C[:, size(A, 1)] 
D[size(C, 1), size(B, 2)] 
Data used to construct discrete from continuous system
TsSample time [s]
B2[size(B, 1), size(B, 2)]Reconstruct continuous state
methodDiscretization method

HTML-documentation generated by Dymola Tue Sep 08 18:52:56 2009.