MCPcopy Index your code
hub / github.com/SLiCAP/SLiCAP_python / _updateCirData

Function _updateCirData

SLiCAP/SLiCAPyacc.py:1167–1265  ·  view source on GitHub ↗

Updates data of the main expanded circuit required for instructions. - Updates the lists with dependent variables (detectors), sources (independent variables) and controlled sources (possible loop gain references). - If global parameters are used in the circuit, their defin

(circuitObject)

Source from the content-addressed store, hash-verified

1165""" PASS 4 FUNCTIONS """
1166
1167def _updateCirData(circuitObject):
1168 """
1169 Updates data of the main expanded circuit required for instructions.
1170
1171 - Updates the lists with dependent variables (detectors), sources
1172 (independent variables) and controlled sources (possible loop gain
1173 references).
1174 - If global parameters are used in the circuit, their definition is added
1175 to the '.parDefs' attribute of the circuit.
1176 - Checks if the global ground node '0' is used in the circuit.
1177 - Checks if the circuit has at least two nodes.
1178 - Checks if the referenced elements exist.
1179 - Converts circuitObject.params into list and puts the undefined parameters
1180 in it
1181
1182 :param circuitObject: Circuit object to be updated
1183 :type circuitObject: SLiCAPprotos.circuit
1184
1185 :return: Updated circuit object
1186 :rtype: SLiCAPprotos.circuit
1187 """
1188 # Convert *char* keys in the .parDefs attribute into sympy symbols.
1189 for key in list(circuitObject.parDefs.keys()):
1190 if type(key) == str:
1191 circuitObject.parDefs[sp.Symbol(key)] = circuitObject.parDefs[key]
1192 del(circuitObject.parDefs[key])
1193 circuitObject.params =[]
1194 circuitObject.nodes = []
1195 circuitObject.dep_vars = []
1196 circuitObject.indepVars = []
1197 circuitObject.references = []
1198 for elmt in circuitObject.elements.keys():
1199 circuitObject.nodes += circuitObject.elements[elmt].nodes
1200 if circuitObject.elements[elmt].type in _INDEPSCRCS:
1201 circuitObject.indepVars.append(elmt)
1202 elif circuitObject.elements[elmt].type in _CONTROLLED:
1203 circuitObject.controlled.append(elmt)
1204 circuitObject.references += circuitObject.elements[elmt].refs
1205 for i in range(len(_MODELS[circuitObject.elements[elmt].model].depVars)):
1206 depVar = _MODELS[circuitObject.elements[elmt].model].depVars[i]
1207 circuitObject.dep_vars.append(depVar + '_' + elmt)
1208 # Add parameters used in element expressions to circuit.params
1209 for par in circuitObject.elements[elmt].params.keys():
1210 try:
1211 circuitObject.params += circuitObject.elements[elmt].params[par].atoms(sp.Symbol)
1212 except:
1213 pass
1214
1215 # Add parameters used in parDef expressions to circuit.params
1216 for par in list(circuitObject.parDefs.keys()):
1217 circuitObject.params.append(par)
1218 circuitObject.params += circuitObject.parDefs[par].atoms(sp.Symbol)
1219 circuitObject.params = list(set(circuitObject.params))
1220 # Try to find required global parameter definitions for undefined params
1221
1222 for par in circuitObject.params:
1223 if par != ini.laplace and par != ini.frequency and par not in list(circuitObject.parDefs.keys()):
1224 circuitObject = _addGlobalParam(par, circuitObject)

Callers 5

checkMethod · 0.90
_doInstructionFunction · 0.90
_addDCvarSourcesFunction · 0.90
_delDCvarSourcesFunction · 0.90
_checkCircuitFunction · 0.85

Calls 2

_addGlobalParamFunction · 0.85
formatMethod · 0.80

Tested by

no test coverage detected