You are on page 1of 11

-----------EXPERIMENT 2 Problem-1 -----HS P-128 -------Ex:4.

2---
Dab= input('Enter Dab value);
Dbc= input('Enter Dbc value);
Dca= input('Enter Dac value);
GMD=(Dab*Dbc*Dca)^(1/3);
GMRL= input('Enter GMRL(GMR) Value in ft (inch/12): ');
disp('Value of L in mH/KM:);
L = 0.2*log(GMD/GMRL)
dia= input('Enter conductor diameter in in);
r=dia/2; GMRC=r/12;
disp('Value of C in F/KM:);
C = 0.0556/log(GMD/GMRC)
--------------------------------------------------------------
-----------EXPERIMENT 2 Problem-2 ------HS P-128 -------Ex:4.3---
Dab= input('Enter Dab value:);
Dbc= input('Enter Dbc value:);
Dca= input('Enter Dac value:);
GMD=(Dab*Dbc*Dca)^(1/3);
dia=input('Enter conductor diameter in in);
r=dia/2;
d=input('Enter Bundle Spacing in inch);
Ds=input('Enter GMR(Ds) in inch);
GMRL=(sqrt(d*Ds))/12;
GMRC=(sqrt(d*r))/12;
disp('Value of L in mH/KM:);
L = 0.2*log(GMD/GMRL)
disp('Value of C in F/KM:);
C = 0.0556/log(GMD/GMRC)
--------------------------------------------
-----------EXPERIMENT 2 Problem-3 -------HS P 131-----Ex:4.5-----
S = input('Enter row vector [S11, S22, S33] = ');
H = input('Enter row vector [H12, H23] = ');
d = input('Bundle spacing in inch = ');
dia = input('Conductor diameter in inch = '); r=dia/2;
Ds = input('Geometric Mean Radius in inch = ');
S11 = S(1); S22 = S(2); S33 = S(3); H12 = H(1); H23 = H(2);
a1 = -S11/2 + j*H12;
b1 = -S22/2 + j*0;
c1 = -S33/2 - j*H23;
a2 = S11/2 + j*H12;
b2 = S22/2 + j*0;
c2 = S33/2 - j*H23;
Da1b1 = abs(a1 - b1); Da1b2 = abs(a1 - b2);
Da1c1 = abs(a1 - c1); Da1c2 = abs(a1 - c2);
Db1c1 = abs(b1 - c1); Db1c2 = abs(b1 - c2);
Da2b1 = abs(a2 - b1); Da2b2 = abs(a2 - b2);
Da2c1 = abs(a2 - c1); Da2c2 = abs(a2 - c2);
Db2c1 = abs(b2 - c1); Db2c2 = abs(b2 - c2);
Da1a2 = abs(a1 - a2);
Db1b2 = abs(b1 - b2);
Dc1c2 = abs(c1 - c2);
DAB=(Da1b1*Da1b2* Da2b1*Da2b2)^0.25;
DBC=(Db1c1*Db1c2*Db2c1*Db2c2)^.25;
DCA=(Da1c1*Da1c2*Da2c1*Da2c2)^.25;
GMD=(DAB*DBC*DCA)^(1/3)
Ds = 2.54*Ds/100; r = 2.54*r/100; d = 2.54*d/100;
Dsb = (d*Ds)^(1/2); rb = (d*r)^(1/2);
DSA=sqrt(Dsb*Da1a2); rA = sqrt(rb*Da1a2);
DSB=sqrt(Dsb*Db1b2); rB = sqrt(rb*Db1b2);
DSC=sqrt(Dsb*Dc1c2); rC = sqrt(rb*Dc1c2);
GMRL=(DSA*DSB*DSC)^(1/3)
GMRC = (rA*rB*rC)^(1/3)
L=0.2*log(GMD/GMRL) % mH/km
C = 0.0556/log(GMD/GMRC) % micro F/km

--------------------------------------------------------------------------
--------EXP 3 PGM -1 short transmission line ----HS P145 -------Ex:5.1----
VRLL=220;
VR=VRLL/sqrt(3);
Z=[0.15+j*2*pi*60*1.3263e-3]*40;
disp=('(a)')
SR=304.8+j*228.6;
IR=conj(SR)/(3*conj(VR));
IS=IR;
VS=VR+Z*IR;
VSLL=sqrt(3)*abs(VS)
SS=3*VS*conj(IS)
REG=((VSLL-VRLL)/(VRLL))*10
EFF=(real(SR)/real(SS))*100
disp=('(b)')
SR=304.8-j*228.6;
IR=conj(SR)/(3*conj(VR));
IS=IR;
VS=VR+Z*IR;
VSLL=sqrt(3)*abs(VS)
SS=3*VS*conj(IS)
REG=((VSLL-VRLL)/(VRLL))*100
EFF=(real(SR)/real(SS))*100

---------------------------------------------------------------------------
------------------EXP 3 PGM -2 MEDIUM TL(General Problem) -----------
clc
clear all
z=[];
z=input('Enter the length of line(km),Receiving
voltage(v),Power(W),Powerfactor,L,R&C(per phase per km)');
l=z(1);vr=z(2);p=z(3);pf=z(4);L=z(5);R=z(6);c=z(7);
z=32+i*81;
y=i*0.00056;
disp('Medium Transmission line by nominal T method:')
A=1+(z*y)/2;C=y;B=z*(1+(z*y)/4);D=1+(z*y)/2;
disp('Generalized ABCD Constants are:')
disp(A);
disp(B);
disp(C);
disp(D);
ir=p/(1.732*vr*0.8)
vs=(A*vrph)+(ir*B);
fprintf('Sending end voltage Vs is %f\n',vs);
is=(vrph*C)+(D*ir);
fprintf('Sending end current Is is %f\n',is);
reg=((3*conj(vs)/conj(A))-v)*100/v;
fprintf('Voltage Regulation is %f\n',reg);
pows=3* conj(vs)* conj(is)*0.808;
eff=p*100/pows;
fprintf('Efficiency is %f\n',eff);

---------------------------------------------------------------------------
-----EXP 4,5---YBUS,ZBUS(INVERSE YBUS)------General Problem-------
clc
clear all
disp('');
b = input('Enter no. of buses:');
s = input('Enter no. of impedences:');
for i=1:s
sb(i)=input('Enter starting bus no.');
rb(i)=input('Enter receiving bus no.');
imp(i)=input('Enter impendance of bus:');
lc(i)=input('Enter line charging admittance:');
ybus=diag(0,b-1);
end
for i=1:s
k1=sb(i);
k2=rb(i);
adm(i)=1/imp(i);
ybus(k1,k1)=ybus(k1,k1)+adm(i)+lc(i);
ybus(k2,k2)=ybus(k2,k2)+adm(i)+lc(i);
ybus(k1,k2)=-adm(i);
ybus(k2,k1)=ybus(k1,k2);
end
disp('bus admittance matrix is:)
ybus
disp('bus impendance matrix is:)
z=inv(ybus)
-----------------------------------------------------------------------------------
-------
-----EXP 5 -----ZBUS using bus building algorithm-----Nagoor Kani Book---Ex:-------
clc
clear all
close all
g=[1.2 0.2 0.15 1.5 0.3];
z1=[g(1)];
disp(z1);
disp('TYPE I MODIFICATION')
z2=[g(1) g(1)
g(1) g(1)+g(2)];
disp(z2);
disp('TYPE II MODIFICATION')
z3=[g(1) g(1) g(1)
g(1) g(1)+g(2) g(1)+g(2)
g(1) g(1)+g(2) g(1)+g(2)+g(3)];
disp(z3);
disp('TYPE III MODIFICATION')
z4=[g(1) g(1) g(1) g(1)
g(1) g(1)+g(2) g(1)+g(2) g(1)+g(2)
g(1) g(1)+g(2) g(1)+g(2)+g(3) g(1)+g(2)+g(3)
g(1) g(1)+g(2) g(1)+g(2)+g(3) g(1)+g(2)+g(3)+g(4)]
z4=[z4];
disp(z4);
disp('Actual Zbus matrix is:')
n=4;
for i=1:1:n
for j=1:1:n
z4(i,j)=z4(i,j)-(z4(i,n)*z4(n,j)/z4(n,n));
end
end
z4(:,4)=[];
z4(4,:)=[];
disp(z4);
disp('TYPE IV MODIFICATION MATRIX')
l=4;
p=2;q=4;
for i=1:l-1
z4(l,i)=z4(p-1,i)-z4(q-1,i);
z4(i,l)=z4(l,i);
end
z4(l,l)=g(5)+z4(1,1)+z4(3,3)-2*z4(1,3);
disp(z4);
n=4;
for i=1:1:n
for j=1:1:n
z4(i,j)=z4(i,j)-(z4(i,n)*z4(n,j)/z4(n,n));
end
end
z4(:,4)=[];
z4(4,:)=[];
disp('THE REQUIRED ZBUS MATRIX IS:');
ZBUS=z4*1i;
disp(ZBUS);
------------------------------------------------------------------------
----------EXP 6------GAUSS SEIDAL Method------HS P213 -------Ex:6.7--
y12=10-j*20;
y13=10-j*30;
y23=16-j*32;
V1=1.05+j*0;
iter =0;
S2=-2.566-j*1.102;
S3=-1.386-j*.452;
V2=1+j*0;
V3=1+j*0;
for I=1:10;
iter=iter+1;
V2 = (conj(S2)/conj(V2)+y12*V1+y23*V3)/(y12+y23);
V3 = (conj(S3)/conj(V3)+y13*V1+y23*V2)/(y13+y23);
disp([iter, V2, V3])
end
V2= .98-j*.06;
V3= 1-j*.05;
I12=y12*(V1-V2); I21=-I12;
I13=y13*(V1-V3); I31=-I13;
I23=y23*(V2-V3); I32=-I23;
S12=V1*conj(I12); S21=V2*conj(I21);
S13=V1*conj(I13); S31=V3*conj(I31);
S23=V2*conj(I23); S32=V3*conj(I32);
I1221=[I12,I21]
I1331=[I13,I31]
I2332=[I23,I32]
S1221=[S12, S21 (S12+S13) S12+S21]
S1331=[S13, S31 (S31+S32) S13+S31]
S2332=[S23, S32 (S23+S21) S23+S32]
----------------------------------------------------------------------------------
-----------EXP 7--------N R method ----HS P 236(model)----Ex:6.10(Model)-----
clear all;
clc;
n=input('no of buses');
n1=input('no of lines');
sb=[1 1 2];
eb=[2 3 3];
y=[inv(0.08+0.24i) inv(0.02+0.06i) inv(0.06+0.18i)];
ybus=zeros(n,n1);
for i=1:n1
k1=sb(i);
k2=eb(i);
ybus(k1,k1)=ybus(k1,k1)+y(i);
ybus(k2,k2)=ybus(k2,k2)+y(i);
ybus(k1,k2)=-y(i);
ybus(k2,k1)=ybus(k1,k2);
end
ybus bcode=[1 2 3];
v=[1.06+0i 1+0i 1+0i];
sg=[0+0i 0.2+0i 0+0i];
sd=[0+0i 0+0i 0.6+0.25i];
qmin=0;
qmax=0.35;
e=real(v);
f=imag(v);
g=real(ybus);
b=-imag(ybus);
pg=real(sg);
qg=imag(sg);
pd=real(sd);
qd=imag(sd);
con=10;
if(con>0.001)
for j=2:3
p(i)=0;
q(i)=0;
for k=1:3
p(j)=p(j)+(e(j)*(e(k)*g(j,k)+f(k)*b(j,k))+f(j)*(f(k)*g(j,k)-e(k)*b(j,k)));
q(j)=q(j)+(f(j)*(e(k)*g(j,k)+f(k)*b(j,k))-e(j)*(f(k)*g(j,k)-e(k)*b(j,k)));
end
end
for i=2:n
ps(i)=pg(i)-pd(i);
qs(i)=qg(i)-qd(i);
delp(i)=ps(i)-p(i);
delq(i)=qs(i)-0
end
for j=2:3
sumpe=0;
sumpf=0;
sumqe=0;
sumqf=0;
for k=1:3
if(k~=j)
sumpe=sumpe+(e(k)*g(j,k)+f(k)*b(j,k));
sumpf=sumpf+(f(k)*g(j,k)-e(k)*b(j,k));
sumqe=sumqe-(f(k)*g(j,k)-e(k)*b(j,k));
sumqf=sumqf+(e(k)*g(j,k)+f(k)*b(j,k));
end

if(k~=1)&(k~=j)
delpe(j,k)=e(j)*g(j,k)-f(j)*b(j,k);
delpf(j,k)=e(j)*b(j,k)+f(j)*g(j,k);
delqe(j,k)=e(j)*b(j,k)+f(j)*g(j,k);
delqf(j,k)=e(j)*g(j,k)+f(j)*b(j,k);
end
end

delpe(j,j)=(2*e(j)*g(j,j))+sumpe;
delpf(j,j)=(2*f(j)*g(j,j))+sumpf;
delqe(j,j)=(2*e(j)*b(j,j))+sumqe;
delqf(j,j)=(2*f(j)*b(j,j))+sumqf;
end

for j=1:2
for k=1:2
delpem(j,k)=delpe(j+1,k+1);
delpfm(j,k)=delpf(j+1,k+1);
delqem(j,k)=delqe(j+1,k+1);
delqfm(j,k)=delqf(j+1,k+1);
end
delpm(j)=delp(j+1);
delqm(j)=delq(j+1);
end
jacob=[delpem delpfm ; delqem delqfm];
dels=[delpm delqm];
con=max(dels);
c=jacob;

for j=2:3
e(j)=e(j)+c(j-1);
f(j)=f(j)+c(j-1);
end
end
p
q
delpm
delqm
jacob
t=inv(jacob)
r=[delpm delqm]
res=r*t

-----------------------------------------------------------------------------------
-
----------Exp 8-----Fast Decouple Method------HS P 243 -------Ex:6.12(same
model)---

----------------------------------out of syllabus------------------

----------------------------------------------------------------------------------
------Exp 9----SINGLE-MACHINE INFINITE BUS SYSTEM ------HS P 477 -------Ex:11.2----
E=1.35;
V=1.0;
H=9.94;
X=0.65;
Pm=0.6;
D=.138;
fo=60;
Pmax=E*V/X
do=asin(Pm/Pmax)
Ps=Pmax*cos(do)
wn=sqrt((pi*60)/(H*Ps))
z=D/2*sqrt((pi*60)/(H*Ps))
wd=wn*sqrt(1-z^2);
fa=wd/(2*pi)
tan=1/(z*wn)
th=acos(z)
Ddo=10*pi/180;
t=0:0.01:10;
Dd=Ddo/sqrt(1-z^2).*exp(-z*wn*t).*sin(wd*t+th);
d=(do+Dd)*180/pi;
Dw=-wn*Ddo/sqrt(1-z^2).*exp(-z*wn*t).*sin(wd*t+th);
f=fo+Dw/(2*pi);
subplot(211),plot(t,d),grid
xlabel('tsec'),ylabel('delta degree')
subplot(212),plot(t,f),grid
xlabel('tsec'),ylabel('frequency Hz')
subplot(111)
-----------------------------------------------------------------------------------
-------Exp 10 -----Multimachine infinite bus system---HS P 516-------Ex:11.7-------
clear all;
clc;
format long
%step1 initialisation wiyh load flow &machince data
f=50;
tstep=0.01;
h=[12 9];
pgnetterm=[3.25 2.10];
qgnetterm=[0.6986 0.3110];
xg=[0.067 0.10];
%use of ; is to transpose without taking the conjugate of each element
v0=[1.0193+j*0.14753 1.012+j*0.12713];
%m is no of generators other than slack bus
m=2;
%step 2
v0conj=conj(v0);
ig0=conj((pgnetterm+j*qgnetterm)/v0);
edash=v0+j*(xg*ig0);
pg0=real(edash0*conj(ig0));
x1_r=angle(edash0);
%initialisation of state vector
pg_r=pg0;
%pg_rplus1=pg0;
x2_r=[0 0];
x1dot_r=[0 0];
x2dot_r=[0 0];
x1dotrplus1=[0 0];
x2dotrplus1=[0 0];
%step 3
ybusdf=[5.7986-j*35.6301 0 -0.0681+j*5.1661
0 -j*11.236 0
-0.0681+j*5.1661 0 0.1362-j*6.2737];
ybuspf=[1.3932-j*13.8731 -0.2214+j*7.6289 -0.0901+j*6.0975
-0.2214+j*7.6289 0.5+j*7.7898 0
-0.0901+j*6.0975 0 0.1591-j*6.1168];
%step 4
%set values for initial time t(occurance of %fault)and
%tc is time of fault clearance
t=0;
tc=0.08;
tfinal=1.0;
r=1;
edash_r=edash0;
edash_rplus1=edash0;
while t<tfinal
%step5 compute generator powers using appropriate ybus
%the ybus choosen in the following step is set accordind to the current
%time
if t<=tc
ybus=ybuspf;
end
i=ybus(2:m+1,:)*[1 edash_r];
pg_r=real(edash_r*conj(i));
%step6 compute x1dot_r and x2dot_r
x1dot_r=x2_r;
for k=1:m
x2dot_r(k,1)=(p1*f/h(k))*(pg0(k)-pg_r(k));
end
%step7 compute first state estimates for t=t(r+1)
x1_rplus1=x1_r+x1dot_r*tstep;
x2_rplus1=x2_r+x2dot_r*tstep;
%step8 compute first state estimates
edash_rplus1=abs(edash0)*(cos(x1_rplus1)+j*sin(x1_rplus1));
%step9 compute pg for t=t(r+1)
i=ybus(2:m)*[1 edash_rplus1];
pg_rplus1=real(edash_rplus1.conj(i));
%step10 compute state derivatives at t=t(r+1)
x1dot_rplus=[0 0];
x2dot_rplus=[0 0];
for k=1:m
x1dot_rplus1(k,1)=x2_rplus1(k,1);
x2dot_rplus1(k,1)=p1*f/h(k)*(pg0(k)-pg_rplus1(k));
end
%step11 compute average values of state derivaties
x1dotav_r=(x1dot_r+x1dot_rplus1)/2.0;
x2dotav_r=(x2dot_r+x12dot_rplus1)/2.0;
%step 12 compute final estimate for edash at t=t(r+1)
x1_rplus1=x1_r+x1dotav_r*tstep;
x2_rplus1=x2_r+x2dotav_r*tstep;
%step 13 compute final estimate for edash at t=t(r+1)
edash_rplus1=abs(edash0)*(cos(x1_rplus1)+j*sin(x1_rplus1));
%step14 print state vector
x2_r=x2_rplus1;
x1_r=x1_rplus1;
edash_r=edash_rplus1;
%step15
time(r)=t;
for k=1:m
ang(r,k)=(x1_r(k)*180)/pi;
end
t=t+tstep;
r=r+1;
end
plot(time,ang)

------EXP 11 ---1.single area(Matlab+Simulink) --Example 12.1---Page 536--

disp('Example 12.1 (b) Root-locus')


num = 1;
den = [1 7.08 10.56 .8];
figure (1), rlocus(num, den)
disp('Example 12.1 (c) Frequency deviation step response')
PL = 0.2;
numc = [0.1 0.7 1];
denc = [1 7.08 10.56 20.8];
t = 0:.02:10;
c = -PL*step(numc, denc, t);
figure(2), plot(t, c), grid
xlabel('t, sec'), ylabel('pu')
title('Frequency deviation step response')
timespec(numc, denc)

-------EXP 11 ---2.TWO area(Matlab+Simulink) --HS Example 12.4---Page 548-------

disp('(a)')
R1 = 0.05; R2 = 0.0625;
D1 = 0.6; D2 = 0.9;
DPL1 = 187.5/1000;
Dw = -DPL1/(1/R1 + D1+ 1/R2+D2)
Df = Dw*60, f = 60+Df
DPm1 = -Dw/R1
DPm2 = -Dw/R2
DP12 = Dw*(1/R2 + D2)
disp('(b) Open sim12ex4.mdl in SIMULINK WINDOW and click on simulation')

-----------------------------------------------------------------

----EXP 12----Economic Dispatch(without LOSSES)---Example 7.4--HS P-271--


clc;
clear all;
n=input('Enter the number of units:');
a=zeros(n);
b=zeros(n);
c=zeros(n);
for i=1:n
fprintf('Enter the unit %g Data \n',i);
a(i)=input('Enter the value of a:');
b(i)=input('Enter the value of b:');
c(i)=input('Enter the value of c:');
end
pd=input('Enter the value of load demand:');
P=zeros(n);
sum=0; den=0;
for i=1:n
sum=sum+(b(i)/(2*a(i)));
end
for i=1:n
den=den+(1/(2*a(i)));
end
num=pd+sum;
lamda=num/den;
for i=1:n
P(i)=(lamda-b(i))/(2*a(i));
end
for i=1:n
fprintf('Optimal Generation of unit %g: %g MW\n',i,P(i));
end
fprintf('Lamda: %g \n',lamda);
for i=1:n
unitcost=a(i)*P(i)^2+b(i)*P(i)+c(i);
fprintf('Generation cost of unit %g : %g\n',i,unitcost);
end
totalcost=0;
for i=1:n
totalcost=totalcost+a(i)*P(i)^2+b(i)*P(i)+c(i);
end
fprintf('Total generation cost : %g\n', totalcost);

--------------------------------------------------------------------

---EXP 12--Economic Dispatch(WITHOUT LOSSES & GENERATING LIMITS)--HSP-277----


Example7.6--
clc;
clear all;
n=input('Enter the number of units:');
a=zeros(n);
b=zeros(n);
c=zeros(n);
pmin=zeros(n);
pmax=zeros(n);
P=zeros(n);
for i=1:n
fprintf('Enter the unit %g Data \n',i);
a(i)=input('Enter the value of a:');
b(i)=input('Enter the value of b:');
c(i)=input('Enter the value of c:');
pmin(i)=input('Enter the minimum value of generation:');
pmax(i)=input('Enter the maximum value of generation:');
end
pd=input('Enter the value of load demand:');
sum=0; den=0;
for i=1:n
sum=sum+(b(i)/(2*a(i)));
den=den+(1/(2*a(i)));
end
num=pd+sum;
lamda=num/den;
t=1;
while t>0
for i=1:n
P(i)=0;
end
PG=0;
for i=1:n
P(i)=(lamda-b(i))/(2*a(i));
end
for i=1:n
if(P(i)>pmax(i))
P(i)=pmax(i);
elseif P(i)<pmin(i)
p(i)=pmin(i);
else
P(i)=P(i);
end
end
PG=PG+P(i);
delp=pd-PG;
dellamda=delp/den;
if PG<pd
lamda=lamda+dellamda;
else
lamda=lamda-dellamda;
end
if delp<0.0001
t=0;
end
for i=1:n
fprintf('Optimal Generation of unit %g: %g MW\n',i,P(i));
end
fprintf('Lamda: %g \n',lamda);
for i=1:n
unitcost=a(i)*P(i)^2+b(i)*P(i)+c(i);
fprintf('Generation cost of unit %g : %g\n',i,unitcost);
end
totalcost=0;
for i=1:n
totalcost=totalcost+a(i)*P(i)^2+b(i)*P(i)+c(i);
end
fprintf('Total generation cost : %g\n', totalcost);
--------------------------------------------------------------------

---Exp 13---------FAULT ANALYSIS-----HS P 427 -------Ex:10.5------


Z133 = j*0.22; Z033 = j*0.35; Zf = j*0.1;
disp('(a) Balanced three-phase fault at bus 3')
Ia3F = 1.0/(Z133+Zf)
disp('(b) Single line-to-ground fault at bus 3')
I03 = 1.0/(Z033 + 3*Zf + Z133 + Z133);
I012=[I03; I03; I03]
%sctm;
global sctm
a =cos(2*pi/3)+j*sin(2*pi/3);
sctm = [1 1 1; 1 a^2 a; 1 a a^2];
Iabc3 = sctm*I012
disp('(c) Line-to-line fault at bus 3')
I13 = 1.0/(Z133 + Z133 + Zf);
I012 = [0; I13; -I13]
Iabc3 = sctm*I012
disp('(d) Double line-to-ground fault at bus 3')
I13 = 1/(Z133 + Z133*(Z033+3*Zf)/(Z133+Z033+3*Zf));
I23 = -(1.0 - Z133*I13)/Z133;
I03 = -(1.0 - Z133*I13)/(Z033+3*Zf);
I012 = [I03; I13; I23]
Iabc3 = sctm*I012
-----------------------------------------------------------------------------------
---------

You might also like