SLiCAPprotos.py
SLiCAP module with basic SLiCAP classes and functions.
- class Snippet(snippet: str = '', format: None | str = None, mode='w')
Text snippet created by the formatters.
- property format
Will be set by the formatter method.
- save(filenameOrPath: str | Path)
Saves the snippet.
If the path is absolute, it saves it in that location. Otherwise, the preffix and suffix are added according to format:
latex
prefix: project folder -> SLiCAP.ini -> [projectpaths] -> tex_snippets
suffix: ‘.tex’
rst
prefix: project folder -> SLiCAP.ini -> [projectpaths] -> rst_snippets
suffix: ‘.rst’
expressions and inline equations are appended to the file as:
|<variable name>| = <expr>|<inline equation>
myst
prefix: project folder -> SLiCAP.ini -> [projectpaths] -> myst_snippets
suffix: ‘.md’
html
prefix: project folder -> SLiCAP.ini -> [projectpaths] -> html_snippets
suffix: ‘.html
md
prefix: project folder -> SLiCAP.ini -> [projectpaths] -> md_snippets
suffix: ‘.md’
- property snippet
Will be set by the formatter method.
- class circuit
Prototype (sub)circuit object.
- circuits
(dict) with key-value pairs:
key: Name (str) of a subcircuit.
value: Associated circuit object (SLiCAPprotos.circuit).
- controlled
(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) – Value of the parameter, defaults to None
- Returns:
None
- Return type:
NoneType
- 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.
- Returns:
None
- Return type:
None
- 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.
- Returns:
None
- Return type:
NoneType
- depVars()
Returns the list with valid detectors.
- Returns:
list with valid detectors
- Return type:
list
- dep_vars
(list) with names (str) of independent variables:
nodal voltages:
A nodal voltage will be named as: ‘V_<node name>’. The reference node ‘V_0’ is also listed, but it cannot be used as detector. use circuit.dep_vars() to obtain the list of valid detectors.
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’
- detector
Signal detector None if not defined, or a list with two names of dependent variales or one name and ‘None’.
- elements
(dict) with key-value pairs:
key: Reference designator (str) of the element.
value: Element object (SLiCAPprotos.element)
- errors
Number (int) of errors found during checking of the circuit. Defaults to 0.
- file
Name (str) of the netlist file. Defaults to None.
- getElementValue(elementID, param='value', substitute=True, numeric=False)
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)
Defaults to ‘value’
substitute (Bool) –
True: circuit parameters will be recursively substituted
False: Element values or expressions will be returned as defined
Defaults to True
numeric (Bool) –
True: Numeric values of functions and constants will be evaluated and rational numbers will be converted to sympy.Float.
False: No numeric evaluation of functions and constants
Defaults to False
- 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, sympy.Float, sympy.Expr
- getParValue(parNames, substitute=True, numeric=False)
Returns the value or expression of one or more parameters.
If substitute == True, recursive substitution of all circuit parameters will be applied.
If numeric == True, numeric values of functions wand constants will be evaluated and converted to sympy.Floats
- Parameters:
parNames (str, sympy.Symbol, list) – name(s) of the parameter(s)
substitute (Bool) –
True: circuit parameters will be recursively substituted
False: Parameter values or expressions will be returned as defined
Defaults to True
numeric (Bool) –
True: Numeric values of functions and constants will be evaluated and rational numbers will be converted to sympy.Float
False: No numeric evaluation of functions and constants
Defaults to False
- Returns:
If type(parNames) == list: a dict with key-value pairs:
key (sympy.Symbol): name of the parameter
value (sympy.Float, sympy.Expr): value of the parameter
Else: value or expression (sympy.Float or sympy.Expr).
- Return type:
dict, sympy.Float, sympy.Expr
- indepVars
(list) with reference designators (str) of independent variables:
independent voltage sources
independent current sources.
- lgRef
Loopgain reference: None if not defined ,or a list with two identifies controlled sources or one idenfifier and ‘None’.
- libs
(list) with names (str) of library files found in netlist lines starting with ‘,lib’ or ‘.inc’.
- modelDefs
(dict) with key-value pairs:
key: Name (sympy.core.symbol.Symbol) of a model.
value: Associated model object (SLiCAPprotos.model).
- nodes
(list) with names (str) of circuit nodes.
- parDefs
(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
(dict) with key-value pairs:
key: Name (sympy.core.symbol.Symbol) of a circuit parameter.
value: Units (str) of the parameter.
- params
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.
- references
(list) with reference designators (str) of referenced elements.
- source
Signal source: None if not defined, or a list with two identifies of independent sources or one idenfifier and ‘None’.
- subCKT
(bool) True if the circuit is a sub circuit. Defaults to False.
- title
Title (str) of the circuit. Defautls to None.
- updateParams()
Updates self.params (list with undefined parameters) after modification of parameter definitions in self.parDefs.
- class element
Prototype circuit element object.
- model
Name (str) of the model of the element.
- nodes
(list) with names (str) of the nodes to which the element is connected.
- params
(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
Element reference designator (str), defaults to ‘’.
- refs
(list) with reference designators of elements (str) that are referenced to by the element.
- type
Element type: First letter of refdes (str).
- class modelDef
Protpotype for model definitions that can be added to SLiCAP.
- name
Name (str) of the model.
- params
(dict) with key-value pairs:
key (str): Model parameter name
value (sympy object, float, int): Value or expression
- type
Name (str) of the built-in model type that should be used for this model.