Department of Electrical and Electronics Engineering: Power System Simulation Lab (Semester: 7 Subject Code: 15EEL76)
Department of Electrical and Electronics Engineering: Power System Simulation Lab (Semester: 7 Subject Code: 15EEL76)
Manual for
************
case 1,
%vr=input('enter Vr/phase');
%ir=input('enter Ir/phase');
vrl=132+0.0i;
ir=174.96-131.22i;
vr=vrl*1e3/sqrt(3);
vs=(A*vr+B*ir);
is=C*vr+D*ir;
fprintf('\n sending end voltage/ph=%f %+fi KV', real(vs)/1e3, imag(vs)/1e3);
fprintf('\n sending end current/ph=%f %+fi AMP', real(is), imag(is));
vsl=vs*sqrt(3.0);
case 2,
%vs=input('enter Vs/phase');
%is=input('enter Is/phase');
vsl=132+0.0i;
is=174.96-131.22i;
vs=vsl*1e3/sqrt(3);
vr=(D*vs-B*is);
ir=-C*vs+D*is;
fprintf('\n Receiving end voltage/ph=%f %+fi KV', real(vr)/1e3, imag(vr)/1e3);
fprintf('\n sending end current/ph=%f %+fi AMP', real(ir), imag(ir));
vrl=vr*sqrt(3.0);
otherwise
disp('wrong choice');
end
rec_pow=3*real(vr*conj(ir))/1e6;
send_pow=3*real(vs*conj(is))/1e6;
eff=rec_pow/send_pow*100;
reg=(abs(vs)/abs(A)-abs(vr))/abs(vr)*100;
fprintf('\n Receiving end power=%.2f MW', rec_pow);
fprintf('\n Sending end power=%.2f MW', send_pow);
fprintf('\n Efficiency=%.2f %%',eff);
fprintf('\n Voltage Regulation=%.2f%%', reg);
O/P 1:-
Enter 1-for short line 2-for medium line 3-for long line:1
O/P 2:-
Enter 1-for short line 2-for medium line 3-for long line:1
O/P 3:-
Enter 1-for short line 2-for medium line 3-for long line:2
O/P 4:-
Enter 1-for short line 2-for medium line 3-for long line:2
O/P 5:-
Enter 1-for short line 2-for medium line 3-for long line:3
the equivalent PI circuit constants:
Zeq= 57.7123 +120.6169i
Yeq= 0.0000 +0.0005i
A,B,C and D constants:
----------------
A= 0.9428 +0.0277i
B= 57.7123 +120.6169i
C= -0.0000 +0.0009i
D= 0.9428 +0.0277i
the product AD-BC=1.000000
Enter 1-To read Vr,Ir and compute Vs,Is
2-To read Vs,Is and compute Vr,Ir:1
O/P6:-
Enter 1-for short line 2-for medium line 3-for long line:3
case 1,
%vr=input('enter Vr/phase');
%ir=input('enter Ir/phase');
vrl=132+0.0i;
ir=174.96-131.22i;
vr=vrl*1e3/sqrt(3);
vs=(A*vr+B*ir);
is=(C*vr+D*ir);
fprintf('\n sending end voltage/ph=%f %+fi KV', real(vs)/1e3, imag(vs)/1e3);
fprintf('\n sending end current/ph=%f %+fi AMP', real(is), imag(is));
vsl=vs*sqrt(3.0);
case 2,
%vs=input('enter Vs/phase');
%is=input('enter Is/phase');
vsl=132+0.0i;
is=174.96-131.22i;
vs=vsl*1e3/sqrt(3);
vr=(D*vs-B*is);
ir=(-C*vs+D*is);
fprintf('\n Receiving end voltage/ph=%f %+fi KV', real(vr)/1e3, imag(vr)/1e3);
fprintf('\n sending end current/ph=%f %+fi AMP', real(ir), imag(ir));
vrl=vr*sqrt(3.0);
otherwise
disp('wrong choice');
end
rec_pow=3*real(vr*conj(ir))/1e6;
send_pow=3*real(vs*conj(is))/1e6;
eff=rec_pow/send_pow*100;
reg=(abs(vs)/abs(A)-abs(vr))/abs(vr)*100;
fprintf('\n Receiving end power=%.2f MW', rec_pow);
fprintf('\n Sending end power=%.2f MW', send_pow);
fprintf('\n Efficiency=%.2f %%',eff);
fprintf('\n Voltage Regulation=%.2f%%', reg);
O/P 1:-
O/P2:-
enter 1-for short line 2-medium line 3-for long line:1
O/P 3:-
enter 1-for short line 2-medium line 3-for long line:2
O/P 4:-
O/P 5:-
enter 1-for short line 2-medium line 3-for long line:3
O/P 6:-
enter 1-for short line 2-medium line 3-for long line:3
the equivalent T circuit constants:
Zeq= 122.3432 +246.5944i
Yeq= -0.0000 +0.0009i
A,B,C and D constants:
-----
A= 0.9428 +0.0277i
B= 57.7123 +120.6169i
C= -0.0000 +0.0009i
D= 0.9428 +0.0277i
the product AD-BC=1.000000
enter 1 to read Vr,Ir and compute Vs,Is
2 to read Vs,Is and compute Vr,Ir:2
PROGRAM 2 a): Power angle characteristics of Salient pole rotor syn. m/c
clc
clear all
%Xd=1.2;xq=0.8;ra=0.025; v=1.0; p=0.6; pf=0.8;
xd=input('Enter direct axis reactance per phase in pu\n');
xq=input('Enter quadrature axis reactance per phase in pu\n');
ra=input('Enter the armature resistance per phase in pu\n');
v=input('Enter the terminal voltage of the generator in pu\n');
p=input('Enter the power output of the generator in pu\n');
pf=input('Enter power factor\n');
pfsign=input('Enter -1 for lagging power factor & 1 for leading power factor');
iamag=p/(v*pf);
theta=acos(pf)*pfsign;
realia=iamag*cos(theta);
imagia=iamag*sin(theta);
ia=complex(realia, imagia);
efdash=v+(ia*ra)+(ia*j*xq);
delta=angle(efdash);
si=delta-theta;
id=iamag*sin(si);
iq=iamag*cos(si);
ef=abs(efdash)+id*(xd-xq);
p1=ef*abs(v)/xd;
p2=abs(v)^2*(xd-xq)/(2*xd*xq);
del=0:0.01:pi;
pext=p1*sin(del);
prlc=p2*sin(2*del);
pe=pext+prlc;
[pmax,k]=max(pe);
plot(del*180/pi,pext,'r');
hold on
plot(del*180/pi,prlc,'m');
plot(del*180/pi,pe,'b');
legend('excitation power','reluctance power', 'salient power');
title('power angle characteristics salient pole syn. m/c');
xlabel('delta in deg');
ylabel('power in pu');
% line(del*180/pi,0); del=0:0.01:del(k); line(del*180/pi,pmax);
%y=0:0.01:pmax; line(pi/2*(180/pi),y); text(75,1.05*pmax,'p_{max}');
% text(del(k)*180/pi,-0.1,'del_{max}');
reg=(abs(ef)-abs(v))/abs(v)*100;
fprintf('\n the excitation voltage=%f p.u',abs(ef));
fprintf('\n the maximum power=%f p.u and the corresponding angle=%f
degrees',pmax,del(k)*180/pi);
fprintf('\n the voltage regulation=%f%%',reg);
fprintf('\n reluctance power=%f pu',p2);
O/P 1:-
Enter direct axis reactance per phase in pu
1.2
Enter quadrature axis reactance per phase in pu
0.8
Enter the armature resistance per phase in pu
0.025
Enter the terminal voltage of the generator in pu
1
Enter the power output of the generator in pu
0.6
Enter power factor
0.8
Enter -1 for lagging power factor& 1 for leading power factor-1
O/P 2:-
Enter direct axis reactance per phase in pu
1.2
Enter quadrature axis reactance per phase in pu
0.8
Enter the armature resistance per phase in pu
0.025
Enter the terminal voltage of the generator in pu
1
Enter the power output of the generator in pu
0.6
Enter power factor
0.8
Enter -1 for lagging power factor& 1 for leading power factor1
PROGRAM 2 b): Power angle characteristics of Non salient pole rotor synchronous
machine
clc
clear all
%Xdd=0.3;ra=0.0; v=1.0; p=0.9; pf=0.8;
fprintf('generator is modelled by a voltage source behind a reactance\n');
xdd=input('Enter generator reactance per phase in pu\n');
ra=input('Enter the armature resistance per phase in pu\n');
v=input('Enter the terminal voltage of the generator in pu\n');
p=input('Enter the power output of the generator in pu\n');
pf=input('Enter power factor\n');
pfsign=input('Enter -1 for lagging power factor & 1 for leading power factor');
iamag=p/(v*pf);
theta=acos(pf)*pfsign;
realia=iamag*cos(theta);
imagia=iamag*sin(theta);
ia=complex(realia, imagia);
ef=v+ia*(ra+j*xdd);
pmax=abs(ef)*abs(v)/xdd;
del=0:0.01:pi;
plot(del*180/pi,pmax*sin(del),'r');
xlabel('Delta in deg');
ylabel('Power in pu');
del=0:0.01:pi/2;
legend('pmax*sin(del)');
%line(del*180/pi,pmax);
% y=0:0.01:pmax; line(pi/2*(180/pi),y);
% text(-10,1.02*pmax,'p_{max}');
% text(pi/2*(180/pi),0.2,'del_{max}');
reg=(abs(ef)-abs(v))/abs(v)*100;
fprintf('\n the voltage regulation=%f %%\n',reg);
fprintf('the maximum power=%f pu',pmax);
O/P 1:-
generator is modelled by a voltage source behind a reactance
enter generator reactance per phase in pu
0.3
enter the armature resistance per phase in pu
0.0
enter the tewrminal voltage of the generator per phase in pu
1.0
enter the power output of the generator in pu
0.9
enter the power factor
0.8
enter -1 for lagging power factor & 1 for leading power factor-1the maximum
power=2.806552 pu
the voltage regulation=23.243915%
the maximum power=4.108130 pu>>
O/P 2:-
generator is modelled by a voltage source behind a reactance
enter generator reactance per phase in pu
0.3
enter the armature resistance per phase in pu
0.0
enter the tewrminal voltage of the generator per phase in pu
1.0
enter the power output of the generator in pu
0.9
enter the power factor
0.8
enter -1 for lagging power factor & 1 for leading power factor1
the voltage regulation=-15.803429%
the maximum power=2.806552 pu>>
PROGRAM 3(a): To determine i) swing curve ii) critical clearing time for a single
machine connected to infinite bus through a pair of identical transmission lines, for a 3
sustained fault on one of the lines.
% ps=mechanical power input.
%x2=reactance after fault
clc
clear all
ps=0.9;e=1.1;v=1;m=0.00028;xe=0.35;xl=0.2;
% m in electrical degrees
x1=xe+xl/2;
ch=input('enter 1 for fault at the beginning \n 2-for fault at the middle: ');
switch(ch)
case 1,
x2=inf;
case 2,
x2=(xe*xl+xe*xl/2+xl*xl/2)/(xl/2);
otherwise
disp('wrong input');
end
dt=0.05;
it=1; % it is the iteration count
t(it)=0;
deld=0;
pm1=e*v/x1;
del(it)=asin(ps/pm1);
pm2=e*v/x2;
pm=pm2;
pe=pm2*sin(del(it));
pa=(ps-pe)/2;
fprintf('\n sustained fault');
fprintf('\n----------------------------');
fprintf('\n time pmax delta');
fprintf('\n----------------------------');
while(t(it)<=1.0)
deld=deld+(pa*(dt^2/m));
it=it+1;
t(it)=t(it-1)+dt;
plot(t,del*(180/pi),'r')
title('Swing curve')
xlabel('time in seconds')
ylabel('\delta in degrees')
x3=xe+xl; % x3=0.55
pm3=e*v/x3;
delm=pi-del(1);
cdc=(ps*(delm-del(1))+pm3*cos(delm)-pm2*cos(del(1)))/(pm3-pm2);
delc=acos(cdc);
D=delc*(180/pi);
fprintf('\n critical clearing angle %f',D);
it=1;
while(t(it)<1)
if(del(it)>=delc)
break;
end
it=it+1;
end
fprintf('critical clearing time=%f sec\n',t(it));
O/P 1:-
enter 1 for fault at the beginning
2-for fault at the middle:1
sustained fault
----------
time pmax delta
-------------
0.050 0.00 25.62
0.100 0.00 37.67
0.150 0.00 57.76
0.200 0.00 85.89
0.250 0.00 122.05
0.300 0.00 166.25
0.350 0.00 218.48
0.400 0.00 278.75
0.450 0.00 347.05
0.500 0.00 423.39
0.550 0.00 507.76
0.600 0.00 600.17
0.650 0.00 700.62
0.700 0.00 809.10
0.750 0.00 925.62
0.800 0.00 1050.17
0.850 0.00 1182.76
0.900 0.00 1323.39
0.950 0.00 1472.05
1.000 0.00 1628.75
critical clearing angle 81.684989critical clearing time=0.200000 sec
>>
O/P 2:-
enter 1 for fault at the beginning
2-for fault at the middle:2
sustained fault
----------
time pmax delta
-------------
0.050 0.88 24.17
0.100 0.88 31.56
0.150 0.88 42.88
0.200 0.88 56.88
0.250 0.88 72.34
0.300 0.88 88.34
0.350 0.88 104.53
0.400 0.88 121.15
0.450 0.88 139.08
0.500 0.88 159.89
0.550 0.88 186.05
0.600 0.88 221.06
0.650 0.88 269.28
0.700 0.88 333.38
0.750 0.88 409.04
0.800 0.88 486.81
0.850 0.88 566.32
0.900 0.88 657.34
0.950 0.88 763.39
1.000 0.88 872.07
critical clearing angle 118.182332critical clearing time=0.400000 sec
>>
PROGRAM 3 (b): Program to obtain swing curve when the fault is cleared using
MATLAB.
pm=pmax2;
else
if (t(it)==ct)
pm=(pmax2+pmax3)/2;
else
pm=pmax3;
end
end
if (r~=0)
if (t(it)<ct)
pm=pmax2;
else
pm=pmax3;
end
end
pe=pm*sin(del(it));
pa=ps-pe;
end
plot(t,del*(180/pi),'r');
title('Swing curve');
xlabel('time in seconds');
ylabel('delta in degrees');
pr=0;
for k=2:it
if (del(k)<del(k-1))
pr=1;
break
end
end
if (pr)
text(0.5,1.0,'system is stable');
else
text(0.5,1.0, 'system is unstable');
end
end
O/P 1:-
enter 1 for fault at the beginning
2-for fault at the middle:1
enter clearing time in sec:0.05
fault is cleared at the beginning of an interval
TIME PMAX DELTA
0.00, 0.00, 21.60
0.05, 1.00, 25.62
0.10, 2.00, 33.81
0.15, 2.00, 40.10
0.20, 2.00, 42.93
0.25, 2.00, 41.62
0.30, 2.00, 36.50
0.35, 2.00, 28.78
0.40, 2.00, 20.51
0.45, 2.00, 14.01
0.50, 2.00, 11.23
0.55, 2.00, 13.00
0.60, 2.00, 18.80
0.65, 2.00, 26.87
0.70, 2.00, 34.91
0.75, 2.00, 40.77
0.80, 2.00, 43.00
0.85, 2.00, 41.09
0.90, 2.00, 35.47
0.95, 2.00, 27.54
1.00, 2.00, 19.38>>
critical clearing angle 81.684989critical clearing time=0.200000 sec
O/P 2:-
enter 1 for fault at the beginning
2-for fault at the middle:1
O/P 3:-
enter 1 for fault at the beginning
2-for fault at the middle:2
O/P 4:-
enter 1 for fault at the beginning
2-for fault at the middle:2
for j=1:nb
for k=1:nb
ybus(j,k)=0; % initializes all elements of
ybus to zero.
end
end
for i=1:nl
j=sb(i);
k=eb(i);
ybus(j,j)=ybus(j,j)+1/serz(i);
ybus(k,k)=ybus(k,k)+1/serz(i);
ybus(j,k)=ybus(j,k)-1/serz(i);
ybus(k,j)=ybus(j,k);
end
ybus % displays ybus
O/P:-
ybus =
PROGRAM 4 b): Program for the formation of Ybus with line charging--Inspection
Method
clear all
% sb eb serr serx shty
linedata=[1 2 0.02 0.06 0.03;
1 3 0.08 0.24 0.025;
2 3 0.06 0.18 0.02;
2 4 0.06 0.18 0.02;
2 5 0.04 0.12 0.015;
3 4 0.01 0.03 0.01;
4 5 0.08 0.24 0.025];
sb=linedata(:,1);
eb=linedata(:,2);
nl=max(size(sb));
nb=max(max(sb,eb));
serz=(linedata(:,3)+j*linedata(:,4));
shty=(0+j*linedata(:,5));
ybus=zeros(nb,nb);
for i=1:nl
j=sb(i);
k=eb(i);
ybus(j,j)=ybus(j,j)+1/serz(i)+shty(i);
ybus(k,k)=ybus(k,k)+1/serz(i)+shty(i);
ybus(j,k)=-1/serz(i);
ybus(k,j)=ybus(j,k);
end
ybus
O/P:-
ybus =
for k=1:nbus
A(k,k)=1;
end
for k=1:nline
A(nbus+k,fb(k))=1;
A(nbus+k,tb(k))=-1;
end
sh=zeros(1,nbus);
for k=1:nline
sh(fb(k))=sh(fb(k))+hlcy(k);
sh(tb(k))=sh(tb(k))+hlcy(k);
end
ypr=zeros(nlb,nlb);
for k=1:nbus
ypr(k,k)=sh(k);
end
for k=1:nline
ypr(nbus+k,nbus+k)=y(k);
end
format short;
ybus=A'*ypr*A;
ybus
O/P:-
ybus =
clc;
clear;
disp('Zbus Building Algorithm');
zprimary = [1 1 0 0.25
2 2 1 0.1
3 3 1 0.1
4 2 0 0.25
5 2 3 0.1];
[elements,columns]=size(zprimary);
zbus=[];
currentbusno=0;
for count=1:elements
[rows cols]=size(zbus);
from=zprimary(count,2);
to=zprimary(count,3);
value=zprimary(count,4);
newbus=max(from,to);
ref=min(from,to);
%Type-1 Modification
%A new element is added from new bus to reference bus
if newbus>currentbusno & ref==0
disp('Adding Z =');
disp(value);
disp('between buses:');
disp(from);
disp(to);
disp('This impedance is added between a new bus and reference(Type1)');
zbus=[zbus zeros(rows,1)
zeros(1,cols) value]
currentbusno=newbus;
continue
end
%Type-2 Modification
%A element is added from new bus to old bus other than reference bus
if newbus>currentbusno & ref~=0
disp('Adding Z =');
disp(value);
disp('between buses:');
disp(from);
disp(to);
disp('This impedance is added between a new bus and an existing bus(Type2)');
zbus=[zbus zbus(:,ref)
zbus(ref,:) value+zbus(ref,ref)]
currentbusno=newbus;
continue
end
%Type-3 Modification
%A new element is added between an old bus and reference bus
if newbus<=currentbusno & ref==0
disp('Adding Z =');
disp(value);
disp('between buses:');
disp(from);
disp(to);
disp('This impedance is added between an existing bus and reference(Type3)');
zbus=zbus-1/(zbus(newbus,newbus)+value)*zbus(:,newbus)*zbus(newbus,:)
continue
end
%Type-4 Modification
%A new element is added between two old buses(bus-2 to 3)
if newbus<=currentbusno & ref~=0
disp('Adding Z =');
disp(value);
disp('between buses:');
disp(from);
disp(to);
disp('This impedance is added between two existing buses(Type4)');
zbus=zbus-1/(value+zbus(from,from)+zbus(to,to)-2*zbus(from,to))*((zbus(:,from)-zbus(:,to)
)*((zbus(from,:)-zbus(to,:))))
continue
end
end
OUTPUT:
between buses:
1
zbus =
0.2500
Adding Z =
0.1000
between buses:
2
zbus =
0.2500 0.2500
0.2500 0.3500
Adding Z =
0.1000
between buses:
3
zbus =
Adding Z =
0.2500
between buses:
2
zbus =
Adding Z =
0.1000
between buses:
2
zbus =
PROGRAM 6: Determination of bus current, bus power & line flows for a specified
voltage bus
clc
clear all
% fb tb z
linedata=[1 2 0.02+0.04i;
1 3 0.01+0.03i;
2 3 0.0125+0.025i];
vb=[1.05+0.0i;
0.98-0.06i;
1.00-0.05i];
fb=linedata(:,1);
tb=linedata(:,2);
z=linedata(:,3);
nl=max(size(fb));
y=1./z;
for k=1:nl
il(fb(k),tb(k))=y(k)*(vb(fb(k))-vb(tb(k)));
il(tb(k),fb(k))=-il(fb(k),tb(k));
end
fprintf('the line currents:\n');
il
for k=1:nl
lf(fb(k),tb(k))=vb(fb(k))*conj(il(fb(k),tb(k)));
lf(tb(k),fb(k))=vb(tb(k))*conj(il(tb(k),fb(k)));
ll(k)=lf(fb(k),tb(k))+lf(tb(k),fb(k));
end
fprintf('the line flows:\n');
lf
fprintf('the line losses:\n');
ll
for k=1:nl
bp(k)=sum(lf(k,:));
ibus(k)=conj(bp(k)/vb(k));
end
fprintf('the bus powers:\n');
bp
fprintf('the bus currents:\n');
ibus
O/P:-
the line currents:
il =
lf =
ll =
bp =
ibus =