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

Function _convertMatrices

SLiCAP/SLiCAPexecute.py:1301–1344  ·  view source on GitHub ↗

Converts the instr attributes M, Iv and Dv into those of equivalent common-mode or differential mode circuits. If instruction.removePairSubName == True, it also removes the pair extensions from paired parameters. The conversion type is defined by the attribute instr.convType i

(instr)

Source from the content-addressed store, hash-verified

1299 return refs
1300
1301def _convertMatrices(instr):
1302 """
1303 Converts the instr attributes M, Iv and Dv into those of equivalent
1304 common-mode or differential mode circuits.
1305
1306 If instruction.removePairSubName == True, it also removes the pair extensions
1307 from paired parameters.
1308
1309 The conversion type is defined by the attribute instr.convType it can be:
1310
1311 - 'dd' Diferential-mode transfer
1312 - 'cc' Common-mode transfer
1313 - 'dc' Differential-mode to common-mode conversion
1314 - 'cd' Common-mode to differential-mode conversion
1315 - 'all' The complete vectors with redefined and re-arranged common-mode
1316 and differential-mode quantities.
1317
1318 """
1319 pairs, unPaired, dmVars, cmVars, A = _createConversionMatrices(instr)
1320 if instr.removePairSubName:
1321 lenExt = len(instr.pairExt[0])
1322 params = list(set(list(instr.M.atoms(sp.Symbol)) + list(instr.Iv.atoms(sp.Symbol))))
1323 substDict = {}
1324 for param in params:
1325 parName = str(param)
1326 if len(parName) > lenExt:
1327 if parName[-lenExt:] in instr.pairExt:# and nameParts[-1][:-lenExt] in baseIDs:
1328 substDict[param] = sp.Symbol(parName[:-lenExt])
1329 instr.M = instr.M.xreplace(substDict)
1330
1331 if instr.dataType != 'noise' and instr.dataType != 'dcvar':
1332 instr.Iv = instr.Iv.xreplace(substDict)
1333
1334 instr.Dv = sp.Matrix(dmVars + cmVars)
1335 instr.M = A.transpose() * instr.M * A
1336 instr.Iv = A.transpose() * instr.Iv
1337 instr.A = A
1338 dimDm = len(pairs)
1339 dimCm = dimDm + len(unPaired)
1340 instr = _getSubMatrices(instr, dimDm, dimCm, instr.convType)
1341 #instr.detector = instr.detector
1342 instr.detector = _makeNewDetector(instr, pairs, dmVars, cmVars)
1343 instr.references = _pairReferences(instr.circuit.references, instr.pairExt, instr.convType)
1344 return instr
1345
1346def _createConversionMatrices(instr):
1347 """

Callers 2

_convertDCsolveFunction · 0.85
_makeAllMatricesFunction · 0.85

Calls 4

_getSubMatricesFunction · 0.85
_makeNewDetectorFunction · 0.85
_pairReferencesFunction · 0.85

Tested by

no test coverage detected