Microwave filters GUI 2.0.3

- Main Page
- Related Pages
- Packages
- Classes
- Files

- Class List
- Class Hierarchy
- Class Members

Public Member Functions | List of all members
libcommonfunc.CouplingMatrices Class Reference

Coupling matrices class. More...

## Public Member Functions
def | __init__
| Compute Coupling Matrices for all the selected topologies.
def | matrixElementsEps
| Convenience function that computes the threshold to determine if coupling matrix elements (or their real or imaginary parts) are null.
def | updateCM_error
| Convenience function that updates the error estimation in self.CM_error.
def | transCouplingMatrix
| Computation of the transversal coupling matrix of the filter defined by its caracteristic polynomials and constants.
def | polyExDiv
| Polynomial exact division.
def | tcm2fcm
| This function transforms the transversal coupling matrix into the coupling matrix in Folded Canonical Form (FCM) .
def | tcm2arrow
| This function transforms the transversal coupling matrix into the coupling matrix in Arrow or Wheel Form .
def | arrow2triplet
| This function transforms the coupling matrix in Arrow or Wheel Form into the coupling matrix in Trisections Form .
def | fcm2culdesac
| This function transforms the coupling matrix in Folded Canonical Form (FCM) into the Cul de Sac coupling matrix .
def | fcm2cqs
| This function transforms the coupling matrix in Folded Canonical Form (FCM) into the Cascaded Quartets coupling matrix .
def | fcm2pfitzenmaier
| This function transforms the coupling matrix in Folded Canonical Form (FCM) into the Pfitzenmaier coupling matrix .
def | fcm2inlineAsymmetric
| This function transforms the coupling matrix in Folded Canonical Form (FCM) into the Inline Asymmetric coupling matrix .
def | fcm2inlineSymmetric
| This function transforms the coupling matrix in Folded Canonical Form (FCM) into the Inline Symmetric coupling matrix .
def | readCouplingMatrix
| Read coupling matrix from disk file.
def | saveCouplingMatrices
| Save coupling matrices in output file.
def | uniformQFCMOrder4
| This function transforms the Folded Canonical Form (FCM) coupling matrix of a filter of order 4 into an N+4 matrix so that all the resonant nodes have equal quality factor Q.
def | uniformQFCMOrder6
| This function transforms the Folded Canonical Form (FCM) coupling matrix of a filter of order 6 into an N+4 matrix so that all the resonant nodes have equal quality factor Q.
def | uniformQOrder6Optimize
| This function performs the hyperbolic rotations in TN102.3 sec.3.3.
def | uniformQFCMOrder6Case3
| This function transforms the Folded Canonical Form (FCM) coupling matrix of a filter of order 6 into an N+4 matrix so that all the resonant nodes have equal quality factor Q.
def | uniformQOrder6Case3Optimize
| This function performs the hyperbolic rotations in TN102.3.

## Detailed Description

Coupling matrices class.

    If \form#0 is the impedance matriz that relates the current at the network loops with the voltage sources within these loops,
    the compupling matriz \form#1 is such that [TN 102.1, sec. 3.2]:

Todo:
  Call numpy functions as methods of array class, whenever possible.

Definition at line 2844 of file libcommonfunc.py.

## Constructor & Destructor Documentation

def libcommonfunc.CouplingMatrices.__init__ | ( |  | self,
|  |  | P,
|  |  | CP,
|  |  | Yo,
|  |  | FT,
|  |  | SP
| ) |  |

Compute Coupling Matrices for all the selected topologies.

        @param P  = Parameters class instance, containing filter, synthesis and sweep parameters.
        @param CP = CharPolys class instance, containing Characteristic Polynomials Es, Ps, Fs and constants eps, epsR.
        @param Yo = Termination admitance.
        @param FT = Frequency transformation class instance.
        @param SP = SParameters class instance.
        @return CM = CouplingMatrices class instance.

Frequency transform used to compute these coupling matrices. It must be used when creating new matrices or reading matrices from disk. SParameters class instance containing the frequency sampling and SP.fromCouplingMatrix() method. Will be used in the sensitivity analysis. Uniform Q folded coupling matrix N+4. List of available coupling matrices Last index of CM selection comboBox. Initially it is equal to zero(first matrix in list). Roundoff error in the computation of the Tranversal Coupling Matrix N+2. The error is obtained as the maximum of the largest of the remainders in the computation of and and the constant term in the partial fraction expansion of Current coupling matrix, after rotations. Is the first in the list. Backup list of self.MatQ values, for undo. Must use deep copy, since self.MatQ will be modified by edit actions. Backup list of actions

Definition at line 2856 of file libcommonfunc.py.

References libcommonfunc.CouplingMatrices.arrow2triplet(), libcommonfunc.CouplingMatrices.bkpActions, libcommonfunc.CouplingMatrices.bkpMatQ, libcommonfunc.CouplingMatrices.CM_error, libcommonfunc.CouplingMatrices.fcm2cqs(), libcommonfunc.CouplingMatrices.fcm2culdesac(), libcommonfunc.CouplingMatrices.fcm2inlineAsymmetric(), libcommonfunc.CouplingMatrices.fcm2inlineSymmetric(), libcommonfunc.CouplingMatrices.fcm2pfitzenmaier(), libcommonfunc.CouplingMatrices.fCM_uniQ, libcommonfunc.Sparameters.FT, libcommonfunc.MatrixQ.FT, libcommonfunc.CouplingMatrices.FT, libcommonfunc.CouplingMatrices.indexCM, libcommonfunc.CouplingMatrices.listM, libcommonfunc.CouplingMatrices.MatQ, libcommonfunc.CouplingMatrices.SP, libcommonfunc.CouplingMatrices.tcm2arrow(), libcommonfunc.CouplingMatrices.tcm2fcm(), libcommonfunc.CouplingMatrices.transCouplingMatrix(), libcommonfunc.CouplingMatrices.uniformQFCMOrder4(), libcommonfunc.CouplingMatrices.uniformQFCMOrder6(), and libcommonfunc.CouplingMatrices.uniformQFCMOrder6Case3().

Here is the call graph for this function:

## Member Function Documentation

def libcommonfunc.CouplingMatrices.arrow2triplet | ( |  | self,
|  |  | MatQarrow,
|  |  | TZ
| ) |  |

This function transforms the coupling matrix in Arrow or Wheel Form into the coupling matrix in Trisections Form .

Parameters

  MatQarrow | = MatrixQ class instance, containing the Arrow topology coupling matrix.
  TZ | = Transmission Zeros.

Returns
  MatQtriplet = MatrixQ class instance, containing the Trisections topology coupling matrix.

[Cameron]

Definition at line 3431 of file libcommonfunc.py.

Referenced by libcommonfunc.CouplingMatrices.__init__().

Here is the caller graph for this function:

def libcommonfunc.CouplingMatrices.fcm2cqs | ( |  | self,
|  |  | MatQfcm,
|  |  | r,
|  |  | UpDownNone
| ) |  |

This function transforms the coupling matrix in Folded Canonical Form (FCM) into the Cascaded Quartets coupling matrix .

Parameters

  MatQfcm | = MatrixQ class instance, containing the Folded Canonical Form (FCM) coupling matrix.
  r | = If we want to shift the quartet, r indicates the position of the first resonator node of the quartet. It should be 0 if we do not want to shift it.
  UpDownNone | = 'Up' : Shift the quartet above the diagonal. 'Down' : Shift the quartet below the diagonal. 'None' : No shifting.

Returns
  MatQcqs = MatrixQ class instance, containing the Cascaded Quartets coupling matrix.

[Cameron]

Definition at line 3507 of file libcommonfunc.py.

Referenced by libcommonfunc.CouplingMatrices.__init__().

Here is the caller graph for this function:

def libcommonfunc.CouplingMatrices.fcm2culdesac | ( |  | self,
|  |  | MatQfcm,
|  |  | TZ
| ) |  |

This function transforms the coupling matrix in Folded Canonical Form (FCM) into the Cul de Sac coupling matrix .

Parameters

  MatQfcm | = MatrixQ class instance, containing the Folded Canonical Form (FCM) coupling matrix.
  TZ | = Transmission Zeros.

Returns
  MatQculdesac = MatrixQ class instance, containing the Cul de Sac coupling matrix.

[Cameron]

Definition at line 3466 of file libcommonfunc.py.

Referenced by libcommonfunc.CouplingMatrices.__init__().

Here is the caller graph for this function:

def libcommonfunc.CouplingMatrices.fcm2inlineAsymmetric | ( |  | self,
|  |  | MatQfcm
| ) |  |

This function transforms the coupling matrix in Folded Canonical Form (FCM) into the Inline Asymmetric coupling matrix .

Parameters

  MatQfcm | = MatrixQ class instance, containing the Folded Canonical Form (FCM) coupling matrix.

Returns
  MatQinasym = MatrixQ class instance, containing the Inline Asymmetric coupling matrix.

[Cameron]

Definition at line 3601 of file libcommonfunc.py.

Referenced by libcommonfunc.CouplingMatrices.__init__().

Here is the caller graph for this function:

def libcommonfunc.CouplingMatrices.fcm2inlineSymmetric | ( |  | self,
|  |  | MatQfcm,
|  |  | TZ
| ) |  |

This function transforms the coupling matrix in Folded Canonical Form (FCM) into the Inline Symmetric coupling matrix .

Parameters

  MatQfcm | = MatrixQ class instance, containing the Folded Canonical Form (FCM) coupling matrix.
  TZ | = Transmission Zeros.

Returns
  MatQinsym = MatrixQ class instance, containing the Inline Symmetric coupling matrix.

[Cameron]

Definition at line 3687 of file libcommonfunc.py.

Referenced by libcommonfunc.CouplingMatrices.__init__().

Here is the caller graph for this function:

def libcommonfunc.CouplingMatrices.fcm2pfitzenmaier | ( |  | self,
|  |  | MatQfcm
| ) |  |

This function transforms the coupling matrix in Folded Canonical Form (FCM) into the Pfitzenmaier coupling matrix .

Parameters

  MatQfcm | = MatrixQ class instance, containing the Folded Canonical Form (FCM) coupling matrix.

Returns
  MatQpfi = MatrixQ class instance, containing the Pfitzenmaier coupling matrix.

[Cameron]

Definition at line 3574 of file libcommonfunc.py.

Referenced by libcommonfunc.CouplingMatrices.__init__().

Here is the caller graph for this function:

def libcommonfunc.CouplingMatrices.matrixElementsEps | ( |  | self,
|  |  | st = `None`
| ) |  |

Convenience function that computes the threshold to determine if coupling matrix elements (or their real or imaginary parts) are null.

Parameters

  st | = String with relevant info. Default None.

Returns
  eps = Threshold.

Definition at line 2962 of file libcommonfunc.py.

References libcommonfunc.CouplingMatrices.CM_error, and libcommonfunc.myPrint().

Here is the call graph for this function:

def libcommonfunc.CouplingMatrices.polyExDiv | ( |  | self,
|  |  | num,
|  |  | den
| ) |  |

Polynomial exact division.

Computes quot and remain polynomials so that num(s) = quot(s)*den(s) + error(s).

Parameters

  num | = Dividend.
  den | = Divisor.

Returns
  quot = Quotient.
  error = Error in the computation of the quotient. Is equal to: num(s)-quot(s)*den(s)

# Algorithm

Since numpy.polydiv or the equivalent numpy.poly1d polynomial division fails for complex coefficients, at least in numpy v1.1.1, here we evaluate num(s)/den(s) for a finite number of points in the imaginary axis and use polyfit to build the polynomial that passes trhough this points. The remainder is the error.

This function does not work well with the example in "Prescribed_insertion_losses_K11+k21_asymmetrical.par" (the example in journal paper publication), while numpy.polydiv from numpy v1.3.0 works perfectly.

Definition at line 3318 of file libcommonfunc.py.

def libcommonfunc.CouplingMatrices.readCouplingMatrix | ( |  | self,
|  |  | fileName
| ) |  |

Read coupling matrix from disk file.

Parameters

  fileName | = File name (string).

Returns
  MatQ = Coupling matrix (MatrixQ class instance.)

Definition at line 3829 of file libcommonfunc.py.

References libcommonfunc.Sparameters.FT, libcommonfunc.MatrixQ.FT, libcommonfunc.CouplingMatrices.FT, and libcommonfunc.myPrint().

Here is the call graph for this function:

def libcommonfunc.CouplingMatrices.saveCouplingMatrices | ( |  | self,
|  |  | P,
|  |  | SP,
|  |  | precCM,
|  |  | precEP
| ) |  |

Save coupling matrices in output file.

The matrices are attributes of CouplingMatrices class, and of type numpy.array.

Parameters

  P | = Parameter class instance.
  SP | = SParameters class instance.
  precCM | = Number of significant digits to save in coupling matrix and Q (int).
  precEP | = Number of significant digits to save in energy and power (int).

Definition at line 3876 of file libcommonfunc.py.

References libcommonfunc.CouplingMatrices.listM, and libcommonfunc.myPrint().

Here is the call graph for this function:

def libcommonfunc.CouplingMatrices.tcm2arrow | ( |  | self,
|  |  | MatQ
| ) |  |

This function transforms the transversal coupling matrix into the coupling matrix in Arrow or Wheel Form .

Parameters

  MatQ | = MatrixQ class instance, containing the transversal coupling matrix.

Returns
  MatQarrow = MatrixQ class instance, containing the Arrow topology coupling matrix.

[Cameron]

Definition at line 3406 of file libcommonfunc.py.

Referenced by libcommonfunc.CouplingMatrices.__init__().

Here is the caller graph for this function:

def libcommonfunc.CouplingMatrices.tcm2fcm | ( |  | self,
|  |  | MatQ
| ) |  |

This function transforms the transversal coupling matrix into the coupling matrix in Folded Canonical Form (FCM) .

        @param MatQ = MatrixQ class instance, containing the transversal \form#189 coupling matrix.
        @return MatQfcm =  MatrixQ class instance, containing the Folded Canonical Form (FCM) coupling matrix.

        [TN 102.2 sec. 9.2]
        The procedure to obtain the matrix [FCM] consists in setting to zero step by step elements of the matrix [M] using the following:

        -Step 1: We remove all the elements of the row 1 (In total there are nerk(1) elements).

        -Step 2: We remove all the elements of the column 1 (In total there are neck(1) elements).

        -Step 3: The same as in step 1 with the row 2 (In total there are nerk(2) elements).

        -Step 4: The same as in step 2 with the column 2 (In total there are neck(2) elements).

        -Step numSteps-1:  We remove all the elements of the row numRows (In total there are nerk(numRows) elements).

        -Step numSteps: We remove all the elements of the column numColumns (In total there are nerk(numColumns) elements).

        The last two steps consist in removing the last remaining row and the last remaining column of the matrix (it is not necessary that they are in that order).

Definition at line 3352 of file libcommonfunc.py.

Referenced by libcommonfunc.CouplingMatrices.__init__().

Here is the caller graph for this function:

def libcommonfunc.CouplingMatrices.transCouplingMatrix | ( |  | self,
|  |  | P,
|  |  | CP,
|  |  | Yo,
|  |  | FT
| ) |  |

Computation of the transversal coupling matrix of the filter defined by its caracteristic polynomials and constants.

            Polynomials are of type numpy.poly1d.
            This function sets the self.CM_error attribute to the roundoff error in the computation of M,
            given by the largest of the remainders in the computation of \form#128 and \form#129
            and the constant term in the partial fraction expansion of \form#130
            @param P  = Parameters class instance, containing filter, synthesis and sweep parameters.
            @param CP = CharPolys class instance, containing Characteristic Polynomials Es, Ps, Fs and constants eps, epsR.
            @param Yo = Termination admitance.
            @param FT = Frequency transformation class instance.
            @return MatQ = MatrixQ class instance, containing the N+2 transversal coupling matrix.

        @section Smat Scattering matrix [S]

        The first step to find the \form#131 transversal coupling matrix of a two-port network is finding the associated scattering matrix \form#132.

        By definition, the scattering matrix of a two-port network is  [TN 102.1, eq (1)]:

       The [S] parameters are computed from the polinomials as:

except for asymmetrical "Prescribed Insertion Loss technique" case 1 (kS21+kS11), where [S] parameters are computed from the lossless case above as:

        and hence the numerators and denominator of the \form#137 rational polynomials are:

except for asymmetrical "Prescribed Insertion Loss technique" case 1 (kS21+kS11), where they are computed as

In practice, the software divides by and by , and stores the updated values to automatically apply the and whenever computing and .

# Admitance matrix [Y]

The next step is the computation of and of the admitance matrix . [Y] is related to [S] as [TN 102.1, eq (12)]:

Where:

= Load admitance at the end of the network.

        @section Mmat N+2 Coupling Matrix
        A partial fraction expansion of \form#156 yields [Cameron, eq. (8.41)] [TN 101.1, eq (12)]:

        <ul>

        <li> Computation of the residuals \form#158 and \form#159:

        The residuals \form#158 and \form#159 can be found as [Cameron, pp. 294, footnote]:

        where:
            <ul>
            <li> \form#161 is the first derivative of \form#162. It is variable Ydp in the code.
            <li> \form#163 are the roots of \form#161.
            </ul>
        The residuals are actually computed using scipy.signal.residue() function in order to obtain the constant terms:
            <ul>
            <li>In \form#164 the constant term is the source-load coupling term \form#165 :

In and , "Prescribed Insertion Loss technique" case 1, there is a constant term that must be included in the N+2 transversal coupling matrix [TN 102.1, eq (13)]:

Computation of :

is a real constant equal to 0 except for fully canonical filters where the number of finite-position transmission zeros is equal to the filter degree . For lossless filters it can be computed as [Cameron, eq (8.43a)]:

However, this formula is not valid for lossy synthesis, so we set equal to the imaginary part of the constant term in the polynomial expansion of .

Computation of the eigenvectors and :

The eigenvectors and can be found as [Cameron eq. (8.55)]:

        <li> Build the \form#131 transversal coupling matrix \form#79:

        The \form#131 transversal coupling matrix is built from the orthogonal vectors \form#178 and \form#177
        and from the eigenvalues \form#181, as follows [Cameron, fig 8.18]:

The steps to build the matrix are the following:

1. We put the vector T1k at the first row (between the first and the last column not-included)
2. We put the value of Kinf at the last column of the first row
3. We put the vector TNk at the last column (between the first and the last row not-included)
4. As the matrix M is symmetric, we copy the upper triangle to the lower
5. We put the lambdak (with opposite sign) at the main diagonal (between the first and the last element not-included)
6. If there is a remaining constants and in the partial fraction expansion of and , set M[0,0] to and M[N+1,N+1] to .

Todo:
  The function "r21k, p21k, remainder = sc.signal.residue(Y21np,Yd)" does not give the correct remainder when it is complex but in the tested cases it does not afect. This function should be improved for the future.

Definition at line 3168 of file libcommonfunc.py.

References libcommonfunc.CouplingMatrices.CM_error, and libcommonfunc.myPrint().

Referenced by libcommonfunc.CouplingMatrices.__init__().

Here is the call graph for this function:

Here is the caller graph for this function:

def libcommonfunc.CouplingMatrices.uniformQFCMOrder4 | ( |  | self,
|  |  | MatQfcm2
| ) |  |

This function transforms the Folded Canonical Form (FCM) coupling matrix of a filter of order 4 into an N+4 matrix so that all the resonant nodes have equal quality factor Q.

        (Valid for Butterworth, Chevyshev, Quasieliptic and Generalized Chebyshev with symmetric transmission zeros).
        @param MatQfcm2 = MatrixQ class instance, containing the Folded \form#189 Canonical Form (FCM) coupling matrix.
        @return MatQfcm4 = MatrixQ class instance, containing the Folded \form#200 Canonical Form (FCM) coupling matrix with uniform Q.

        For a better description see TN102.3 sec. 3.2.

        First of all we add two non-resonant nodes, what means converting the N+2 folded matrix into the N+4. Then we apply two hyperbolic rotations so that we have a uniform Q. For doing so, it can be proved that the necessary angle is (TN102.3 eq. (10)):

Finally, we need to re-scale with a value so that the non-resonant nodes have a sum of imaginary parts equal to 0.

Definition at line 3904 of file libcommonfunc.py.

Referenced by libcommonfunc.CouplingMatrices.__init__().

Here is the caller graph for this function:

def libcommonfunc.CouplingMatrices.uniformQFCMOrder6 | ( |  | self,
|  |  | MatQfcm2
| ) |  |

This function transforms the Folded Canonical Form (FCM) coupling matrix of a filter of order 6 into an N+4 matrix so that all the resonant nodes have equal quality factor Q.

(Valid for Butterworth, Chevyshev, Quasieliptic and Generalized Chebyshev with symmetric transmission zeros).

Parameters

  MatQfcm2 | = MatrixQ class instance, containing the Folded Canonical Form (FCM) coupling matrix.

Returns
  MatQfcm4 = MatrixQ class instance, containing the Folded Canonical Form (FCM) coupling matrix with uniform Q.

See TN102.3 sec. 3.3.

Definition at line 3945 of file libcommonfunc.py.

References libcommonfunc.CouplingMatrices.uniformQOrder6Optimize().

Referenced by libcommonfunc.CouplingMatrices.__init__().

Here is the call graph for this function:

Here is the caller graph for this function:

def libcommonfunc.CouplingMatrices.uniformQFCMOrder6Case3 | ( |  | self,
|  |  | MatQfcm2
| ) |  |

This function transforms the Folded Canonical Form (FCM) coupling matrix of a filter of order 6 into an N+4 matrix so that all the resonant nodes have equal quality factor Q.

(Valid for Butterworth, Chevyshev, Quasieliptic and Generalized Chebyshev with symmetric transmission zeros).

Parameters

  MatQfcm2 | = MatrixQ class instance, containing the Folded Canonical Form (FCM) coupling matrix.

Returns
  MatQfcm4 = MatrixQ class instance, containing the Folded Canonical Form (FCM) coupling matrix with uniform Q.

Definition at line 4008 of file libcommonfunc.py.

References libcommonfunc.CouplingMatrices.uniformQOrder6Case3Optimize().

Referenced by libcommonfunc.CouplingMatrices.__init__().

Here is the call graph for this function:

Here is the caller graph for this function:

def libcommonfunc.CouplingMatrices.uniformQOrder6Case3Optimize | ( |  | self,
|  |  | angRot,
|  |  | MatQfcm2a,
|  |  | flag
| ) |  |

This function performs the hyperbolic rotations in TN102.3.

Given four angles angRot it performs the hyperbolic rotations with those angles. and sees the differences between the quality factors of the different nodes [TN102.3].

Parameters

  angRot | = Vector containing two angles. The first angle corresponds with in TN102.3 eq. (14) and the second one with
  MatQfcm2a | = MatrixQ class instance, containing the Folded Canonical Form (FCM) coupling matrix.
  flag | = If False, return goal; if True, return MatQfcm2.

Returns
  goal = Function we are minimizing. It contains the summation of the absolute values of the diferences in losses in the different nodes.
  MatQfcm2 = MatrixQ class instance, containing the transformed Folded Canonical Form (FCM) coupling matrix.

Definition at line 4038 of file libcommonfunc.py.

Referenced by libcommonfunc.CouplingMatrices.uniformQFCMOrder6Case3().

Here is the caller graph for this function:

def libcommonfunc.CouplingMatrices.uniformQOrder6Optimize | ( |  | self,
|  |  | angRot,
|  |  | MatQfcm2a,
|  |  | flag
| ) |  |

This function performs the hyperbolic rotations in TN102.3 sec.3.3.

Given two angles angRot it performs the hyperbolic rotations with those angles and sees the differences between the quality factors of the different nodes [TN102.3 sec.3.3].

Parameters

  angRot | = Vector containing two angles. The first angle corresponds with in TN102.3 eq. (14) and the second one with
  MatQfcm2a | = MatrixQ class instance, containing the Folded Canonical Form (FCM) coupling matrix.
  flag | = If False, return goal; if True, return MatQfcm2.

Returns
  goal = Function we are minimizing. It contains the summation of the absolute values of the diferences in losses in the different nodes.
  MatQfcm2 = MatrixQ class instance, containing the transformed Folded Canonical Form (FCM) coupling matrix.

Definition at line 3975 of file libcommonfunc.py.

Referenced by libcommonfunc.CouplingMatrices.uniformQFCMOrder6().

Here is the caller graph for this function:

def libcommonfunc.CouplingMatrices.updateCM_error | ( |  | self,
|  |  | CM_error,
|  |  | st = `None`
| ) |  |

Convenience function that updates the error estimation in self.CM_error.

Parameters

  CM_error | = New error estimation.
  st | = String with relevant info. Default None.

Definition at line 2979 of file libcommonfunc.py.

References libcommonfunc.CouplingMatrices.CM_error, and libcommonfunc.myPrint().

Here is the call graph for this function:

The documentation for this class was generated from the following file:

- libcommonfunc.py