# MATLAB code of formation of bus admittance matrix (Ybus) by singular transformation?

All QuestionsCategory: Transmission And Distribution SystemMATLAB code of formation of bus admittance matrix (Ybus) by singular transformation?
chetan shidling asked 2 weeks ago

I need code with output:

chetan shidling answered 2 weeks ago

Here is the code of formation of bus admittance matrix (Ybus) by singular transformation.

clc;
ne=4; nn=4; nref=0;
net=[ 0 1;
0 2;
1 2;
2 3];
flag=input(‘Enter \n 1-System with mutual coupling \n 2-System without mutual coupling\n’);
if flag==1
z= [(0.0+0.12i) (0.0+0.0i) (0.0+0.0i) (0.0+0.0i);
(0.0+0.0i) (0.0+0.2i) (0.0+0.1i) (0.0+0.0i);
(0.0+0.0i) (0.0+0.1i) (0.0+0.1i) (0.0+0.0i);
(0.0+0.0i) (0.0+0.0i) (0.0+0.0i) (0.0+0.24i)];
else
z= [(0.0+0.12i) (0.0+0.0i) (0.0+0.0i) (0.0+0.0i);
(0.0+0.0i) (0.0+0.2i) (0.0+0.0i) (0.0+0.0i);
(0.0+0.0i) (0.0+0.0i) (0.0+0.1i) (0.0+0.0i);
(0.0+0.0i) (0.0+0.0i) (0.0+0.0i) (0.0+0.24i)];
end
ebus=[ (0.98-0.05i);
(0.95-0.1i);
(0.92-0.12i)];
a=zeros(ne,nn-1);
for i=1:ne
nf=net(i,1);
nt=net(i,2);
if nf~=nref
a(i,nf)=1;
end
if nt~=nref
a(i,nt)=-1;
end
end
y=inv(z);
ybus=transpose(a)*y*a;
ibus=ybus*ebus;
sbus=conj(ebus).*ibus;
disp(‘ BUS INCIDENCE MATRIX (A): ‘);
disp(a);
disp(‘ PRIMITIVE IMPEDENCE MATRIX (y): ‘);
disp(y);
disp(‘ BUS ADMITTANCE MATRIX [Ybus]: ‘);
disp(ybus);
disp(‘ BUS CURRENTS [Ibus]: ‘);
disp(ibus);
disp(‘ COMPLEX POWER AT BUSES [Sbus]: ‘);
disp(sbus);

Output:

Enter
1-System with mutual coupling
2-System without mutual coupling
1
BUS INCIDENCE MATRIX (A):
-1 0 0
0 -1 0
1 -1 0
0 1 -1
PRIMITIVE IMPEDENCE MATRIX (y):
0.0000 – 8.3333i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i
0.0000 + 0.0000i 0.0000 -10.0000i 0.0000 +10.0000i 0.0000 + 0.0000i
0.0000 + 0.0000i 0.0000 +10.0000i 0.0000 -20.0000i 0.0000 + 0.0000i
0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 – 4.1667i
0.0000 -28.3333i 0.0000 +10.0000i 0.0000 + 0.0000i
0.0000 +10.0000i 0.0000 -14.1667i 0.0000 + 4.1667i
0.0000 + 0.0000i 0.0000 + 4.1667i 0.0000 – 4.1667i
BUS CURRENTS [Ibus]:
-0.4167 -18.2667i
-0.4167 + 0.1750i
-0.0833 + 0.1250i
COMPLEX POWER AT BUSES [Sbus]:
0.5050 -17.9222i
-0.4133 + 0.1246i
-0.0917 + 0.1050i