functionfromStateSpace
Generate a DiscreteStateSpace data record from a continuous state space system
Information
Syntax
dss = 'constructor'.fromStateSpace(ss, Ts) dss = 'constructor'.fromStateSpace(ss, Ts, method)
Description
This function derives 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.
from continuous state space form
der(xc(t)) = ss.A * xc(t) + ss.B * us(t)
yc(t) = ss.C * xc(t) + ss.D * uc(t)
The applied discretization method is selected by the user from
- ExplicitEuler - Discretization with explicit Euler integration,
- ImplicitEuler - Discretization with implicit Euler integration,
- Trapezoidal - Discretization with trapezoidal integration (Tustins method, recommended),
- ImpulseExact - Exact discretization for impulse inputs,
- StepExact - Exact discretization for step inputs (zero-order hold equivalent),
- RampExact - Exact discretization for ramp inputs (first-order hold equivalent).
Example
import dss=Modelica_LinearSystems2.DiscreteStateSpace; import Modelica_LinearSystems2.StateSpace; StateSpace ss=StateSpace(A = [1], B = [1], C = [1], D = [0]); Modelica.Units.SI.Time Ts=0.1; Modelica_LinearSystems2.Types.Method method=Modelica_LinearSystems2.Types.Method.Trapezoidal; public DiscreteStateSpace dss; algorithm dss := dss.'constructor'.fromStateSpace(ss, Ts); //or just: //dss := dss(ss=ss, Ts=Ts, method=method); // dss.A = [1.1053], // dss.B = [0.11080], // dss.C = [1], // dss.D = [0.0526], // dss.Ts = 0.1, // dss.B2 = [0.0526], // dss.method = Modelica_LinearSystems2.Types.Method.Trapezoidal
See also
Inputs
| Type | Name | Default | Description |
|---|---|---|---|
| Modelica_LinearSystems2.StateSpace | ss | Continuous linear state space system | |
| Modelica.Units.SI.Time | Ts | Sample time | |
| Modelica_LinearSystems2.Utilities.Types.Method | method | Modelica_LinearSystems2.Utilities.Types.Method.Trapezoidal | Discretization method |
Outputs
| Type | Name | Default | Description |
|---|---|---|---|
| Modelica_LinearSystems2.DiscreteStateSpace | dss | Discrete state space system |