SLiCAPdesignData.py
Created on Fri Nov 18 13:24:17 2022
@author: anton
- createSubstDict(specs)
Returns a subsitutution dictionary from a list with specifications. substDict[<parname>] = <parValue>
- Parameters:
specs (list) – list with specItem objects
- Returns:
dictionary with key-value pairs; for each specitem:
key: parameter name (sympy.Symbol)
value: parameter value (sympy.expression)
- Return type:
dict
- csv2specs(csvFile)
Reads the CSV file with specifications and converts it into a list with specitems.
The file will be read from the ini.csv_folder, which defaults to the ‘csv’ folder in the project diretory.
- Parameters:
csvFile (str) – name of the CSV file in the directory ‘ini.csv_path’
- Returns:
Lit with specification items
- Return type:
list
- selectPars(cir, specList=None, circuit=(), specs=(), user=None)
Returns a dictionary with parameter definitions for the ‘pardefs’ argument of an instruction, selected from three sources: definitions of the circuit, values of specification items, and user-defined values. Parameters that are not selected stay undefined in the analysis.
Each source is given as a list with parameter names. The values of ‘circuit’ and ‘specs’ parameters are read when this function is called, so a specification written to the CSV file by a design script is used in the next analysis.
- Parameters:
cir (SLiCAPprotos.circuit, str) – Circuit from which ‘circuit’ definitions are taken: a SLiCAP circuit object, or the name (without extension) of an NGspice circuit file in the cir folder, whose ‘.param’ definitions are then used.
specList (list) – List with specification items from which ‘specs’ values are taken. Defaults to None.
circuit (list, tuple, str) – Names of parameters that take the definition of the circuit (cir.parDefs), or ‘all’ for all of them. Defaults to an empty tuple.
specs (list, tuple, str) – Names of parameters that take the value of the specification item with the same symbol, or ‘all’ for all items that have a value. Defaults to an empty tuple.
user (dict) – Dictionary with user-defined values: key = parameter name, value = number or expression. Defaults to None.
- Returns:
Dictionary with key-value pairs: key = parameter name (sympy.Symbol), value = parameter value (sympy.Expr)
- Return type:
dict
- Raises:
ValueError – a parameter selected from two sources, a ‘circuit’ parameter without a definition in the circuit, a ‘specs’ parameter without a specification item or with an empty value.
- Example:
>>> import SLiCAP as sl >>> cir = sl.makeCircuit("myCircuit.cir") >>> specs = sl.csv2specs("specs.csv") >>> pardefs = sl.selectPars(cir, specs, circuit=["C_L"], specs=["C_f"], ... user={"R_s": "50"}) >>> result = sl.doLaplace(cir, pardefs=pardefs)
The same selection for an NGspice analysis, the circuit given by its file name:
>>> AC1 = sl.ac("myCircuit", "dec", 20, 1, 1e9, ... params=sl.selectPars("myCircuit", specs, specs=["C_f"]))
- class specItem(symbol, description='', value='', units='', specType='')
Class for specification items. These are parameter definitions with descriptions that can be assigned to the circuit. Specification items must have:
A unique symbol (their parameter name)
A spectype defintion, such as ‘functional’, ‘environment’, ‘design’, etc.
A value
- specs2circuit(specList, cir)
Adds all prameter definitions from the specList to the circuit ‘cir’.
- Parameters:
specList (list) – List with spec items
cir (SLiCAPprotos.circuit) – circuit to which the parameters definitions will be added
- Returns:
None
- Return type:
NoneType
- specs2csv(specList, fileName)
Saves the list with spec items as a CSV file.
The file will be stored in the ini.csv_folder, which defaults to the ‘csv’ folder in the project diretory.
- Parameters:
specList (list) – List with spec items
- Returns:
None
- Return type:
NoneType
- specs2dict(specList)
Creates a dictionary with spec items. the parameter name is used as key. Also checks for unique parameter names.
- Parameters:
specList (List) – List with spec items
- Returns:
dictionary with specification items
- Return type:
dict
- specs2html(specs, types=[])
Displays specification items for the list ‘specs’ on the active HTML page. Specifications of the same type are placed in one table.
If a list of specification types is provided, it creates tables for specified types only. By default, tables for all types will be created.
- Parameters:
specs (list) – List with spec items.
types (str) – List with specification types to be placed on the html page, defaults to [].
- Returns:
HTML code that will be placed on the page
- Return type:
str