MCPcopy Create free account
hub / github.com/SLiCAP/SLiCAP_python / _pairVariables

Function _pairVariables

SLiCAP/SLiCAPexecute.py:1381–1428  ·  view source on GitHub ↗

Combines nodal voltages and branch currents in pairs of variables that can be resolved in common-mode, and differential-mode variables. Pairing is defined by the instr.pairedVars and instr.pairedCircuits.

(instr)

Source from the content-addressed store, hash-verified

1379 return pairs, unPaired, dmVars, cmVars, A
1380
1381def _pairVariables(instr):
1382 """
1383 Combines nodal voltages and branch currents in pairs of variables that
1384 can be resolved in common-mode, and differential-mode variables.
1385
1386 Pairing is defined by the instr.pairedVars and instr.pairedCircuits.
1387 """
1388 depVars = [var for var in instr.circuit.dep_vars]
1389 paired = []
1390 pairs = []
1391 unPaired = []
1392 dmVars = []
1393 cmVars = []
1394 sub1, sub2 = instr.pairExt
1395 if sub1 != None and sub2 != None:
1396 l_sub1 = len(sub1)
1397 l_sub2 = len(sub2)
1398 while len(depVars) != 0:
1399 var = depVars[0]
1400 if var != 'V_0':
1401 paired = False
1402 if var[-l_sub1:] == sub1:
1403 pairedVar = var[0:-l_sub1] + sub2
1404 if pairedVar in depVars:
1405 paired = True
1406 pairs.append((var, pairedVar))
1407 elif var[-l_sub2:] == sub2:
1408 pairedVar = var[0:-l_sub2] + sub1
1409 if pairedVar in depVars:
1410 paired = True
1411 pairs.append((pairedVar, var))
1412 if paired:
1413 depVars.remove(var)
1414 depVars.remove(pairedVar)
1415 if pairs[-1][0][-l_sub1:] == sub1:
1416 baseName = pairs[-1][0][0: -l_sub1]
1417 if baseName[-1] != '_':
1418 baseName += '_'
1419 dmVars.append(baseName + 'D')
1420 cmVars.append(baseName + 'C')
1421 #_makeNewDetector(instr, [pairedVar, var], baseName)
1422 else:
1423 unPaired.append(var)
1424 depVars.remove(var)
1425 else:
1426 depVars.remove(var)
1427 cmVars += unPaired
1428 return pairs, unPaired, dmVars, cmVars
1429
1430def _makeNewDetector(instr, pairs, dmVars, cmVars):
1431 old_detector = instr.detector

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected