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

%ABCD

clc
clear all
vr_mag= 6.35*1e3;
vr_angle= 0;
ir_mag= 50;
ir_angle= -10;
length= input(" enter the length :- ");
r=0.02*length;
x=0.08*length;
y=i*0.0000008;
z= r+i*x;
vr=((vr_mag)*(cos(vr_angle)*pi/180)+i*sin(vr_angle)*pi/180)/sqrt(3);
ir=((ir_mag)*(cos(ir_angle)*pi/180)+i*sin(ir_angle)*pi/180);
if length <80
a=1;
b=z;
c=0;
d=1;
else if length>250
a= cosh(sqrt(y*z));
b= sqrt(z/y)*sinh(sqrt(y*z));
c=sqrt(y/z)*sinsqrt((y*z));
d= cosh(sqrt(y*z));
else
type= input("enter 1 for pi and 2 for T")
if type ==1
a=1+(y*z)/2;
b=z;
c=y+(y*y*z)/4;
d=1+(y*z)/2;
else
a= 1+(y*z)/2;
b=z+(z*y*z)/4;
c=y;
d=1+(y*z)/2;
end
end
end
verify=(a*d)-(b*c);
vs= (a*vr)-(b*ir);
is= (c*vs)-(d*ir);
pfr= cos(angle(vr) - angle(ir));
pfs= cos(angle(vs)- angle (is));
pr= abs(3*vr*ir*pfr);
ps=abs(3*vs*is*pfs);
eff=pr/ps*100;
reg=((abs(vs/a)- abs(vr))/abs(vr))*100;
verify=(a*d)-(b*d);
disp('AB-CD');
disp(verify);

% YBUS INSPECTION

clear all
clc
load name.txt
data=name;
sb= data( :,2);
eb= data ( :,3);
r= data( :,4);
x= data( :,5);
ysh= data( :,6);
z=r+i*x;
y=1./z;
ysh=i*ysh;
nbus=max(max(sb),max(eb));
nele=length(sb);
ybus=zeros(nbus, nbus);
for i=1:nele
ybus(sb(i),sb(i))=ybus(sb(i),sb(i))+y(i)+ysh(i);
ybus(eb(i),eb(i))=ybus(eb(i),eb(i))+y(i)+ysh(i);
end
for i= 1:nele
ybus(sb(i),eb(i))=ybus(sb(i),eb(i))-y(i);
ybus(eb(i),sb(i))= ybus(sb(i),eb(i));
end

%YBUS SINGULAR WITHOUT MUTUAL

clear all
clc
data= [ 1 2 0 0.1
1 4 0 0.2
2 3 0 0.3
3 4 0 0.5
2 3 0 0.4]
fb=data( :,1);
tb= data( :,2);
r= data( :,3);
x= data( :,4);
z= r+i*x;
y=1./z;
nele=length(fb);
nbus= max(max(fb),max(tb));
acap= zeros(nbus, nele);
yprim=zeros(nele,nele);
for i=1:nele
acap(i,fb(i))=1;
acap(i,tb(i))=-1;
end
acap( :,1)=[];
a=acap;
for i = 1:nele
yprim(i,i)=y(i);
end
ybus= a'*yprim*a;
disp(ybus)

%YBUS WITH MUT

clc
clear all
data=[1 1 2 0 0.1 0 0
2 1 3 0 0.2 0 0.01
3 3 4 0 0.3 0 0
4 1 4 0 0.4 0 0.02
5 2 3 0 0.5 0 0
6 2 3 0 0.6 0 0];
en=data( :,1);
fb= data( :,2);
tb= data( :,3);
r= data( :,4);
x= data( :,5);
men= data( :,6);
mut=data( :,7);
z=r+i*x;
nele= length(fb);
nbus= max(max(fb),max(tb));
acap= zeros(nele, nbus);
zprim= zeros(nele,nele);
for i = 1:nele
acap(i,fb(i))=1;
acap(i,tb(i))=-1;
end
acap( :,1)=[];
a=acap;
for i =1:nele
zprim(i,i)= z(i)
end
for i = 1:nele
if men(i)>0
zprim(en(i),men(i))=mut(i);
zprim(men(i),en(i))=mut(i);
end
end
yprim=inv(zprim);
ybus=a'*yprim*a;
disp(ybus)

%SALIENT
clc
clear all
vl=34.64*10^3;
s=60*10^6;
pf =0.8;
p=s*pf
vph= vl/sqrt(3);
xd= 13.5;
xq= 9.33;
phi= acos(pf)
q=p*tan(phi);
i= (p-j*q)/(3*vph);
delta=0:10:180;
eq= vph+ i*j*xq;
id= abs(i)*sin(angle(eq)-angle(i));
e= abs(eq)+ ((xd-xq)*id);
pa=(e*vph*sin(delta*pi/180))/xd;
pactual= (3*pa)/(10^6);
pr=((vph^2)*(xd-xq)*sin(2*delta*pi/180))/(2*xd*xq);
preluctance=(3*pr)/10^6;
psalient=pactual+preluctance;
excitationEMF=e
regulation=((e-vph)/vph);
plot(delta,pactual,delta,preluctance,delta,psalient);
xlabel("delta");
ylabel("power");
legend("actual power","reluctance power","real power");
title("salient ploe ");

% NON SALIENT

clc
clear all
vl= 34.64*10^3;
pf=0.8;
p=48*10^6;
xd=10;
xq= 10;
vph = vl/sqrt(3);
phi=acos(pf);
q=p*tan(phi);
i=(p-j*q)/(3*vph);
delta=0:10:180;
e=abs(vph+i*j*xd);
pph=(e*vph*sin(delta*pi/180))/xd;
p=3*pph/10^6;
regulation=((abs(e)-abs(vph))/abs(vph));
plot(delta,p);
xlabel("delta");
ylabel("power");
legend("non salient pole");
title("non salient pole sm")

% LINE CHARGE
clear all
clc
data = [ 1 2 0.1i 0.01i
1 3 0.2i 0.02i
3 2 0.3i 0.03i]
sb= data( :,1);
eb =data ( :,2);
z= data ( :,3);
ysh = data ( :,4);
y=1./z;
nele= length(sb);
nbus= max(max(sb),max(eb));
ybus= zeros(nbus,nbus);
for i=1:nele
ybus(sb(i),sb(i))=ybus(sb(i),sb(i))+y(i)+ysh(i);
ybus(eb(i), eb(i))=ybus(eb(i),eb(i))+y(i)+ysh(i);

ybus(sb(i),eb(i))=ybus(sb(i),eb(i))-y(i);
ybus(eb(i),sb(i))=ybus(eb(i),sb(i))- y(i);
end
volt_data=[1.04 0
1.021 -2.34
1.012 0.786];
vbus= volt_data( :,1).*(cos(volt_data(:,2))+j*sin(volt_data(:,2)))
ibus=ybus*vbus;
for i=1:nele
ipq=((vbus(sb(i))-vbus(eb(i)))*y(i))+(vbus(sb(i))*ysh(i));
spq(i)= vbus(sb(i))*conj(ipq);
iqp=((vbus(eb(i))- vbus(sb(i)))*y(i))+(vbus(eb(i))*ysh(i));
sqp(i)= vbus(eb(i))*conj(iqp);
S(i)=spq(i)+sqp(i);
end
sp=sum(S);
sbus=vbus.*conj(ibus) ;
disp(ybus)

%zbus
clear all
clc
data =[ 0 1 0.1i 0
0 2 0.1i 0
1 3 0.2i 1
2 3 0.2i 3
2 3 0.2i 3
3 0 0.1i 2]
zbus=[];
for i= length(data( :,1));
sb=data( i,1);
eb=data(i,2);
z=data(i,3);
type=data(i,4);
p=min(sb,eb);
q=max(sb,eb);
if type==0
zbus(i,i)=z
elseif type==1
zbus=[zbus zbus(:,p)
zbus(p,:) z+zbus(p,p)]
elseif type==2
zbus=zbus-(1/(zbus(q,q)+z))*((zbus(:,q)*zbus(q,:)))
else
zbus=zbus-(1/(z+zbus(p,p)+zbus(q,q))+2*zbus(p,q))*(zbus(:,p)-
zbus(:,q))*(zbus(p,:)-zbus(q,:))
end
end

You might also like