SLiCAPexecute.py¶
SLiCAP module with functions for execution of instructions.
Imported by the module SLiCAPinstruction.py.
Execution instruction.execute() proceeds as follows:
- The instruction settings will be checked for completeness and consistency
- If no errors are found doInstruction(<allResults obj>) performs the actual execution of the instruction
-
doDC(instObj, detP, detN)¶ Calculates the DC voltage or current at the detector.
It uses the dc value field of independent sources and replaces the Laplace variable in the MNA matrix with 0.
Parameters: - instObj (
allResult()) – allResults() object that holds instruction data. - detP (int) – position of the positive detector quantity in the vector with dependent variables
- detN (int) – position of the negative detector quantity in the vector with dependent variables
- instObj (
-
doDCvar(instObj, detP, detN)¶ Calculates the contributions of variances of DC sources and resistors to detector-referred variance.
After execution of this function the circuit is modified: dc variance current sources have been added in parallel with resistors that have a nonzero value of their dcvar parameter.
The names of these sources are those of the currents through these resistors. These names have been added to the list circuit.indepVars.
If these elements already existed because of an earlier DCvar analysis, they will be removed, as well as the references in to them the list circuit.indepVars.
Parameters: instObj ( allResult()) – allResults() object that holds instruction data.Returns: Tuple with a dictionary ovarTerms and the dc solution of the network. - ovarTerms (dict):
- key (str): ID of the dc variance source
- value (sympy.Expr) contribution of this source to the dc variance at the detector in \(V^2\) or in \(A^2\).
- dcSolution(sympy.Matrix): DC solution of the network
- ovarTerms (dict):
-
doDataType(instObj)¶ Executes the instruction without parameter stepping.
- It builds the matrices in accordance with the specified gain type
- It executes instruction for the specified dataype
Parameters: instObj ( allResult()) – allResults() objectthat holds instruction data.Returns: allResults() object that holds instruction data Return type: allResults() object
-
doDenom(instObj)¶ Calculates the denominator of a transfer by evaluating the determinant of the MNA matrix.
Parameters: instObj ( allResult()) – allResults() object that holds instruction data.Returns: denominator of a transfer or a detector voltage or current: - gain type = ‘vi’, ‘gain’, ‘direct’, ‘asymptotic’:
dDeterminant of the MNA matrix for that gain type
- gain type = ‘loopgain’:
Determinant of the MNA matrix for gain type ‘loopgain’ multiplied with the denominator of the gain of the loop gain reference.
- gain type = ‘servo’:
Determinant of the MNA matrix for gain type ‘loopgain’ multiplied with the denominator of the gain of the loop gain reference, plus the numerator of the loop gain. The latter one is calculated as the product of the sum of cofactors of the MNA matrix for gain type ‘loopgain’ and the numerator of the gain of the loop gain reference.
Return type: sympy.Expr - gain type = ‘vi’, ‘gain’, ‘direct’, ‘asymptotic’:
-
doInstruction(instObj)¶ Executes the instruction with or without parameter stepping.
Called by instruction.execute(). This function should not be called directly by the user.
Parameters: instObj ( allResult()) – allResults() object that holds instruction data.Returns: allResults() object that holds instruction data. Return type: allResults() object
-
doLaplace(instObj)¶ Calculates the numerator and the denominator of the transfer and normalizes the result to:
\(F(s) = G s^{\ell} \frac{1+b_1s + ... + b_ms^m}{1+a_1s + ... + a_ns^n}\),
with \(\ell\) equal zero if there is a finite nonzero zero-frequency value, else a positive or negative integer.
Parameters: instObj ( allResult()) – allResults() object that holds instruction data.Returns: Laplace transform of a transfer or detector voltage or current Return type: sympy.Expr
-
doNoise(instObj, detP, detN, denom2)¶ Calculates the contributions of all noise sources to the noise spectral density at the detector.
Returns a dictionary with key-value pairs:
- key = ID of the noise source
- value = contribution to the noise spectral density th the detector in \(\frac{V^2}{Hz}\) or in \(\frac{A^2}{Hz}\).
Parameters: instObj ( allResult()) – allResults() object that holds instruction data.Returns: onoiseTerms Return type: dict
-
doNumer(instObj)¶ Calculates the numerator of a transfer by evaluating cofactors or by using Cramer’s rule.
Parameters: instObj ( allResult()) – allResults() object that holds instruction data.Returns: numerator of a transfer or a detector voltage or current: - gain type = ‘vi’:
Application of Cramer’s rule
- gain type = ‘gain’, ‘direct’, ‘asymptotic’:
Sum of cofactors of the MNA matrix for that gain type
- gain type = ‘loopgain’:
Sum of cofactors of the MNA matrix for gain type ‘loopgain’ multiplied with the numerator of the gain of the loop gain reference.
- gain type = ‘servo’:
Sum of cofactors of the MNA matrix for gain type ‘loopgain’ multiplied with the the negative value of the numerator of the gain of the loop gain reference.
Return type: sympy.Expr - gain type = ‘vi’:
-
doPZ(instObj)¶ Calculates the DC gain, and the numric roots of the numerator and the denominator of a transfer.
- Calculate the numerator and the denominator
- Calculate the poles and the zeros
- Calculate the DC gain
- Cancel poles and zeros that coincide within a relative tolerance of \(10^{-\mathrm{ini.disp}}\).
Parameters: instObj ( allResult()) – allResults() object that holds instruction data.Returns: tuple: (poles, zeros, DCvalue) Return type: tuple
-
doPoles(instObj)¶ Calculates the numeric roots of the denominator of a transfer.
It first calls execute.doDenom() to calculate the denominator of the transfer defined by the gain type. It then calculates the numerical roots by calling SLiCAPmath.numRoots().
Parameters: instObj ( allResult()) – allResults() object that holds instruction data.Returns: list with numerical roots of the denominator of a transfer Return type: list
-
doSolve(instObj)¶ Calculates the symbolic or numeric solution of a network.
Parameters: instObj ( allResult()) – allResults() object that holds instruction data.Returns: Network solution (vector) Return type: sympy.Matrix
-
doSolveDC(instObj)¶ Calculates the DC solution of a network.
It uses the dc value field of independent sources and replaces the Laplace variable in the MNA matrix with 0.
Parameters: instObj ( allResult()) – allResults() object that holds instruction data.Returns: DC solution of the network Return type: sympy.Matrix
-
doZeros(instObj)¶ Calculates the numeric roots of numerator of a transfer.
It first calls execute.doNumer() to calculate the numerator of the transfer defined by the gain type. It then calculates the numerical roots by calling SLiCAPmath.numRoots().
Parameters: instObj ( allResult()) – allResults() object that holds instruction data.Returns: list with numerical roots of the numerator of a transfer Return type: list
-
lgValue(instObj)¶ Calculates the corrected gain of the loop gain reference.
In case of a loop gain reference of the type EZ and HZ the calculation of the loop gain is performed as if a current source was placed in parallel with the output impedance (zo) of this controlled source (Norton equivalent representation). The value of this current source is that of the loop gain reference divided by the output impedance of the device.
Parameters: instObj ( allResult()) – allResults() object that holds instruction data.Returns: Gain of the loop gain reference, modified in a Norton equivalent in cases in which the model of the loop gain reference is ‘EZ’ or ‘HZ’. Return type: sympy.
-
makeSrcDetPos(instObj)¶ Returns the number of the source row(s) and detector colum(s) for calculation of cofactors or for application of Cramer’s rule.
If the gain type is ‘loopgain’ or ‘servo’, the source and the detector are taken at the input and the output of the loop gain reference.
Parameters: instObj ( allResult()) – allResults() object that holds instruction data.Returns: tuple: (detP, detN, srcP, srcN): - detP (None, int): number of the row of the vector with dependent variables that corresponds with the positive detector
- detN (None, int): number of the row of the vector with dependent variables that corresponds with the negative detector
- srcP (None, int): number of the row of the vector with dependent variables that corresponds with the positive source
- srcN (None, int): number of the row of the vector with dependent variables that corresponds with the negative source
Return type: tuple
-
stepFunctions(instObj, function)¶ Substitutes values for step parameters in functions and returns a list of functions with these substitutions.
Parameters: - instObj (
allResult()) – allResults() object that holds instruction data. - function (sympy.Expr) –
Returns: List with functions (sympy.Expr). The number of functions equals the number of steps. Function i equals the input function in which the step variable has been replaced with its i-th step value.
Return type: list
- instObj (