Microwave filters GUI  2.0.3
Public Member Functions | List of all members
libcommonfunc.MatrixQ Class Reference

Class that contains a coupling matrix, its name, the number of non-resonant nodes, the Q of resonators and some operations. More...

Public Member Functions

def __init__
 Initialize MatrixQ class.
def copy
 Function to copy instances of the MatrixQ class (copies the self instance).
def setName
 Function to set name field of the instance of the MatrixQ class.
def setFileExt
 Function to set file extension field of the instance of the MatrixQ class.
def Qresonators
 Compute the quality factors of each resonant node of coupling matrix self.M.
def lp2bp2cbw
 Compute bandpass and coupling bandwidth versions of the matrix.
def rotateMatrix
 Rotate the coupling matrix self.M.
def inflateMatrix
 Add external non-resonant nodes to the coupling matrix self.M at the source or load sides, or both.
def scaleNode
 Scale a node of the coupling matrix self.M, by multiplying row [i] and column [i] by a factor.
def rotAngleEliminate
 Compute the rotation angle such that, after applying a rotation of type rotationType, the element $ M[m,n] $ of the matrix self.M is equal to zero.
def addLossesQeff
 Add losses to resonators by substracting a factor 1/(Qeff*FBW) to the diagonal of the coupling matrix.
def setupOptimTopology
 Prepare optimization parameters depending on matrix topology and forced signs.
def newMatQFromNonZero
 Return a new MatrixQ object that is a copy of self, except for the M matrix which is created from the NonZeroValues, NonZeroReal, NonZeroImag and Q parameters.
def uniformQ
 Optimize the coupling matrix to achieve a prescribed uniform Q and [S] parameters as close as possible to those computed from the characteristic polynomials.
def uniformQOptimize
 Optimization objective function for uniformQ function.
def uniformQMask
 Optimize the coupling matrix to achieve a prescribed uniform Q and [S] parameters that comply with a specification mask.
def uniformQOptimizeMask
 Optimization objective function for uniformQMask function.
def saveMat
 Save this MatrixQ instance to an ascii file, including energy and power.
def __str__
 Convert numpy matrix to string representation.

Detailed Description

Class that contains a coupling matrix, its name, the number of non-resonant nodes, the Q of resonators and some operations.

Definition at line 1566 of file libcommonfunc.py.

Constructor & Destructor Documentation

def libcommonfunc.MatrixQ.__init__ (   self,
  parent,
  M,
  name,
  extraNodesS,
  extraNodesL,
  FT,
  fileExt = None,
  nodeScalingFactor = None,
  flagRotateAllowed = True 
)

Initialize MatrixQ class.

Computes Q of resonators and stores the vector of Q values in self.Q .

Parameters
parent= CouplingMatrices class instance to which this coupling matrix belongs.
M= Coupling matrix.
name= Matrix name.
extraNodesS= Number of extra rows and columns in current matrix M at the source side (non-resonant nodes).
extraNodesL= Number of extra rows and columns in current matrix M at the load side (non-resonant nodes).
FT= Frequency transformation class instance.
fileExt= Extension of file name, if this matrix is to be automatically saved in a file (with the output file name in the parameters class). If equal to None, this matrix is not automatically saved. Anyway the matrix can be manually saved. Default None.
nodeScalingFactor= Vector containing in each node position the factor of the node scaling applied to that node. Default None.
flagRotateAllowed= Flag that indicates if it is allowed to do a matrix rotation (Impossible after a resonant node scaling). Default True. Coupling matrix Matrix order Number of extra rows and columns in current matrix M at the source side (non-resonant nodes). Number of extra rows and columns in current matrix M at the load side (non-resonant nodes). Matrix name. It is converted to unicode to allow safe comparison with matrix names entered by the user in Matrix Edit Gui. Frequency transform to use when computing Q of resonators. Extension of file name, if this matrix is to be saved in a file. Otherwise None. CouplingMatrices class instance to which this coupling matrix belongs. Band pass version of the matrix Coupling bandwidth version of the matrix Coupling bandwidth with transmission lines version of the matrix Labels for rows and columns. Will be used for saving energy and power. Characteristic impedance of resonators Characteristic impedance of source Characteristic impedance of load

Definition at line 1582 of file libcommonfunc.py.

References libcommonfunc.MatrixQ.extraNodesL, libcommonfunc.MatrixQ.extraNodesS, libcommonfunc.MatrixQ.fileExt, libcommonfunc.MatrixQ.flagRotateAllowed, libcommonfunc.Sparameters.FT, libcommonfunc.MatrixQ.FT, libcommonfunc.MatrixQ.M, libcommonfunc.MatrixQ.Mbp, libcommonfunc.MatrixQ.Mcbw, libcommonfunc.MatrixQ.McbwTL, libcommonfunc.MatrixQ.name, dbplot.CurveFamily.name, libcommonfunc.MatrixQ.nodeScalingFactor, libcommonfunc.MatrixQ.order, libcommonfunc.MatrixQ.parent, libcommonfunc.MatrixQ.Qresonators(), libcommonfunc.MatrixQ.rowIndices, libcommonfunc.MatrixQ.Zo, libcommonfunc.MatrixQ.ZoL, and libcommonfunc.MatrixQ.ZoS.

Here is the call graph for this function:

Member Function Documentation

def libcommonfunc.MatrixQ.__str__ (   self,
  prec = 5 
)

Convert numpy matrix to string representation.

Rounds coupling matrix elements to given precision using complexStr() function.

Parameters
prec= Number of significant digits (int). Default 5.
Returns
st = String representation of the numpy matrix self.M.

Definition at line 2791 of file libcommonfunc.py.

References libcommonfunc.complexStr(), libcommonfunc.MatrixQ.lp2bp2cbw(), libcommonfunc.MatrixQ.M, libcommonfunc.MatrixQ.Mcbw, libcommonfunc.MatrixQ.McbwTL, libcommonfunc.MatrixQ.name, and dbplot.CurveFamily.name.

Referenced by libcommonfunc.MatrixQ.saveMat().

Here is the call graph for this function:

Here is the caller graph for this function:

def libcommonfunc.MatrixQ.addLossesQeff (   self,
  Qeff 
)

Add losses to resonators by substracting a factor 1/(Qeff*FBW) to the diagonal of the coupling matrix.

The typical application is to set a prescribed flatness in the ideal response of a lossy filter synthesis by emulating the non-flat response of a lossy filter of quality factor equal to Qeff. Qeff = Quality factor of the resonators to emulate.

Definition at line 2216 of file libcommonfunc.py.

References libcommonfunc.MatrixQ.extraNodesL, libcommonfunc.MatrixQ.extraNodesS, and libcommonfunc.MatrixQ.M.

def libcommonfunc.MatrixQ.copy (   self)
def libcommonfunc.MatrixQ.inflateMatrix (   self,
  position 
)

Add external non-resonant nodes to the coupling matrix self.M at the source or load sides, or both.

    The resulting self.M matrix will have one or two columns and rows more than the input one.
    @param position = Position where we want to inflate the matrix (string). It can be 'source', 'load' or 'both'.

    If position == 'source'

\[ Minflate=\begin{bmatrix} 0 & k_1 & 0 & \hdots \\ k_1 & & & \\ 0 & & M & \\ \vdots & & & \end{bmatrix} \]

    If position == 'load'

\[ Minflate=\begin{bmatrix} & & & \vdots \\ & M & & 0 \\ & & & k_2 \\ \hdots & 0 & k_2 & 0 \end{bmatrix} \]

    If position == 'both'

\[ Minflate=\begin{bmatrix} 0 & k_1 & 0 & \hdots & 0 \\ k_1 & & & & \vdots \\ 0 & & M & & 0 \\ \vdots & & & & k_2 \\ 0 & \hdots & 0 & k_2 & 0 \end{bmatrix} \]

    where \form#117 and \form#118 are usually equal to 1 unless the first or last nodes of the matrix have been previously scaled by respective values \form#117 and \form#118 with node-scaling operations. 
    If this is the case, the value of \form#117 and \form#118 for that nodes are retrieved from the self.nodeScalingFactor attribute.

Definition at line 2058 of file libcommonfunc.py.

References libcommonfunc.MatrixQ.extraNodesL, libcommonfunc.MatrixQ.extraNodesS, libcommonfunc.MatrixQ.M, and libcommonfunc.MatrixQ.nodeScalingFactor.

def libcommonfunc.MatrixQ.lp2bp2cbw (   self)

Compute bandpass and coupling bandwidth versions of the matrix.

    <b>Coupling bandwidth matrix</b>

    The diagonal elements of the coupling bandwidth matrix \form#84 is obtained as:

\[ \Delta f_{ii} = f_i \]

where the unnormalised resonant frequencies (Hz) of the resonators are:

\[ f_i = \frac {f_0}{2} \left( \omega'' + \sqrt{ \omega'' \, ^2 + 4 } \right) \]

with $ \omega'' = - B_i \Delta f / f_0 $ and $ B_i = \Re M_{ii} $ . The factor $ \Delta f / f_0 $ is the fractional bandwidth.

For non-resonant nodes $ f_i = f_0 $ .

The couplings with source and load are:

\[ \Delta f_{Si} = M_{Si}^2 \Delta f \qquad \Delta f_{Li} = M_{Li}^2 \Delta f \]

\[ \Delta f_{SS} = \Delta f_{LL} = 0 \]

where $ M_{ij} $ are the normalised low-pass coupling matrix elements and $ \Delta f $ is the bandwidth (MHz).

The couplings between inner nodes (resonators or non-resonant nodes) are:

\[ \Delta f_{ij} = M_{ij} \Delta f \]

    <b>Coupling bandwidth matrix with transmission lines </b>

    For each matrix element \form#96, the scaling factor for the pass-band coupling matrix is 

\[ K_{ij} = \alpha_{ij} M_{ij} \]

where $ [M] $ is the low-pass normalised matrix and $ [K] $ is the pass-band coupling matrix.

\[ \alpha_{ij} = \frac{\pi}{2} \frac{\mathrm{FBW}}{Z_0} \qquad \mathrm{if} \; i \; \mathrm{and} \; j \neq S \; \mathrm{or} \; L \]

\[ \alpha_{ij} = \sqrt{\frac{\pi}{2} \frac{\mathrm{FBW}}{Z_0 Z_{S,L}}} \qquad \mathrm{if} \; i \; \mathrm{or} \; j = S \; \mathrm{or} \; L \]

\[ \alpha_{SS} = \alpha_{SL} = \alpha_{LS} = \alpha_{LL} = 1 \]

\[ Z_0 = Z_S = Z_L = 50 \Omega \]

      The diagonal elements of the coupling bandwidth matrix \form#84 is obtained as:

\[ \Delta f_{ii} = f_i \]

where the unnormalised resonant frequencies (Hz) of the resonators are:

\[ f_i = \frac {f_0}{2} \left( \omega'' + \sqrt{ \omega'' \, ^2 + 4 } \right) \]

with $ \omega'' = - B_i \Delta f / f_0 $ and $ B_i = \Re M_{ii} $ . The factor $ \Delta f / f_0 $ is the fractional bandwidth.

For non-resonant nodes $ f_i = f_0 $ .

The couplings with source and load are:

\[ \Delta f_{Si} = \frac{f0}{K_{Si}} \qquad \Delta f_{Li} = \frac{f0}{K_{Li}} \]

\[ \Delta f_{SS} = \Delta f_{LL} = 0 \]

      The couplings between inner nodes (resonators or non-resonant nodes) are:

\[ \Delta f_{ij} = f_0 \sqrt{ \left( \frac{K_{ij}}{A} \right) ^2 + C } \]

with

\[ A = \frac{1}{2} \left( \frac{f_j}{f_i} + \frac{f_i}{f_j} \right) \]

\[ C = \left| \frac{f_j^2 - f_i^2}{f_j^2 + f_i^2} \right| ^2 \]

      For syncronous nodes, \form#90 and therefore

\[ A = 1 \qquad C = 0 \]

\[ \Delta f_{ij} = K_{ij} f_0 \]

Definition at line 1851 of file libcommonfunc.py.

References libcommonfunc.MatrixQ.M, libcommonfunc.MatrixQ.Mbp, libcommonfunc.MatrixQ.Mcbw, libcommonfunc.MatrixQ.McbwTL, libcommonfunc.MatrixQ.Zo, libcommonfunc.MatrixQ.ZoL, and libcommonfunc.MatrixQ.ZoS.

Referenced by libcommonfunc.MatrixQ.__str__().

Here is the caller graph for this function:

def libcommonfunc.MatrixQ.newMatQFromNonZero (   self,
  NonZeroValues,
  NonZeroReal,
  NonZeroImag,
  numReal,
  Q 
)

Return a new MatrixQ object that is a copy of self, except for the M matrix which is created from the NonZeroValues, NonZeroReal, NonZeroImag and Q parameters.

Parameters
NonZeroValues= Double numpy vector with the values of the matrix entries which are different from zero. It is a concatenation of the non-zero real elements and the non-zero imaginary elements.
NonZeroReal= Bool numpy array having True values at the position of coupling matrix entries with non-zero real part in the upper-triangular part, including the diagonal, of the matrix.
NonZeroImag= Bool numpy array having True values at the position of coupling matrix entries with non-zero imaginary part in the upper-triangular part, including the diagonal, of the matrix. The entries corresponding to resonators are False, since the imaginary part will be obtained from the prescribed Q.
numReal= Number of entries in the upper triangular part of the matrix, including the diagonal, with non-zero real part.
Q= Prescribed uniform Q for the resonators.
Returns
newMatQ = New MatrixQ object

Definition at line 2314 of file libcommonfunc.py.

References libcommonfunc.MatrixQ.extraNodesL, libcommonfunc.MatrixQ.extraNodesS, libcommonfunc.MatrixQ.fileExt, libcommonfunc.MatrixQ.flagRotateAllowed, libcommonfunc.Sparameters.FT, libcommonfunc.MatrixQ.FT, libcommonfunc.MatrixQ.name, dbplot.CurveFamily.name, libcommonfunc.MatrixQ.nodeScalingFactor, libcommonfunc.MatrixQ.order, and libcommonfunc.MatrixQ.parent.

Referenced by libcommonfunc.MatrixQ.uniformQ(), libcommonfunc.MatrixQ.uniformQMask(), libcommonfunc.MatrixQ.uniformQOptimize(), and libcommonfunc.MatrixQ.uniformQOptimizeMask().

Here is the caller graph for this function:

def libcommonfunc.MatrixQ.Qresonators (   self)

Compute the quality factors of each resonant node of coupling matrix self.M.

    Frequency transform is self.FT and output Q is stored in self.Q.

    For each node \form#62, the quality factor is 

\[ Q_{n} = \frac{1}{G_n \, \mathrm{FBW}} \]

where the loss conductance of the unloaded resonator is:

\[ G_{n} = - \sum_{k} \Im M_{kn} \]

    <b> Proof: </b>

    In the parallel N+2 normalized lowpass prototype equivalent circuit, at each node we have current excitation \form#65 equal to 
    the current that flows away from the node through the circuit elements and couplings:

\[ I_n = \left( G_n + j B_n + s C_n \right) V_n + \sum_{k \neq n} j M'_{nk} V_k + \sum_{k \neq n} G_{nk} (V_n - V_k) \]

where $ M'_{kn} $ are the real couplings, $ G_n $ is the unloaded resonator conductance (losses), $ G_{kn} $ is the conductance of resistive couplings between resonators and, obviously, the excitation is $ I_n = 0 $ for $ n \neq S $ . For $ n = S $ we have $ I_n = I_S $ (source) .

If we define the mutual admittances between nodes as:

\[ Y_{nm} = \left. \frac{I_n}{V_m} \right|_{V_{k \neq m}= 0} \]

we have

\[ Y_{nn} = G_n + j B_n + s C_n + \sum_{k \neq n} G_{kn} \]

and

\[ Y_{nm} = j M'_{nm} - G_{nm} \]

In matrix form, with $ C_n = 1 $ :

\[ [Y] = j[M] + s [I] \]

where the elements of the coupling matrix $ [M] $ are:

\[ M_{nn} = \frac{Y_{nn} - s}{j} = B_n - j G_{n} - j \sum_{k \neq n} G_{kn} \]

and

\[ M_{nm} = \frac{Y_{nm}}{j} = M'_{nm} + j G_{nm} \]

Therefore:

\[ \Im M_{nn} = - G_{n} - \sum_{k \neq n} G_{kn} = - G_{n} - \sum_{k \neq n} \Im M_{kn} \]

and we can compute the resonator unloaded conductance as:

\[ G_{n} = - \Im M_{nn} - \sum_{k \neq n} \Im M_{kn} = - \sum_{k} \Im M_{kn} \]

Q of resonators

Definition at line 1741 of file libcommonfunc.py.

References libcommonfunc.MatrixQ.extraNodesL, libcommonfunc.MatrixQ.extraNodesS, libcommonfunc.MatrixQ.M, and libcommonfunc.MatrixQ.Q.

Referenced by libcommonfunc.MatrixQ.__init__(), libcommonfunc.MatrixQ.rotateMatrix(), libcommonfunc.MatrixQ.scaleNode(), libcommonfunc.MatrixQ.uniformQ(), and libcommonfunc.MatrixQ.uniformQMask().

Here is the caller graph for this function:

def libcommonfunc.MatrixQ.rotAngleEliminate (   self,
  rotationType,
  i,
  j,
  m,
  n 
)

Compute the rotation angle such that, after applying a rotation of type rotationType, the element $ M[m,n] $ of the matrix self.M is equal to zero.

    The element to set to zero [m,n] must be in the row or column of the rotation pivot [i,j] or its transpose [j,i].
    @param rotationType = Type of rotation to perform. The possible values are: {'trigonometric', 'hyperbolic'}.
    @param i = Row index of the pivot that will be used in the rotation.
    @param j = Column index of the pivot that will be used in the rotation.
    @param m = Row index of the element that will become zero after rotation.
    @param n = Column index of the element that will become zero after rotation.
    @return rotAng = Rotation angle to remove the element \form#119.

    First of all, and following the rules in the next table [TN 102.2 tab. A.1], we need to compute a value \form#120 which depends on the position \form#121 of the element to eliminate and 
    on the pivot \form#122:

\[ \begin{tabular}{|l|l|l|l|l|l|} \hline & Element to eliminate & $i$ & $j$ & $k$ & $val$ \\ \hline 1 & $M_{mn}$ & $m$ & $\neq m,n$ & $n$ & $\frac{M_{ik}}{M_{jk}}$\\ \hline 2 & $M_{mn}$ & $\neq m,n$ & $m$ & $n$ & $-\frac{M_{jk}}{M_{ik}}$\\ \hline 3 & $M_{mn}$ & $n$ & $\neq m,n$ & $m$ & $\frac{M_{ki}}{M_{kj}}$\\ \hline 4 & $M_{mn}$ & $\neq m,n$ & $n$ & $m$ & $-\frac{M_{kj}}{M_{ki}}$\\ \hline 5 & $M_{mm}$ & $m$ & $\neq m$ & - & $\frac{-M_{ij}+\sqrt{M_{ij}^{2}-M_{ii}M_{jj}}}{M_{jj}}$\\ \hline 6 & $M_{mm}$ & $\neq m$ & $m$ & - & $\frac{M_{ij}+\sqrt{M_{ij}^{2}-M_{ii}M_{jj}}}{M_{ii}}$\\ \hline 7 & $M_{mn}$ & $m$ & $n$ & - & $\frac{2M_{ij}}{M_{jj}-M_{ii}}$\\ \hline 8 & $M_{mn}$ & $n$ & $m$ & - & $\frac{2M_{ij}}{M_{jj}-M_{ii}}$\\ \hline \end{tabular} \]

We define $f_{l}=1$ for the cases {1,2,3,4,5,6} and $f_{l}=0.5$ for cases {7,8}. Then, the rotation angle which sets the element $[m,n]$ to zero after applying the rotation is:

\[\begin{matrix} rotAng & = & f_{l}tan^{-1}(val), & \text{if rotationType = 'trigonometric'} \\ rotAng & = & -jf_{l}tan^{-1}(val), & \text{if rotationType = 'hyperbolic'} \\ \end{matrix} \]

Definition at line 2156 of file libcommonfunc.py.

References libcommonfunc.MatrixQ.M.

def libcommonfunc.MatrixQ.rotateMatrix (   self,
  rotationType,
  i,
  j,
  rotAng,
  flagQ = True 
)

Rotate the coupling matrix self.M.

The resulting self.M matrix maintains the eigenvalues of the original matrix and his reflection and transmission properties.

Parameters
rotationType= Type of rotation to perform. The possible values are: {'trigonometric', 'hyperbolic'}.
i= Row index of the pivot that will be used in the rotation.
j= Column index of the pivot that will be used in the rotation.
rotAng= Rotation angle (rad).
flagQ= Flag that determines if the quality factor attribute self.Q is updated or not (True / False).

[TN 102.2 sec. 9.1] By definition, a rotation matrix is a matrix where every value in the diagonal is 1 except the two values $R_{ii}=R_{jj}=c_{r}$ and the rest of the values of the matrix are zero except the two values $R_{ji}=-R_{ij}=s_{r}$, where [TN 102.2 eq.(A.2) and (A.3)]:

\[\begin{matrix}[i,j] & = & \text{rotation pivot} &\\ c_r & = & cos(rotAng), & \text{if rotationType = 'trigonometric'} \\ & & cosh(rotAng), & \text{if rotationType = 'hyperbolic'} \\ s_r & = & sin(rotAng), & \text{if rotationType = 'trigonometric'} \\ & & jsinh(rotAng), & \text{if rotationType = 'hyperbolic'} \end{matrix} \]

    To apply the rotation we just need to do the product [TN 102.2 eq.(A.1)]:

\[M_{rot} = RMR^{T}\]

where $R$ is the rotation matrix described above.

Definition at line 1930 of file libcommonfunc.py.

References libcommonfunc.MatrixQ.extraNodesL, libcommonfunc.MatrixQ.extraNodesS, libcommonfunc.MatrixQ.flagRotateAllowed, libcommonfunc.MatrixQ.M, and libcommonfunc.MatrixQ.Qresonators().

Here is the call graph for this function:

def libcommonfunc.MatrixQ.saveMat (   self,
  fileName,
  P,
  SP,
  precCM,
  precEP 
)

Save this MatrixQ instance to an ascii file, including energy and power.

Uses self.__str__() to generate the ascii representation of the numpy matrix self.M.

Parameters
fileName= Name of file, including extension (string).
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 2675 of file libcommonfunc.py.

References libcommonfunc.MatrixQ.__str__(), libcommonfunc.MatrixQ.extraNodesL, libcommonfunc.MatrixQ.extraNodesS, libcommonfunc.MatrixQ.flagRotateAllowed, libcommonfunc.MatrixQ.name, dbplot.CurveFamily.name, libcommonfunc.MatrixQ.nodeScalingFactor, libcommonfunc.pkgNameVersion(), and libcommonfunc.MatrixQ.Q.

Here is the call graph for this function:

def libcommonfunc.MatrixQ.scaleNode (   self,
  i,
  b,
  flagQ = True 
)

Scale a node of the coupling matrix self.M, by multiplying row [i] and column [i] by a factor.

Matrix rotations are not allowed after node scaling of a resonant node.

Parameters
i= Index of row and column which we want to scale.
b= Factor to use to scale the ith row and column.
flagQ= Flag that determines if the quality factor attribute self.Q is updated or not (True / False).

Definition at line 2100 of file libcommonfunc.py.

References libcommonfunc.MatrixQ.extraNodesL, libcommonfunc.MatrixQ.extraNodesS, libcommonfunc.MatrixQ.flagRotateAllowed, libcommonfunc.MatrixQ.M, libcommonfunc.MatrixQ.nodeScalingFactor, and libcommonfunc.MatrixQ.Qresonators().

Here is the call graph for this function:

def libcommonfunc.MatrixQ.setFileExt (   self,
  fileExt 
)

Function to set file extension field of the instance of the MatrixQ class.

Parameters
fileExt= Extension of file name, if this matrix is to be saved in a file. Otherwise None.

Definition at line 1680 of file libcommonfunc.py.

References libcommonfunc.MatrixQ.fileExt.

def libcommonfunc.MatrixQ.setName (   self,
  name 
)

Function to set name field of the instance of the MatrixQ class.

Parameters
name= Matrix name.

Definition at line 1671 of file libcommonfunc.py.

References libcommonfunc.MatrixQ.name, and dbplot.CurveFamily.name.

def libcommonfunc.MatrixQ.setupOptimTopology (   self,
  topologyReal,
  topologyImag,
  topologySignReal,
  topologySignImag 
)

Prepare optimization parameters depending on matrix topology and forced signs.

Parameters
topologyReal= Bool numpy array having True values at the position of coupling matrix entries with non-zero real part.
topologyImag= Bool numpy array having True values at the position of coupling matrix entries with non-zero imaginary part.
topologySignReal= Int numpy array having -1,1 or 0 values at the position of coupling matrix entries with negative, positive or any real part, respectively.
topologySignImag= Int numpy array having -1,1 or 0 values at the position of coupling matrix entries with negative, positive or any imaginary part, respectively.
Returns
x0 = Initial guess. Double numpy vector with the values of the matrix entries which are different from zero. It is a concatenation of the non-zero real elements and the non-zero imaginary elements.
NonZeroReal = Bool numpy array having True values at the position of coupling matrix entries with non-zero real part in the upper-triangular part, including the diagonal, of the matrix.
NonZeroImag = Bool numpy array having True values at the position of coupling matrix entries with non-zero imaginary part in the upper-triangular part, including the diagonal, of the matrix. The entries corresponding to resonators are False
numReal = Number of entries in the upper triangular part of the matrix, including the diagonal, with non-zero real part.
bounds = List of tuples (Min,Max) with bounds for all variables to optimize. The maximum abs of any matrix element is set to 4 times the largest coupling, with a minimum of 2. This bound also affects the real part of diagonal elements (normalized resonant frequencies).

Definition at line 2245 of file libcommonfunc.py.

References libcommonfunc.MatrixQ.extraNodesL, libcommonfunc.MatrixQ.extraNodesS, and libcommonfunc.MatrixQ.M.

Referenced by libcommonfunc.MatrixQ.uniformQ(), and libcommonfunc.MatrixQ.uniformQMask().

Here is the caller graph for this function:

def libcommonfunc.MatrixQ.uniformQ (   self,
  P,
  CP,
  weights,
  Q,
  algor,
  maxIter,
  Nsamples,
  S11DR,
  S21DR,
  topologyReal,
  topologyImag,
  topologySignReal,
  topologySignImag 
)

Optimize the coupling matrix to achieve a prescribed uniform Q and [S] parameters as close as possible to those computed from the characteristic polynomials.

The non-zero coupling matrix entries to optimize are specified by topologyReal and topologyImag parameters, which are set by the matrix topology widget in the GUI.

Parameters
P= Parameters class instance, containing filter, synthesis and sweep parameters.
CP= CharPolys class instance, containing Characteristic Polynomials Es, Ps, Fs and constants eps, epsR.
weights= Optimization weights for the difference in S11 and S21 between the computation from the coupling matrix and from polynomials: List [ weightS11, weightS22, weightS21, weightGD ]
Q= Prescribed uniform Q for the resonators.
algor= Constrained optimization algorithm. String equal to 'L-BFG-S', 'TNC' or 'SLSQP'. See below.
maxIter= Maximum number of iterations, or function evaluations, depending on algorithm.
Nsamples= Number of samples to test. Half of them go to the pass band and the other half to the rejection band, between P.minFreq and P.maxFreq.
S11DR= Dynamic range of S11 and S22 to test.
S21DR= Dynamic range of S21 to test.
topologyReal= Bool numpy array having True values at the position of coupling matrix entries with non-zero real part.
topologyImag= Bool numpy array having True values at the position of coupling matrix entries with non-zero imaginary part.
topologySignReal= Int numpy array having -1,1 or 0 values at the position of coupling matrix entries with negative, positive or any real part, respectively.
topologySignImag= Int numpy array having -1,1 or 0 values at the position of coupling matrix entries with negative, positive or any imaginary part, respectively.

Constrained optimization algorithms:

In optimization, quasi-Newton methods (also known as variable metric methods) are algorithms for finding local maxima and minima of functions. Quasi-Newton methods are based on Newton's method to find the stationary point of a function, where the gradient is 0. Newton's method assumes that the function can be locally approximated as a quadratic in the region around the optimum, and use the first and second derivatives (gradient and Hessian) to find the stationary point. In Quasi-Newton methods the Hessian matrix of second derivatives of the function to be minimized does not need to be computed. The Hessian is updated by analyzing successive gradient vectors instead (or approximate gradient evaluations computed using finite differences). Quasi-Newton methods are a generalization of the secant method to find the root of the first derivative for multidimensional problems. In multi-dimensions the secant equation is under-determined (has not a unique solution), and quasi-Newton methods differ in how they constrain the solution, typically by adding a simple low-rank update to the current estimate of the Hessian.

A necessary condition for optimality is that the gradient be zero. Quasi-Newton's method need not converge unless the function has a quadratic Taylor expansion near an optimum.

Limited memory variation Broyden–Fletcher–Goldfarb–Shanno algorithm (L-BFGS-B)

Limited memory variation of the Broyden–Fletcher–Goldfarb–Shanno (BFGS) update to approximate the inverse Hessian matrix.

The BFGS method is one of the most popular quasi-Newton optimization methods. L-BFGS is a limited-memory version of BFGS that is particularly suited to problems with very large numbers of variables.

References:

  • Wright, and Nocedal ‘Numerical Optimization’, 1999, pg. 198.
  • R. H. Byrd, P. Lu and J. Nocedal. A Limited Memory Algorithm for Bound Constrained Optimization, (1995), SIAM Journal on Scientific and Statistical Computing , 16, 5, pp. 1190-1208.
  • C. Zhu, R. H. Byrd and J. Nocedal. L-BFGS-B: Algorithm 778: L-BFGS-B, FORTRAN routines for large scale bound constrained optimization (1997), ACM Transactions on Mathematical Software, Vol 23, Num. 4, pp. 550 - 560.

Sequential Least SQuares Programming (SLSQP)

SLSQP optimizer is a sequential least squares programming algorithm which uses the Han–Powell quasi–Newton method with a BFGS update of the B–matrix and an L1–test function in the step–length algorithm. The optimizer uses a slightly modified version of Lawson and Hanson’s NNLS nonlinear least-squares solver.

Sequential quadratic programming (SQP) is one of the most popular and robust algorithms for nonlinear continuous optimization. The method is based on solving a series of subproblems designed to minimize a quadratic model of the objective subject to a linearization of the constraints. If the problem is unconstrained, then the method reduces to Newton's method for finding a point where the gradient of the objective vanishes. If the problem has only equality constraints, then the method is equivalent to applying Newton's method to the first-order optimality conditions, or Karush–Kuhn–Tucker conditions, of the problem. A number of packages (including NPSOL, NLPQL, OPSYC, OPTIMA, MATLAB, and SQP) are founded on this approach.

References:

  • Kraft D (1988) A software package for sequential quadratic programming. Tech. Rep. DFVLR-FB 88-28, DLR German Aerospace Center — Institute for Flight Mechanics, Koln, Germany.

Bound-constrained truncated newton algorithm (TNC)

Bound-constrained truncated newton algorithm using gradient information.

Truncated-Newton methods are a family of methods suitable for solving large nonlinear optimization problems. At each iteration, the current estimate of the solution is updated (i.e., a step is computed) by approximately solving the Newton equations using an iterative algorithm. This results in a doubly iterative method: an outer iteration for the nonlinear optimization problem, and an inner iteration for the Newton equations. The inner iteration is typically stopped or truncated before the solution to the Newton equations is obtained. Over the past two decades, a solid convergence theory has been derived for the methods. In addition, many algorithmic enhancements have been developed and studied, resulting in a number of publicly-available software packages. The result has been a collection of powerful, flexible, and adaptable tools for large-scale nonlinear optimization.

References:

  • Stephen G. Nash, “A Survey of Truncated-Newton Methods”, Journal of Computational and Applied Mathematics, 124 (2000), pp. 45-59. http://iris.gmu.edu/~snash/papers/nash_3_99.ps
    Return a SParameters class instance with sampling frequencies to optimize. 
    S11, S22, S21 and groupDelay attributes are initialized with those computed from the polynomials.
    
    @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 FT = FrequencyTransform class instance, containing f0 and BW parameters.
    @param minFreq = Minimum frequency to optimize.
    @param maxFreq = Maximum frequency to optimize.
    @param Nsamples = Number of samples to test. Half of them go to the pass band and the other half to the rejection band, between minFreq and maxFreq.
    
    @return SPref = SParameters class instance with sampling frequencies to optimize and [S] parameters computed from CP.

Definition at line 2432 of file libcommonfunc.py.

References libcommonfunc.Sparameters.FT, libcommonfunc.MatrixQ.FT, libcommonfunc.MatrixQ.M, libcommonfunc.MatrixQ.newMatQFromNonZero(), libcommonfunc.MatrixQ.Qresonators(), libcommonfunc.MatrixQ.setupOptimTopology(), and libcommonfunc.MatrixQ.uniformQOptimize().

Here is the call graph for this function:

def libcommonfunc.MatrixQ.uniformQMask (   self,
  P,
  CP,
  weights,
  Q,
  algor,
  maxIter,
  Nsamples,
  SM,
  topologyReal,
  topologyImag,
  topologySignReal,
  topologySignImag 
)

Optimize the coupling matrix to achieve a prescribed uniform Q and [S] parameters that comply with a specification mask.

The non-zero coupling matrix entries to optimize are specified by topologyReal and topologyImag parameters, which are set by the matrix topology widget in the GUI. Only the magnitude of [S] is optimized to comply with the S11 and S21 masks. Group delay in the mask file, if any, is not used in optimization,

Parameters
P= Parameters class instance, containing filter, synthesis and sweep parameters.
CP= CharPolys class instance, containing Characteristic Polynomials Es, Ps, Fs and constants eps, epsR.
weights= Optimization weights for the difference in S11 and S21 between the computation from the coupling matrix and from polynomials: List [ weightS11, weightS22, weightS21, weightGD ]. The last element, weightGD, is not used.
Q= Prescribed uniform Q for the resonators.
algor= Constrained optimization algorithm. String equal to 'L-BFG-S', 'TNC' or 'SLSQP'. See algorithms description MatrixQ.uniformQ method documentation.
maxIter= Maximum number of iterations, or function evaluations, depending on algorithm.
Nsamples= Number of samples to test. Half of them go to the pass band and the other half to the rejection band, between P.minFreq and P.maxFreq.
SM= SpecMask class instance, with the mask to compare with.
topologyReal= Bool numpy array having True values at the position of coupling matrix entries with non-zero real part.
topologyImag= Bool numpy array having True values at the position of coupling matrix entries with non-zero imaginary part.
topologySignReal= Int numpy array having -1,1 or 0 values at the position of coupling matrix entries with negative, positive or any real part, respectively.
topologySignImag= Int numpy array having -1,1 or 0 values at the position of coupling matrix entries with negative, positive or any imaginary part, respectively.

Definition at line 2577 of file libcommonfunc.py.

References libcommonfunc.Sparameters.FT, libcommonfunc.MatrixQ.FT, libcommonfunc.MatrixQ.M, libcommonfunc.MatrixQ.newMatQFromNonZero(), libcommonfunc.MatrixQ.Qresonators(), libcommonfunc.MatrixQ.setupOptimTopology(), and libcommonfunc.MatrixQ.uniformQOptimizeMask().

Here is the call graph for this function:

def libcommonfunc.MatrixQ.uniformQOptimize (   self,
  NonZeroValues,
  SPref,
  S11min,
  S21min,
  NonZeroReal,
  NonZeroImag,
  numReal,
  weights,
  Q 
)

Optimization objective function for uniformQ function.

The output matrix is forced symmetric, with positive imaginary part out of the diagonal and with uniform Q in all the resonators. The imaginary part of the diagonal elements is determined so that the Q is constant,so it is not a variable to optimize.

Parameters
NonZeroValues= Double numpy vector with the values of the matrix entries which are different from zero. It is a concatenation of the non-zero real elements and the non-zero imaginary elements.
SPref= SParameters class instance containing [S] computed from the characteristic polynomials. It is used as the reference to compare.
S11min= Minimum value of S11 and S22 to test.
S21min= Minimum value of S21 outside to test.
NonZeroReal= Bool numpy array having True values at the position of coupling matrix entries with non-zero real part in the upper-triangular part, including the diagonal, of the matrix.
NonZeroImag= Bool numpy array having True values at the position of coupling matrix entries with non-zero imaginary part in the upper-triangular part, including the diagonal, of the matrix. The entries corresponding to resonators are False, since the imaginary part will be obtained from the prescribed Q.
numReal= Number of entries in the upper triangular part of the matrix, including the diagonal, with non-zero real part.
weights= Optimization weights for the difference in S11(dB), S21(dB) and GD(inband) between the computation from the coupling matrix and from polynomials: List [ weightS11, weightS22, weightS21, weightGD ]
Q= Prescribed uniform Q for the resonators.
Returns
goal = Objective function value to minimize.

Definition at line 2513 of file libcommonfunc.py.

References libcommonfunc.MatrixQ.newMatQFromNonZero().

Referenced by libcommonfunc.MatrixQ.uniformQ().

Here is the call graph for this function:

Here is the caller graph for this function:

def libcommonfunc.MatrixQ.uniformQOptimizeMask (   self,
  NonZeroValues,
  SPref,
  SM,
  NonZeroReal,
  NonZeroImag,
  numReal,
  weights,
  Q 
)

Optimization objective function for uniformQMask function.

The output matrix is forced symmetric, with positive imaginary part out of the diagonal and with uniform Q in all the resonators. The imaginary part of the diagonal elements is determined so that the Q is constant,so it is not a variable to optimize. Only the magnitude of [S] is optimized to comply with the S11 and S21 masks. Group delay in the mask file, if any, is not used in optimization,

Parameters
NonZeroValues= Double numpy vector with the values of the matrix entries which are different from zero. It is a concatenation of the non-zero real elements and the non-zero imaginary elements.
SPref= SParameters class instance containing method and storage to compute [S] from CM.
SM= SpecMask class instance, with the mask to compare with.
NonZeroReal= Bool numpy array having True values at the position of coupling matrix entries with non-zero real part in the upper-triangular part, including the diagonal, of the matrix.
NonZeroImag= Bool numpy array having True values at the position of coupling matrix entries with non-zero imaginary part in the upper-triangular part, including the diagonal, of the matrix. The entries corresponding to resonators are False, since the imaginary part will be obtained from the prescribed Q.
numReal= Number of entries in the upper triangular part of the matrix, including the diagonal, with non-zero real part.
weights= Optimization weights for the difference in S11(dB), S21(dB) and GD(inband) between the computation from the coupling matrix and from polynomials: List [ weightS11, weightS22, weightS21, weightGD ]. The last element, weightGD, is not used.
Q= Prescribed uniform Q for the resonators.
Returns
goal = Objective function value to minimize.

Definition at line 2624 of file libcommonfunc.py.

References libcommonfunc.MatrixQ.newMatQFromNonZero().

Referenced by libcommonfunc.MatrixQ.uniformQMask().

Here is the call graph for this function:

Here is the caller graph for this function:


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