Adds the dcvar sources of resistors to instr.circuit for dataType: 'dcvar'. :param dcSolution: DC solution of the network obtained from execution of this instruction with dataType: 'dcsolve' :type dcSolution: sympy.Matrix :param instr: SLiCAP instruction ob
(instr, dcSolution)
| 650 | return instr |
| 651 | |
| 652 | def _addDCvarSources(instr, dcSolution): |
| 653 | """ |
| 654 | Adds the dcvar sources of resistors to instr.circuit for dataType: 'dcvar'. |
| 655 | |
| 656 | :param dcSolution: DC solution of the network obtained from execution of |
| 657 | this instruction with dataType: 'dcsolve' |
| 658 | |
| 659 | :type dcSolution: sympy.Matrix |
| 660 | |
| 661 | :param instr: SLiCAP instruction object that holds instruction data. |
| 662 | :type instr: SLiCAPinstruction.instruction |
| 663 | |
| 664 | :return: instr of the execution of the instruction. |
| 665 | :rtype: SLiCAPinstruction.instruction |
| 666 | """ |
| 667 | newElements = {} |
| 668 | for el in instr.circuit.elements.keys(): |
| 669 | if instr.circuit.elements[el].model.upper() == 'R' and instr.circuit.elements[el].params['value'] != 0: |
| 670 | lotparnames = [] |
| 671 | refDes = instr.circuit.elements[el].refDes |
| 672 | if 'dcvar' in instr.circuit.elements[el].params.keys(): |
| 673 | DCcurrent = 0 |
| 674 | if instr.circuit.elements[el].model == 'r': |
| 675 | pos = instr.depVars().index('I_' + refDes) |
| 676 | DCcurrent = dcSolution[pos] |
| 677 | elif instr.circuit.elements[el].model == 'R': |
| 678 | nodeP, nodeN = instr.circuit.elements[el].nodes |
| 679 | if nodeP != '0': |
| 680 | posP = instr.depVars().index('V_' + nodeP) |
| 681 | Vpos = dcSolution[posP] |
| 682 | else: |
| 683 | Vpos = 0 |
| 684 | if nodeN != '0': |
| 685 | posN = instr.depVars().index('V_' + nodeN) |
| 686 | Vneg = dcSolution[posN] |
| 687 | else: |
| 688 | Vneg = 0 |
| 689 | DCcurrent = sp.simplify((Vpos - Vneg)/instr.circuit.elements[el].params['value']) |
| 690 | if DCcurrent != 0: |
| 691 | errorCurrentVariance = instr.circuit.elements[el].params['dcvar'] * DCcurrent**2 |
| 692 | newCurrentSource = element() |
| 693 | newCurrentSource.refDes = 'I_dcvar_' + refDes |
| 694 | newCurrentSource.params['dcvar'] = errorCurrentVariance |
| 695 | newCurrentSource.params['noise'] = 0 |
| 696 | newCurrentSource.params['dc'] = 0 |
| 697 | newCurrentSource.params['value'] = 0 |
| 698 | newCurrentSource.model = 'I' |
| 699 | newCurrentSource.type = 'I' |
| 700 | newCurrentSource.nodes = instr.circuit.elements[refDes].nodes |
| 701 | newElements[newCurrentSource.refDes] = newCurrentSource |
| 702 | instr.circuit.indepVars.append(newCurrentSource.refDes) |
| 703 | if 'dcvarlot' in list(instr.circuit.elements[el].params.keys()): |
| 704 | lotparname = instr.circuit.elements[el].params['dcvarlot'] |
| 705 | if lotparname: |
| 706 | if lotparname in instr.circuit.parDefs.keys(): |
| 707 | if lotparname not in lotparnames: |
| 708 | lotparnames.append(lotparname) |
| 709 | newVoltageSource = element() |
no test coverage detected