1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
clear;
clc;
Ybus=zeros(4,4);
Za=%i*.1;
Z12=%i*.25;
Z14=%i*.4;
Z43=%i*.1;
Z42=%i*.2;
Z32=%i*.1;
Z13=%i*.5;
Zg=%i*4;
V1=1;
V2=complex(.9787,-.0513);
V3=complex(1.019,.0445);
V4=complex(1.0098,-.0176);
Ybus(1,1)=1/Zg+1/Z12+1/Z13+1/Z14;
Ybus(1,2)=-1/Z12;
Ybus(2,1)=Ybus(1,2);
Ybus(1,3)=-1/Z13;
Ybus(3,1)=Ybus(1,3);
Ybus(1,4)=-1/Z14;
Ybus(4,1)=Ybus(1,4);
Ybus(2,2)=1/Z12+1/Z32+1/Z42;
Ybus(2,3)=-1/Z32;
Ybus(3,2)=Ybus(2,3);
Ybus(2,4)=-1/Z42;
Ybus(4,2)=Ybus(2,4);
Ybus(3,3)=1/Z13+1/Z43+1/Z32;
Ybus(3,4)=-1/Z43;
Ybus(4,3)=Ybus(3,4);
Ybus(4,4)=1/Z14+1/Z43+1/Z42;
Z=inv(Ybus);
Zt34=Z(3,3)+Z(4,4)-2*Z(3,4);
V=[V1;V2;V3;V4];
I12=(V1-V2)/Z12;
I13=(V1-V3)/Z13;
I14=(V1-V4)/Z14;
I23=(V2-V3)/Z32;
I24=(V2-V4)/Z42;
I34=(V3-V4)/Z43;
Zaa=-Za;
Zden=Zt34-Zaa;
L1234=Zaa/Z12*((Z(1,3)-Z(1,4))-(Z(2,3)-Z(2,4)))/Zden;
L1334=Zaa/Z13*((Z(1,3)-Z(1,4))-(Z(3,3)-Z(3,4)))/Zden;
L1434=Zaa/Z14*((Z(1,3)-Z(1,4))-(Z(4,3)-Z(4,4)))/Zden;
L2334=Zaa/Z32*((Z(2,3)-Z(2,4))-(Z(3,3)-Z(3,4)))/Zden;
L2434=Zaa/Z42*((Z(2,3)-Z(2,4))-(Z(4,3)-Z(4,4)))/Zden;
I112=I12+L1234*I34;
I113=I13+L1334*I34;
I114=I14+L1434*I34;
I223=I23+L2334*I34;
I224=I24+L2434*I34;
Iinj=Ybus*V;
S1=V(1)*conj(Iinj(1));
S2=V(2)*conj(Iinj(2));
S3=V(3)*conj(Iinj(3));
S4=V(4)*conj(Iinj(4));
K321=(Z(3,1)-Z(2,1))/Z32;
K323=(Z(3,3)-Z(2,3))/Z32;
delIinj1=.8340;
delIinj3=-delIinj1;
delI32=K321*delIinj1+K323*delIinj3;
I32d=I23+delI32;
In=[(Iinj(1,1)+delIinj1);Iinj(2,1);(Iinj(3,1)+delIinj3);Iinj(4,1)];
Vnew=inv(Ybus)*In;
I32n=(Vnew(3)-Vnew(2))/Z32;
mprintf("Power at each bus are S1=%.4f+%.4f, S2=%.4f%.4f, S3=%.4f+%.4f and S4=%.4f+%.4f\n",real(S1),imag(S1),real(S2),imag(S2),real(S3),imag(S3),real(S4),imag(S4));
mprintf("Change in current is I32=%.4f%.4f",real(I32n),imag(I32n));
|