You are on page 1of 21

Scilab manual for

Power System Simulation Laboratory


by
Prof.B.A.Sridhara, Prof.Madhu B.M, Prof.Naveen Kumar
Department of Electrical and Electronics Engineering
Siddaganga Institute ofTechnology Tumakuru - 572103

July 18, 2016


Contents
1. Determination of ABCD parameters of a Transmission line......................................................................1
2. Formation of Bus admittance matrix – inspection and singular transformation method..................4
3. Load Flow analysis using Gauss-seidel method.............................................................................................8
4. Swing curve............................................................................................................................................................10
5. Economic operation of power system.............................................................................................................13
6. Formation of Bus impedance matrix................................................................................................................15
List of Experiments
1. Determination of ABCD parameters of a Transmission line................................................................1
2. a) Formation of Bus admittance matrix – inspection method...............................................................4
b) Formation of bus admittance matrix - singular transformation........................................................6
3. Load Flow analysis using Gauss-seidel method.......................................................................................8
4. Swing curve.......................................................................................................................................................10
5. Economic operation of power system.........................................................................................................13
6. Formation of Bus impedance matrix...........................................................................................................15
List of Figures

Figure 4.1 Swing curve – sustained fault..........................................................................................................12


Figure 4.2 Swing curve – fault cleared in 0.125 s..........................................................................................12
Figure 4.3 Swing curve – fault cleared in 0.05 s.............................................................................................12

0
Experiment: 1

Determination of ABCD parameters of a Transmission line


A transmission line on per phase basis can be regarded as a two port network. The sending ending
voltage VS and sending end current IR are related to the receiving end voltage VR and receiving end
current IR through ABCD constants.

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.

/ ABCD constants for a medium length line


//Program to calculate ABCD constants for a medium length line and to determine sending
end voltage ,current and power

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 ;

26. if rep == 1 //Nominal T representation


27. A = 1 + (ZT*YT/2);
28. B = ZT * ( 1 + (ZT*YT/4) );
29. C=YT;
30. D = 1 + (ZT*YT/2) ;
31. else //Nominal pi representation
32. A = 1 + (ZT*YT/2) ;
33. B=ZT;
34. C = YT * ( 1 + (ZT*YT/4) );
35. D = 1 + (ZT*YT/2) ;
36. end
/ VS_phase - sending end voltage (L-N)
/ IS - sending end current
/ S_sending_end - sending end complex power
/ P_s - sending end - real power (MW)
/ eff - efficiency
37. VS_phase = A*VR_phase + B*IR ;
38. IS = C*VR_phase + D*IR ;
39. S_sending_end = 3*VS_phase*IS';
40. P_s = real(S_sending_end);
41. eff = (P_r / P_s)*100;
//to calculate receiving end voltage when load at receiving end is
removed //VR_NL - Receiving end voltage (L-N) when load is removed
42. VR_NL = abs(VS_phase / A); //
43. percent_regulation = (abs(VR_NL) - abs(VR_phase))*100 /abs(VR_NL);
//to print results
44. fp2 = mopen('out_abcd.res','w');
//write constant A, B, C and D to output file
45. mfprintf(fp2,'A =%f+i%f\n',real(A),imag(A) );
46. mfprintf(fp2,'B =%f+i%f\n',real(B),imag(B) );
47. mfprintf(fp2,'C =%f+i%f\n',real(C),imag(C) );
48. mfprintf(fp2,'D =%f+i%f\n\n',real(D),imag(D) );
/ to show that AD-BC=1

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.

// Formation of Bus admittance matrix(Ybus ) - inspection method


1. clc;
2. clear;
3. // F T Z HLC
4. linedata = [1 2 0.2*(%i) 0.03*(%i);
5. 1 4 0.25*(%i) 0.025*(%i);
6. 2 3 0.4*(%i) 0.02*(%i);
7. 2 40.5*(%i) 0.015*(%i);
8. 3 4 0.2*(%i) 0.01*(%i)];
// F- from bus number, T - To bus number, Z-line impedance, HLC -half line charging
admittance
/ b- bus number , SC-shunt compensation at bus b
/ from_bus- column matrix storing 'from' bus numbers
/ to_bus-column matrix storing 'to' bus numbers
/ Z-column matrix storing line impedances
/ HLC-half line charging admittance
9. Sh=[4 0.02*(%i)]; // b-,
10. from_bus=real(linedata(:,1)); //
11. to_bus=real(linedata(:,2)); //
12. Z=linedata(:,3); //
13. HLC=linedata(:,4);
/ nbus - stores the number of buses
/ e - stores the number of lines
/ initialize Ybus to zero
14. nbus=max(max(from_bus),max(to_bus));
15. e=length(from_bus);
16. Ybus=zeros(nbus, nbus);
/ k takes values from 1 to maximum line number e
/ p - From bus number of line k
/ q - To bus number of line k
/ z - Series impedance of line k
/ hlc - Half line charging admittance of line k
/ y = reciprocal of z

17. for k=1:e


18. p=from_bus(k);
19. q=to_bus(k);
20. z=Z(k);
21. hlc=HLC(k);
22. y=1/z;
/ formation of the off diagonal elements

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

/ Addition of shunt admittance data

/ Bus no. at which shunt compensation is provided

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.i - 9.435i 2.5i 2.i


0 2.5i - 7.47i 5.i
4.i 2.i 5.i - 10.93i

5
Experiment: 2 b

Formation of bus admittance matrix(YBUS) by singular


transformation
1. clc;
2. clear;
// F T Z HLC
3. linedata = [1 2 0.02+0.06*(%i) 0.03*(%i)
4. 1 30.08+0.24*(%i) 0.025*(%i)
5. 2 30.06+0.18*(%i) 0.02*(%i)
6. 2 40.06+0.18*(%i) 0.02*(%i)
7. 2 50.04+0.12*(%i) 0.015*(%i)
8. 3 40.01+0.03*(%i) 0.01*(%i)
9. 4 5 0.08+0.24*(%i) 0.025*(%i)];
/ F- from bus number, T - To bus number, Z-line impedance, HLC -half line charging
admittance

/ from_bus- column matrix storing 'from' bus numbers


/ to_bus-column matrix storing 'to' bus numbers
/ Z-column matrix storing line impedances
/ HLC-half line charging admittance
10. from_bus=real(linedata(:,1));
11. to_bus=real(linedata(:,2));
12. Z=linedata(:,3);
13. HLC=linedata(:,4);
/ nbus - stores the number of buses
/ e - stores the number of lines
14. nbus=max(max(from_bus),max(to_bus));
15. e=length(from_bus);
16. a=zeros(e,nbus); // initialize matrix A to zero
17. Zpri=zeros(e,e); // Zpri - primitive impedance matrix
/ k takes values from 1 to maximum line number e
/ p - From bus number of line k
/ q - To bus number of line k
/ z - Series impedance of line k

18. for k=1:e


19. p=from_bus(k,1);
20. q=to_bus(k,1);
21. z=linedata(k,3);
//Formation of Bus Incidence matrix
/ Because, line k is connected from bus number p to bus number q
22. a(k,p)=1;
23. a(k,q)=-1; //
//Formation of the Primitive Impedance matrix
/ diagonal elements of primitive impedance are made equal to line impedances (mutual
//impedances are not considered in )

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

- 5. + 15.i 10.83 - 32.415i - 1.67+ 5.i - 1.67 + 5.i - 2.5 + 7.5i


- 1.25 + 3.75i - 1.67 + 5.i 12.92- 38.695i - 10. + 30.i 0
0 - 1.67 + 5.i - 10. + 30.i 12.92 - 38.695i - 1.25 + 3.75i
0 - 2.5 + 7.5i 0 - 1.25 + 3.75i 3.75 - 11.21i

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.

// Program is based on algorithm detailed in pp 202, Modern Power System Analysis by


D.P.Kothari and I.J.Nagrath ,4th edition, Tata McGraw Hill Publications
//In this program, Bus admittance matrix Y bus of the system is given
1. clc
2. clear
3. num_buses = 4; //number of buses
/ Bus voltage magnitude (V) and angle arrays are created with initial value as zero
4. V = zeros(num_buses,1) ;
5. delta = zeros(num_buses,1) ;
/ initializeslack bus voltage magnitude and angle
6. V_mag_slack= 1.04 ;
7. delta_slack = 0.0;
8. V(1) = V_mag_slack*cos( delta_slack*(%pi)/180) +
(%i)*V_mag_slack*sin(delta_slack*(%pi)/180);
/ Initial values for real bus powers Pi for ii = 2,3,4,......,n
9. P = zeros(num_buses,1) ;
10. P(2) = 0.5 ;
11. P(3) = -1.0 ;
12. P(4) = 0.3 ;
// Reactive bus powers Qi, for i = m+1, .......,n (PQ buses) , here m=1
13. Q = zeros(num_buses,1) ;
14. Q(2) = -0.2;
15. Q(3) = 0.5;
16. Q(4) = -0.1;
// formation of Y bus - data is given
17. Y = [3-9*(%i) -2+6*(%i) -1+3*(%i) 0;
18. -2+6*(%i) 3.666-11*(%i) -0.666+2*(%i) -1+3*(%i);
19. -1+3*(%i) -0.666 +2*(%i) 3.666- 11*(%i) -2+6*(%i);
20. 0 -1+3*(%i) -2+6*(%i) 3-9*(%i) ];
21.
// make initial assumptions Vi for l = m+1,....,n and delta for i = 2,...,m , here m=1
22. for ii = 2:num_buses
23. V(ii) = 1.0;
24. end
//compute the parameters Ai for l=m+1,...,n and Bik for i=1,2...,n and
25. A = zeros(num_buses,1) ;
26. B = zeros(num_buses, num_buses) ;

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:

Generator Inertia constant H in MJ/MVA = 2.52


Pre fault reactance Xpre in p.u. = 0.45
Reactance during fault Xfault in p.u. = 1.25
Post fault reactance Xpost in p.u. = .55 Sending
end voltage E in p.u. = 1.1 Receiving end
voltage V in p.u. = 1
Base MVA = 20
Generator output power in MW = 18 Initial
displacement angle in degree = 21.64 Fault
clearing time in sec = 10
Final time for swing equation in sec = .6

11
Output:

Figure 4.1: Swing curve – sustained fault

Figure 4.2: Swing curve – fault cleared in 0.05 s

Figure 4.3: Swing curve – fault cleared in 0.125 s

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

losses. The total cost of generation is given by, C = ∑Ci PGi


i=1
k k

Also, total generation , ∑ PGi = PD or ∑ PGi - PD =0


i=1 i=1

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

Formation of Bus impedance matrix


Bus impedance matrix (ZBUS) is a full matrix. Its diagonal elements are short circuit driving points
impedances and the off-diagonal elements are short circuit transfer impedances. Bus impedance
matrix is most useful for short circuit studies.
ZBUS building algorithm is a step-by-step programmable technique for forming ZBUS and it
proceeds branch by branch. The main advantage of this algorithm is that any modification of the
network does not require rebuilding of the entire ZBUS.
//Formation of Bus impedance matrix by Zbus building algorithm
1. clc
2. clear
// zb F T
3. data1= [ 0.25 1 0;
4. 0.1 2 1;
5. 0.1 3 1;
6. 0.25 0 2;
7. 0.1 2 3 ];
/ zb - impedance of line , F - from bus number , T - to bus number
/ e - number of lines , initially zbus is a null matrix
8. [e,n1]=size(data1);
9. zbus = [ ];
/ initially only reference bus(bus 0) is present
10. max_bus_no= 0;
/ zb - impedance of line ll, ii - from bus number of line ll, jj - to bus number of line ll
11. for ll = 1:e
12. zb = data1(ll,1);
13. ii = real( data1(ll,2) );
14. jj = real( data1(ll,3) );
// connection between reference bus (ii=0) and new bus (jj), type 1 modification and
maximum bus number is changed to jj
15. if ((ii==0)& (jj>max_bus_no)) then
16. typem = 1; //
17. max_bus_no=jj;
// connection between reference bus (jj=0) and new bus (ii), type 1 modification and
maximum bus number is changed to ii
18. elseif ((jj==0)& (ii>max_bus_no)) then
19. typem = 1;
20. max_bus_no=ii;
// connection between old bus (ii) and new bus (jj) , type 2 modification and maximum
bus number is changed to jj
21. elseif ((ii<=max_bus_no)& (jj>max_bus_no)) then
22. typem=2;
23. max_bus_no=jj;
24. kk = ii;
// connection between old bus (jj) and new bus (ii) , type 2 modification and maximum
bus number is changed to ii

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

0.125 0.125 0.175


16

You might also like