recordDiscreteStateSpace

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

Extends from Modelica.Icons.Record (Icon for records).

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

  • Ts - the sample time
  • k - the index of the actual sample instance (k=0,1,2,3,...)
  • t - the time
  • u(t) - the input vector,
  • y(t) - the output vector,
  • x(t) - the discrete state vector (x(t=Ts*0) is the initial state),
  • x_continuous(t) - the state vector of the continuous system from which the discrete block has been derived (details see below),
  • A,B,C,D,B2 - matrices of appropriate dimensions.

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.

Components

TypeNameDefaultDescription
Real[:,size(A, 1)]A
Real[size(A, 1),:]B
Real[:,size(A, 1)]C
Real[size(C, 1),size(B, 2)]D
Modelica.Units.SI.TimeTs1Sample time
Real[size(B, 1),size(B, 2)]B2fill(0, size(B, 1), size(B, 2))Reconstruct continuous state
Modelica_LinearSystems2.Utilities.Types.MethodmethodModelica_LinearSystems2.Utilities.Types.Method.TrapezoidalDiscretization method

Contents

NameDescription
'constructor'
timeResponseCompute time response of DiscreteStateSpace system
initialResponseCompute initial response of DiscreteStateSpace system
ConversionConversion functions from DiscreteStateSpace into DiscreteTransferFunction
PlotFunctions to plot discrete state space system responses
Internal
DesignDesign functions for DiscreteStateSpace