SLiCAPprotos.py¶
SLiCAP module with basic SLiCAP classes and functions.
Imported by the module SLiCAPmatrices.py.
-
class
allResults¶ Return structure for results, has attributes with instruction data and execution results.
-
DCvalue= None¶ Zero-frequency value in case of dataType ‘pz’.
-
Dv= None¶ Vector with dependent variables.
-
Iv= None¶ Vector with independent variables.
-
M= None¶ MNA matrix.
-
circuit= None¶ Circuit (SLiCAPprotos.circuit) used for this instruction.
Will be copied from SLiCAPinstruction.instruction.circuit at the start of the execution of the instruction. This instance will not be a deep copy.
-
dataType= None¶ Defines the simulation data type.
Will be copied from SLiCAPinstruction.instruction at the start of the execution of the instruction.
-
dc= None¶ DC solution at the detector.
-
dcSolve= None¶ DC solution of the network.
-
denom= None¶ Laplace poly of denominator.
-
detLabel= None¶ Name for the detector quantity to be used in expressions or plots.
Will be copied from SLiCAPinstruction.instruction at the start of the execution of the instruction.
-
detUnits= None¶ Detector units ‘V’ or ‘A’.
Will be copied from SLiCAPinstruction.instruction at the start of the execution of the instruction.
-
detector= None¶ Names of the positive and negative detector.
Will be copied from SLiCAPinstruction.instruction at the start of the execution of the instruction.
-
errors= None¶ Number of errors found in the definition of this instruction.
Will be copied from SLiCAPinstruction.instruction at the start of the execution of the instruction.
-
gainType= None¶ Defines the simulation gain type.
Will be copied from SLiCAPinstruction.instruction at the start of the execution of the instruction.
-
impulse= None¶ Unit impulse responses.
-
inoise= None¶ Total source-referred noise spectral density.
-
inoiseTerms= None¶ Dict with lists with contributions to source-referred noise.
-
ivar= None¶ Total source-referred variance.
-
ivarTerms= None¶ Dict with lists with contributions to source-referred variance.
-
laplace= None¶ Laplace transfer functions.
-
lgRef= None¶ Refdes of the controlled source that is assigned as loop gain reference.
Will be copied from SLiCAPinstruction.instruction at the start of the execution of the instruction.
-
numer= None¶ Laplace poly of numerator.
-
numeric= None¶ Variable used during analysis an presentation of analysis results.
Will be copied from SLiCAPinstruction.instruction at the start of the execution of the instruction.
-
onoise= None¶ Total detector-referred noise spectral.
-
onoiseTerms= None¶ Dict with lists with contributions to detector-referred noise.
-
ovar= None¶ Total detector-referred variance.
-
ovarTerms= None¶ Dict with lists with contributions to detector-referred variance.
-
parDefs= None¶ Parameter definitions for the instruction.
Will be copied from SLiCAPinstruction.instruction at the start of the execution of the instruction. This instance will be e deep copy.
-
params= None¶ Results of parameter sweep (dataType = ‘param’).
-
poles= None¶ Complex frequencies in [rad/s] or [Hz]
-
simType= None¶ Defines the simulation gain type.
Will be copied from SLiCAPinstruction.instruction at the start of the execution of the instruction.
-
snoiseTerms= None¶ Dict with lists with source noise spectra.
-
solve= None¶ Solutions of the network.
-
source= None¶ Refdes of the signal source (independent v or i source).
Will be copied from SLiCAPinstruction.instruction at the start of the execution of the instruction.
-
srcUnits= None¶ Source units ‘V’ or ‘A’.
Will be copied from SLiCAPinstruction.instruction at the start of the execution of the instruction.
-
step= None¶ Setting for parameter stepping.
Will be copied from SLiCAPinstruction.instruction at the start of the execution of the instruction.
-
stepArray= None¶ Array (list of lists) with values for step method array.
Will be copied from SLiCAPinstruction.instruction at the start of the execution of the instruction. This instance will be a deep copy.
-
stepList= None¶ List with values for step method ‘list’.
Will be copied from SLiCAPinstruction.instruction at the start of the execution of the instruction. This instance will be a deep copy.
-
stepMethod= None¶ Step method for parameter stepping.
Will be copied from SLiCAPinstruction.instruction at the start of the execution of the instruction.
-
stepNum= None¶ Number of steps for step methods ‘lin’ and ‘log’.
Will be copied from SLiCAPinstruction.instruction at the start of the execution of the instruction.
-
stepResp= None¶ Unit step responses.
-
stepStart= None¶ Start value for stepping methods ‘lin’ and ‘log’.
Will be copied from SLiCAPinstruction.instruction at the start of the execution of the instruction.
-
stepStop= None¶ Stop value for stepping methods ‘lin’ and ‘log’.
Will be copied from SLiCAPinstruction.instruction at the start of the execution of the instruction.
-
stepVar= None¶ Defines the step variable (str) for step types ‘lin’, ‘log’ and ‘list’.
Will be copied from SLiCAPinstruction.instruction at the start of the execution of the instruction.
-
stepVars= None¶ Defines the step variables for ‘array’ type parameter stepping.
Will be copied from SLiCAPinstruction.instruction at the start of the execution of the instruction.
-
svarTerms= None¶ Dict with lists with source variances
-
time= None¶ Time-domain responses.
-
zeros= None¶ Complex frequencies in [rad/s] or [Hz]
-
-
class
circuit¶ Prototype (sub)circuit object.
-
circuits= None¶ (dict) with key-value pairs:
- key: Name (str) of a subcircuit.
- value: Associated circuit object (SLiCAPprotos.circuit).
-
controlled= None¶ (list) with reference designators (str) of controlled sources.
-
defPar(parName, parValue, units=None)¶ Updates or adds a parameter definition and updates the list SLiCAPprotos.circuit.params with names (sympy.Symbol) of undefined parameters.
Parameters: - parName (str, sympy.Symbol) – Name of the parameter.
- parValue (str, sympy.Symbol, sympy.Expr, int, float) – Value of the parameter.
- units (str, sympy.Symbol, sympy.Expr, int, float) – Value of the parameter, defaults to None
Example: >>> # create my_circuit from the netlist 'myFirstRCnetwork.cir' >>> my_circuit = checkCircuit('myFirstRCnetwork.cir') >>> # Define the value of 'R' as 2000 >>> my_circuit.defPar('R', '2k', ) >>> # Or: >>> my_circuit.defPar('R', 2e3)
-
defPars(parDict)¶ Adds or modifies multiple parameter definitions and updates the list circuit.params with names (sympy.Symbol) of undefined parameters.
Params parDict: Dictionary with key-value pairs:
- key: parName (str, sympy.Symbol): name of the parameter.
- value: parValue (str, float, int, sympy object): value or expression of the parameter.
Example: >>> # Create my_circuit from the netlist 'myFirstRCnetwork.cir' >>> my_circuit = checkCircuit('myFirstRCnetwork.cir') >>> # Define the value of 'R' as 2000 and 'C' as 5e-12: >>> my_circuit.defPars({'R': '2k', 'C': '5p')
-
delPar(parName)¶ Deletes a parameter definition and updates the list SLiCAPprotos.circuit.params with names (sympy.core.symbol.Symbol) of undefined parameters.
Parameters: parName (str, sympy.core.symbol.Symbol) – Name of the parameter. Example: >>> # create my_circuit from the netlist 'myFirstRCnetwork.cir' >>> my_circuit = checkCircuit('myFirstRCnetwork.cir') >>> # Delete the definition for the parameter 'R': >>> my_circuit.delPar('R')
-
depVars= None¶ (list) with names (str) of independent variables:
nodal voltages:
A nodal voltage will be named as: ‘V_<node name>’
branch currents. Branch current will be named ad follows:
- Current through a two-terminal element:
- Vxxx: ‘I_Vxxx’
- Rxxx with model ‘r’: ‘I_Rxxx’
- Lxxx: ‘I_Lxxx’
- Currents through the input port or the output port of controlled
sources:
- Exxx output port: ‘Io_Exxx’
- Fxxx input port: ‘Ii_Fxxx’
- Gxxx, model = ‘G’, output port: ‘Io_Gxxx’
- Hxxx, input port: ‘Ii_Hxxx’, output port: ‘Io_xxx’
- Current through a two-terminal element:
-
elements= None¶ (dict) with key-value pairs:
- key: Reference designator (str) of the element.
- value: Element object (SLiCAPprotos.element)
-
errors= None¶ Number (int) of errors found during checking of the circuit. Defaults to 0.
-
file= None¶ Name (str) of the netlist file. Defaults to None.
-
getElementValue(elementID, param, numeric)¶ Returns the value or expression of one or more circuit elements.
If instruction.numeric == True it will perform a full recursive substitution of all circuit parameter definitions.
This method is called by instruction.circuit.getElementValue() with keyword arg numeric = True if instruction.simType is set to ‘numeric’.
Parameters: - elementID (str, list) – name(s) of the element(s)
- param (str) –
name of the parameter (equal for all elements):
- ’value’: Laplace value
- ’dc’: DC value (independent sources only)
- ’noise’: Noise spectral density (independent sources only)
- ’dcvar’: DC variance (independent sources only)
Returns: if type(parNames) == list:
return value = dict with key-value pairs: key (sympy.core.symbol.Symbol): name of the parameter, value (int, float, sympy expression): value of the parameter
else: value or expression
Return type: dict, float, int, sympy.Expr
Example: >>> # Create an instance if a SLiCAP instruction >>> my_instr = instruction() >>> # Create my_instr.circuit from the netlist 'myFirstRCnetwork.cir' >>> my_instr.setCircuit('myFirstRCnetwork.cir') >>> # Obtain the numeric value of 'R1' and 'C1': >>> my_instr.symType = 'numeric' >>> print my_instr.getElementValue(['R1', 'C1']) {'C1': 5.0e-7/pi, 'R1': 1000.00000000000}
-
getParValue(parNames, numeric=False)¶ Returns the value or expression of one or more parameters.
If numeric == True it will perform a full recursive substitution of all circuit parameter definitions.
Parameters: parNames (str, sympy.Symbol, list) – name(s) of the parameter(s) Returns: If type(parNames) == list: (dict) with key-value pairs:
- key (sympy.Symbol): name of the parameter
- value (int, float, sympy object): value of the parameter
Else: value or expression (int, float, sympy object).
Return type: dict, float, int, sympy obj Example: >>> # create an instance if a SLiCAP instruction >>> my_instr = instruction() >>> # create my_instr.circuit from the netlist 'myFirstRCnetwork.cir' >>> my_instr.checkCircuit('myFirstRCnetwork.cir') >>> # Obtain the numeric parameter definitions of of 'R' and 'C': >>> my_instr.symType = 'numeric' >>> my_instr.getParValues(['R', 'C'])
-
indepVars= None¶ (list) with reference designators (str) of independent variables:
- independent voltage sources
- independent current sources.
-
lexer= None¶ Tokenized (ply.lex.lex) netlist file. Defaults to None.
-
libs= None¶ (list) with names (str) of library files found in netlist lines starting with ‘,lib’ or ‘.inc’.
-
modelDefs= None¶ (dict) with key-value pairs:
- key: Name (sympy.core.symbol.Symbol) of a model.
- value: Associated model object (SLiCAPprotos.model).
-
nodes= None¶ (list) with names (str) of circuit nodes.
-
parDefs= None¶ (dict) with key-value pairs:
- key: Name (sympy.core.symbol.Symbol) of a circuit parameter.
- value: Value (sympy object, float, int) of the parameter.
-
parUnits= None¶ (dict) with key-value pairs:
- key: Name (sympy.core.symbol.Symbol) of a circuit parameter.
- value: Units (str) of the parameter.
-
params= None¶ If SLiCAPcircuit.subCKT == True:
(dict) with key-value pairs:
- key: Name (sympy.core.symbol.Symbol) of a parameter that can be passed to the sub circuit.
- value: Default value (sympy object, float, int) of the parameter.
Else:
- (list) with names (sympy.core.symbol.Symbol) of undefined parameters.
-
subCKT= None¶ (bool) True if the circuit is a sub circuit. Defaults to False.
-
title= None¶ Title (str) of the circuit. Defautls to None.
-
updateParams()¶ Updates self.params (list with undefined parameters) after modification of parameter definitions in self.parDefs.
-
varIndex= None¶ (dict) with key-value pairs:
- key (str): node name or name of branch current.
- value(int) : row position in the vector with independent variables, before elemination of the row anmd column associated with the reference node ‘0’.
-
-
copyNotOverwrite(src, dest)¶ Copies the file ‘src’ to ‘dest’ if the latter one does not exist.
Parameters: - src (str) – Name of the source file.
- dest (str) – Name of the desitination file.
-
class
device¶ Prototype for devices that can be used in SLiCAP.
-
ID= None¶ ID of the device, e.g. ‘V’ for voltage source. Defaults to ‘’.
-
models= None¶ (list) with names (str) of valid models for the device.
-
nNodes= None¶ Number (int) of nodes of the device. Defaults to 0.
-
nRefs= None¶ Number (int) of reference designators of referenced devices. Defaults to 0.
-
value= None¶ (bool) True if model or value is required. Defaults to True.
-
-
class
element¶ Prototype circuit element object.
-
model= None¶ Name (str) of the model of the element.
-
nodes= None¶ (list) with names (str) of the nodes to which the element is connected.
-
params= None¶ (dict) with key-value pairs:
- key (sympy.core.symbol.Symbol): Name of an element parameter.
- value (sympy object, float, int): Value of the parameter.
-
refDes= None¶ Element reference designator (str), defaults to ‘’.
-
refs= None¶ (list) with reference designators of elements (str) that are referenced to by the element.
-
type= None¶ Element type: First letter of refdes (str).
-
-
initAll()¶ Creates the SLiCAP built-in models and devices.
-
makeDir(dirName)¶ Creates the directory ‘dirName’ if it does not yet exist.
Parameters: dirName (str) – Name of the ditectory.
-
class
model¶ Protpotype for element models that can be used in SLiCAP.
-
depVars= None¶ (list) with names of dependent variables to be used in the vector with dependent variables.
-
name= None¶ Name (str) of the model.
-
params= None¶ (dict) with key-value pairs:
- key (str): Name of the model parameter
- value (bool): True if the Laplace variable is allowed in the expression for this parameter, else False.
-
stamp= None¶ (bool) True if model has associated matrix stamp, False if it requires expansion.
-
-
class
modelDef¶ Protpotype for model definitions that can be added to SLiCAP.
-
name= None¶ Name (str) of the model.
-
params= None¶ (dict) with key-value pairs:
- key (str): Model parameter name
- value (sympy object, float, int): Value or expression
-
type= None¶ Name (str) of the built-in model type that should be used for this model.
-