My ProgramMatlab Prepared
My ProgramMatlab Prepared
KURUKSHETRA
PROGRAM 1
AIM:To determine the Bus incidence and reduced bus incidence matrices using MATLAB
THEORY:The incidence of branches to nodes in a connected graph is given by the element-node incidence
matrix, A . An element aij of A is defined as under:
aij
GIVEN NETWORK:
ALGORITHM: START
STEP1:
Form data matrices such that they represent line data of the given network
For the above network linedata = [e.no,
from node,
to node]
STEP2:
Form a zero metrics of order element by nodes
STEP3:
Use for loop and for each element choose the from node and to node in the created matrics and
give the value as 1 and -1 respectively
STEP4:
Perform STEP3 for all elements to get the Bus incidence matrices
STEP5:
Remove the column corresponding to the reference node in the obtained matrics to get the
reduced bus incidence matrices
STOP
PROGRAM: data=[1,1,2;2,1,3;3,1,5;4,5,4;5,3,4;6,2,3;7,4,2];
%BUS INCIDENCE MATRX STARTS
e=max(data(:,1));
n=max(max(data(:,2)),max(data(:,3)));
matA=zeros(e,n);
for i=1:e
matA(i,data(i,2))=1;
matA(i,data(i,3))=-1;
end
matA
A=matA;
A(:,1)=[ ]
%A IS REDUCED BUS INCIDENCE MATRIX
Result:
matA =
1
1
1
0
0
0
0
-1 0 0 0
0 -1 0 0
0 0 0 -1
0 0 -1 1
0 1 -1 0
1 -1 0 0
-1 0 1 0
A=
-1 0 0 0
0 -1 0 0
0 0 0 -1
0 0 -1 1
0 1 -1 0
1 -1 0 0
-1 0 1 0
ROGRAM 2
AIM:Formation of reduced bus incident matrixA, basic cut set matrix B and basic loop matrix C.
Bl=Al*Ab^(-1)
Cb= -(Bl)
ALGORITHM:STEP1
Form a data matrix to represent the line data of the given system
STEP2
Form the reduced Incidence matrix A
STEP3
From the reduced incidence matrix select the rows which belong to tree elements and place them
in matrix Ab and the rows which belong to link elements in matrix Al .This way we can
partition the A matrix into Ab and Al
STEP4
Use the following relations to get the required matrices
1
K t =A b
'
K=K t
B l= A l K t
'
Cb =Bl
STEP5
Form augmented matrices of B and C
STOP
PROGRAM:data=[1,1,2;2,1,3;3,1,5;4,5,4;5,3,4;6,2,3;7,4,2];
e=max(data(:,1));
n=max(max(data(:,2)),max(data(:,3)));
b=n-1;
l=e-b;
matA=zeros(e,n);
for i=1:e
matA(i,data(i,2))=1;
matA(i,data(i,3))=-1;
end
matA;
A=matA;
A(:,1)=[]
Ab=A(1:b,:);
Al=A(b+1:e,:);
Bl=Al*Ab^(-1);
B=zeros(e,b);
Ub=eye(b);
B(1:b,:)=Ub;
B(n:e,:)=Bl;
B
% BASIC CUT SET B
Cb=-(Bl)';
Cl=eye(l);
C=zeros(e,l);
C(1:b,:)=Cb;
C(n:e,:)=Cl;
C
RESULT:-
A=
-1
0
0
0
0
1
-1
0
-1
0
0
1
-1
0
0
0
0
-1
-1
0
1
0
0
-1
1
0
0
0
0
1
0
0
-1
1
0
0
0
1
0
1
0
-1
0
0
0
1
1
0
-1
1
-1
0
0
0
1
0
-1
0
1
1
0
0
1
B=
1
0
0
0
0
-1
1
C=
0
1
-1
-1
1
0
0
PROGRAM 3
AIM:To determine Y Bus and Z Bus using singular transformation
THEORY:By using primitive admittance matrices we can find Y bus matrices. The relation as follows
Y BUS= A t yA
Where y is primitive admittance matrix and A is reduced bus incidence matrix
GIVEN NETWORK:-
ELEMENT
1
2
3
4
5
SELF IMPEDANCE
J0.6
J0.5
J0.5
J0.4
J0.2
ALGORITHM:STEP1
Create two matrices to represent line data and the mutual impedance data line data contains
information about element number, from node , to node, element impedance where as mutual
data contains element, mutual element, mutual impedance.
STEP2
Form the reduced bus incidence matrix
STEP3
Form the primitive impedance matrix z. Where z is a matrix of order element by element in
which diagonal elements are self-impedances and off diagonal elements are mutual impedances
STEP4
Find primitive admittance matrix y using the relation
y=z1
STEP5
t
Using the given relation Y BUS= A yA
find
Y BUS
STOP
PROGRAM:-
end
A=zeros(nl,nb);
for i=1:nl;
k=sb(i);
m=eb(i);
A(i,k)=1;
A(i,m)=-1;
end
A(:,1)=[];
z=zeros(nl,nl);
for i=1:nl;
z(i,i)=u(i);
end
for j=1:mb;
e=input ('first line=');
f=input ('second line=');
g=input ('enter the value=');
z(e,f)=g;
z(f,e)=g;
end
A
%INCIDENCE MATRIX
z
%IMPEDENCE MATRIX
Y=z^-1
%ADMITTANCE MATRIX
Ybus=A'*Y*A
%BUS ADMITTANCE MATRIX
Zbus=Ybus^-1 %BUS IMPEDECE MATRIX
RESULT:-
starting bus=1
ending bus=3
input values=.5
starting bus=3
ending bus=4
input values=.5
starting bus=1
ending bus=2
input values=.4
starting bus=2
ending bus=4
input values=.2
A=
-1
0
0
-1
1
0
-1
1
0
0
0
0
-1
0
-1
z=
0.6000
0.1000
0
0.2000
0
0.1000
0.5000
0
0
0
0
0
0.5000
0
0
0.2000
0
0
0.4000
0
0
0
0
0
0.2000
Y=
2.0833
-0.4167
0
-1.0417
0
-0.4167
2.0833
0
0.2083
0
Ybus =
4.0833 -2.0000
-5.0000 -2.0000
7.0000
Zbus =
0.2713
0.1264
0.2299
0.1264
0.3437
0.1885
0.2299
0.1885
0.3609
0
0
2.0000
0
0
-1.0417
0.2083
0
3.0208
0
0
0
0
0
5.0000
PROGRAM -4
AIM:To determine Y Bus and Z Bus using singular transformation
THEORY:By using primitive admittance matrices we can find Y bus matrices. The relation as follows
t
Y BUS= A yA
Where y is primitive admittance matrix and A is reduced bus incidence matrix
Element
1
2
3
4
5
Mutual impedance data
From Bus
1
1
2
2
3
To Bus
2
3
4
3
4
Impedance
J0.1
J0.15
J0.4
j0.6
J0.4
Tree
1
1
1
0
0
Mutual impedance
J0.1
J0.2
Element 1
1
1
Element 2
2
4
ALGORITHM:STEP1
Create two matrices to represent line data and the mutual impedance data line data contains
information about element number, from node , to node, element impedance where as mutual
data contains element, mutual element, mutual impedance.
STEP2
Form the reduced bus incidence matrix
STEP3
Form the primitive impedance matrix z. Where z is a matrix of order element by element in
which diagonal elements are self-impedances and off diagonal elements are mutual impedances
STEP4
Find primitive admittance matrix y using the relation
y=z1
STEP5
t
Using the given relation Y BUS= A yA
find
Y BUS
STOP
A(i,k)=1;
A(i,m)=-1;
end
A(:,1)=[];
z=zeros(nl,nl);
for i=1:nl;
z(i,i)=u(i);
end
for j=1:mb;
e=input ('first line=');
f=input ('second line=');
g=input ('enter the value=');
z(e,f)=g;
z(f,e)=g;
end
A
%INCIDENCE MATRIX
z
%IMPEDENCE MATRIX
Y=z^-1
%ADMITTANCE MATRIX
Ybus=A'*Y*A
%BUS ADMITTANCE MATRIX
Zbus=Ybus^-1 %BUS IMPEDECE MATRIX
RESULT:formation of bus admittance matrix
no of buses including the slack bus=4
no of lines=5
no of mutal links=2
starting bus=1
ending bus=2
input values=.1
starting bus=1
ending bus=3
input values=.15
starting bus=2
ending bus=4
input values=.4
starting bus=2
ending bus=3
input values=.6
starting bus=3
ending bus=4
input values=.4
first line=1
second line=2
enter the value=.1
first line=1
second line=4
enter the value=.2
A=
-1
-1
-1
-1
-1
z=
0.1000
0.1000
0.1000
0.1500
0
0.2000
0
0.2000
0.4000
0.6000
0
0.4000
Y=
-30.0000
20.0000
10.0000
20.0000
-6.6667
-6.6667
0
10.0000
0
-6.6667
2.5000
0
-1.6667
0
Ybus =
-49.1667
38.3333
-2.5000
38.3333
-19.1667
-2.5000
-2.5000
-2.5000
Zbus =
0.0590
0.1072
0.0831
5.0000
0
2.5000
0.1072
0.1458
0.1265
0.0831
0.1265
0.3048