Supplementary Gmatrix Nodal

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 15

How to define G

Supplementary for the nodal analysis assignment!

View in slide show to see the step-by-step


animation
Bahareh Abdi, 10 Oct 2022
First, your matrix G should look like below if you have got
the correct answer!

Let’s look at the element of this matrix and how we can


make such a matrix for any given circuit.
We want to put this matrix into a numpy array.
As you can see the size is (n,n) where n=number of node
We have also added the row and column index for an easier investigation!

0 1 2 3
0 Gs0 + G01 + G02 + G03 - G01 - G02 - G03

1 - G01 Gs1 + G01 + G12 + G13 - G12 - G13

2 - G02 - G12 G02 + G12 0

3 - G03 - G13 0 G03 + G13


As you can see all resistors including source resistance and other resistors
in the circuit (branch/line resistors) appear in this table and we want to
find out the pattern!

0 1 2 3
0 Gs0 + G01 + G02 + G03 - G01 - G02 - G03

1 - G01 Gs1 + G01 + G12 + G13 - G12 - G13

2 - G02 - G12 G02 + G12 0

3 - G03 - G13 0 G03 + G13


The circuit has two sources at node 0 and 1 with internal
conductance Gs0 and Gs0 (or 1/Rs0 and 1/Rs1)!
Source at node 0, Let’s see where they appear!
added to the diagonal
element (0,0) Source at node 1, added to the
diagonal element (1,1) And that’s all!

0 1 2 3
0 Gs0 + G01 + G02 + G03 - G01 - G02 - G03

1 - G01 Gs1 + G01 + G12 + G13 - G12 - G13

2 - G02 - G12 G02 + G12 0

3 - G03 - G13 0 G03 + G13


Now let’s look at the line resistors!
Let’s start with G01 the conductance value of the resistor between
node 0 and 1!
Added to the values at Subtracted from the values
element (0,0) and (1,1) at element (0,1) and (1,0) And that’s all!

0 1 2 3
0 Gs0 + G01 + G02 + G03 - G01 - G02 - G03

1 - G01 Gs1 + G01 + G12 + G13 - G12 - G13

2 - G02 - G12 G02 + G12 0

3 - G03 - G13 0 G03 + G13


Let’s look at G02 the conductance value of the resistor between
node 0 and 2!
Same pattern here: added to the diagonal element of it’s two nodes (0,0)
and (2,2), and subtracted from the elements made by its two nodes (0,2)
and (2,0)!
0 1 2 3
0 Gs0 + G01 + G02 + G03 - G01 - G02 - G03

1 - G01 Gs1 + G01 + G12 + G13 - G12 - G13

2 - G02 - G12 G02 + G12 0

3 - G03 - G13 0 G03 + G13


Another one G13 the conductance value of the resistor between
node 1 and 3!
Same pattern again: added to the diagonal element of it’s two nodes
(1,1) and (3,3), and subtracted from the elements made by its two nodes
(1,3) and (3,1)!
0 1 2 3
0 Gs0 + G01 + G02 + G03 - G01 - G02 - G03

1 - G01 Gs1 + G01 + G12 + G13 - G12 - G13

2 - G02 - G12 G02 + G12 0

3 - G03 - G13 0 G03 + G13


And you can see the same pattern for all other line resistors!

0 1 2 3
0 Gs0 + G01 + G02 + G03 - G01 - G02 - G03

1 - G01 Gs1 + G01 + G12 + G13 - G12 - G13

2 - G02 - G12 G02 + G12 0

3 - G03 - G13 0 G03 + G13


Now that you know the pattern try to code it. If it’s still hard,
continue reading the rest of of these slides.

0 1 2 3
0 Gs0 + G01 + G02 + G03 - G01 - G02 - G03

1 - G01 Gs1 + G01 + G12 + G13 - G12 - G13

2 - G02 - G12 G02 + G12 0

3 - G03 - G13 0 G03 + G13


To make G and to put the values at correct elements, we need the values
for conductance and the nodes they are connected to (indices).
Look at the screenshots from the colab notebook, can you find where the
values and nodes are stored?
Lines gives us the two
nodes each line resistor is
connected between

gen gives us the nodes the sources


are connected two

Gp gives us the values of


line conductance

Rs gives us the values of


source resistance
In practice, we usually start with a matrix filled with zeros.

Step by step we add or subtract the values to/from the value that is
already there at the location we are interested in!

0 1 2 3
0 0 0 0 0

1 0 0 0 0

2 0 0 0 0

3 0 0 0 0
Let’s begin with source resistance.

You can loop for the length of gen or Rs (in this example it would be 2).

Get the index from gen: n0=gen[i]


Use that to add the resistance to the correct element: G[n0,n0] += (1/Rs[i])

0 1 2 3
0 +Gs0 0 0 0

1 0 +Gs1 0 0

2 0 0 0 0

3 0 0 0 0
Now let’s include the line resistors!
Loop through all line resistors, that is length of Gp, for each:
First get both nodes it’s connected to from lines:
n1 = lines[i][0]; n2 = lines[i][1];
Use that to add the resistance to the correct element:
G[n1,n1] += Gp[i]; G[n1,n2] -= Gp[i];
Here you see the result after the
G[n2,n1] -= Gp[i]; G[n2,n2] += Gp[i]; first iteration of the loop

0 1 2 3
0 Gs0 + G01 - G01 0 0

1 - G01 Gs1 + G01 0 0

2 0 0 0 0

3 0 0 0 0
That’s it, good luck!

You might also like