SLiCAPmatrices.py

SLiCAP module for building the MNA matrix and the associated vectors.

Imported by the module SLiCAPpythonMaxima.py

getValue(elmt, param, numeric, parDefs)

Returns the symbolic or numeric value of a parameter of an element.

This function is called by makeMatrices().

Parm elmt:

element object

Parameters:
  • param (str) – parameter of interest (‘value’, ‘noise’, ‘dc’ or ‘dcvar’)
  • numeric (bool) – If True is uses full substitution and sympy.N for converting parameters to sympy floats
  • parDefs (dict) –

    Dict with key value pairs:

    • key : parameter name (sympy.Symbol)
    • value: numeric value of sympy expression
Returns:

value: sympy expresssion or numeric value of the element parameter

Return type:

sympy.Expr, int, float, sympy.Float

getValues(elmt, param, numeric, parDefs)

Returns the symbolic or numeric value of numerator and the denominator of a parameter of an element. This function is called by makeMatrices().

Parm elmt:

element object

Parameters:
  • param (str) – parameter of interest (‘value’, ‘noise’, ‘dc’ or ‘dcvar’)
  • numeric (bool) – If True is uses full substitution and sp.N for converting parameters to sympy floats
  • parDefs (dict) –

    Dict with key value pairs:

    • key : parameter name (sympy.Symbol)
    • value: numeric value of sympy expression
Returns:

Tuple with sympy expresssions or numeric values of the numerator and the denominator of the element parameter.

Return type:

tuple

makeMatrices(cir, parDefs, numeric, gainType, lgRef)

Returns the MNA matrix and the vector with dependent variables of a circuit.

Modifications in the circuit object, necessary for calculation of different gain types are temporary. The circuit data before and after running ‘makeMatrices’ is the same:

  1. If gainType == ‘asymptotic’:
    • store the model of lgRef
    • modify the model of lgRef to ‘N’
    • update depVars and varIndex
    • create the matrices
    • restore the model of lgRef
    • update depVars and varIndex
  2. If gainType == ‘direct’, ‘loopgain’ or ‘servo’:
    • store value of lgRef
    • set value of lgRef element to zero
    • create the matrices
    • restore the value of lgRef
    • loopgain and servo will be calculated with the output of lgRef as source and the input of lgRef as detector.
  3. If gainType == ‘vi’ or ‘gain’:
    • no alterations of the circuit need to be made
Parameters:
  • cir (SLiCAPprotos.circuit) – Circuit of which the matrices need to be returned.
  • parDefs (dict) –

    Dict with key value pairs:

    • key : parameter name (sympy.Symbol)
    • value: numeric value of sympy expression
  • numeric (bool) – If True is uses full substitution and sympy.N for converting parameters to sympy floats
  • gainType (str) – Gain type of the instruction
  • lgRef (str) – ID of the loop gain reference of the instruction
Returns:

tuple with two sympy matrices:

  1. MNA matrix M
  2. Vector with dependent variables Dv

Return type:

tuple

makeSrcVector(cir, parDefs, elid, value='id', numeric=True)

Creates the vector with independent variables. The vector can be created for a single independent variable or for all.

This can be used for determination of a transfer using Cramer’s rule.

If a single variable is used, this vector and Cramer’s rule can be used as an alternative for calculation cofactors:

The refDes of the independent variable (source) is substituted in the vecor with independent variables (value = ‘id’). This vector is then substituted in the detector col, of the MNA matrix. After calculation of the determinant of this modified matrix, the result is divided by refDes.

This method is used for determination of gain factors for noise sources and for DC variance sources.

Parameters:
  • cir (SLiCAPprotos.circuit) – Circuit of which the matrices need to be returned.
  • parDefs (dict) –

    Dict with key value pairs:

    • key : parameter name (sympy.Symbol)
    • value: numeric value of sympy expression
  • elid (str) – Refdes (ID) of a source to be included in this vector; ‘all’ for all sources.
  • numeric (bool) – If True is uses full substitution and sympy.N for converting parameters to sympy floats
Returns:

Iv: vector with in dependent variables

Return type:

sympy.Matrix