SLiCAPprotos.py — SLiCAP 3.3.0.2 documentation

# SLiCAPprotos.py

SLiCAP module with basic SLiCAP classes and functions.

class allResults

  Return structure for results, has attributes with instruction data and execution results.

  A

    Base conversion matrix (sympy.Matrix).

  DCvalue

    Zero-frequency value in case of dataType ‘pz’. (sympy.Expr, sympy.Float)

  Dv

    Vector with dependent variables (sympy.Matrix).

  Iv

    Vector with independent variables (sympy.Matrix).

  M

    MNA matrix (sympy.Matrix).

  convType

    Defines the circuit conversion type.

    Will be copied from the instruction at the start of ts execution.

  dataType

    Defines the simulation data type.

    Will be copied from the instruction at the start of its execution.

  dcSolve

    DC solution of the network.

  denom

    Laplace poly of denominator (sympy.Expr).

  depVars()

    Returns the list of detecors available AFTER execution of an instruction.

  detLabel

    Name for the detector quantity to be used in expressions or plots.

    Will be generated by SLiCAPinstruction.instruction at the start of its execution.

  detUnits

    Detector units ‘V’ or ‘A’.

    Will be copied from the instructionat the start of its execution.

  detector

    Names of the positive and negative detector.

    Will be copied from the instructionat the start of its execution.

  errors

    Number of errors found in the definition of this instruction.

    Will be copied from the instructionat the start of its execution.

  gainType

    Defines the simulation gain type.

    Will be copied from the instruction at the start of its execution.

  impulse

    Unit impulse response (ILT) (sympy.Expr).

  inoise

    Total source-referred noise spectral density (sympy.Expr) in V^2/Hz or A^2/Hz.

  inoiseTerms

    Dict with lists with contributions to source-referred noise spectrum

    Key = (str) name of the noise source Value = (sympy.Expr) contribution of that noise source to the source-referred noise spectrum in V^2/Hz or A^2/Hz

  ivar

    Total source-referred variance in V^2 or A^2 (sympy.Expr)

  ivarTerms

    Dict with lists with contributions to source-referred variance.

    Key = (str) name of the dcvar source Value = (sympy.Expr) contribution to the source-referred variance in V^2 or A^2

  label

    Label to be used in plots.

  laplace

    Laplace transfer function, or detector current or voltage (sympy.Expr).

  lgRef

    Refdes of the controlled source that is assigned as loop gain reference.

    Will be copied from the instructionat the start of its execution.

  numer

    Laplace poly of numerator (sympy.Expr).

  numeric

    If True, functions and constants will be evaluated numerically and rational numbers will be converted in sympy.Float

  onoise

    Total detector-referred noise spectrum (sympy.Expr) in V^2/Hz or A^2/Hz.

  onoiseTerms

    Dict with with contributions to detector-referred noise spectrum

    Key = (str) name of the noise source Value = (sympy.Expr) contribution of that noise source to the detector-referred noise spectrum in V^2/Hz or A^2/Hz

  ovar

    Total detector-referred variance in V^2 or A^2 (sympy.Expr)

  ovarTerms

    Dict with lists with contributions to detector-referred variance.

    Key = (str) name of the dcvar source Value = (sympy.Expr) contribution to the detector-referred variance in V^2 or A^2

  pairedCircuits

    Identifiers of paired subcircuits for base transformation of the circuit.

    Will be copied from the instructionat the start of its execution.

  pairedVars

    Extension of paired nodes and branches for base transformation of the circuit.

    Will be copied from SLiCAPinstruction.instruction at the start of its execution.

  parDefs

    Parameter definitions for the instruction.

    Will be copied from SLiCAPinstruction.instruction at the start of its execution.

  params

    Results of parameter sweep (dataType = ‘param’).

  poles

    Complex frequencies in [rad/s] (list)

  removePairSubName

    Setting for changing the parameter names of paired subcircuits.

    Will be copied from the instructionat the start of its execution.

  snoiseTerms

    Dict with source noise spectra.

    Key = (str) name of the noise source Value = (sympy.Expr) noise spectral density in V^2/Hz or A^2/Hz

  solve

    Laplace solution of the network.

  source

    Refdes of the signal source (independent v or i source).

    Will be copied from the instructionat the start of its execution.

  srcUnits

    Source units ‘V’ or ‘A’.

    Will be copied from the instructionat the start of its execution.

  step

    Setting for parameter stepping.

    Will be copied from the instructionat the start of its execution.

  stepArray

    Array (list of lists) with values for step method array.

    Will be copied from the instructionat the start of its execution.

  stepList

    List with values for step method ‘list’.

    Will be copied from the instructionat the start of its execution.

  stepMethod

    Step method for parameter stepping.

    Will be copied from the instructionat the start of its execution.

  stepNum

    Number of steps for step methods ‘lin’ and ‘log’.

    Will be copied from the instructionat the start of its execution.

  stepResp

    Unit step response (ILT) (sympy.Expr).

  stepStart

    Start value for stepping methods ‘lin’ and ‘log’.

    Will be copied from the instructionat the start of its execution.

  stepStop

    Stop value for stepping methods ‘lin’ and ‘log’.

    Will be copied from the instructionat the start of its execution.

  stepVar

    Defines the step variable (str) for step types ‘lin’, ‘log’ and ‘list’.

    Will be copied from the instructionat the start of its execution.

  stepVars

    Defines the step variables for ‘array’ type parameter stepping.

    Will be copied from the instructionat the start of its execution.

  substitute

    If True: parameters from self.circuit will be substituted recursively in element values.

    Else: element values defined in the circuit will be used

  svarTerms

    Dict with source variances

    Key = (str) name of the dcvar source Value = (sympy.Expr) dcvar value in V^2 or A^2

  time

    Time-domain response of the circuit (ILT) (sympy.Expr).

  timeSolve

    Time-domain solution of the network.

  zeros

    Complex frequencies in [rad/s] (list)

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.

  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.