Module circ :: Class NodeToCurrents
[frames] | no frames]

Class NodeToCurrents

Keep track of which currents are flowing in and out of which nodes in a circuit.

Instance Methods
 
__init__(self)
 
addCurrent(self, current, node, sign)
 
addCurrents(self, currents)
 
getKCLEquations(self, gnd)
Returns: a list of equations, one for each node.
Instance Variables
  d
Dictionary, mapping a node name to a list of current descriptions.
Method Details

addCurrent(self, current, node, sign)

 
Parameters:
  • current - name of a current variable (string)
  • node - name of a node (string)
  • sign - +1 or -1, indicating whether the current is flowing into or out of the node

    Adds the new current, with approrpiate sign to node. Adds an entry for node, if doesn't already exist in the dictionary.

addCurrents(self, currents)

 
Parameters:
  • currents - list of tuples (currentName, nodeName, sign), with the same meaning as for addCurrent. Add several currents at once.

getKCLEquations(self, gnd)

 
Parameters:
  • gnd - name of a node that will have its voltage assigned to 0 (string)
Returns:
a list of equations, one for each node. For the ground node, it just asserts that its voltage is 0. For the other nodes, the equation asserts that the sum of the currents going into the node minus the sum of currents going out of the node is equal to zero.

Instance Variable Details

d

Dictionary, mapping a node name to a list of current descriptions. Each current description is a list of a current name and a sign (+1 or -1), indicating whether the current is flowing into or out of that node.