SLiCAPexecute.py

Created on Sat Aug 7 17:08:41 2021

@author: anton

addDCvarSources(instr, dcSolution)

Adds the dcvar sources of resistors to instr.circuit for dataType: ‘dcvar’.

Parameters
  • instr (instruction()) – instruction() object that holds instruction data.

  • dcSolution (sympy.Matrix) – DC solution of the network obtained from execution of this instruction with dataType: ‘dcsolve’

Returns

updated instruction object

Return type

:class`SLiCAPinstruction.instruction`

addResNoiseSources(instr)

Adds the noise sources of resistors to instr.circuit for dataType: ‘noise’.

Parameters

instr (instruction()) – instruction() object that holds instruction data.

Returns

updated instruction object

Return type

SLiCAPinstruction.instruction

calcNumer(instr, result)

Calculates the numerator of the source-detector gain.

Parameters
  • instr (instruction()) – instruction() object that holds instruction data.

  • result (allResult()) – allResults() object that holds instruction results

convertMatrices(instr, result)

Converts the result attributes M, Iv and Dv into those of equivalent common-mode or differential mode circuits.

If instruction.removePairSubName == True, it also removes the pair extensions from paired parameters.

The conversion type is defined by the attribute instr.convType it can be:

  • ‘dd’ Diferential-mode transfer

  • ‘cc’ Common-mode transfer

  • ‘dc’ Differential-mode to common-mode conversion

  • ‘cd’ Common-mode to differential-mode conversion

  • ‘all’ The complete vectors with redefined and re-arranged common-mode and differential-mode quantities.

Parameters
  • instr (instruction()) – instruction() object that holds instruction data.

  • result (allResult()) – allResults() object that holds instruction results

correctDMcurrentResult(instr, result)

In cases of a differential-mode current detector the numerator of the differential output current, or its associated transfer must be divided by two I_diff = (I_P - I_N)/2

Parameters
  • instr (instruction()) – instruction() object that holds instruction data.

  • result (allResult()) – allResults() object that holds instruction results

createConversionMatrices(instr)

Creates the matrax for a base transformation from nodal voltages and branche currents to common-mode and differential-mode equivalents.

Parameters

instr (instruction()) – instruction() object that holds instruction data.

Returns

pairs, unPaired, dmVars, cmVars, A

  • pairs: a list with tuples with paired variables

  • unPaired: a list with unpaired variables

  • dmVars: a list with differential-mode variables

  • cmVars: a list with common mode variables

  • A: the base transformation matrix

Return type

tuple

createResultObject(instr)

Returns an instance of the allResults object with the instruction data copied to it.

Parameters

instr (SLiCAPinstruction.instruction) – SLiCAP instruction object.

Returns

result

Return type

SLiCAPprotos.allResults object

delDCvarSources(instr)

Deletes the dcVar sources from instr.circuit, added by executing this instruction with dataType: ‘dcvar’.

Parameters

instr (instruction()) – instruction() object that holds instruction data.

Returns

updated instruction object

Return type

:class`SLiCAPinstruction.instruction`

delResNoiseSources(instr)

Deletes the noise sources from instr.circuit, added by executing this instruction with dataType: ‘noise’.

Parameters

instr (instruction()) – instruction() object that holds instruction data.

Returns

updated instruction object

Return type

SLiCAPinstruction.instruction

doDC(instr, result)

Calculates the DC response at the detector using the parameter ‘dc’ of independent sources as input.

The result will be stored in the .dc attribute of the result object.

Parameters

instr (instruction()) – instruction() object that holds instruction data.

doDCsolve(instr, result)

Finds the DC solution of the network using the .dc attribute of independent sources as inputs.

The DC solution will be stored in the .dcSolve attribute of the result object.

Parameters
  • instr (instruction()) – instruction() object that holds instruction data.

  • result (allResult()) – allResults() object that holds instruction results

doDCvar(instr, result)

Adds the result of a dcvar analysis to result.

Parameters
  • instr (instruction()) – instruction() object that holds instruction data.

  • result (allResult()) – allResults() object that holds instruction results

doDenom(instr, result)

Returns the denominator of a transfer function, or of the Laplace Transform of a detector voltage or current.

The result will be stored in the .denom attribute of the resturn object. In cases of parameter stepping, this attribute is a list with numerators.

Parameters
  • instr (instruction()) – instruction() object that holds instruction data.

  • result (allResult()) – allResults() object that holds instruction results

Returns

Result of the execution of the instruction.

Return type

SLiCAPprotos.allResults()

doImpulse(instr, result)

Calculates the inverse Laplace transform of the source-detector transfer.

First it calculates the Laplace transform of the sou-detector transfer and subsequently the inverse Laplace Transform.

The Laplace Transform of the source-detector transfer will be stored in the .laplace attribute of the result object.

The result will be stored in the .impulse attribute of the result object.

Parameters
  • instr (instruction()) – instruction() object that holds instruction data.

  • result (allResult()) – allResults() object that holds instruction results

doInstruction(instr)

Executes the instruction and returns the result.

Parameters
  • instr (instruction()) – instruction() object that holds instruction data.

  • result (allResult()) – allResults() object that holds instruction results

Returns

Result of the execution of the instruction.

Return type

SLiCAPprotos.allResults()

doLaplace(instr, result)

Returns a transfer function, or the Laplace Transform of a detector voltage or current.

The result will be stored in the .laplace attribute of the resturn object. In cases of parameter stepping, this attribute is a list with numerators.

Parameters
  • instr (instruction()) – instruction() object that holds instruction data.

  • result (allResult()) – allResults() object that holds instruction results

Returns

Result of the execution of the instruction.

Return type

SLiCAPprotos.allResults()

doLoopGainServo(instr, result)

Returns the Laplace expression of the loop gain of the asymptotic-gain feedback model, or of the ‘servo function’ as defined by Montagne. The calculation uses the return difference, as defined by Bode (1945).

The results are stored in the following attributes of the return object:

  • .numer: the numerator of the loop gain or the servo fucntion or a list of numerators if parameter stepping is applied.

  • .denom: the denominator of the loop gain or the servo fucntion or a list of denominators if parameter stepping is applied.

  • .laplace: the loop gain or the servo fucntion or a list of laplace expressions if parameter stepping is applied.

Parameters
  • instr (instruction()) – instruction() object that holds instruction data.

  • result (allResult()) – allResults() object that holds instruction results

Returns

Result of the execution of the instruction.

Return type

SLiCAPprotos.allResults()

doMatrix(instr, result)

Calculates the MNA matrix and the vector with dependent and independent variables, based on the conversion type:

  • instr.convType == None: The basic MNA equation

  • instr.convType == ‘all’: The basic equation on a basis of common-mode and differential-mode variables

  • instr.convType == ‘dd’: The differential-mode equivalent representation

  • instr.convType == ‘cc’: The common-mode equivalent representation

  • instr.convType == ‘cd’: The differential-mode to common-mode conversion reprsentation

  • instr.convType == ‘dc’: The common-mode to differential-mode conversion reprsentation

The results are stored in the following attributes of the result object:

  • .Iv: Vector with independent variables (independent voltage and current sources)

  • .Dv: Vector with dependent variables (nodal voltages and branch currents)

  • .M: Matrix: Iv=M*Dv

Parameters
  • instr (instruction()) – instruction() object that holds instruction data.

  • result (allResult()) – allResults() object that holds instruction results

doMaxFunction(funcName, args)

Calls a Maxima CAS function and executes it with the given arguments args.

Parameters
  • funcName (str) – Name of the function to be executed.

  • args (list) – List with function arguments

Returns

Sympy expression (execution result)

Return type

Sympy.Expr

doMaxIlt(laplaceRational)

Calculates the inverse Laplace Transform of laplaceRational using Maxima CAS.

Parameters
  • laplaceRational (Sympy.Expr) – Sympy rational function of the Laplace variable.

  • result (Sympy.Expr) – Inverse Laplace Transform of laplaceRational

doMaxInstr(instr, result)

Executes an instruction with Maxima CAS and updates result with the instruction results.

Parameters
  • instr (instruction()) – instruction() object that holds instruction data.

  • result (allResult()) – allResults() object that holds instruction results

doMaxLoopGainServo(instr, result)

Returns a tuple with the numerator and the denominator of the loop gain or the servo function; depeding on the gain type.

Parameters
  • instr (instruction()) – instruction() object that holds instruction data.

  • result (allResult()) – allResults() object that holds instruction results

Returns

numer, denom

Return type

tuple with two sympy expressions

doNoise(instr, result)

Adds the result of a noise analysis to result.

Parameters
  • instr (instruction()) – instruction() object that holds instruction data.

  • result (allResult()) – allResults() object that holds instruction results

doNumer(instr, result)

Returns the numerator of a transfer function, or of the Laplace Transform of a detector voltage or current.

The result will be stored in the .numer attribute of the resturn object. In cases of parameter stepping, this attribute is a list with numerators.

Parameters
  • instr (instruction()) – instruction() object that holds instruction data.

  • result (allResult()) – allResults() object that holds instruction results

Returns

Result of the execution of the instruction.

Return type

SLiCAPprotos.allResults()

doPZ(instr, result)

Adds the result of a pole-zero analysis to result.

Parameters
  • instr (instruction()) – instruction() object that holds instruction data.

  • result (allResult()) – allResults() object that holds instruction results

doPoles(instr, result)

Adds the result of a poles analysis to result.

Parameters
  • instr (instruction()) – instruction() object that holds instruction data.

  • result (allResult()) – allResults() object that holds instruction results

doSolve(instr, result)

Solves the network: calculates the Laplace transform of all dependent variables.

Parameters
  • instr (instruction()) – instruction() object that holds instruction data.

  • result (allResult()) – allResults() object that holds instruction results

doStep(instr, result)

Calculates the unit step response of the circuit. This is the inverse Laplace transform of the source-detector transfer divided by the Laplace variable.

First it calculates the Laplace transform of the source-detector transfer and subsequently the inverse Laplace Transform.

The Laplace Transform of the source-detector transfer will be stored in the .laplace attribute of the result object.

The unit step response will be stored in the .stepResp attribute of the result object.

Parameters
  • instr (instruction()) – instruction() object that holds instruction data.

  • result (allResult()) – allResults() object that holds instruction results

doTime(instr, result)

Calculated the inverse Laplace transform of the detector voltage or current.

Parameters
  • instr (instruction()) – instruction() object that holds instruction data.

  • result (allResult()) – allResults() object that holds instruction results

doTimeSolve(instr, result)

Calculates the time-domain solution of the circuit.

The result will be stored in the .timeSolve attribute of the result object.

Parameters
  • instr (instruction()) – instruction() object that holds instruction data.

  • result (allResult()) – allResults() object that holds instruction results

doZeros(instr, result)

Adds the result of a zeros analysis to result.

Parameters
  • instr (instruction()) – instruction() object that holds instruction data.

  • result (allResult()) – allResults() object that holds instruction results

getSubMatrices(result, dimDm, dimCm, convType)

Updates the attributes M, Iv, and Dv of result according to the conversion type: convType.

Parameters
  • result – instruction results of which the matrix attributes M, Iv, and Dv have been set.

  • dimDm (str) – Number of differential-mode variables

  • dimCm (str) – Number of common-mode variables

  • convType (str) – Conversion type, can be ‘dd’, ‘dc’, ‘cd’, ‘cc’ and ‘all’.

Result

updated instruction result

Return type

class

SLiCAP.allResults()

makeMaxDetPos(instr, result)

Returns the index of the detector colum(s) for calculation of Cramer’s rule.

Parameters
  • instr (instruction()) – instruction() object that holds instruction data.

  • result (allResult()) – allResults() object that holds instruction results

Returns

tuple: (detP, detN):

  • detP (int, int): number of the row of the vector with dependent variables that corresponds with the positive detector

  • detN (int, int): number of the row of the vector with dependent variables that corresponds with the negative detector

Return type

tuple

makeMaxInstr(instr, result)

Creates the Maxima CAS input for execution of the instruction.

Parameters
  • instr (instruction()) – instruction() object that holds instruction data.

  • result (allResult()) – allResults() object that holds instruction results

Returns

tuple with Input for Maxima CAS and result object.

Return type

tuple with str and allResult()

makeMaxMatrices(instr, result)

Returns an allResults() object of which the following attributes have been updated:

  • M = MNA matrix

  • Iv = Vector with independent variables (voltages and current of independent voltage and current sources, repectively)

  • Dv = Vector with dependent variables (unknown nodal voltages and branch currents)

Parameters
  • instr (instruction()) – instruction() object that holds instruction data.

  • result (allResult()) – allResults() object that holds instruction results

Returns

result object with updated attributes Iv, M, and Dv:

Return type

SLiCAPprotos.allResults

makeSubsDict(instr)

Creates a substitution dictionary that does not contain the step parameters for the instruction.

Parameters

instr (instruction()) – instruction() object that holds instruction data.

Returns

Updated instruction object

Return type

:class`SLiCAPinstruction.instruction()`

maxString(maxInstr, numeric)

Returns the instruction for maxima with either symbolic or numeric output.

Parameters
  • maxInstr (str) – Function to be evaluated by maxima CAS.

  • numeric (Bool) – True if the result must be converted to ‘big float’, else False.

Returns

Maxima instruction for string output.

Return type

str.

pairParDefs(instr)

Removes the pair extension from paired parameters in both keys and values in instr.parDefs.

Parameters

instr (SLiCAPinstruction.instruction()) – instruction with circuit and pairing extensions

Returns

instr

Rtupe

SLiCAPinstruction.instruction()

pairVariables(instr)

Combines nodal voltages and branche currents in pairs of variables that can be resolved in common-mode, and differential-mode variables.

Pairing is defined by the instr.pairedVars and instr.pairedCircuits.

Parameters

instr (instruction()) – instruction() object that holds instruction data.

Returns

pairs, unPaired, dmVars, cmVars

  • pairs: a list with tuples with paired variables

  • unPaired: a list with unpaired variables

  • dmVars: a list with differential-mode variables

  • cmVars: a list with common mode variables

Return type

tuple

parseMaxResult(result, indepVars, maxResult)

Adds Maxima CAS execution results to the result object.

Parameters
  • result (:class`SLiCAPprotos.allResults()`) – Result object to which the results must be added

  • inDepVars (List of str) – Names of independent variables

  • maxResult (Sympy.Expr) – Maxima CAS execution result.

stepFunctions(stepDict, function)

Substitutes values for step parameters in function and returns a list of functions with these substitutions.

Parameters
  • stepDict (Dictionary) – Dictionary with key-value pair: key: step parameter name (sympy.Symbol) value: list with step values for this parameter.

  • function (sympy.Expr) – Function in which the parameters need to be substituted

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