.Modelica_LinearSystems2.Controllers.ZerosAndPoles

Information

This function transforms a zeros-poles-gain system representation into state space representation. To achieve well numerical condition the ZerosAndPoles transfer function is transformed into state space form by creating first and second order blocks that are connected together in series. Every block is represented in controller canonical form and scaled such that the gain from the input of this block to its output is one (i.e. y(s=0) = u(s=0)), if this is possible. Details are given below.

Algorithmic details

The ZerosAndPoles transfer function is defined as:

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

This is treated as a series connection of first and second order systems. If size(n1) == size(d1) and size(n2) == size(d2) this gives the following sequence of operations:

        s^2 + n2[1,1]*s + n2[1,2]
  y_1 = ------------------------- * u
        s^2 + d2[1,1]*s + d2[1,2]
 
        s^2 + n2[2,1]*s + n2[2,2]
  y_2 = ------------------------- * y_1
        s^2 + d2[2,1]*s + d2[2,2]
 
     ...
 
        s + n1[..]
  y_n = ---------- * y_(n-1)
        s + d1[..]
 
    y = k*y_n

Based on this representation, evrey block with transfer function G(s) could be transformed into

  G(s) = k * F(s)

with F(s) has unit gain. This leads to representations of the forms

           a2 + a1*s + s^2       a2      b2 + a1*b2/a2*s + b2/a2*s^2
  G(s) = -------------------- = ---- * ------------------------------ = k * F(s),  k = a2/b2  (1)
           b2 + b1*s + s^2       b2           b2 + b1*s + s^2
 
for second order systems and
 
           a + s     a     b + b/a*s
  G(s) = -------- = --- * ---------- = k * F(s),   k = a/b
           b + s     b      b + s

for first order systems respectively.

The complete system is now considered as the series connections of all the single unit gain transfer functions and an overall gain k with

  k = product(ki).

In the general case, the following system structures and the corresponding state space systems can appear (note, 'c' is the reciprocal local gain 1/k):

(1)
          a2 + a1*s + s^2           der(x1) = x2
    y = ---------------------  -->  der(x2) = -b2*x1 - b1*x2 + b2*u
          b2 + b1*s + s^2                 y = c*((a2-b2)*x1 + (a1-b1)*x2 + u),  c = b2/a2
 
(2)
             s + a                 der(x1) = x2
    y = ---------------- * u  -->  der(x2) = -b2*x1 - b1*x2 + b2*u
        b2 + b1*s + s^2                  y = k*(a1/b2*x1 +x2/b2),  c = b2/a
 
(3)
               1                  der(x1) = x2
    y = --------------- *u   -->  der(x2) = -b2*x1 - b1*x2 + b2*u
        b2 + b1*s + s^2                 y = c*x1/b2,  c = b2
 
(4)
       a + s                       der(x) = -b*x + b*u
   y = ----- * u             -->        y = c*((a-b)/b*x + u),  c = b/a
       b + s
 
(5)
         1
   y = ----- * u             -->   der(x) = -b*x + b*u
       b + s                            y = x,  c = b

If the sizes of the numerator and denominator polynomials do not match, the small systems are built in the following way:

(1) Build systems of form (1) by combining
    - 1 d2 and 1 n2
      (= 1 second order denominator and 1 second order numerator) or
    - 1 d2 and 2 n1 or
    - 2 d1 and 1 n2
(2) Build at most one system of form (2) by combining
    - 1 d2 and 1 n2
(3) Build systems of form (3) by
    - 1 d2
(4) Build systems of form (4) by combining
    - 1 d1 and 1 n1
(5) Build systems of form (5) by
    - 1 d1

The numeric properties of the resulting state space system depends on which first and second order polynomials are combined and connected together. From a numerical point of view, it would therefore be useful to combine the polynomials based on the numeric values of the polynomial coefficients, (e.g., in a first step the polynomials could be sorted according to their cut-off frequency).

However, this has the disadvantage that the structure of the resulting state space system depends on the numeric values of the polynomial coefficients. Since Modelica environments perform symbolic pre-processing on equations, this would mean that a change of a polynomial coefficient requires to newly compile the state space system.

If, on the other hand, the structure of the state space system depends only on dimension information of the n1,n2,d1,d2 arrays, then the polynomial coefficients can be changed without a new translation of the model. This is the major reason why the structure of the state space system in the implementation of this block is based only on dimension information.

This is, e.g., not critical for the provided filters: The dimension of the n1,n2,d1,d2 arrays depend for filters only on the filter characteristics (Bessel, Butterworth etc.), the filter type (low pass, high pass etc.) and on the filter order. If any of this data is changed, the model has to be newly compiled. All the other filter data, such as cut-off frequency or ripple amplitude, can be changed without re-compilation of the model. The ZerosAndPoles transfer function is now constructed for the filters in such a way that the filter zeros and poles are appropriately sorted to give better numerical properties.

Another alternative implementation of the state space system would be to use the function controller canonical form that directly results from the transfer function. The severe disadvantage of this approach is that the structure of the state space system from above is lost for the symbolic preprocessing. If, e.g., index reduction has to be applied (e.g. since a filter is used to realize a non-linear inverse model), then the tool cannot perform the index reduction. Example:

Assume, a generic first order state space system is present

   der(x) = a*x + b*u
        y = c*x + d*u

and the values of the scalars a,b,c,d are parameters that might be changed before the simulation starts. If y has to be differentiated symbolically during code generation, then

      der(y) = c*der(x) + d*der(u)
      der(x) = a*x + b*u

As a result, u needs to be differentiated too, and this might not be possible and therefore translation might fail.

On the other hand, if the first order system is defined to be a low pass filter and the state space system is generated by keeping this structure, we have (see form (5) above):

   der(x) = -b*x + u
        y = x

Differentiating y symbolically leads to:

     der(y) = der(x)
     der(x) = -b*x + u

Therefore, in this case, the derivative of u is not needed and the tool can continue with the symbolic processing.


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