Package Modelica.​Blocks.​Continuous.​Internal.​Filter.​roots
Filter roots and gain as needed for block implementations

Information

This icon shall be used for a package that contains internal classes not to be directly utilized by a user.

Extends from Modelica.​Icons.​InternalPackage (Icon for an internal package (indicating that the package should not be directly utilized by user)).

Package Contents

NameDescription
bandPassReturn band pass filter roots as needed for block for given cut-off frequency
bandStopReturn band stop filter roots as needed for block for given cut-off frequency
highPassReturn high pass filter roots as needed for block for given cut-off frequency
lowPassReturn low pass filter roots as needed for block for given cut-off frequency

Function Modelica.​Blocks.​Continuous.​Internal.​Filter.​roots.​lowPass
Return low pass filter roots as needed for block for given cut-off frequency

Information

The goal is to implement the filter in the following form:

  // real pole:
   der(x) = r*x - r*u
       y  = x

  // complex conjugate poles:
  der(x1) = a*x1 - b*x2 + ku*u;
  der(x2) = b*x1 + a*x2;
       y  = x2;

            ku = (a^2 + b^2)/b

This representation has the following transfer function:

// real pole:
    s*y = r*y - r*u
  or
    (s-r)*y = -r*u
  or
    y = -r/(s-r)*u

  comparing coefficients with
    y = cr/(s + cr)*u  ->  r = -cr      // r is the real eigenvalue

// complex conjugate poles
    s*x2 =  a*x2 + b*x1
    s*x1 = -b*x2 + a*x1 + ku*u
  or
    (s-a)*x2               = b*x1  ->  x2 = b/(s-a)*x1
    (s + b^2/(s-a) - a)*x1 = ku*u  ->  (s(s-a) + b^2 - a*(s-a))*x1  = ku*(s-a)*u
                                   ->  (s^2 - 2*a*s + a^2 + b^2)*x1 = ku*(s-a)*u
  or
    x1 = ku*(s-a)/(s^2 - 2*a*s + a^2 + b^2)*u
    x2 = b/(s-a)*ku*(s-a)/(s^2 - 2*a*s + a^2 + b^2)*u
       = b*ku/(s^2 - 2*a*s + a^2 + b^2)*u
    y  = x2

  comparing coefficients with
    y = c0/(s^2 + c1*s + c0)*u  ->  a  = -c1/2
                                    b  = sqrt(c0 - a^2)
                                    ku = c0/b
                                       = (a^2 + b^2)/b

  comparing with eigenvalue representation:
    (s - (a+jb))*(s - (a-jb)) = s^2 -2*a*s + a^2 + b^2
  shows that:
    a: real part of eigenvalue
    b: imaginary part of eigenvalue

  time -> infinity:
    y(s=0) = x2(s=0) = 1
             x1(s=0) = -ku*a/(a^2 + b^2)*u
                     = -(a/b)*u

Extends from Modelica.​Icons.​Function (Icon for functions).

Inputs

TypeNameDescription
Realcr_in[:]Coefficients of real poles of base filter
Realc0_in[:]Coefficients of s^0 term of base filter if conjugate complex pole
Realc1_in[size(c0_in, 1)]Coefficients of s^1 term of base filter if conjugate complex pole
Frequencyf_cutCut-off frequency

Outputs

TypeNameDescription
Realr[size(cr_in, 1)]Real eigenvalues
Reala[size(c0_in, 1)]Real parts of complex conjugate eigenvalues
Realb[size(c0_in, 1)]Imaginary parts of complex conjugate eigenvalues
Realku[size(c0_in, 1)]Input gain

Function Modelica.​Blocks.​Continuous.​Internal.​Filter.​roots.​highPass
Return high pass filter roots as needed for block for given cut-off frequency

Information

The goal is to implement the filter in the following form:

  // real pole:
   der(x) = r*x - r*u
       y  = -x + u

  // complex conjugate poles:
  der(x1) = a*x1 - b*x2 + ku*u;
  der(x2) = b*x1 + a*x2;
       y  = k1*x1 + k2*x2 + u;

            ku = (a^2 + b^2)/b
            k1 = 2*a/ku
            k2 = (a^2 - b^2) / (b*ku)
               = (a^2 - b^2) / (a^2 + b^2)
               = (1 - (b/a)^2) / (1 + (b/a)^2)

This representation has the following transfer function:

// real pole:
    s*x = r*x - r*u
  or
    (s-r)*x = -r*u   -> x = -r/(s-r)*u
  or
    y = r/(s-r)*u + (s-r)/(s-r)*u
      = (r+s-r)/(s-r)*u
      = s/(s-r)*u

  comparing coefficients with
    y = s/(s + cr)*u  ->  r = -cr      // r is the real eigenvalue

// complex conjugate poles
    s*x2 =  a*x2 + b*x1
    s*x1 = -b*x2 + a*x1 + ku*u
  or
    (s-a)*x2               = b*x1  ->  x2 = b/(s-a)*x1
    (s + b^2/(s-a) - a)*x1 = ku*u  ->  (s(s-a) + b^2 - a*(s-a))*x1  = ku*(s-a)*u
                                   ->  (s^2 - 2*a*s + a^2 + b^2)*x1 = ku*(s-a)*u
  or
    x1 = ku*(s-a)/(s^2 - 2*a*s + a^2 + b^2)*u
    x2 = b/(s-a)*ku*(s-a)/(s^2 - 2*a*s + a^2 + b^2)*u
       = b*ku/(s^2 - 2*a*s + a^2 + b^2)*u
    y  = k1*x1 + k2*x2 + u
       = (k1*ku*(s-a) + k2*b*ku +  s^2 - 2*a*s + a^2 + b^2) /
         (s^2 - 2*a*s + a^2 + b^2)*u
       = (s^2 + (k1*ku - 2*a)*s + k2*b*ku - k1*ku*a + a^2 + b^2) /
         (s^2 - 2*a*s + a^2 + b^2)*u
       = (s^2 + (2*a-2*a)*s + a^2 - b^2 - 2*a^2 + a^2 + b^2) /
         (s^2 - 2*a*s + a^2 + b^2)*u
       = s^2 / (s^2 - 2*a*s + a^2 + b^2)*u

  comparing coefficients with
    y = s^2/(s^2 + c1*s + c0)*u  ->  a = -c1/2
                                     b = sqrt(c0 - a^2)

  comparing with eigenvalue representation:
    (s - (a+jb))*(s - (a-jb)) = s^2 -2*a*s + a^2 + b^2
  shows that:
    a: real part of eigenvalue
    b: imaginary part of eigenvalue

Extends from Modelica.​Icons.​Function (Icon for functions).

Inputs

TypeNameDescription
Realcr_in[:]Coefficients of real poles of base filter
Realc0_in[:]Coefficients of s^0 term of base filter if conjugate complex pole
Realc1_in[size(c0_in, 1)]Coefficients of s^1 term of base filter if conjugate complex pole
Frequencyf_cutCut-off frequency

Outputs

TypeNameDescription
Realr[size(cr_in, 1)]Real eigenvalues
Reala[size(c0_in, 1)]Real parts of complex conjugate eigenvalues
Realb[size(c0_in, 1)]Imaginary parts of complex conjugate eigenvalues
Realku[size(c0_in, 1)]Gains of input terms
Realk1[size(c0_in, 1)]Gains of y = k1*x1 + k2*x + u
Realk2[size(c0_in, 1)]Gains of y = k1*x1 + k2*x + u

Function Modelica.​Blocks.​Continuous.​Internal.​Filter.​roots.​bandPass
Return band pass filter roots as needed for block for given cut-off frequency

Information

The goal is to implement the filter in the following form:

  // complex conjugate poles:
  der(x1) = a*x1 - b*x2 + ku*u;
  der(x2) = b*x1 + a*x2;
       y  = k1*x1 + k2*x2;

            ku = (a^2 + b^2)/b
            k1 = cn/ku
            k2 = cn*a/(b*ku)

This representation has the following transfer function:

// complex conjugate poles
    s*x2 =  a*x2 + b*x1
    s*x1 = -b*x2 + a*x1 + ku*u
  or
    (s-a)*x2               = b*x1  ->  x2 = b/(s-a)*x1
    (s + b^2/(s-a) - a)*x1 = ku*u  ->  (s(s-a) + b^2 - a*(s-a))*x1  = ku*(s-a)*u
                                   ->  (s^2 - 2*a*s + a^2 + b^2)*x1 = ku*(s-a)*u
  or
    x1 = ku*(s-a)/(s^2 - 2*a*s + a^2 + b^2)*u
    x2 = b/(s-a)*ku*(s-a)/(s^2 - 2*a*s + a^2 + b^2)*u
       = b*ku/(s^2 - 2*a*s + a^2 + b^2)*u
    y  = k1*x1 + k2*x2
       = (k1*ku*(s-a) + k2*b*ku) / (s^2 - 2*a*s + a^2 + b^2)*u
       = (k1*ku*s + k2*b*ku - k1*ku*a) / (s^2 - 2*a*s + a^2 + b^2)*u
       = (cn*s + cn*a - cn*a) / (s^2 - 2*a*s + a^2 + b^2)*u
       = cn*s / (s^2 - 2*a*s + a^2 + b^2)*u

  comparing coefficients with
    y = cn*s / (s^2 + c1*s + c0)*u  ->  a = -c1/2
                                        b = sqrt(c0 - a^2)

  comparing with eigenvalue representation:
    (s - (a+jb))*(s - (a-jb)) = s^2 -2*a*s + a^2 + b^2
  shows that:
    a: real part of eigenvalue
    b: imaginary part of eigenvalue

Extends from Modelica.​Icons.​Function (Icon for functions).

Inputs

TypeNameDescription
Realcr_in[:]Coefficients of real poles of base filter
Realc0_in[:]Coefficients of s^0 term of base filter if conjugate complex pole
Realc1_in[size(c0_in, 1)]Coefficients of s^1 term of base filter if conjugate complex pole
Frequencyf_minBand of band pass filter is f_min (A=-3db) .. f_max (A=-3db)
Frequencyf_maxUpper band frequency

Outputs

TypeNameDescription
Reala[size(cr_in, 1) + 2 * size(c0_in, 1)]Real parts of complex conjugate eigenvalues
Realb[size(cr_in, 1) + 2 * size(c0_in, 1)]Imaginary parts of complex conjugate eigenvalues
Realku[size(cr_in, 1) + 2 * size(c0_in, 1)]Gains of input terms
Realk1[size(cr_in, 1) + 2 * size(c0_in, 1)]Gains of y = k1*x1 + k2*x
Realk2[size(cr_in, 1) + 2 * size(c0_in, 1)]Gains of y = k1*x1 + k2*x

Function Modelica.​Blocks.​Continuous.​Internal.​Filter.​roots.​bandStop
Return band stop filter roots as needed for block for given cut-off frequency

Information

The goal is to implement the filter in the following form:

  // complex conjugate poles:
  der(x1) = a*x1 - b*x2 + ku*u;
  der(x2) = b*x1 + a*x2;
       y  = k1*x1 + k2*x2 + u;

            ku = (a^2 + b^2)/b
            k1 = 2*a/ku
            k2 = (c0 + a^2 - b^2)/(b*ku)

This representation has the following transfer function:

// complex conjugate poles
    s*x2 =  a*x2 + b*x1
    s*x1 = -b*x2 + a*x1 + ku*u
  or
    (s-a)*x2               = b*x1  ->  x2 = b/(s-a)*x1
    (s + b^2/(s-a) - a)*x1 = ku*u  ->  (s(s-a) + b^2 - a*(s-a))*x1  = ku*(s-a)*u
                                   ->  (s^2 - 2*a*s + a^2 + b^2)*x1 = ku*(s-a)*u
  or
    x1 = ku*(s-a)/(s^2 - 2*a*s + a^2 + b^2)*u
    x2 = b/(s-a)*ku*(s-a)/(s^2 - 2*a*s + a^2 + b^2)*u
       = b*ku/(s^2 - 2*a*s + a^2 + b^2)*u
    y  = k1*x1 + k2*x2 + u
       = (k1*ku*(s-a) + k2*b*ku + s^2 - 2*a*s + a^2 + b^2) / (s^2 - 2*a*s + a^2 + b^2)*u
       = (s^2 + (k1*ku-2*a)*s + k2*b*ku - k1*ku*a + a^2 + b^2) / (s^2 - 2*a*s + a^2 + b^2)*u
       = (s^2 + c0 + a^2 - b^2 - 2*a^2 + a^2 + b^2) / (s^2 - 2*a*s + a^2 + b^2)*u
       = (s^2 + c0) / (s^2 - 2*a*s + a^2 + b^2)*u

  comparing coefficients with
    y = (s^2 + c0) / (s^2 + c1*s + c0)*u  ->  a = -c1/2
                                              b = sqrt(c0 - a^2)

  comparing with eigenvalue representation:
    (s - (a+jb))*(s - (a-jb)) = s^2 -2*a*s + a^2 + b^2
  shows that:
    a: real part of eigenvalue
    b: imaginary part of eigenvalue

Extends from Modelica.​Icons.​Function (Icon for functions).

Inputs

TypeNameDescription
Realcr_in[:]Coefficients of real poles of base filter
Realc0_in[:]Coefficients of s^0 term of base filter if conjugate complex pole
Realc1_in[size(c0_in, 1)]Coefficients of s^1 term of base filter if conjugate complex pole
Frequencyf_minBand of band stop filter is f_min (A=-3db) .. f_max (A=-3db)
Frequencyf_maxUpper band frequency

Outputs

TypeNameDescription
Reala[size(cr_in, 1) + 2 * size(c0_in, 1)]Real parts of complex conjugate eigenvalues
Realb[size(cr_in, 1) + 2 * size(c0_in, 1)]Imaginary parts of complex conjugate eigenvalues
Realku[size(cr_in, 1) + 2 * size(c0_in, 1)]Gains of input terms
Realk1[size(cr_in, 1) + 2 * size(c0_in, 1)]Gains of y = k1*x1 + k2*x
Realk2[size(cr_in, 1) + 2 * size(c0_in, 1)]Gains of y = k1*x1 + k2*x