Automation of Network Analysis Techniques Based On Graph Theory - Aissa
Automation of Network Analysis Techniques Based On Graph Theory - Aissa
Title:
Presented By:
AZZAZ Aissa
Supervisor:
Pr. Abdelmadjid Recioui
1
Contents
Title Page 1
Abstract 1
Contents 2
Introduction 4
3 Implementation 27
3.1 MatLab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
2
Contents Contents
Conclusion 37
References 39
3
Introduction
The field of graph theory is a vastly used and well established mathematical field. The usefulness of
graph theory lies in its ability to model many different science areas and solve their fundamental prob-
lems. Graph theory finds use cases in network traffic, neuronal networks, social networks, biological
networks and computer networks. [1] [2] [3]
Electrical networks theory and analysis often uses graph theory principles. The simple and fundamen-
tal laws of electrical circuits (KVL, KCL) could handle simple networks very easily and perfectly, but
when it comes to huge electrical networks such as those modeling the behavior of large systems, the
simple laws and approaches could become very hard and cumbersome to apply especially if they are
applied manually.
Almost all electrical simulators make use of graph theory principles in which they extract information
from the circuit being simulated and then apply the graph theory principles to obtain the different
network parameters. An example of this, is NI Multisim[4] simulation software which uses the nodal
analysis method implemented on the SPICE (Simulation Program with Integrated Circuit Emphasis)
engine[5] to perform circuit simulation.[6]
In this project, we examine some of the main principles of graph theory in the first chapter along
with the basic representations of graphs through matrices. In the second chapter, we illustrate and
approach network analysis using the graph theory principles obtained earlier by explanting how elec-
trical networks are represented through graphs. In the third chapter, we give a brief explanation on
how to build a program implementing the different network analysis techniques presented in earlier
chapters using MatLab, along with a comparison with NI Multisim.
4
Chapter 1
0.5 mH
5
2 mH 1 kΩ
1 2 3
2 4
1 2 3
3 kΩ
0.25 kΩ 2 nF 3
1 6
+
v(t) −
0
0
1.2 Graphs
In order to proceed any further in the topic of graph theory, we have to define some basic definitions
and concepts that are necessary and useful for a proper understating [13] [14]:
5
1.2. Graphs Chapter 1. Introduction to graph theory
Graph: a collection of nodes and branches that connect these nodes. Figure 1.2 shows examples of
graphs.
Node: an end point of a line segment or an isolated point. It is also called a vertex or junction.
Branch: a line segment which represents a network element or a combination of elements connected
between two points. Each branch joins two distinct nodes. It is also called an edge.
An incident branch izs a branch that starts or ends at that node. In the example of Figure 1.2(b),
branch ’1’ is incident to nodes "1" and "2", whereas branch 8 is incident to nodes "2" and "6".
Path: any sequence of nodes connected by branches. A path maybe closed or open.In the graph
Figure 1.2(b), the path connecting nodes 1,2,3 and 5 by the branches 1,2,3 and 4 is a closed path
whereas the path connecting nodes 2,3,5 and 4 by the branches 2,3 and 6 is an open path.
Loop: any closed path. In the graph Figure 1.2(b), the path joining nodes 5,6 and 4 using the branches
7,5 and 6 is a closed path.
Mesh: a loop that doesn’t contain any other loops within it.
Connected graph: a graph in which at least one path could be found between any two nodes of it.
Directed (Oriented) graph: a graph in which all the nodes and branches are numbered or a direction
is assigned to the branches by an arrow. Figure 1.2 shows an example of a direct and undirected graph.
Subgraph: a subset of the original graph that contains fewer nodes and branches than the original
one. The example of Figure 1.3(a) shows an arbitrary subgraph of the graph on Figure 1.2(b).
Tree: a connected subgraph with no loops. The subgraph of Figure 1.3(b) shows an arbitrary tree
whereas the one on Figure 1.3(a) does not because it contains a loop. The tree contains all nodes of
the graph and only one branch (twig) is connecting any two nodes, hence the number of twigs in a
tree is one less than the number of nodes (N − 1).
The branches of a tree are called twigs and the remaining ones are called links. Branches 1,2,3,5 and
7 of the graph on Figure 1.2(b) generate a tree and the corresponding links are the branches 4,6 and 8.
Co-tree: the subgraph formed by the set of links (the complement of a tree). The subgraph of Fig-
ure 1.3(c) shows the corresponding co-tree of the tree shown in Figure 1.3(b).
6
1.2. Graphs Chapter 1. Introduction to graph theory
1
1
1
2
2
2 4
3
6
8 3
5
3
4 6 6
5 4
(a) Undirected Graph (b) Directed Graph
1
1
1
2
2 2
2
2 4
3
3
3
3 8
5
5 5
7
7
6 6 6 6
6
5
5
4 4
4
(c) Co-tree
(a) Subgraph
(b) Tree
7
1.3. Matrix representation of a graph Chapter 1. Introduction to graph theory
A directed graph may be described completely in a compact and convenient matrix, this is known as
the complete incidence matrix AA . It describes how nodes and branches of a graph are interconnected.
To obtain A we shall first obtain the complete node to branch matrix AA . For a graph containing N + 1
nodes numbered from 0 to N and B branches, AA is defined as:
+1 if branch j is directed away from node i
ai j = 0 if branch j is not incident to node i
−1 if branch j is directed towards node i
The graph in Figure 1.4 has 5 nodes and 8 branches, hence the construction of AA can be organized in
Table 1.1.
2 4
1 2 3
1 7
3 6
0 4
8
Figure 1.4: Graph Example
Branches
1 2 3 4 5 6 7 8
Nodes
0 -1 0 -1 0 0 0 0 -1
1 1 1 0 0 0 0 0 0
2 0 -1 1 1 1 0 1 0
3 0 0 0 -1 -1 1 0 0
4 0 0 0 0 0 -1 -1 1
8
1.3. Matrix representation of a graph Chapter 1. Introduction to graph theory
The complete incidence matrix is characterized by the fact that the sum of all elements along each
column is zero because a branch would leave a node and enter another one. As a result, eliminating
one row from AA wouldn’t affect the information conveyed about the graph. This elimination of one
row from AA would result in the incidence matrix A (also called the reduced node to branch incidence
matrix).
In the graph of Figure 1.4, eliminating the first row corresponding to node 0 we could obtain the
incidence matrix as:
1 1 0 0 0 0 0 0
0 −1 1 1 1 0 1 0
A= 0 0 0 −1 −1 1
0 0
0 0 0 0 0 −1 −1 1
The incidence matrix A could be partitioned such that N columns correspond to the twigs of an
arbitrary selected tree and the remaining B − N columns represent the co-tree links. Hence, A would
be partitioned to square sub-matrix At and a rectangular sub-matrix Ac which results in:
A = At Ac
In At at least one column has only a non zero entry that is +1 or −1 because any branch is incident to
two nodes. Hence, the matrix At is a non-singular (invertible) matrix and det(At ) = ±1.
In the graph of Figure 1.4, if branches 2,4,6 and 8 are selected to form an arbitrary tree then the
incidence matrix could be partitioned as follows:
1 0 0 0 1 0 0 0
−1 1 0 0 0 1 1 1
A = At Ac = 0 −1 1 0 0 0 −1 0
; det(At ) = +1
0 0 −1 1 0 0 0 −1
9
1.3. Matrix representation of a graph Chapter 1. Introduction to graph theory
In the graph of Figure 1.4 and the incidence matrix obtained earlier, we get :
2 −1 0 0
−1 5 −2 −1
AAT = 0 −2 3 −1 ; det(AA ) = 34
T
0 −1 −1 3
which means there are 34 possible trees in the graph shown of Figure 1.4.
In an electric network, V denotes the column vector of branch voltages and E the column vector that
represents the node voltages with respect to the reference node (the one eliminated from the complete
incidence matrix ). A relation linking V, E and the incidence matrix A is formed as:
V = AT E (1.3.1)
vk
+ −
i kth branch element j
+ +
ei ej
− o −
KCL states that the algebraic sum of the currents entering a node is equal to the algebraic sum of
currents leaving it [16]. In other words, the sum of currents incident to a node is zero. If I denotes the
column matrix of branch currents, that is:
AI = 0 (1.3.2)
The nonzero entries of any row of A reflect branch incidence at the node corresponding to the row
and the sign is one to one correspondence to branch directions.
If I is partitioned for some tree and co-tree as:
It
I = · · ·
Ic
10
1.3. Matrix representation of a graph Chapter 1. Introduction to graph theory
It = −At−1 Ac Ic (1.3.3)
In the graph in Figure 1.6, taking the branches 1,3 and 6 as a tree results in the following partitioned
incidence matrix:
−1 0 0 1 0 1 0
A = 0 1 0 −1 1 0 0
0 0 1 0 −1 −1 1
2 4
1 2 3
3
1 6
7
0
As a result, the tree current could be expressed in terms of the co-tree currents as follows:
i2
i1 = i2 + i5
i1 1 0 1 0
−1 i 4
It = i3 = −At Ac Ic = 1 −1 0 0
i5 ⇒ i3 = i2 − i4
i6 0 1 1 −1
i6 = i4 + i5 − i7
i7
11
1.3. Matrix representation of a graph Chapter 1. Introduction to graph theory
The complete loop to branch incidence matrix BA conveys information about the branches direction
when traversing the loops obtained from a selected tree of a graph.
The complete loop-to-branch incidence matrix BA has entries as follows:
+1 if branch j is oriented in the same direction as the path of loop i
bi j = 0 if branch j is not incident with loop i i
−1 if branch j is oriented in opposite direction as the path of loop i
2 4
1 2 3
5
1 6
branches
1 2 3 4 5 6
Loops
L1 : {1; 2; 5} 1 1 0 0 1 0
L2 : {2; 3; 4} 0 -1 1 -1 0 0
L3 : {4; 6; 5} 0 0 0 1 -1 1
L4 : {1; 2; 4; 6} 1 1 0 1 0 1
L5 : {1; 3; 4; 5} 1 0 1 -1 1 0
L6 : {2; 3; 6; 5} 0 -1 1 0 -1 1
L7 : {1; 3; 6} 1 0 1 0 0 1
12
1.3. Matrix representation of a graph Chapter 1. Introduction to graph theory
The number of nonzero entries along each column represents the number of loops in which that branch
appears, while the number of nonzero entries in each row is equal to the number of branches in the
loop corresponding to that row.
The number of nonzero entries in each row is equal to the number of branches in the loop correspond-
ing to that row.
The fundamental loop matrix B f is a submatrix of BA that defines the minimum number of indepen-
dent loops. B is constructed based on trees and co-trees. It is constructed by selecting a tree from the
graph, then deducing the corresponding independent loops by taking the corresponding links one at a
time. The construction of B f proceeds by rearranging the columns so that the twigs appear first then
the links.
Each link results in a fundamental loop, as a result the number of fundamental loops is equal to the
number of links that is B − N + 1.
It happens that the co-tree submatrix Bc is square with one nonzero element in each row and column.
Since B is not unique and no restrictions are made on the choice of row and column order selection;
one may choose to make B appear in the normal fundamental form or simply the fundamental loop
matrix as follows:
..
B = Bt . U
where Bc is reduced to the identity matrix U. This is done by starting the numbering of the funda-
mental loops from the links.
In the graph of Figure 1.7, choosing the branches 2,4 and 5 as a tree, will lead to branches 1,3 and
6 being the links. Then, the obtained fundamental loops (shown in Figure 1.8) are L1 : {1; 2; 5}, L2 :
{2; 3; 4}, L3 : {4; 6; 5} which results in the following reduced fundamental loop matrix B:
1 0 1 1 0 0
B = Bt Bc = Bt U = −1 −1 0 0 1 0
0 1 −1 0 0 1
3
2 4 2 4 2 4 2 4
1 2 3 1 2 3 1 2 3 1 2 3
5 5 5 5
1 6
0 0 0 0
(a) Tree (b) L1 (c) L2 (d) L3
KVL states that the algebraic sum of the voltage drop is equal to the algebraic sum of the voltage rise
in any closed path [16]. In other words, the algebraic sum of branch voltages along any loop is zero.
13
1.3. Matrix representation of a graph Chapter 1. Introduction to graph theory
BV = 0 (1.3.4)
Vc = −Bt Vt (1.3.5)
In the example of Figures 1.7 and 1.8, applying this rule would result in:
v1 = −v2 − v5
v1 −1 0 −1 v2
Vc = v3 = −Bt Vt = 1 1 0 v4 ⇒ v3 = v2 + v4
v6 0 −1 1 v5
v6 = v4 − v5
ABT = 0 (1.3.6a)
BAT = 0 (1.3.6b)
and this is also true for the complete non-reduced versions of A and B, that is:
AA BTA = 0
BA ATA = 0
. .
If A is known and written in partitioned form: A = [ At .. Ac ] and B = [ Bt .. U ], applying equation 1.3.6a
and since At is invertible, we obtain:
T
Bt
AB = At Ac · · · = At BtT + Ac = 0 ⇒ B = −(At−1 Ac )T U
T
Bt = −(At−1 Ac )T (1.3.8)
14
1.3. Matrix representation of a graph Chapter 1. Introduction to graph theory
The cut-set
The cut set is a minimal set of branches of a graph, removal of which cuts the graph into two parts.
It separates the nodes of the graph into two groups. The cut-set consists of only one tree branch and
remainders are links. Each branch of the cut-set has one of its terminal incident at a node in one
group and its other end at a node in the other group and its other end at a node in the other group. The
orientation of the cut-set is the same as the orientation of the tree branch.
The fundamental cut set matrix D is just the reduced incidence matrix written such that: At = U, so:
D = U Dc = U Ac ; DI = 0 ⇒ It = −Dc Ic
.
To write D as D = [U .. Dc ] , Dc must correspond to a co-tree. A tree should be selected first. Then D
is constructed with entries as follows and the reference direction is taken as the direction of the twig:
+1 if branch j belongs to cut set i and reference direction agree
di j = −1 if branch j belongs to cut set i and reference direction opposite
0 if branch j doesn’t belong to cut set i
In the graph of Figure 1.9(a), by selecting branches 1,4 and 5 as a tree, we obtain three fundamental
cut-sets:{1; 2; 6}, {2; 3; 4}, {2; 3; 5} which are shown in Figure 1.9(b).
C3
6 C2 6
2 2
1 2 C1 1 2
3 3
1 4 1 4
4 3 4 3
5 5
(a) Graph (b) Cut-sets
15
1.3. Matrix representation of a graph Chapter 1. Introduction to graph theory
The construction of the fundamental cut-set matrix C for the graph of Figure 1.9 is organized in
Table 1.3.
Table 1.3: Construction of D
Branches
1 2 3 4 5 6
f-cut-sets
C1 : {1; 2; 6} 1 1 0 0 0 -1
C2 : {2; 3; 4} 0 -1 -1 1 0 0
C3 : {2; 3; 5} 0 -1 -1 0 1 1
Since the fundamental cut set matrix D is just the reduced incidence matrix written such that: At = U,
then KCL could be applied using D as follows:
AI = DI = 0 (1.3.9a)
V = DT E = 0 (1.3.9b)
Then:
It
DI = U Dc · · · = UIt + Dc Ic = 0 ⇒ It = −Dc Ic
Ic
In the graph of Figure 1.9, and by taking the fundamental cut set matrix obtained previously, we get:
i1 = −i2 + i6
i1 1 0 −1 i2
It = i4 = −Dc Ic = − −1 −1 0 i3 ⇒ i4 = i2 + i3
i5 −1 −1 1 i6
i5 = i2 + i3 − i6
Orthogonality of B and D
DBT = 0 (1.3.10a)
BDT = 0 (1.3.10b)
16
1.3. Matrix representation of a graph Chapter 1. Introduction to graph theory
Applying equation 1.3.10a to the partitioned forms of B and D would result in:
T
Bt
DBT = U Dc · · · = BtT + Dc = 0
Dc = −BtT (1.3.11)
Dc = (At−1 Ac ) (1.3.12)
Using equations 1.3.5 and 1.3.11 and if the twig voltages are known, all branch voltages can be
found if the fundamental cutset matrix is known as follows:
Vt U U
V = · · · = · · · Vt = · · ·
−Bt Vc −Bt DTc
V = DT Vt (1.3.13)
Using equations 1.3.3 and 1.3.12 and if the link currents are known, all branch currents can be found
if the fundamental loop matrix is known as follows:
−1 t
−At Ac Ic −Dc Bt
I= ··· = · · · Ic = · · · Ic
Ic U U
I = BT Ic (1.3.14)
17
Chapter 2
0
ik
+ +
vk
0 − ik
jk vk
− vKE
+
−
18
2.2. Impedance Z and admittance matrices Y Chapter 2. Network analysis techniques
Applying KVL and KCL on the branch of Figure 2.1, would result in the following:
v0k = vk − vkE
i0k = ik − jk
V 0 = V −VE (2.1.1a)
I0 = I − J (2.1.1b)
BV 0 = B(V −VE ) = 0
AI 0 = A(I − J) = 0
DI 0 = D(I − J) = 0
which would result in the set of equilibrium equations between the input and output variables:
BV = BVE (2.1.2a)
AI = AJ (2.1.2b)
DI = DJ (2.1.2c)
If Ic is the vector of link currents, Vt is the vector of twig voltages and E is the vector of node-to-
reference voltages, applying equation 1.3.1, 1.3.14 and 1.3.9b would result in:
I 0 = BT Ic ⇒ (I − J) = BT Ic
V 0 = DT Vt ⇒ (V −VE ) = DT Vt
V 0 = AT E ⇒ (V −VE ) = AT E
I = J + BT Ic (2.1.3a)
V = VE + DT Vt (2.1.3b)
V = VE + AT E (2.1.3c)
19
2.2. Impedance Z and admittance matrices Y Chapter 2. Network analysis techniques
In order to represent and convey information (value and transfer functions ) about the network ele-
ments, the b × b impedance matrix Z is introduced with element as follows:
(
Diagonal elements zii = the impedance along branch i
zi j =
Off-diagonal elements zi j = the transimpedance of branch j on branch i
The admittance matrix Y of a network is the inverse of the impedance matrix Z ,that is:
Y = Z −1 (2.2.1)
The information about the external voltage and current sources is conveyed by the b vectors VE and J
as follows:
0 if the branch doesn’t contain any external voltage sources
vEi = +vEi if the external voltage sources contributes current to the branch current
−vEi if the external voltage sources opposes current to the branch current
0 if the branch doesn’t have an external current sources
ji = + ji if the external current sources contributes current to the branch current
− ji if the external current sources opposes current to the branch current
The matrices Y and Z could be used to obtain the network parameters based on Ohm’s law, that is:
V = ZI (2.2.2)
I = YV (2.2.3)
2.2.1 Example 1
The graph on Figure 2.2, could be extracted from the network of Figure 2.3.
2 4
1 2 3
3
1 5
20
2.2. Impedance Z and admittance matrices Y Chapter 2. Network analysis techniques
R4
−
+
+
−
R1 R2 R3
i1 (t) i2 (t)
−
+ +
v1 (t) − v2 (t) + v3 (t) −
1
R1 0 0 0 0 0
R1 0 0 0 0 0
−V s1
Is1
0 1
0 L1 s 0 0 0 0 L1 s 0 0 0 0 −V s2 0
1
0 0 R2 0 0 0
0 0 0 0 0
V s 3
0
Z = ; Y = R2 ; VE =
1 −V s4 ; J = 0
0 0 0 0 0 0
0 0 C1 s 0 0
C1 s
0 0 0 0 R3 0
0 1 V s5 −Is2
0 0 0 R3 0
0 0 0 0 0 R4 0 0 0 0 0 1 0 −Is3
R4
2.2.2 Example 2
The graph on Figure 2.4, could be extracted from the network of Figure 2.5.
3 4
1 2 3
5
4
1 2
7
0
21
2.2. Impedance Z and admittance matrices Y Chapter 2. Network analysis techniques
C2
Is2
L1 L3
R1 L2 (t)
Is1 R3 gm vC (t)
+ +
Vs − vC C1
−
1
R1 0 0 0 0 0 0 R1 0 0 0 0 0 0
0 R2 0
0 0 0 − gCm1Rs2
0
1
R2 0 0 0 0 gm
0 1
0 0 L s 0
1 0 0 0 0 L1 s 0 0 0 0
0 0 0 L3 s 0 0 0 ; Y = 1
Z= 0 0 0 0 0 0
L3 s
0 0
0 0 L2 , s 0 0
0 0 0 0 1
0 0
1 L2 s
0 0 0 0 0 0
C2 s 0 0 0 0 0 C2 s 0
1
0 0 0 0 0 0 C1 s 0 0 0 0 0 0 C1 s
−Vs
0 −Is1
0
0
0
0
0 ; J = −Is2
VE =
0
0
0
0
0
0
22
2.3. Analysis Techniques Chapter 2. Network analysis techniques
AY (s) VE + AT E = AJ(s)
By denoting the nodal current vector that follows through the nodes due to external current source as
JN (s) and the nodal admittance matrix as YN (s), we get the following:
23
2.3. Analysis Techniques Chapter 2. Network analysis techniques
By denoting the column vector of link currents as Ic (s), the co-tree impedance matrix as Zc (s), and
co-tree voltage vector as Ec we get the following:
Once the link currents are known, all branch currents can be found using equation 1.3.14.
Fom equations 2.3.4 and 2.3.5c, it is evident that to do a loop analysis of a certain network the
external sources vectors J and VE along with the impedance and admittance matrices Z and Y should
be reordered such that they maintain the same branch order as in the loop matrix B.
In the example of Figure 2.5, by selecting the tree {3; 4; 5; 7} as shown in Figure 2.6, the resulting
matrices and modified vectors are:
1 0 1 1 1 0 0
B= 0 1 −1 −1 0 1 0
−1 −1 0 0 0 0 1
1
L1 s 0 0 0 0 0 0 L1 s 0 0 0 0 0 0
0 L3 s 0 0 0 0 0 1
0 L3 s 0 0 0 0 0
0 0 L2 s 0 0 0 0
0 0 1
0 0 0 0
1
L2 s
Zreordered =
0 0 0 C1 s 0 0 0 ; Yreordered =
0 0 0 C1 s 0 0 0
0 0 0 0 R1 0 0
0 0 0 0 1
0 0
R1
gm R2
0 0 0 − C1 s 0 R2 0 1
0 0 0 gm 0 R2 0
1
0 0 0 0 0 0 C2 s 0 0 0 0 0 0 C2 s
0 0
0 −Is2
0
0
V s − Is1 R1
VE,reordered 0 ; Jreordered = 0 ; Ec =
= Is2 L3 s
Vs
Is1
−Is2 L3 s
0 0
0 0
24
2.3. Analysis Techniques Chapter 2. Network analysis techniques
3 4
1 2 3
5
4
1 2
7
0
Using the same derivation used to obtain equation 2.3.4, we could obtain the following:
By denoting the column vector of mesh currents as IM (s), the mesh impedance matrix as ZM (s), and
mesh voltage vector as EM we get the following:
ZM (s) = BM Z(s)BTM (2.3.7a)
EM = BM {VE (s) − Z(s)J(s)} (2.3.7b)
EM (s) = ZM (s)IM (s) (2.3.7c)
−1
IM (s) = ZM (s)EM (s) (2.3.7d)
The meshes matrix BM has the branches in the same order of the graph as a result mesh analysis solves
the main problem arising from the loop analysis because the different network vectors and matrices
(J,VE , Z,Y ) don’t need to be updated.
25
2.3. Analysis Techniques Chapter 2. Network analysis techniques
DY (s) VE + DT Vt = DJ(s)
By defining the tree current vector that follows through the a certain tree due to external current source
as as Jt (s) and the tree admittance matrix as Yt (s), we get the following:
Once the twig voltages are found, all branch voltages can be found using equation 1.3.13.
Fom equations 2.3.9b and 2.3.9a, it is evident that to do a cutset analysis, the different network
vectors and matrices (J,VE ,Y ) should be reordered such that they maintain the same branch order as
in the cutset matrix D.
In the example of Figure 2.5, applying cutset analysis with the tree {3; 4; 5; 7} as shown in Figure 2.6,
would result in the following:
V
s
− I
1 0 0 0 −1 0 1 R s1
0 1 0 0 0 −1 1 1−I
s2
D= 0 0 1 0 −1 1 0 ; Jt (s) =
Vs
R1 − Is1
0 0 0 1 −1 1 0 Vs
R1 − Is1
C s + R11 + L11 s C2 s 1 1
2 R1 R1
C2 s + R12 + L13 s − R12 − R12 − gm
C2 s
Yt (s) =
1
− R12 1 1 1 1 1
R1 R1 + R2 + L2 s R1 + R2 + gm
1
R1 − R12 1
R1 + R2
1
C1 s + R11 + R12 + gm
26
Chapter 3
Implementation
3.1 MatLab
The different analysis techniques described previously could be implemented using MatLab which
is a software package that is used for implementing, developing and analyzing algorithms and high-
performance technical computations. MATLAB is a matrix-based language hence it natively supports
vector and matrix operations that are fundamental to engineering and scientific problems.
Obtain AA , A, B, D
netlist
Circuit Extract the graph Perform Analysis Results
Get Z, J,VE
The circuit is provided by the user in the form of a netlist saved in a separate text file. After that, the
graph is extracted along with the different matrices that represent the graph and the network. Then,
they are fed into the analysis program to obtain the results.
Using a SPICE netlist as the link between the user and the simulation program enables the ability to
import different external SPICE netlists from other simulation packages along with the flexibility of
using the simulation program as a standalone simulator.
27
3.3. Simulation program Chapter 3. Implementation
The simulation program uses a variance on Pspice[18] netlist format where each line of the text file
represents an element defined as follows:
XXXX N1 N2 Val S1 S2
• XXXX: the element and the first letter determines the element type.
• S1: the net connected to the first sense terminal of the element (only if it’s a controlled source).
• S2: the net connected to the second sense terminal of the element (only if it’s a controlled
source).
28
3.3. Simulation program Chapter 3. Implementation
Netlist
circuit.branches()
circuit.nets()
Build graph
Construct B, D
circuit.branches()
circuit.nets
No
Is tree ?
Yes
Extract cotree
29
3.4. Examples Chapter 3. Implementation
Firstly a number of (N − 1) is selected randomly from all branches that represent the graph then, they
are tested using the isdiag matlab function which tells whether a graph is directed acyclic graph (i,e
is it a tree or not). When the selected branches don’t form a tree another set of branches is selected
randomly. When a tree is obtained the corresponding co-tree branches are extracted.
3.4 Examples
3.4.1 Example 1
In this example, we shall demonstrate the nodal analysis method. The circuit in Figure 3.4 is imple-
mented by the netlist given in Listing 3.1. The results are shown on Listing 3.2. Using the probe
functionality of Multisim, we got the results shown on Figure 3.5.
C1 4 2 10 e−09
C2 4 3 3e−09
C3 5 0 1e−09
I1 3 4 1e−03
L1 3 5 30e−3
L2 5 4 10e−3
R1 3 1 5 e03
R2 4 0 1 e03
V1 1 0 10
V2 2 0 6
Listing 3.1: Circuit netlist
30
3.4. Examples Chapter 3. Implementation
I1
3 4
1mA
10kHz
0°
C2
3nF
L1 5 L2
30mH 10mH
R1
5kΩ
C1
1 10nF
2
V1
C3 R2
10Vpk V2
1nF 1kΩ
10kHz 6Vpk
0° 10kHz
0 0°
V_N3 = 3 . 6 2 2 3 Vrms
V_N4 = 2 . 0 1 2 Vrms
V_N5 = 2 . 4 7 6 9 Vrms
Listing 3.2: Nodal analysis output
31
3.4. Examples Chapter 3. Implementation
I1
3 4
1mA
10kHz
0°
C2
3nF
V L1 5 V L2 V V
PR1 PR2 PR3 PR4
30mH 10mH V(p-p): 6.03 V
V(rms): 2.08 V
R1 V(freq): 10.0 kHz
V(p-p): 8.05 V V(p-p): 6.07 V
5kΩ V(p-p): 10.4 V V(rms): 2.91 V V(rms): 2.08 V
V(freq): 21.5 kHz V(freq): 10.0 kHz
V(rms): 3.67 V C1
V(freq): 10.0 kHz
1 10nF
2
V1
C3 R2
10Vpk V2
1nF 1kΩ
10kHz 6Vpk
0° 10kHz
0 0°
3.4.2 Example 2
In this example, we shall demonstrate the loop analysis method. The circuit in Figure 3.6 is imple-
mented by the netlist given in Listing 3.3. The results are shown on Listing 3.4. Using the probe
functionality of Multisim, we got the results shown on Figure 3.7.
C1 4 2 10 e−09
C2 4 3 3e−09
C3 5 4 1e−09
G1 4 0 5 5 0
I1 3 4 1e−03
L1 3 5 90e−3
L2 0 5 10e−3
R1 3 1 5 e03
R2 4 0 1303
V1 1 0 10
V2 2 0 6
Listing 3.3: Circuit netlist
32
3.4. Examples Chapter 3. Implementation
I1
3
1mA
10kHz
0°
C2
3nF
L1 C3
90mH 1nF
5
R1 C1
5kΩ 4 10nF
1 2
I2
L2 R2
5Mho
V1 10mH 1kΩ V2
10Vpk 0 6Vpk
10kHz 10kHz
0° 0°
I_branch_L1 = 0 . 0 0 0 2 2 4 5 6 Arms
I_branch_C2 = 0 . 0 0 1 1 2 3 5 Arms
I_branch_L2 = 8 . 2 9 6 e−07 Arms
I_branch_C1 = 0 . 0 0 2 8 0 1 1 Arms
I_branch_C3 = 0 . 0 0 0 2 2 4 5 5 Arms
I_branch_R1 = 0 . 0 0 1 3 4 3 Arms
I_branch_R2 = 0 . 0 0 3 7 8 3 6 Arms
Listing 3.4: loop analysis output
33
3.4. Examples Chapter 3. Implementation
I1
3
I(p-p): 1.23 mA
1mA I(rms): 434 uA
I(p-p): 636 uA I(freq): 10.0 kHz
I(p-p): 635 uA
I(rms): 225 uA 10kHz
I(rms): 225 uA
I(freq): 10.0 kHz I(freq): 10.0 kHz 0°
C2 A
PR1
3nF
A L1 C3
PR3
90mH A PR2
1nF I(p-p): 7.93 mA
A I(rms): 2.81 mA
PR5 5 I(freq): 10.0 kHz A
PR7
R1 I(p-p): 3.80 mA C1
I(rms): 1.34 mA
5kΩ I(freq): 10.0 kHz 4 10nF
1 2
G1
L2 R2
5Mho
V1 I(p-p): 2.44 uA 10mH 1kΩ I(p-p): 10.1 mA V2
I(rms): 866 nA
10Vpk I(freq): 10.0 kHz I(rms): 3.57 mA 6Vpk
0 I(freq): 10.0 kHz
10kHz 10kHz
0° A A 0°
PR4 PR6
3.4.3 Example 3
In this example, we shall demonstrate the cutset analysis method. The circuit in Figure 3.8 is im-
plemented by the netlist given in Listing 3.5. The results are shown on Listing 3.6. Using the probe
functionality of Multisim, we got the results shown on Figure 3.9.
C1 5 0 10 e−09
C2 4 2 3e−09
C3 5 4 1e−09
G1 4 0 2 5 0
I1 3 4 1e−03
L1 3 4 90e−3
L2 3 5 10e−3
R1 3 1 5 e03
R2 4 0 1 e03
V1 1 0 10
V2 2 0 6
Listing 3.5: Circuit netlist
34
3.4. Examples Chapter 3. Implementation
I1
3 4
1mA
10kHz
0°
L1
90mH
L2 5 C3
10mH 1nF
R1 C2
5kΩ 3nF
1 2
G1
R2
C1 2Mho
V1 1kΩ V2
10nF
10Vpk 6Vpk
10kHz 10kHz
0° 0 0°
V_L2 = 0 . 3 5 8 7 0 Vrms
V_L1 = 0 . 3 7 0 5 2 Vrms
V_C1 = 1 . 1 4 9 2 0 Vrms
V_C2 = 0 . 7 5 2 3 5 Vrms
V_C3 = 0 . 0 6 0 1 4 Vrms
V_R1 = 6 . 6 7 4 0 Vrms
V_R2 = 1 . 2 8 5 2 Vrms
Listing 3.6: cutset analysis output
35
3.4. Examples Chapter 3. Implementation
I1
3 4
90mH
PR1 C3 PR3
Ref1 V L2 5 V Ref3
Ref1
10mH V 1uF
PR2
V Ref2 V(p-p): 3.65 V
V(rms): 1.29 V
R1 V(freq): 10.0 kHz C2
5kΩ V(p-p): 18.9 V 10uF
V(rms): 6.69 V
V(freq): 10.0 kHz
1 2
V G1
Ref2 R2
C1 2Mho
V1 1kΩ V2
10nF
10Vpk 6Vpk
10kHz 10kHz
0° 0 0°
V
Ref3
36
Conclusion
Numerical simulation of electrical networks are a valuable tool in circuit analysis and design. Electri-
cal engineers should gain expertise in the underlying work of circuit simulators, because without an
accurate understanding of the equations that the programs use to simulate the networks, it is impossi-
ble to fully interpret obtained computational results properly.
The graph theory approach for network and circuit analysis provides an easy way to explore the design
of circuit simulators. Based on the different network analysis techniques, different parameters could
be extracted about the simulated network and the other parameters could be easily computed based
on the obtained ones as explored in Chapter 1 and 2.
The nodal analysis method is the easiest and most fast method to apply since it could be applied
directly without the need to extract a tree or any graph matrix rather than the incidence matrix.
The developed program did show approximately the same results provided by Multisim for the differ-
ent networks examined on Chapter 3. The difference in the results are a consequence of the slightly
different models of each element, because the developed program uses ideal models for each elements
whereas Multisim take into consideration different parasitics present on each element and their tem-
perature dependency along with their proper behavioral conditions(break down voltage, maximum
dissipated power, . . . ).
This project is still a "work under progress" where the following notes could be improved:
• Optimizing the circuit representation during the program execution by utilizing spares matrices.
• Cleaning the code using advanced data structures and object oriented programming tools.
• Extending the program to handle the non-linear components by introducing separate model
based simulation.
• Developing a GUI (graphical user interface) to ease the use of the program through the MatLab
AppDesigner[19], and making it a standalone application.
37
References
[1] J. A. Bondy and U. S. R. Murty, Graph theory with applications / J. A. Bondy and U. S. R.
Murty. Macmillan London, 1976, x, 264 p. : ISBN: 0333177916.
[2] N. Bhagya Jyoti, “Applications of graph theory in different branches of science,” International
Journal of Mathematics And its Applications, vol. 5, pp. 57–60, 3-A 2017.
[3] P. Anandhan, K. Uma, and J. Anuradha, “An overview of application of graph theory,” vol. 9,
pp. 242–248, Jan. 2016.
[4] NI, Multisim, version 14.2. [Online]. Available: https://www.ni.com/multisim.
[5] J. M. Rabaey, The spice page, http://bwrcs.eecs.berkeley.edu/Classes/IcBook/
SPICE/.
[6] P. Sekalski, “Electronic technology design & workshop,” Notes, Lodz University of Technol-
ogy, 2007, [Online]. Available: https://lux.dmcs.p.lodz.pl/etdw.
[7] A. Klos, Mathematical Models of Electrical Network Systems - Theory and Applications- An
Introduction, ser. Lecture Notes in Electrical Engineering. Springer, 2017, vol. 412, ISBN: 978-
3-319-52176-3. DOI: 10.1007/978-3-319-52178-7.
[8] R. J. Wilson, Introduction to graph theory, 4th. Prentice Hall, 1996, ISBN: 0582249937.
[9] J. L. Gross and J. Yellen, Graph Theory and Its Applications, 2nd. Chapman amp; Hall/CRC,
2005, ISBN: 158488505X.
[10] Reducible. (Jun. 2020). Introduction to graph theory: A computer science perspective, [Online].
Available: https://www.youtube.com/watch?v=LFKZLXVO-Dg.
[11] B. Xie, C. Qi, H. Ben, and W. Yu, “The applications of graph theory in electric network,”
in 2019 International Conference on Sensing, Diagnostics, Prognostics, and Control (SDPC),
2019, pp. 780–784. DOI: 10.1109/SDPC.2019.00148.
[12] F. Dörfler, J. W. Simpson-Porco, and F. Bullo, “Electrical networks and algebraic graph theory:
Models, properties, and applications,” Proceedings of the IEEE, vol. 106, no. 5, pp. 977–1005,
2018. DOI: 10.1109/JPROC.2018.2821924.
[13] M. Arshad, Network Analysis and Synthesis, 1st. Laxmi Publications Pvt. Ltd, 2006.
[14] Pr A. Recioui, “EE446: Network analysis and synthesis,” Lecture Notes, IGEE, Apr. 2021.
[15] E. R. Gansner and S. C. North, “An open graph visualization system and its applications to
software engineering,” Software: Practice and Experience, vol. 30, no. 11, pp. 1203–1233,
2000.
[16] W. Hayt, J. Kemmerly, and S. Durbin, Engineering Circuit Analysis, 7th. USA: McGraw-Hill,
Inc., 2007, ISBN: 0073366617.
[17] Dr. Boonying Charoen, “182304: Electrical network analysis notes,” KKU, 2018, [Online].
Available: http://eestaff.kku.ac.th/~jamebond/182304/.
38
References References
39