Professional Documents
Culture Documents
0
Experiment: 1
VS=AVR+BIR
IS=CVR+DIR
For short and medium lines, line impedances and admittances are assumed to be lumped and
ABCD constants can be determined. For long lines, ABCD constants are to be determined by using
distributed parameter modelling.
1. clc
2. clear
3. f1 = mopen("inp_abcd.txt","r");
// rep = 1, T-representation rep=2, pi- representation //
line_length - line length in km
//data1- series impedance and shunt admittance data of the line/unit
length //line_R - resistance/unit length/phase
//line_X - inductive reactance/unit length/phase
/ line_G - shunt conductance/unit length = 0
/ line_B - capacitive reactance / unit length / phase to neutral
4. rep = mfscanf(f1,'%f');
5. line_length = mfscanf(f1,'%f');
6. data1(1,:) = mfscanf(f1,'%f %f');
7. data1(2,:) = mfscanf(f1,'%e %e');
8. line_R = data1(1,1);
9. line_X = data1(1,2);
10. line_G = data1(2,1);
11. line_B = data1(2,2);
//VR_LL_mag - Receiving end voltage (L-L)
//VR_phase_mag - L-N Receiving end voltage magnitude (L-N)
//VR_phase_angle-L-N Receiving end voltage angle (degrees) - assumed to be zero
12. VR_LL_mag = mfscanf(f1,'%e');
13. VR_phase_mag = VR_LL_mag / sqrt(3);
14. VR_phase_angle = 0;
15. VR_phase = VR_phase_mag*cos(VR_phase_angle*(%pi)/180) + (%i)*
VR_phase_mag*sin(VR_phase_angle*(%pi)/180);
/ P_r - Receiving end - real power (MW)
/ Q_r - Receiving end - reactive power (MVAR)
1
//S_r_phase - Receiving end - complex power(per phase)
//IR - Receiving end current
16. data2 = mfscanf(f1,'%f %f');
17. P_r = data2(1,1);
18. Q_r = data2(1,2);
19. S_r_phase = (P_r + (%i)*Q_r)/3;
20. IR = conj(S_r_phase / VR_phase ) ;
21. mclose(f1);
/ line_Z - series line impedance (per unit length)
//line_Y - line shunt admittance per unit
length //ZT - total series line impedance
/ YT - total series line impedance
22. line_Z = line_R + (%i)*line_X;
23. line_Y = line_G + (%i)*line_B;
24. ZT = line_Z * line_length ;
25. YT = line_Y * line_length ;
2
49. mfprintf(fp2,'AD-BC =%f\n',(A*D-B*C) );
/ write percentage regulation when receiving end load is removed
50. mfprintf(fp2,'Percentage voltage regulation =%f\n', percent_regulation);
/ write percentage efficiency
51. mfprintf(fp2,'Percentage efficiency =%f\n', eff);
52. mclose(fp2);
/ Exercise: Modify the above program to calculate constants of short and long transmission
line
input_file
1
200
0.2435 0.401
0 8.42e-9
88e3
13.5e3 6.53e3
output file:
A =0.999932+i0.000041 B
=48.696710+i80.198289
C =0.000000+i0.000002
D =0.999932+i0.000041
AD-BC =1.000000
Percentage voltage regulation =0.015251
Percentage efficiency =99.989531
3
Experiment: 2 a
Formation of Bus admittance matrix – inspection method
Bus admittance matrix is widely used in carrying out Load flow solution of a power system. The
advantages of YBUS are simplicity in data preparation, it can be easily formed and modified for any
changes in the network. It is also sparse matrix, which results in reduction of memory required
and time. It can be formed either by method of inspection or by singular transformation.
4
/ addition of -y to offdiagonal element Ybus(p, q))
23. Ybus(p,q)=Ybus(p,q)-y;
24. Ybus(q,p)=Ybus(p,q);
/ formation of the diagonal elements
//addition of y and hlc to diagonal element Ybus(p,p)
//addition of y and hlc to diagonal element Ybus(q,q)
25. Ybus(p,p)=Ybus(p,p)+y+hlc; //
26. Ybus(q,q)=Ybus(q,q)+y+hlc; //
27. end
28. p=Sh(1,1);
29. sh_compensation=Sh(1,2); // Shunt compensation
30. p=real(p);
31. Ybus(p,p)=Ybus(p,p)+sh_compensation ;
32. Ybus
Output:
Ybus = - 8.945i 5.i 0 4.i
5
Experiment: 2 b
6
24. Zpri(k,k)=z;
25. end
/ Primitive admittance matrix is obtained by inverting primitive impedance matrix
26. Ypri=inv(Zpri);
/ Formation of Ybus
27. Ybus=a'*Ypri*a;
//Addition of Half Line Charging Admittance to diagonal elements of Ybus
/ Half line charging admittance of line k is added to diagonal elements corresponding to
bus p and q
28. for k=1:1:e
29. p=from_bus(k,1);
30. q=to_bus(k,1);
31. hlc=HLC(k,1);
32. Ybus(p,p)=Ybus(p,p)+hlc;
33. Ybus(q,q)=Ybus(q,q)+hlc;
34. end
35. Ybus
output:
Ybus =
6.25 - 18.695i - 5. + 15.i - 1.25 + 3.75i 0 0
7
Experiment: 3
Load Flow analysis using Gauss-seidel method
Load flow study is the steady state solution of a power system network. The power system is
modelled by an electrical network by suitable assumptions. The main information obtained from the
load flow study are the magnitudes and phase angles of load bus voltages, reactive powers and
voltage phase angles at generator buses, real and reactive power flow on transmission lines and real
and reactive power generation at slack bus.
The Gauss-seidel method is an iterative technique for solving a set of nonlinear algebraic equations.
The iterative solution is repeated till the solution converges within the prescribed accuracy.
8
27. for ii = 2:num_buses
28. A(ii) = ( P(ii) - (%i)*Q(ii) )/ Y(ii,ii) ;
29. for kk = 1:num_buses
30. if kk~= ii
31. B(ii,kk) = Y(ii,kk) / Y(ii,ii) ;
32. end
33. end
34. end
35.
36. V_prev = V ;
/ start iteration
37. tolerance = 0.0001;
38. for iter = 1:15
39. del_Vmax = 0.0;
40. for ii = 2:num_buses
41. V(ii) = A(ii) / conj( V_prev(ii) );
42. for kk = 1:num_buses
43. if kk < ii
44. V(ii) = V(ii) – B(ii, kk)*V(kk) ;
45. elseif kk > ii
46. V(ii) = V(ii) – B(ii, kk)*V_prev(kk) ;
47. end
48. end
49. del_V = abs( V_prev(ii) - V(ii) );
50. if del_V > del_Vmax
51. del_Vmax = del_V ;
52. end
53. end // end of bus loop
54. V_prev = V
55. if del_Vmax < tolerance
56. break;
57. end
58. end // end of iteration loop
59. //1. Write a program in Scilab to compute line flows
60. //2. Extend the above program by including voltage limits at any one of the buses
61. //3. Extend the above program by including acceleration factor.
Output:
V = 1.04
1.0390697 + 0.0155230i
1.04601 - 0.1077528i
1.0447561 - 0.0347893i
9
Experiment: 4
Swing curve
The dynamics of a single synchronous machine connected to infinite bus is governed by nonlinear
differential equation, M d2 δ =Pm-Pe
d t2
The solution of the swing equation in case of disturbances, gives swing curve which is a plot of δ
vs. time. In this program, the swing curve of a single machine system connected to an infinite
bus, when subjected to a three-phase fault with subsequent clearance of the fault is considered.
The method used is Point-by-Point method of solution.
// Data is from Example 12.10, pp 462, Modern Power System Analysis by D.P.Kothari
and I.J.Nagrath ,4th edition, Tata McGraw Hill Publications
1. clc
2. clear
3. H = input('Generator Inertia constant H in MJ/MVA = ');
4. Xpre = input('Pre fault reactance Xpre in p.u. = ');
5. Xfault = input('Reactance during fault Xfault in p.u. = ');
6. Xpost = input('Post fault reactance Xpost in p.u. = ');
7. E = input('Sending end voltage E in p.u. = ');
8. V = input('Receiving end voltage V in p.u. = ');
9. MVA = input('Base MVA = ');
10. MW = input('Generator output power in MW = ');
11. delta = input('Initial displacement angle in degree = ');
12. tc = input('Fault clearing time in sec = ');
13. tfinal = input('Final time for swing equation in sec = ');
14. M = H/(180*50);
15. Pm = MW/MVA;
//Pm - Mechnical power input(in pu) Before fault, mechanical power input=electrical
power output
// Ppre- Prefault power transfer, Post - Power transfer during fault, Ppost - Post fault power
transfer
// ddelta - The change in delta during (n-1) interval, tstep - time step, tf - time at which
fault occurs
16. Ppre = (E*V)/Xpre;
17. Pfault = (E*V)/Xfault;
18. Ppost = (E*V)/Xpost;
19. ddelta = 0;
20. tstep = 0.05;
21. t = 0;
22. tf = 0;
23. i = 2;
24. time(1) = 0;
25. ang(1) = delta;
tf - time is equal to time at which the fault occurs, tc- time is equal to time at which fault
is cleared,
26. while t<tfinal
27. if (t == tf) then
28. Paa = Pm-Ppre*sin(delta*(%pi)/180);
10
29. Pab = Pm-Pfault*sin(delta*(%pi)/180);
30. Pa = (Paa+Pab)/2;
31. end
32. if (t == tc) then
33. Paa = Pm-Pfault*sin(delta*(%pi)/180);
34. Pab = Pm-Ppost*sin(delta*(%pi)/180);
35. Pa = (Paa+Pab)/2;
36. end
/ during fault
37. if(t>tf & t<tc) then
38. Pa = Pm-Pfault*sin(delta*(%pi)/180);
39. end
/ post fault period
40. if(t>tc) then
41. Pa = Pm-Ppost*sin(delta*(%pi)/180);
42. end
43. ddelta = ddelta+(tstep*tstep*Pa/M); // calculation of change in delta during n th interval
44. delta = (delta+ddelta); // calculation of delta
45. t = t+tstep;
46. time(i) = t;
47. ang(i) = delta;
48. i = i+1;
49. end
50. plot(time, ang,'bo-');
51. title(['One-machine system swing curve by Point by Point method. Fault cleared
at ',string(tc),' s']);
52. xlabel('t, sec'), ylabel('Delta, degree');
input:
11
Output:
12
Experiment : 5
Economic operation of power system
The aim of economic operation of a power system is to operate different generating stations, in such a
way that the total cost of generation is minimised while satisfying the loads and transmission
k
The problem of minimising the total cost can be solved by the method of Lagrange multipliers.
The optimal operation of generators corresponds to the equal incremental cost of all generators.
1. clc
2. clear
/ n - number of units, Pr - load demand, lambda - Initially, lambda is chosen as 5
3. tot=0;
4. n=3;
5. Pr=240;
6. lambda=5;
//a,b and c values of all generators
7. a=[.05 0.06 0.07];
8. b=[20 15 18];
9. c=[800 1000 900];
/ B – coefficient matrix
10. B=[0.0005 0.00005 0.0002;
11. 0.00005 0.0004 0.00018;
12. 0.0002 0.00018 0.0005];
/ P_min and P_max of all generators
13. Pmin = [ 0 0 0];
14. Pmax = [100 100 100];
/ Assume Pi=0, i =1,2,...,n
15. for i =1 : n
16. P(i)=0;
17. end
//Start of iterations
18. for itr = 1 : 100
19. PL=0;
20. tot=0;
21. dowP=0;
22. for i = 1 : n
23. temp1=0;
24. for j = 1 : n
25. if(i~=j)
26. temp1=temp1+(2*B(i,j)*P(j));
27. end
28. end
/ Solve for Pi with the current value of lambda
29. P(i)=(lambda-lambda*temp1-b(i))/(2*(a(i)+(lambda*B(i,i))));
/ if Pi<Pi_min , then set Pi=Pi_min else Pi>Pi_max , then set Pi=Pi_max
13
30. if(P(i)<Pmin(i))
31. P(i)=Pmin(i);
32. elseif P(i)>Pmax(i)
33. P(i)=Pmax(i);
34. end
35. tot=tot+P(i);
/ Calculate PL
36. for j = 1 : n
37. PL=PL+B(i,j)*P(i)*P(j);
38. end
39. dowP=dowP+( a(i)+b(i)*B(i,i)-2*a(i)*temp1 )/(2*(a(i)+lambda*B(i,i))^2);
40. end
/ Calculate power balance
41. delp=Pr+PL-tot;
/ if power balance < specified limit, stop the iterations
42. if abs(delp)<0.00000001
43. break
44. end
/ Calculate delta_lambda and change lambda by adding delta_lambda
45. deltalambda=delp/dowP;
46. lambda=lambda+deltalambda;
47. end
48. fp2=mopen('output_economic_operation.txt','w');
49. mfprintf(fp2,'scheduled power \n');
50. for i = 1 : n
51. mfprintf(fp2,'Power output of unit %d is %f\n',i,P(i));
52. end
53. mfprintf(fp2,'Lambda for economic scheduling: %3.2f\n', lambda);
54. mfprintf(fp2,'Transmission loss in MW : %3.2f\n', PL);
55. mfprintf(fp2,'Number of iterations taken: %d\n', itr-1);
56. mclose(fp2);
output:
Scheduled power:
Power output of unit 1 is 85.012396
Power output of unit 2 is 100.000000
Power output of unit 3 is 70.932638
Lambda for economic scheduling: 32.51
Transmission loss in MW : 15.95
Number of iterations taken: 33
14
Experiment : 6
15
25. elseif ((ii>max_bus_no)& (jj<=max_bus_no)) then
26. typem=2;
27. max_bus_no=ii;
28. kk=jj;
/ connection between reference bus (ii) and old bus (jj), type 3 modification
29. elseif ((ii==0)& (jj<=max_bus_no)) then
30. typem = 3;
31. kk=jj;
/ connection between reference bus (jj) and old bus (ii), type 3 modification
32. elseif ((jj==0)& (ii<=max_bus_no)) then
33. typem = 3;
34. kk=ii;
/ connection between old bus (jj) and old bus (ii), type 4 modification
35. elseif ((jj<=max_bus_no)& (ii<=max_bus_no)) then
36. typem = 4; //
37. end
38. [m,n] = size(zbus); // size of zbus after connecting (ll-1) buses
39. if typem == 1
/ modify zbus by adding a row and a column
40. zbus = [zbus zeros(m,1);
41. zeros(1,n) zb ];
// modify zbus by adding a row and a column
42. elseif typem == 2
43. zbus = [zbus zbus(:,kk);
44. zbus(kk,:) zbus(kk,kk)+zb];
/ type 3 modification, modify zbus
45. elseif typem == 3
46. z1 = zbus(:,kk) * zbus(kk,:) / ( zbus(kk,kk)+ zb );
47. zbus = zbus - z1 ;
/ type 4 modification
48. elseif typem == 4
49. z1 = zbus(:,ii) - zbus(:,jj) ;
50. z2 = zb + zbus(ii,ii) + zbus(jj,jj) - 2*zbus(ii,jj) ;
51. zbus = zbus - (1/z2) * z1*z1.' ; // non-conjugate transpose operator .' is used
52. end
53. end
output:
zbus =
0.1397059
0.1102941
0.125
0.1102941
0.1397059
0.125