Você está na página 1de 51

Lakehead University Engineering 0438 WA Power Systems

The IEEE Five Bus Power System Analysis


S im ulations and R esults f or N orm al Operation, S y m m etrical B us Faults, and L ine R em ov als

Presentation Date April 8, 2013 Report Submission Date April 3,2013 Instructor/Supervisor Dr. K. Natarajan Group Members Jonathan Evangelista (# 0497627) Joey Mercier (# 0502424) Maxime Veillette (# 0455142)

ENGI-0438-WA

Electrical Engineering Dept.

Lakehead University

Statement of Work and Responsibilities


By: Jonathan Evangelista, Joey Mercier, Maxime V eillette

This statement is to declare that the work and responsibilities of the report for the IEEE 5-bus power system analysis and corresponding coding was divided equitably among the three aforementioned individuals.

Jonathan Evangelista

Joey Mercier

Maxime V eillette

-i-

ENGI-0438-WA

Electrical Engineering Dept.

Lakehead University

Abstract
The IEEE Five Bus Power System A nalysis Power systems analysis is a critical part of any transmission or distribution system. Using physical properties of a system to perform calculations on how the entire system behaves is paramount to not only the design, but the maintenance and care of such a system. This report does such calculations from provided data on a 5-bus system. Additionally, fault analysis are performed for two types of faults: having a three-phase symmetrical bus fault to ground, and having a symmetrical fault on a line between two buses that results in the line being taken out of service. The latter fault is very important and is used to determine what would happen to not only the stability of the system, but also the overall effect on loadflow to each remaining line in service.

- ii -

ENGI-0438-WA

Electrical Engineering Dept.

Lakehead University

Contents
!"#"$%$&"'()'*(+,'#&-'+$!.(&!/0/1/"/$!'22222222222222222222222222222222222222222222222222222222222222222'/! #0!"+#3"'2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222'//! "#01$'()')/45+$!'22222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222'6! 1/!"'()'$75#"/(&!'22222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222' 6 /! 82! /&"+(-53"/(&' 2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222'8! 92! -$!/4&'()'":$')/6$;05!'!<!"$%'2222222222222222222222222222222222222222222222222222222222222222222222222222222222'9! "#$! %&'()*!###################################################################################################################################################!"! !"#"#! $%&'()*+("""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""(!! !"#"!! ,-.-/&0%/()*+(""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""(!! !"#"1(! 23&45()*+("""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""(!! !"#"6! ,78-.(9&0&("""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""(!! "#"! +',-)./%.(0!(1!/)(2)34,5362().%&4,!7,'+!#########################################################################!8! !"!"#! :;*+(<++-=;3>("""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""(?! !"!"!! @%A-/(B&34*3&07%.+(""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""(?! !"!"1! C-A0%.DE&FG+%.(<3H%/70G=( """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""(I! !"!"6! $%&'J3%A(<.&3>+7+(""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""(K! !"!"?! L/%.(E-'*407%.("""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""(M! !"!"I! $7.-(E-=%8&3(&.'(N;*+(O%'7J74&07%.+(""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""(M! !"!"K! 2>==-0/74&3()*+(P&*30+(Q2*F-/F%+707%.R("""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""(S! "#9! 3//6.-3%.(0!%(!,%30+3)+!/(:')!,*,%'4!#############################################################################!$;! =2! !/%51#"/(&'+$!51"!'2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222'88! 9#$! 2'0')3%'+!*<7,!##############################################################################################################################!$$! 9#"! 0()436!(/')3%.(0!########################################################################################################################!$$! 9#9! 6.0'!)'4(=36!###################################################################################################################################!$9! 9#8! ,*44'%).-36!<7,!1376%!###############################################################################################################!$8! >2! -/!35!!/(&'()'+$!51"!'22222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222'8?! 8#$! 0()436!(/')3%.(0!########################################################################################################################!$>! 8#"! 6.0'!)'4(=36!###################################################################################################################################!$>! 8#9! ,*44'%).-36!<7,!1376%!###############################################################################################################!$?!

- iii -

ENGI-0438-WA

Electrical Engineering Dept.

Lakehead University

?2! 3(&315!/(&'#&-')5"5+$'*(+,' 222222222222222222222222222222222222222222222222222222222222222222222222222222222'8@! >#$! 17%7)'!:()@!30+!6.4.%3%.(0,!#################################################################################################!$A! >#"! -(0-67,.(0!#######################################################################################################################################!$B! A2! +$)$+$&3$!' 22222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222'9B! <.<6.(2)3/&*!###############################################################################################################################################!";! #..$&-/C'#'D'%#"1#0E(3"#6$'3(-$'2222222222222222222222222222222222222222222222222222222222222222222222222222222'99! #..$&-/C'0'D'!(16/&4'?;05!'!<!"$%'(&'%(0/1$'-$6/3$'5!/&4'(3"#6$'222222222'=@!

- iv -

ENGI-0438-WA

Electrical Engineering Dept.

Lakehead University

Table of Figures
1.27)'!$C!6.0'!+.32)34!(1!%&'!>!<7,!,*,%'4!##########################################################################################!9! 1.27)'!"C!2.='0!(/')3%.02!-(0+.%.(0,!(1!>!<7,!###################################################################################!9! 1.27)'!9C!=(6%32'!)'2763%'+!<7,!D<7,!8E!(/')3%.02!-(0+.%.(0,!################################################!9! 1.27)'!8C!6.0'!+3%3!1()!>!<7,!,*,%'4!#######################################################################################################!8! 1.27)'!>C!6(3+16(:!-7))'0%,!######################################################################################################################!?! 1.27)'!FC!2'0')3%'+!*<7,!###########################################################################################################################!$$! 1.27)'!?C!)',76%,!1()!0()436!(/')3%.(0!############################################################################################!$$! 1.27)'!AC!)',76%,!1()!0()436!(/')3%.(0!7,.02!(-%3='! ################################################################!$"! 1.27)'!BC!)',76%,!1()!)'4(=.02!6.0'!<'%:''0!<7,!$!30+!<7,!8!#################################################!$9! 1.27)'!$;C!)',76%,!1()!)'4(=.02!6.0'!<'%:''0!<7,!9!30+!<7,!>!##############################################!$9! 1.27)'!$$C!,*44'%).-36!<7,!1376%!%(!2)(70+!(0!<7,!8!################################################################!$8! 1.27)'!$"C!%)30,.'0%!3036*,.,!(/%.(0!D17%7)'!:()@E! ##################################################################!$A! 1.27)'!$9C!,-)''0!-3/%7)',!(1!>G<7,!-(+'!)700.02!.0!(-%3='!(0!30!30+)(.+!/(:')'+! 4(<.6'!+'=.-'!#######################################################################################################################################!89!

-v-

ENGI-0438-WA

Electrical Engineering Dept.

Lakehead University

List of Equations
D"#$E!3+4.%%30-'!43%).H!###############################################################################################################################!>! D"#"E!-36-763%.02!0(+'!3+4.%%30-',! #######################################################################################################!>! D"#9E!3//3)'0%!/(:')!'I73%.(0! #################################################################################################################!>! D"#8E!/(:')!%(%36,!##########################################################################################################################################!>! D"#>E!%&'!J3-(<.30!43%).H!#############################################################################################################################!F! D"#FE!074').-36!3//)(H.43%.(0!%(!/3)%.36!+').=3%.=',!#################################################################!?! D"#?E!0':!=(6%32'!=367'!D0':%(0G)3/&,(0E!######################################################################################!?! D"#AE!,'0+.02!'0+!6(3+16(:!########################################################################################################################!?! D"#BE!@)(0!)'+7-%.(0!362().%&4!###############################################################################################################!A! D"#$;E!/3)366'6!.4/'+30-',!!########################################################################################################################!A! D"#$$E!-3,'G8!362().%&4!################################################################################################################################!B! D"#$"E!,*44'%).-36!<7,!1376%!362().%&4! ###########################################################################################!$;!

- vi -

ENGI-0438-WA

Electrical Engineering Dept.

Lakehead University

[This page was left blank intentionally.]

ENGI-0438-WA

Electrical Engineering Dept.

Lakehead University

1.

Introduction

The objective of this project is to create a 5 bus electrical network from the provided information and complete a load flow analysis. The analysis must solve for the voltages, voltage angles and the amount of apparent power at each bus during various scenarios by using a system of equations. For this project the Newton-Raphson iteration method is used, due to its accuracy and speed in calculating load flow. The Newton-Raphson iterations require a great deal of matrix calculations; hence MATLAB and OCTAVE were used, since they are themselves designed for matrix manipulation. Furthermore, a GUI can be executed in MATLAB, and one was designed for this report. This GUI allows the selection of a fault type and section affected in the network. The information is then displayed in a table in the same display, allowing for the user to see all the values obtained from the load flow analysis. GNU Octave (which is initially UNIX based) was used because of its cross-platform portability; since it is an open-source software package, individuals may port it to different operating systems (it is native to Linux, but is already been ported to Windows, Mac OS, Android for mobile devices, etc).

Introduction !

ENGI-0438-WA

Electrical Engineering Dept.

Lakehead University

2.

Design of the Five-Bus System

2.1

Theory

The material covered in this section describes the different bus types used in the project, which have different applications and different known values. These values are the voltage magnitude (|V|), the voltage angle (!), the real power (P) and the Reactive power (Q). 2.1.1 Load Bus A Load bus (P.Q. Bus) does not generate power, but has active and reactive loads connected to it. A load bus has information on the real and reactive power, but no information about the voltage magnitude or its angle. 2.1.2 Generator Bus A generator bus (Voltage Controlled Bus) has a generator connected to it, which can be used to control the output voltage by adjusting the generator excitation. This output voltage remains constant during the normal operations of the system. The known values of a generator bus are the voltage magnitude and the real power. The unknown values are the voltage angle and the reactive power. 2.1.3 Slack Bus A slack bus (Swing Bus) can generate extra power, if the generating bus cannot handle the load demanded by the system. The extra power is generated at a constant voltage magnitude and angle, however, the active and reactive power at the bus are unknown. A slack bus is also considered to be a reference bus since it will maintain a constant voltage magnitude and angle under different system conditions. 2.1.4 Given Data The following figures contain all pertinent information on the 5-bus system:

Design of the Five-Bus System !

ENGI-0438-WA

Electrical Engineering Dept.

Lakehead University

Figure 1: Line Diagram of the 5 Bus System

Figure 2: Given Operating Conditions of 5 Bus

Figure 3: Voltage Regulated Bus (Bus 4) Operating Conditions

Design of the Five-Bus System !

ENGI-0438-WA

Electrical Engineering Dept.

Lakehead University

Figure 4: Line Data for 5 Bus System

2.2

Description of Programs/Algorithms Used

In order to solve the 5 bus power system, various algorithms were used, all of which are based on numerical methods that stem from actual equations/functions. This section will provide insight into the inner workings of the code by explaining where their functions originate. The entire code was written for MATLAB/Octave. A Graphical User Interface, or GUI, was created to simplify and accelerate fault simulations. Even if the GUI was used to obtain the results, Octave can also be used to obtain the same results, and an example on how to do this is provided below (additionally, Octave has been ported to the Android OS, which makes it usable on mobile devices, and for a display of this, please refer to Appendix B): Using the [report, Lineflow] = report_5bus(ybus,busj,busk) (located in the report_5bus.m script file) function in octave will produce results similar to the GUI, but in a much less user friendly way. A snippet of the code used to generate the solution of the 5 bus system under normal operation in octave is shown below: octave:1> [results,loadflow] = report_5bus(Y5bus(),1,1); The actual results generated from using this code are included in section 3.2. All the code can be found in Appendix A of the report, and since it is well commented, only descriptions of the algorithms used will be explained, and not a line by line description. The following subsections will describe the algorithms used.

Design of the Five-Bus System !

ENGI-0438-WA 2.2.1 Ybus Assembly

Electrical Engineering Dept.

Lakehead University

The Ybus (or admittance matrix) for the power system was assembled using nodal equations and king of the hill principle, and can be shown in the equations: !!! !!!" !"#$ ! ! !!!" !!!" !!!" !!" ! ! ! !! ! !! !!! ! ! !!"
!

!!!" !!! !!!" !!!" !!!"

!!!" !!!" !!! !!!" !!!"

!!!" !!!" !!!" !!! !!!"

!!!" !!!" !!!" !!!" !!!

(2.1)

!! !!"##$!%$& !!"!!"#$!! ! ! !"#$!!!!"#$%#!! !

(2.2)

The line charging is given as an admittance in the data provided, and its positive values implies that they are a capacitive load (which is where line charging comes from). Having the Ybus for the system is very important, as the Zbus (or impedance matrix) can be obtained by inverting the Ybus. 2.2.2 Power Calculations The most straightforward calculations done are achieved with the following simple power equation: ! ! ! ! !!
(2.3)

By manipulating Equation 3, any of the three variables can be found given the two other ones are known. Another important calculation used was power loss, and this can be calculated using the formulas provided below:
!

!!"!!!"# !
! !! ! !

!!!!"# ! ! !!"!!!"# ! !!!"!!!"#


(2.4)

!!"!!!"#$ !
! !! !

!!!!"#$ ! ! !!"!!!"#$ ! !!!"!!!"!"

!!"!!!"##$# ! ! !!"!!!"# ! ! !!"!!!"#$ ! ! !!"!!!"# ! ! !!"!!!"#$

Design of the Five-Bus System !

ENGI-0438-WA

Electrical Engineering Dept.

Lakehead University

2.2.3 Newton-Raphson Algorithm Newton-Raphson Algorithm has been applied in this power system analysis through a series of equations and initial guesses at each bus, to find a new voltage which approaches the actual bus voltage present. The number of iterations performed is determined by the error tolerance, where a smaller tolerance will require the algorithm to do more iterations. The error, or in other words the voltage correction value, is determined by looking at the amount of change in the new voltage levels on the bus, and if this error is larger than the tolerance, the process is repeated. In essence, the Newton-Raphson method is quadratically convergent, and this is due to the fact that it used the Taylor series expansion approximation with the first derivative (the fact that it is quadratically convergent implies that is an efficient algorithm for large scale systems). The method used to find the voltage correction, is to set up the initial guess voltages magnitude and phase into a vector, perturb these values with the determined step size and use the new voltages to calculate the new perturbed apparent power at each bus. A numerically calculated derivative is then performed for each element of the perturbed apparent power, which is placed in a new matrix called the Jacobian. The Jacobian used in this report has the following form: !"! !"! !"! !"! !"! !"! !"! !! !"! !"! !"! !"! !"! !"! !"! !"! ! !"! !"! !"! !"! !"! !"! !"! !"! !"! !"! !"! !"! !"! !"! !"! !"! !"! !"! !"! !"! !"! !"! !"! !"! !"! !"! !"! !"! ! !"! !"! !"! !"! !"! !"! !!! !"! !"! !"! !"! !"! !"! !"! !"! !"! !"! !"! !"! !"! !"! !"! !"! !"! !"! !"! !"! !"! !"! !"! !"! !"! !"! !"! !"! !"! !"! !"! !"! !"! !"! !"! !"! !"! !"! !"! !"! !"! !"! !"! !"! !"! !"! !"! !"!

(2.5)

And as previously mentioned, the partial derivatives are calculated numerically with the definition of the derivative, as shown below:

Design of the Five-Bus System !

ENGI-0438-WA

Electrical Engineering Dept. !"!! ! !! ! ! ! ! ! ! ! ! !! ! ! ! !! ! !" !

Lakehead University

(2.6)

The voltage correction value is calculated by inverting the Jacobian matrix and multiplying it to the difference of the perturbed and original power matrix, as can be seen in the equation below (the new voltage is calculated by adding the correction value to the current voltage value): ! !"# ! !!"!# ! !!
(2.7)

2.2.4 Loadflow Analysis Loadflow (or lineflow) analysis consists of calculating the power transferred from one bus to another through a tie line. In order to compute the apparent power (and corresponding active [P] and reactive [Q] powers), the tie line and shunt currents must be known. The figure below shows the different impedances and corresponding currents between two buses (assuming Bus 1 has a higher potential than Bus 2):

Figure 5: Loadflow Currents

In order to obtain the loadflow from a given bus to another, the conjugate of the line current (I12 in the figure) is added to the conjugate of the line charging current (IiC in the figure, where i is 1 or 2) and multiplied to the bus voltage (much like equation 3) and can be summarized by the equation below (which would calculate sending end loadflow from bus 1 to bus 2): !!" ! !!" ! !!!" ! ! !! ! ! ! !!!" ! ! !!! !! power transferred.
(2.8)

A negative active power implies that there is consumption while a positive power indicates

Design of the Five-Bus System !

ENGI-0438-WA 2.2.5 Kron Reduction

Electrical Engineering Dept.

Lakehead University

The Kron reduction is a very powerful matrix operation.

It can be used for wye-delta

transformations, amongst other things. In essence, Kron reduction reduces a matrix that has zero elements in a vector. Explaining this process is quite complex and trivial, and is much better expressed through matrix algebra, and is shown in the equation below: !! ! ! ! !!! ! !! ! ! ! ! ! ! ! ! ! ! ! ! ! !!! ! !!" !! !! ! ! !! ! ! ! ! ! ! !! ! ! ! !! ! !! !! ! ! !! !! !!!! ! ! ! ! !! ! !! !! ! ! ! !! !!
(2.9)

! ! ! ! !! ! !! ! !! ! !

! ! ! ! !! ! !!!

!! ! ! ! ! ! !

! ! !!

!!

! ! !!

!! ! ! ! !

!! ! ! ! !! ! ! ! ! ! ! ! ! ! ! !

!! ! ! ! !

!!

! ! ! !!

!!

It can be seen that the A matrix was initially NxN, and after being Kron reduced it became MxM. Kron reductions were used in the power system to analyze the removal of a line, as explained in section 2.2.6. 2.2.6 Line Removal and Zbus Modifications In order to remove a line, simple metrics on parallel impedances must be understood. If an impedance is in parallel with its negative value, the resulting parallel impedance is infinity, or an open circuit. This is displayed by the equation below: ! !! !! ! ! ! ! !! ! ! !! ! !!!!!"#$!!!"! ! ! ! !! !

(2.10)

However, negative impedances are impossible to achieve when resistors are involved, but the idea shown in the above equation can be applied to removing a line in the power system without

Design of the Five-Bus System !

ENGI-0438-WA

Electrical Engineering Dept.

Lakehead University

having to rebuild a Ybus from scratch. Using case 4 of zbus modification algorithm [1], which is to add an impedance between two buses, an open circuit can be created, thus effectively eliminating a tie line between two buses. The modifications to the Zbus can be seen in the following equation, where an impedance Zb is added in between buses j and k: !!! ! !!! !! ! ! !"#$ ! ! ! ! !!! ! !!! !! !!! ! !!! ! !!" ! !!" ! !!! ! !!! ! !!" ! !!" !! ! !!! ! !!! ! !!!" !! ! !! !!

(2.11)

It can be seen that the resulting matrices can be Kron reduced by 1 to obtain a new Zbus of the same size (the Zbus is obtained by inverting the original Ybus matrix) that accounts for this removed line. 2.2.7 Symmetrical Bus Faults (Superposition) In order to perform analysis of a symmetrical bus fault to ground, superposition is used [1]. The main idea behind this technique is that the fault voltage on the faulted bus is equal to its negative value during steady-state operation. When steady-state and fault voltages are added, the result is zero, which implies the bus potential is zero itself (ie: it is grounded). From there, a subtransient fault current can be calculated, along with changes in voltage on the other buses. This can be summarized with the equations below, assuming a fault occurs on bus 4:

Design of the Five-Bus System !

ENGI-0438-WA

Electrical Engineering Dept.

Lakehead University

!!! !!! !!! ! !!! !!!


! ! ! !! ! ! ! !!! !

!"#$

! ! ! !!! ! !
(2.12)

; !!! ! ! !!!! ! !! !

!!!!"!#!$% !!!!"!#!$% ! !!! !!! !! !!!!"!#!$% !!!!"!#!$% ! !!! !!! !! !! ! ! !!!!"!#!$% ! ! !!! ! ! !!!!"!#!$% ! !!! !!! !! !!!!"!#!$% ! !! !!! !!!!"!#!$% ! !!! !!!!"!#!$%

2.3

Application to Standard Power System

The above admittance matrix assembly, power calculations, Newton-Raphson algorithm, Kron reduction, z-bus modification (including line removal) and symmetrical bus fault methods may all be applied to any standard power system. Differences arise when certain buses include tap ratios and shunt admittances, for example. If a transient stability study were to be conducted, i.e. solving for the clearing time of a fault or solving the general swing equation, different approaches would be taken depending on whether the architecture is a single-machine or multimachine system. In a multi-machine system, certain assumptions would be made to reduce the system using Kron reduction and with those values, proceed to a swing solution.

Design of the Five-Bus System !

10

ENGI-0438-WA

Electrical Engineering Dept.

Lakehead University

3.

Simulation Results

The results are given with the GUI first, and then with a snippet of the code used to generate the same results in octave (exception is the Ybus, which was only generated in octave). A sample of the results for normal operation analysis obtained in Octave is also given.

3.1

Generated Ybus

Figure 6: Generated Ybus

3.2

Normal Operation

Figure 7: Results for Normal Operation

Simulation Results !

11

ENGI-0438-WA

Electrical Engineering Dept.

Lakehead University

octave:1> [results,loadflow] = report_5bus(Y5bus(),1,1);

Figure 8: Results for Normal Operation Using Octave

Simulation Results !

12

ENGI-0438-WA

Electrical Engineering Dept.

Lakehead University

3.3

Line Removal

Figure 9: Results for Removing Line Between Bus 1 and Bus 4

octave:2> [results,loadflow] = report_5bus(removeLine(1,4),1,4);

Figure 10: Results for Removing Line Between Bus 3 and Bus 5

octave:2> [results,loadflow] = report_5bus(removeLine(3,5),3,5);

Simulation Results !

13

ENGI-0438-WA

Electrical Engineering Dept.

Lakehead University

3.4

Symmetrical Bus Fault

Figure 11: Symmetrical Bus Fault to Ground on Bus 4

octave:4>[faultI,faultV] = gen_SymmBusFault(4,NR5bus_driver(Y5bus()));

Simulation Results !

14

ENGI-0438-WA

Electrical Engineering Dept.

Lakehead University

4.

Discussion of Results

4.1

Normal Operation

The voltages obtained using the Newton-Raphson method converged in four iterations (which indicate the initial guesses given were very good) and all where within 10% of the slack bys voltage. The results obtained in the Normal Operation simulation indicate that Bus 1 generated the bulk of the power for the entire system (since bus 2 only generated a constant 45 MW of active power). In terms of losses, the entire system had about a 2.61% of active losses present, which can be considered relatively low. The active losses are most likely due to active impedance of the lines (since other higher order effects are neglected [ie: flux loss, parasitic capacitances, etc]). The highest loadflow occurred between buses 1 and 4, and between buses 4 and 5, locking in at approximately 84 MW and 54 MW respectively. This is due to buses 1 and 4 generating all the power in the system; therefore most of the power is transferred between those two buses. The high power transferred from bus 4 to 5 is due to the power demand on bus 5 being the highest of all buses. The lowest loadflow occurred between buses 3 and 5, and between buses 2 and 3, coming in at approximately 6 MW and 18 MW respectively (the reasoning for this is explained in the Line Removal section below).

4.2

Line Removal

After performing every possible permutation of line removals, only the cases at both extremes were included in the results section. In terms of voltage stability, no single line removal created enough changes to induce voltage instability (the Newton-Raphson method converged in 4 iterations and all the voltages were within 10% [or +/- 0.106] of the slack bus voltage for all possible line removals).

Discussion of Results

15

ENGI-0438-WA

Electrical Engineering Dept.

Lakehead University

The biggest losses occurred when the buses having the highest loadflow between their tie line had that line removed (highest loadflow is between buses 1 and 4, and between buses 4 and 5, as mentioned above). The converse of the above statement also holds true, and the proofs are in the results, and explained hereinafter. When the line between buses 1 and 4 was removed, the highest active power loss was recorded (a loss of approximately 8.46%), which makes sense since it is the main tie line between the two buses that generate the power. One reason for this high power loss is due to the power demand at bus 5. Since bus 5 is not directly connected to bus 1 (power must go from bus 1 through bus 2 and then through buses 3 or 4), the path for power becomes longer, meaning more power will be lost on the lines through the line impedances. A big problem also stemming from this line removal comes from the reactive power on bus 4. According to the specifications, the MVAR capabilities on bus 4 are from -40 to 50 MVAR (see Figure 3), in which case these limits are exceeded when line 1-4 is removed (33.2663 MVAR [-20 MVAR] = 53.2663 MVAR). This would cause the bus to trip, thus potentially causing more problems having this bus out of service (the entire generation would have to come from bus 1)1. And finally, another very important side effect of this line removal can be seen on bus 2: the entire power generated by bus 1 now had to be routed by bus 2 to the entire grid. In reality, this could potentially cause problems if bus 2 was not rated high enough for this power. Other interesting observations were made during simulations: removing the line between bues 4 and 5 also yielded high active power loss, since bus 5 has the highest power demand and this demand now had to be completed routed through bus 3. Furthermore, the lowest loss occurred when the line between buses 3 and 5 was removed. This was because this was the farthest tie line from power generation and there is little loadflow between the two buses in normal operation (as mentioned above).

The 5-bus system was simulated as a 4-bus system (without bus 4), and the Newton-Raphson method was non-convergent after 100 iterations (might be due to initial guesses) this was not investigated further, since it was felt that if bus 4 would trip, the entire five bus system would be in trouble and proactive measures (beyond the scope of this report) would have to be taken. Discussion of Results ! 16

ENGI-0438-WA

Electrical Engineering Dept.

Lakehead University

4.3

Symmetrical Bus Fault

The results obtained in the symmetrical bus faults simulation provide a little insight into the high subtransient currents that would be present if all three phases of an entire bus became shorted to ground. The probability of having a symmetrical fault is not as great as having just one phase of the bus grounded, but the simplicity of the superposition model trumped using a more complex unsymmetrical model (and corresponding information is missing for this ie: zero sequence impedances and such). Even if the simulations gave an idea of fault currents and voltages, those cannot be interpreted as actual phase/line currents/voltages since only a power base of 100 MVA was given; there was no information on the voltage or current base, so only per unit values can be used and are therefore reported. The highest fault currents were recorded when bus 4 was grounded, since this bus has the most tie lines to other buses.

Discussion of Results

17

ENGI-0438-WA

Electrical Engineering Dept.

Lakehead University

5.

Conclusion and Future Work

5.1

Future Work and Limitations

Although quite complete, the GUI could be optimized to show Y and Z buses in real time. Additionally, adding transient analysis to the remove line function (ie: a ground fault occurs at a point along a tie line, the user being able to select the distance of the fault from a bus) could also be a nice feature. This was slightly implemented, but not completed, as can be seen by the figure below:

Figure 12: Transient Analysis Option (Future Work)

By adding these features, perhaps stability (in terms of clearing angle and maximum swing analysis) for the generators could also be achieved. A more in depth analysis of symmetrical bus faults would also be a nice addition. However convenient the proposed future work/additions are, their incorporation was not performed primarily because some of the information on the system is lacking: there is no data on the subtransient and transient impedances of the system or of the generators, no information on transformers or distance of the lines, no base voltage or current given, no zero sequence impedances (for unsymmetrical faults), and so on.

Conclusion and Future Work !

18

ENGI-0438-WA

Electrical Engineering Dept.

Lakehead University

5.2

Conclusion

From the provided line data and operating conditions for the above 5-bus transmission system in Figure 1, a successful loadflow solution and fault analysis is performed. Matlab and Octave software are utilized to compute the necessary numerical methods, i.e. the Newton-Raphson iterative process. Furthermore, the Kron reduction technique is performed to reduce the faulted network when a symmetrical fault is simulated in the program. Matlab provides a GUI (graphical user interface) creator, which was used to create a user-friendly interface that can be used to easily simulate and visualize the loadflow results and also the effect of a simulated symmetrical fault on the loadflow results. Additionally, a user interactive script was written to extend the capabilities to mobile devices that support Octave (the script can also be used in Octave on a personal computer as well). Finally, all the results were as expected and seem to agree with established principles of theory.

Conclusion and Future Work !

19

ENGI-0438-WA

Electrical Engineering Dept.

Lakehead University

6.

References

Bibliography
[1] Grainger, J. J., & Stevenson, Jr, W. D. (2003). Power Systems A nalysis. New York: Tata McGraw-Hill.

Dr. K. Natarajan, Power System A nalysis and Design, Engi-0438, Lakehead University, Thunder Bay

References !

20

ENGI-0438-WA

Electrical Engineering Dept.

Lakehead University

[This page was left blank intentionally.]

ENGI-0438-WA

Electrical Engineering Dept.

Lakehead University

Appendix A MATLAB/Octave Code

% Filename: % Description: % % Authors:

c5busMVA.m calculate powers at each node and either return a vector to be used with newton raphson to return all powers Joey Mercier, Jonathan Evangelista, Maxime Veillette

function [Sval] = c5busMVA(Ybus,V,~) all = nargin(); % check to see if all power are to be returned I=Ybus*V; % Current S=V.*conj(I); % Power at each node P=real(S);Q=imag(S); %Real and reactive parts of the power if (all<3) % check if all powers are to be included P=P(2:5); % Powers needed for 5 bus problem Q=[Q(2,1);Q(3,1);Q(5,1)]; % Reactive powers for 5 bus problem Sval=[P;Q]; % put them together into a vector else Sval=[P Q]; % if all powers included return different matrix end;

% Author: Dr. Natarajan function Znew=case4_zbus(Zorig,Zb,j,k) %function Znew=case4_zbus(Zorig,Zb,j,k) % add element Zb between nodes j,k (only k can be zero j cannot) if (k==0) Znew=case3_zbus(Zorig,Zb,j); return; end; Znew=[Zorig, Zorig(:,j)-Zorig(:,k); Zorig(j,:)-Zorig(k,:), Zorig(k,k)+Zorig(j,j)-Zorig(j,k)-Zorig(k,j)+Zb]; Znew=kronRed(Znew,1);

% Filename: % Description: % % Authors:

gen_SymmBusFault.m simulates a ground fault on a certain bus and calculates resulting voltages/currents superposition Joey Mercier, Jonathan Evangelista, Maxime Veillette

function [faultV,faultI] = gen_SymmBusFault(fbus,Vinit) % initialize impedances using bus data z14 z12 z42 z43 z45 z23 z35 = = = = = = = 0.02 0.08 0.06 0.06 0.04 0.01 0.08 + + + + + + + j*0.06; j*0.24; j*0.18; j*0.18; j*0.12; j*0.03; j*0.24;

Appendix A MATLAB/Octave Code !

22

ENGI-0438-WA

Electrical Engineering Dept.

Lakehead University

% generate matrix with actual line impedances between buses impMat = [0 z12 0 z14 0; z12 0 z23 z42 0; 0 z23 0 z43 z35; z14 z42 z43 0 z45; 0 0 z35 z45 0]; ybus = Y5bus(); zbus = inv(ybus) % get zbus from ybus Vf = Vinit(fbus,1) % fetch initial fault voltage If = Vf/zbus(fbus,fbus) % find fault current Imat = zeros(5,1); % setup fault current vector Imat(fbus,1) = -If; % setup fault current vector delV = zeros(5,1); % setup voltage change vector faultI = zeros(5,1); delV = zbus*Imat; % find change in voltages in dead network faultV = Vinit+delV; % use superposition to find fault current for i=1:5 % discard low values if (abs(faultV(i,1)) < 1e-10) faultV(i,1)=0; end; end; for i=1:5 % fault current from other buses flowing into faulted bus if (impMat(fbus,i) == 0) % if no connection between buses i=i+1; % increment by 1 else faultI(i,1) = faultV(i,1)/impMat(fbus,i); % find current i=i+1; end; end;

% Filename: % Description: % Authors:

kronRed.m recursive kron reduction algorithm Joey Mercier, Jonathan Evangelista, Maxime Veillette

function redBus = kronRed(bus,amnt) i = 0; % number of iterations of kron reduction while (i < amnt) % keep iterating until amount of wanted reductions reached N = length(bus); bus = bus(1:N-1,1:N-1) - (bus(1:N-1,N)/bus(N,N))*bus(N,1:N-1); i = i+1; end; redBus = bus; % return final value

% Filename: % Description: % % Authors:

loadflow.m calculate power flow from line to line using line admittances and line charging values Joey Mercier, Jonathan Evangelista, Maxime Veillette

function [S_flow] = loadflow(Vnode1, Vnode2, LineAdm, LineShunt)

Appendix A MATLAB/Octave Code !

23

ENGI-0438-WA

Electrical Engineering Dept.

Lakehead University

% Find currents I12 = (Vnode1-Vnode2).*LineAdm; % calculate line current from node 1 to node 2 Ishunt1 = Vnode1.*LineShunt; % calculate shunt current from node 1 to ground Ishunt2 = Vnode2.*LineShunt; % calculate shunt current from node 2 to ground % Put answer in a vector/matrix S_flow = Vnode1.*(conj(I12) + conj(Ishunt1));

% Filename: % Description: % Authors:

NR5bus_driver.m drives and automates the use of newton-raphson method Joey Mercier, Jonathan Evangelista, Maxime Veillette

function V=NR5bus_driver(Ybus); V=[1.06;1;1;1.047;1]; % initial voltage guess as per given data c=[1;1;1;1;1;1;1]; % initial correction vector not used just to get into while loop tol=1e-8; % tolerance can be changed computing to approximately 5 decimals. iter=1; % keep track of # of iterations % This is the Pscheduled converted to per unit on 100MVA base (as per given data) % organized in similar manner as 5busMVA function: [P2;P3;P4;P5;Q2;Q3;Q5] Psch=[-45;-40;45-20;-60;-15;-5;-10]/100; % Main NR iterations while(norm(c)>tol && iter<100) % assure breaking out of non-converging loop iter [c,V_u] = NR_5bus(V,Ybus,Psch,tol); % run a newton-raphson iteration Voltages = [abs(V_u) angle(V_u)*180/pi] % display the updated magnitude & angle(degrees) of voltages V = V_u; % update the voltage at each bus and iterate again if need be. iter = iter+1; end;

% Filename: % Description: % Authors:

NR_5bus.m perform a single iteration of the newton-raphson method Joey Mercier, Jonathan Evangelista, Maxime Veillette

function [corr,Vnew]= NR_5bus(V,Ybus,Psch,tol) h=tol/1000; % setup step size % setup pertubation variables, V# = Voltage at node #, D# = angle at node # using initial conditions: V2 = abs(V(2,1)); D2 = angle(V(2,1)); V3 = abs(V(3,1)); D3 = angle(V(3,1)); V4 = abs(V(4,1)); D4 = angle(V(4,1)); V5 = abs(V(5,1)); D5 = angle(V(5,1)); % setup pertubation variables in a vector Vp1 = V;Vp1(2,1) = V2*exp(j*(D2+h)); % x1 = delta2

Appendix A MATLAB/Octave Code !

24

ENGI-0438-WA
Vp2 Vp3 Vp4 Vp5 Vp6 Vp7 = = = = = = V;Vp2(3,1) V;Vp3(4,1) V;Vp4(5,1) V;Vp5(2,1) V;Vp6(3,1) V;Vp7(5,1) = = = = = =

Electrical Engineering Dept.


V3*exp(j*(D3+h)); V4*exp(j*(D4+h)); V5*exp(j*(D5+h)); (V2+h)*exp(j*(D2)); (V3+h)*exp(j*(D3)); (V5+h)*exp(j*(D5)); % % % % % % x2 x3 x4 x5 x6 x7 = = = = = = delta3 delta4 delta5 V2 V3 V5

Lakehead University

Sorig = c5busMVA(Ybus,V); power

% Original power vector 1:4 = real power, 5:7 = reactive

% perturb powers and put them in matrix Spert = [c5busMVA(Ybus,Vp1) c5busMVA(Ybus,Vp2) c5busMVA(Ybus,Vp3) c5busMVA(Ybus,Vp4) c5busMVA(Ybus,Vp5) c5busMVA(Ybus,Vp6) c5busMVA(Ybus,Vp7)]; % Setup an approximate Jacobian using the perturbed and unperturbed powers J = [(Spert(:,1)-Sorig)/h (Spert(:,2)-Sorig)/h (Spert(:,3)-Sorig)/h (Spert(:,4)-Sorig)/h (Spert(:,5)-Sorig)/h (Spert(:,6)-Sorig)/h (Spert(:,7)-Sorig)/h]; % Rhs of Newton Rapshon is delta_powers delta_S = Psch-Sorig; % compute the correction corr = inv(J)*(delta_S); % update voltage using correction data: % corr = [newD2; newD3; newD4; newD5; newV2; newV3; newV5] Vnew = zeros(5,1); Vnew(1,1) = V(1,1); Vnew(2,1) = (V2+corr(5,1))*exp(j*(D2+corr(1,1))); Vnew(3,1) = (V3+corr(6,1))*exp(j*(D3+corr(2,1))); Vnew(4,1) = V4*exp(j*(D4+corr(3,1))); Vnew(5,1) = (V5+corr(7,1))*exp(j*(D5+corr(4,1)));

% Filename: % Description: % % % Authors:

printTable_5bus.m uses results obtained in other simulations and displays them is a neat little table (for standalone use, does not affect GUI) Joey Mercier, Jonathan Evangelista, Maxime Veillette

function printTable_5bus(report,lineflow) disp(' ENGI 0438 - 5 Bus Final Answers (buses 1 thru 5): ') disp('===============================================================================') disp(' V(pu) Angle(rad) P Gen(MW) Q Gen(MVAR) P Load(MW) Q Load(MVAR)') disp('===============================================================================') disp(report) disp('===============================================================================') disp(' System Power Totals:') r1 = [sum(report(:,3)) sum(report(:,5)) sum(report(:,4)) sum(report(:,6)) sum(report(:,3))-sum(report(:,5)) sum(report(:,4))-sum(report(:,6))]; disp('========================================================================') disp(' P Gen(MW) P Load(MW) Q Gen(MVAR) QLoad(MVAR) Loss(MW) Loss(MVAR)') disp(r1) disp('========================================================================') disp(' Line Flow: ') disp('=================================================================================== ======')

Appendix A MATLAB/Octave Code !

25

ENGI-0438-WA

Electrical Engineering Dept.

Lakehead University

disp(' Bus 1 to Bus 2 Bus 1 to Bus 3 Bus 1 to Bus 4 Bus 1 to Bus 5'); disp(' MW MVAR MW MVAR MW MVAR MW MVAR'); r1 = [real(lineflow(1,2)) imag(lineflow(1,2)) real(lineflow(1,3)) imag(lineflow(1,3)) real(lineflow(1,4)) imag(lineflow(1,4)) real(lineflow(1,5)) imag(lineflow(1,5))]; disp(r1); disp(' ----------------------'); disp(' Bus 2 to Bus 1 Bus 2 to Bus 3 Bus 2 to Bus 4 Bus 2 to Bus 5'); disp(' MW MVAR MW MVAR MW MVAR MW MVAR'); r1 = [real(lineflow(2,1)) imag(lineflow(2,1)) real(lineflow(2,3)) imag(lineflow(2,3)) real(lineflow(2,4)) imag(lineflow(2,4)) real(lineflow(2,5)) imag(lineflow(2,5))]; disp(r1); disp(' ----------------------'); disp(' Bus 3 to Bus 1 Bus 3 to Bus 2 Bus 3 to Bus 4 Bus 3 to Bus 5'); disp(' MW MVAR MW MVAR MW MVAR MW MVAR'); r1 = [real(lineflow(3,1)) imag(lineflow(3,1)) real(lineflow(3,2)) imag(lineflow(3,2)) real(lineflow(3,4)) imag(lineflow(3,4)) real(lineflow(3,5)) imag(lineflow(3,5))]; disp(r1); disp(' ----------------------'); disp(' Bus 4 to Bus 1 Bus 4 to Bus 2 Bus 4 to Bus 3 Bus 4 to Bus 5'); disp(' MW MVAR MW MVAR MW MVAR MW MVAR'); r1 = [real(lineflow(4,1)) imag(lineflow(4,1)) real(lineflow(4,2)) imag(lineflow(4,2)) real(lineflow(4,3)) imag(lineflow(4,3)) real(lineflow(4,5)) imag(lineflow(4,5))]; disp(r1); disp(' ----------------------'); disp(' Bus 5 to Bus 1 Bus 5 to Bus 2 Bus 5 to Bus 3 Bus 5 to Bus 4'); disp(' MW MVAR MW MVAR MW MVAR MW MVAR'); r1 = [real(lineflow(5,1)) imag(lineflow(5,1)) real(lineflow(5,2)) imag(lineflow(5,2)) real(lineflow(5,3)) imag(lineflow(5,3)) real(lineflow(5,4)) imag(lineflow(5,4))]; disp(r1); disp('=================================================================================== ======');

% Filename: % Description: % % % Authors:

removeLine.m uses case4_zbus and kron reduction algorithms to remove a line by setting a parallel branch with negative impedance between two buses Joey Mercier, Jonathan Evangelista, Maxime Veillette

function [ybusNew] = removeLine(busj,busk) ybus = Y5bus(); zbus = inv(ybus); % get original zbus from ybus z14 z12 z42 z43 z45 z23 = = = = = = 0.02 0.08 0.06 0.06 0.04 0.01 + + + + + + j*0.06; j*0.24; j*0.18; j*0.18; j*0.12; j*0.03;

Appendix A MATLAB/Octave Code !

26

ENGI-0438-WA
z35 = 0.08 + j*0.24;

Electrical Engineering Dept.

Lakehead University

% matrix with actual line impedances between lines impMat = [0 z12 0 z14 0; z12 0 z23 z42 0; 0 z23 0 z43 z35; z14 z42 z43 0 z45; 0 0 z35 z45 0]; Zb = impMat(busj,busk); % find impedance of line to be removed zbusNew = case4_zbus(zbus,-Zb,busj,busk); % generate new zbus ybusNew = inv(zbusNew); % return new ybus (to be used with other algorithms)

% Filename: % Description: % % Authors:

report_5bus.m automates entire simulation process using many different scripts and functions and returns printable results Joey Mercier, Jonathan Evangelista, Maxime Veillette

function [report,Lineflow] = report_5bus(ybus,busj,busk) % This is an automated script that calculates voltages at each bus % then it calculates power and loadflow at each line and reports it V = NR5bus_driver(ybus); % calculates bus voltages from newton-raphson method [Vn1 Vn2 LineAdm LineShunt] = setup5bus_loadflow(busj,busk,V); % setup loadflow flowPU = loadflow(Vn1, Vn2, LineAdm, LineShunt); % calculate lineflow in p.u. ploadPU = c5busMVA(ybus,V,1); % calculate total power at each bus report = zeros(5,6); % setup gen and load power answer matrix Lineflow = flowPU*100; % put lineflow powers in MVA (multiply by base) ploadMVA = ploadPU*100; % put powers in MVA busQgen = ploadMVA(4,2) + (-20); % find Qgen for bus 4 using power balance % Report Final Answers % voltages and angles report(:,1:2) = [abs(V) angle(V)*180/pi]; % generated power report(1,3:4) = [ploadMVA(1,1) ploadMVA(1,2)]; % bus 1 generated power report(4,3:4) = [45 busQgen]; % bus 4 generated power % loaded power (multiplied by -1 because they are negative indicating power loss) report(2:3,5:6) = [ploadMVA(2:3,1) ploadMVA(2:3,2)]*-1; % buses 2-3 load power report(4,5:6) = [20 -20]; % bus 4 load power (as given) report(5,5:6) = [ploadMVA(5,1) ploadMVA(5,2)]*-1; % bus 5 load power printTable_5bus(report,Lineflow) % print results outside of GUI also

% Filename: % Description: % Authors:

setup5bus_loadlflow.m sets up matrices to be used with loadflow.m Joey Mercier, Jonathan Evangelista, Maxime Veillette

function [Vn1 Vn2 LineAdm LineShunt] = setup5bus_loadflow(busj,busk,V)

Appendix A MATLAB/Octave Code !

27

ENGI-0438-WA

Electrical Engineering Dept.

Lakehead University

% admittance values as per given data Y14 Y12 Y42 Y43 Y45 Y23 Y35 = = = = = = = 1/(0.02 1/(0.08 1/(0.06 1/(0.06 1/(0.04 1/(0.01 1/(0.08 + + + + + + + j*0.06); j*0.24); j*0.18); j*0.18); j*0.12); j*0.03); j*0.24); Ys14 Ys12 Ys42 Ys43 Ys45 Ys23 Ys35 = = = = = = = j*0.03; j*0.025; j*0.02; j*0.02; j*0.015; j*0.01; j*0.025;

V1=V(1,1);V2=V(2,1);V3=V(3,1);V4=V(4,1);V5=V(5,1); % setup node voltages starting from 1, going to 5 % voltages taken from newton raphson solution % cover any conceivable permutation possible Vn1 = [V1 V2 V3 V4 V5 Vn2 = [V1 V1 V1 V1 V1 V1 V2 V3 V4 V5 V2 V2 V2 V2 V2 V1 V2 V3 V4 V5 V3 V3 V3 V3 V3 V1 V2 V3 V4 V5 V4 V4 V4 V4 V4 V1; V2; V3; V4; V5]; V5; V5; V5; V5; V5];

% setup line shunt and series admittances LineAdm = [0 Y12 0 Y14 0; Y12 0 Y23 Y42 0; 0 Y23 0 Y43 Y35; Y14 Y42 Y43 0 Y45; 0 0 Y35 Y45 0]; LineShunt = [0 Ys12 0 Ys14 0; Ys12 0 Ys23 Ys42 0; 0 Ys23 0 Ys43 Ys35; Ys14 Ys42 Ys43 0 Ys45; 0 0 Ys35 Ys45 0]; % removed line admittances must be set to zero to assure no loadflow LineAdm(busj,busk) = LineAdm(busk,busj) = LineShunt(busj,busk) LineShunt(busk,busj) 0; 0; = 0; = 0;

% Filename: % Description: % Authors:

Y5bus.m creates ybus using king of the hill principle Joey Mercier, Jonathan Evangelista, Maxime Veillette

function AdmMatrix = Y5bus() % Data from project handout (in same order as provided)

Appendix A MATLAB/Octave Code !

28

ENGI-0438-WA
Y14 Y12 Y42 Y43 Y45 Y23 Y35 = = = = = = = 1/(0.02 1/(0.08 1/(0.06 1/(0.06 1/(0.04 1/(0.01 1/(0.08 + + + + + + + j*0.06); j*0.24); j*0.18); j*0.18); j*0.12); j*0.03); j*0.24); Ys14 Ys12 Ys42 Ys43 Ys45 Ys23 Ys35

Electrical Engineering Dept.


= = = = = = = j*0.03; j*0.025; j*0.02; j*0.02; j*0.015; j*0.01; j*0.025;

Lakehead University

% put in a matrix using king of the hill principle AdmMatrix = [Y14+Y12+Ys14+Ys12 -Y12 0 -Y14 0; -Y12 Y12+Y23+Y42+Ys12+Ys23+Ys42 -Y23 -Y42 0; 0 -Y23 Y23+Y43+Y35+Ys23+Ys43+Ys35 -Y43 -Y35; -Y14 -Y42 -Y43 Y14+Y42+Y43+Y45+Ys14+Ys42+Ys43+Ys45 -Y45; 0 0 -Y35 -Y45 Y35+Y45+Ys35+Ys45];

% Filename: % Description: % % % Authors:

GUI.m GUI code for system interface designed using MATLAB GUIDE, varations using handles done by authors Joey Mercier, Jonathan Evangelista, Maxime Veillette

function varargout = GUI(varargin) % GUI MATLAB code for GUI.fig % GUI, by itself, creates a new GUI or raises the existing % singleton*. % % H = GUI returns the handle to a new GUI or the handle to % the existing singleton*. % % GUI('CALLBACK',hObject,eventData,handles,...) calls the local % function named CALLBACK in GUI.M with the given input arguments. % % GUI('Property','Value',...) creates a new GUI or raises the % existing singleton*. Starting from the left, property value pairs are % applied to the GUI before GUI_OpeningFcn gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to GUI_OpeningFcn via varargin. % % *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one % instance to run (singleton)". % % See also: GUIDE, GUIDATA, GUIHANDLES % Edit the above text to modify the response to help GUI % Last Modified by GUIDE v2.5 24-Feb-2013 15:44:06 % Begin initialization code - DO NOT gui_Singleton = 1; gui_State = struct('gui_Name', 'gui_Singleton', 'gui_OpeningFcn', 'gui_OutputFcn', 'gui_LayoutFcn', 'gui_Callback', if nargin && ischar(varargin{1}) EDIT mfilename, ... gui_Singleton, ... @GUI_OpeningFcn, ... @GUI_OutputFcn, ... [] , ... []);

Appendix A MATLAB/Octave Code !

29

ENGI-0438-WA
end

Electrical Engineering Dept.

Lakehead University

gui_State.gui_Callback = str2func(varargin{1});

if nargout [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); else gui_mainfcn(gui_State, varargin{:}); end % End initialization code - DO NOT EDIT

% --- Executes just before GUI is made visible. function GUI_OpeningFcn(hObject, eventdata, handles, varargin) % This function has no output args, see OutputFcn. % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % varargin command line arguments to GUI (see VARARGIN) axes(handles.diag) % set display picture imshow('diagram.png') % load display picture % make various initial buttons/tables invisible set(handles.gndBus, 'Visible', 'off'); set(handles.busFVTable, 'Visible', 'off'); set(handles.busFITable, 'Visible', 'off'); set(handles.text6, 'Visible', 'off'); set(handles.text7, 'Visible', 'off'); set(handles.remBus1, 'Visible', 'off'); set(handles.remBus2, 'Visible', 'off'); set(handles.tglTran, 'Visible', 'off'); set(handles.tranSel, 'Visible', 'off'); % Choose default command line output for GUI handles.output = hObject; % Update handles structure guidata(hObject, handles); % UIWAIT makes GUI wait for user response (see UIRESUME) % uiwait(handles.figure1);

% --- Outputs from this function are returned to the command line. function varargout = GUI_OutputFcn(hObject, eventdata, handles) % varargout cell array for returning output args (see VARARGOUT); % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Get default command line output from handles structure varargout{1} = handles.output;

% --- Executes on button press in simButton. function simButton_Callback(hObject, eventdata, handles) % hObject handle to simButton (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) if (get(handles.normOp, 'Value') == 1) % if normal operation selected % run simulation scripts for normal operation and display data in % corresponding tables

Appendix A MATLAB/Octave Code !

30

ENGI-0438-WA

Electrical Engineering Dept.

Lakehead University

[report,lineflow] = report_5bus(Y5bus(),1,1); set(handles.reportTable, 'Data', report); r1 = [sum(report(:,3)) sum(report(:,5)) sum(report(:,4)) sum(report(:,6)) sum(report(:,3))-sum(report(:,5)) sum(report(:,4))-sum(report(:,6))]; r2 = zeros(5,10); r2(:,1:2:9) = [real(lineflow)]; % set P of lineflow r2(:,2:2:10) = [imag(lineflow)]; % set Q of lineflow set(handles.totTable, 'Data', r1); set(handles.flowTable, 'Data', r2); elseif (get(handles.busFault, 'Value') == 1)% if bus fault operation selected Vinit = NR5bus_driver(Y5bus()); % get voltages from Newton-Raphson % depending on which bus is to be grounded, perform the simulation with % the particular bus grounded if (get(handles.bus1Gnd, 'Value') == 1) [Vf,If] = gen_SymmBusFault(1,Vinit); elseif (get(handles.bus2Gnd, 'Value') == 1) [Vf,If] = gen_SymmBusFault(2,Vinit); elseif (get(handles.bus3Gnd, 'Value') == 1) [Vf,If] = gen_SymmBusFault(3,Vinit); elseif (get(handles.bus4Gnd, 'Value') == 1) [Vf,If] = gen_SymmBusFault(4,Vinit); elseif (get(handles.bus5Gnd, 'Value') == 1) [Vf,If] = gen_SymmBusFault(5,Vinit); end; % put all generated information in tables r1 = [abs(If) angle(If)]; set(handles.busFITable, 'Data', r1); r1 = [abs(Vf) angle(Vf)]; set(handles.busFVTable, 'Data', r1); r1(:,2) = r1(:,2)*180/pi; r2 = zeros(5,6); r2(:,1:2) = r1; set(handles.reportTable, 'Data', r2); elseif (get(handles.remLine, 'Value') == 1)% if remove line selected % depending which buses are selected, perform corresponding simulations % with corresponding line removed from system (ie: faulted line) % the remaining system remains connected throughout if (get(handles.tglTran, 'Value') == 0) if (get(handles.rem1Bus1, 'Value') == 1); % First bus is Bus 1 if (get(handles.rem2Bus2, 'Value') == 1); [report,lineflow] = report_5bus(removeLine(1,2),1,2); elseif (get(handles.rem2Bus4, 'Value') == 1); [report,lineflow] = report_5bus(removeLine(1,4),1,4); end; elseif (get(handles.rem1Bus2, 'Value') == 1); % First bus is Bus 2 if (get(handles.rem2Bus1, 'Value') == 1); [report,lineflow] = report_5bus(removeLine(2,1),2,1); elseif (get(handles.rem2Bus3, 'Value') == 1); [report,lineflow] = report_5bus(removeLine(2,3),2,3); elseif (get(handles.rem2Bus4, 'Value') == 1); [report,lineflow] = report_5bus(removeLine(2,4),2,4); end; elseif (get(handles.rem1Bus3, 'Value') == 1); % First bus is Bus 3 if (get(handles.rem2Bus2, 'Value') == 1); [report,lineflow] = report_5bus(removeLine(3,2),3,2); elseif (get(handles.rem2Bus4, 'Value') == 1);

Appendix A MATLAB/Octave Code !

31

ENGI-0438-WA

Electrical Engineering Dept.

Lakehead University

[report,lineflow] = report_5bus(removeLine(3,4),3,4); elseif (get(handles.rem2Bus5, 'Value') == 1); [report,lineflow] = report_5bus(removeLine(3,5),3,5); end; elseif (get(handles.rem1Bus4, 'Value') == 1); % First bus is Bus 4 if (get(handles.rem2Bus1, 'Value') == 1); [report,lineflow] = report_5bus(removeLine(4,1),4,1); elseif (get(handles.rem2Bus2, 'Value') == 1); [report,lineflow] = report_5bus(removeLine(4,2),4,2); elseif (get(handles.rem2Bus3, 'Value') == 1); [report,lineflow] = report_5bus(removeLine(4,3),4,3); elseif (get(handles.rem2Bus5, 'Value') == 1); [report,lineflow] = report_5bus(removeLine(4,5),4,5); end; elseif (get(handles.rem1Bus5, 'Value') == 1); % First bus is Bus 5 if (get(handles.rem2Bus3, 'Value') == 1); [report,lineflow] = report_5bus(removeLine(5,3),5,3); elseif (get(handles.rem2Bus4, 'Value') == 1); [report,lineflow] = report_5bus(removeLine(5,4),5,4); end; end; % display data in tables set(handles.reportTable, 'Data', report); r1 = [sum(report(:,3)) sum(report(:,5)) sum(report(:,4)) sum(report(:,6)) sum(report(:,3))-sum(report(:,5)) sum(report(:,4))-sum(report(:,6))]; r2 = zeros(5,10); r2(:,1:2:9) = [real(lineflow)]; % set P of lineflow r2(:,2:2:10) = [imag(lineflow)]; % set Q of lineflow set(handles.totTable, 'Data', r1); set(handles.flowTable, 'Data', r2); else if (get(handles.faultFirstBus, 'Value') == 1) % if fault at first bus % % transient code (future work) % else % if fault at second bus % % transient code (future work) % end; end; end;

% --- Executes when selected object is changed in uipanel2. function uipanel2_SelectionChangeFcn(hObject, eventdata, handles) % hObject handle to the selected object in uipanel2 % eventdata structure with the following fields (see UIBUTTONGROUP) % EventName: string 'SelectionChanged' (read only) % OldValue: handle of the previously selected object or empty if none was selected % NewValue: handle of the currently selected object % handles structure with handles and user data (see GUIDATA) % these changes in visibilty happen when different options are selected, % and all data in the tables are zeroed when operations are switched, to % prevent pre-simulation confusion if (get(handles.normOp, 'Value') == 1) % if normal operation is selected

Appendix A MATLAB/Octave Code !

32

ENGI-0438-WA

Electrical Engineering Dept.

Lakehead University

axes(handles.diag) % set display picture imshow('diagram.png') set(handles.reportTable, 'Data', zeros(5,6)); set(handles.totTable, 'Data', zeros(1,6)); set(handles.flowTable, 'Data', zeros(5,10)); end; if (get(handles.busFault, 'Value') == 1) % if bus fault is selected axes(handles.diag) % set display picture imshow('b1gnd.png') set(handles.gndBus, 'Visible', 'on'); set(handles.flowTable, 'Visible', 'off'); set(handles.text5, 'Visible', 'off'); set(handles.busFVTable, 'Visible', 'on'); set(handles.busFITable, 'Visible', 'on'); set(handles.text6, 'Visible', 'on'); set(handles.text7, 'Visible', 'on'); set(handles.reportTable, 'Data', zeros(5,6)); set(handles.totTable, 'Data', zeros(1,6)); set(handles.flowTable, 'Data', zeros(5,10)); else set(handles.gndBus, 'Visible', 'off'); set(handles.busFVTable, 'Visible', 'off'); set(handles.busFITable, 'Visible', 'off'); set(handles.text6, 'Visible', 'off'); set(handles.text7, 'Visible', 'off'); set(handles.flowTable, 'Visible', 'on'); set(handles.text5, 'Visible', 'on'); end; if (get(handles.remLine, 'Value') == 1) % if remove line is selected axes(handles.diag) % set display picture imshow('r12.png') set(handles.rem1Bus1, 'Value', 1); set(handles.rem2Bus2, 'Value', 1); set(handles.remBus1, 'Visible', 'on'); set(handles.remBus2, 'Visible', 'on'); set(handles.rem2Bus1, 'Visible', 'off'); set(handles.rem2Bus2, 'Visible', 'on'); set(handles.rem2Bus3, 'Visible', 'off'); set(handles.rem2Bus4, 'Visible', 'on'); set(handles.rem2Bus5, 'Visible', 'off'); set(handles.tglTran, 'Visible', 'on'); if (get(handles.tglTran, 'Value') == 1); set(handles.text5, 'String', 'Load Flow (MW, MVAR [transient state])'); set(handles.tranSel, 'Visible', 'on'); else set(handles.text5, 'String', 'Load Flow (MW, MVAR [steady state])'); end; set(handles.reportTable, 'Data', zeros(5,6)); set(handles.totTable, 'Data', zeros(1,6)); set(handles.flowTable, 'Data', zeros(5,10)); else set(handles.remBus1, 'Visible', 'off'); set(handles.remBus2, 'Visible', 'off'); set(handles.tglTran, 'Visible', 'off'); set(handles.tranSel, 'Visible', 'off'); set(handles.text5, 'String', 'Load Flow (MW, MVAR)'); end;

Appendix A MATLAB/Octave Code !

33

ENGI-0438-WA

Electrical Engineering Dept.

Lakehead University

% --- Executes when selected object is changed in gndBus. function gndBus_SelectionChangeFcn(hObject, eventdata, handles) % hObject handle to the selected object in gndBus % eventdata structure with the following fields (see UIBUTTONGROUP) % EventName: string 'SelectionChanged' (read only) % OldValue: handle of the previously selected object or empty if none was selected % NewValue: handle of the currently selected object % handles structure with handles and user data (see GUIDATA) % assure the correct bus is grounded in the image according to the selected % bus if (get(handles.bus1Gnd, 'Value') == 1) axes(handles.diag) % set display picture imshow('b1gnd.png') % load display picture elseif (get(handles.bus2Gnd, 'Value') == 1) axes(handles.diag) % set display picture imshow('b2gnd.png') % load display picture elseif (get(handles.bus3Gnd, 'Value') == 1) axes(handles.diag) % set display picture imshow('b3gnd.png') % load display picture elseif (get(handles.bus4Gnd, 'Value') == 1) axes(handles.diag) % set display picture imshow('b4gnd.png') % load display picture elseif (get(handles.bus5Gnd, 'Value') == 1) axes(handles.diag) % set display picture imshow('b5gnd.png') % load display picture end; % --- Executes when selected object is changed in remBus1. function remBus1_SelectionChangeFcn(hObject, eventdata, handles) % hObject handle to the selected object in remBus1 % eventdata structure with the following fields (see UIBUTTONGROUP) % EventName: string 'SelectionChanged' (read only) % OldValue: handle of the previously selected object or empty if none was selected % NewValue: handle of the currently selected object % handles structure with handles and user data (see GUIDATA) % assure the correct line is removed in the image according to the selected % buses, and set buttons visible according to the bus connectivity if (get(handles.rem1Bus1, 'Value') == 1) axes(handles.diag) % set display picture imshow('r12.png') % load display picture set(handles.rem2Bus2, 'Value', 1); set(handles.rem2Bus1, 'Visible', 'off'); set(handles.rem2Bus2, 'Visible', 'on'); set(handles.rem2Bus3, 'Visible', 'off'); set(handles.rem2Bus4, 'Visible', 'on'); set(handles.rem2Bus5, 'Visible', 'off'); elseif (get(handles.rem1Bus2, 'Value') == 1) axes(handles.diag) % set display picture imshow('r12.png') % load display picture set(handles.rem2Bus1, 'Value', 1); set(handles.rem2Bus1, 'Visible', 'on'); set(handles.rem2Bus2, 'Visible', 'off');

Appendix A MATLAB/Octave Code !

34

ENGI-0438-WA

Electrical Engineering Dept.

Lakehead University

set(handles.rem2Bus3, 'Visible', 'on'); set(handles.rem2Bus4, 'Visible', 'on'); set(handles.rem2Bus5, 'Visible', 'off'); elseif (get(handles.rem1Bus3, 'Value') == 1) axes(handles.diag) % set display picture imshow('r23.png') % load display picture set(handles.rem2Bus2, 'Value', 1); set(handles.rem2Bus1, 'Visible', 'off'); set(handles.rem2Bus2, 'Visible', 'on'); set(handles.rem2Bus3, 'Visible', 'off'); set(handles.rem2Bus4, 'Visible', 'on'); set(handles.rem2Bus5, 'Visible', 'on'); elseif (get(handles.rem1Bus4, 'Value') == 1) axes(handles.diag) % set display picture imshow('r14.png') % load display picture set(handles.rem2Bus1, 'Value', 1); set(handles.rem2Bus1, 'Visible', 'on'); set(handles.rem2Bus2, 'Visible', 'on'); set(handles.rem2Bus3, 'Visible', 'on'); set(handles.rem2Bus4, 'Visible', 'off'); set(handles.rem2Bus5, 'Visible', 'on'); elseif (get(handles.rem1Bus5, 'Value') == 1) axes(handles.diag) % set display picture imshow('r35.png') % load display picture set(handles.rem2Bus3, 'Value', 1); set(handles.rem2Bus1, 'Visible', 'off'); set(handles.rem2Bus2, 'Visible', 'off'); set(handles.rem2Bus3, 'Visible', 'on'); set(handles.rem2Bus4, 'Visible', 'on'); set(handles.rem2Bus5, 'Visible', 'off'); end;

% --- Executes when selected object is changed in remBus2. function remBus2_SelectionChangeFcn(hObject, eventdata, handles) % hObject handle to the selected object in remBus2 % eventdata structure with the following fields (see UIBUTTONGROUP) % EventName: string 'SelectionChanged' (read only) % OldValue: handle of the previously selected object or empty if none was selected % NewValue: handle of the currently selected object % handles structure with handles and user data (see GUIDATA) % assure correct image is displayed if (get(handles.rem2Bus1, 'Value') == 1) if (get(handles.rem1Bus2, 'Value') == 1) axes(handles.diag) % set display picture imshow('r12.png') % load display picture elseif (get(handles.rem1Bus4, 'Value') == 1) axes(handles.diag) % set display picture imshow('r14.png') % load display picture end; elseif (get(handles.rem2Bus2, 'Value') == 1) if (get(handles.rem1Bus1, 'Value') == 1) axes(handles.diag) % set display picture imshow('r12.png') % load display picture elseif (get(handles.rem1Bus3, 'Value') == 1) axes(handles.diag) % set display picture

Appendix A MATLAB/Octave Code !

35

ENGI-0438-WA

Electrical Engineering Dept.

Lakehead University

imshow('r23.png') % load display picture elseif (get(handles.rem1Bus4, 'Value') == 1) axes(handles.diag) % set display picture imshow('r24.png') % load display picture end; elseif (get(handles.rem2Bus3, 'Value') == 1) if (get(handles.rem1Bus2, 'Value') == 1) axes(handles.diag) % set display picture imshow('r23.png') % load display picture elseif (get(handles.rem1Bus4, 'Value') == 1) axes(handles.diag) % set display picture imshow('r34.png') % load display picture elseif (get(handles.rem1Bus5, 'Value') == 1) axes(handles.diag) % set display picture imshow('r35.png') % load display picture end; elseif (get(handles.rem2Bus4, 'Value') == 1) if (get(handles.rem1Bus1, 'Value') == 1) axes(handles.diag) % set display picture imshow('r14.png') % load display picture elseif (get(handles.rem1Bus2, 'Value') == 1) axes(handles.diag) % set display picture imshow('r24.png') % load display picture elseif (get(handles.rem1Bus3, 'Value') == 1) axes(handles.diag) % set display picture imshow('r34.png') % load display picture elseif (get(handles.rem1Bus5, 'Value') == 1) axes(handles.diag) % set display picture imshow('r45.png') % load display picture end; elseif (get(handles.rem2Bus5, 'Value') == 1) if (get(handles.rem1Bus3, 'Value') == 1) axes(handles.diag) % set display picture imshow('r35.png') % load display picture elseif (get(handles.rem1Bus4, 'Value') == 1) axes(handles.diag) % set display picture imshow('r45.png') % load display picture end; end;

% --- Executes on button press in tglTran. function tglTran_Callback(hObject, eventdata, handles) % hObject handle to tglTran (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) if (get(handles.tglTran, 'Value') == 0)% if steady state analysis selected set(handles.tglTran, 'String', 'Steady State Analysis'); set(handles.text5, 'String', 'Load Flow (MW, MVAR [steady state])'); set(handles.tranSel, 'Visible', 'off'); set(handles.flowTable, 'Data', zeros(5,10)); else set(handles.tglTran, 'String', 'Transient Analysis'); % if transient selected set(handles.text5, 'String', 'Load Flow (MW, MVAR [transient state])'); set(handles.tranSel, 'Visible', 'on'); set(handles.flowTable, 'Data', zeros(5,10)); end;

Appendix A MATLAB/Octave Code !

36

ENGI-0438-WA

Electrical Engineering Dept.

Lakehead University

% --- Executes on button press in saveData. function saveData_Callback(hObject, eventdata, handles) % hObject handle to saveData (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) prompt = {'Enter Filename: '}; dlg_title = 'Save Data...'; num_lines = 1; def = {'FiveBusData'}; answer = inputdlg(prompt,dlg_title,num_lines,def); % get filename from user if (isempty(answer)) % if user presses cancel or inputs nothing return; % exit function else if (get(handles.busFault, 'Value') == 1) % only save pertinent info busFaultVoltage = get(handles.busFVTable, 'Data'); % get data busFaultCurrent = get(handles.busFITable, 'Data'); % get data save(answer{1}, 'busFaultVoltage', 'busFaultCurrent'); % save to .mat file else systemResults = get(handles.reportTable, 'Data'); % get data systemTotals = get(handles.totTable, 'Data'); % get data loadFlow = get(handles.flowTable, 'Data'); % get data save(answer{1}, 'systemResults', 'systemTotals', 'loadFlow'); % save to .mat file end; end; clear; % clear all

Appendix A MATLAB/Octave Code !

37

ENGI-0438-WA

Electrical Engineering Dept.

Lakehead University

Appendix B Solving 5-Bus System on Mobile Device Using Octave

As mentioned briefly in the introduction, Octave is very versatile due to its cross-platform portability. Since the codes where written in MATLAB/Octave, it is possible to solve the 5-bus system on a mobile device2. A simple user-interactive script was written to simplify the process for normal operation and remove line. The following are the results of diaries created using Octave on an Android Smartphone to solve for normal operation and the removal of the line between bus 1 and 4:
octave:7> pwd ans = /storage/sdcard0/Octave octave:8> startupFxn(); Hello, Octave is at your disposal!! Root Folder set to: ans = /storage/sdcard0/Octave Startup Menu: [ 1] Run 5 Bus Scripts [ 2] Just use Octave pick a number, any number: 1 5-Bus Analysis: [ 1] Normal Operation [ 2] Remove a Line [ 3] Exit pick a number, any number: 1 iter = 1 Voltages = 1.06000 1.02648 1.02573 1.04700 1.01986 iter = 2 Voltages = 1.06000 1.02388 1.02323 1.04700 1.01752 0.00000 -4.88353 -5.20790 -2.65139 -6.00850 0.00000 -4.88853 -5.21877 -2.57775 -6.01142

Even if this was not a requirement, many applications are migrating to the mobile scene, which is why this was done Appendix B Solving 5-bus System on Mobile Device Using Octave ! 38

ENGI-0438-WA
iter = 3 Voltages = 1.06000 1.02387 1.02323 1.04700 1.01751 iter = 4 Voltages = 1.06000 1.02387 1.02323 1.04700 1.01751 0.00000 -4.88355 -5.20790 -2.65158 -6.00854 0.00000 -4.88355 -5.20790 -2.65158 -6.00854

Electrical Engineering Dept.

Lakehead University

ENGI 0438 - 5 Bus Final Answers (buses 1 thru 5): =============================================================================== V(pu) Angle(rad) P Gen(MW) Q Gen(MVAR) P Load(MW) Q Load(MVAR) =============================================================================== 1.06000 0.00000 124.42560 -5.10799 0.00000 0.00000 1.02387 -4.88355 0.00000 0.00000 45.00000 15.00000 1.02323 -5.20790 0.00000 0.00000 40.00000 5.00000 1.04700 -2.65158 45.00000 -2.77827 20.00000 -20.00000 1.01751 -6.00854 0.00000 0.00000 60.00000 10.00000 =============================================================================== System Power Totals: ======================================================================== P Gen(MW) P Load(MW) Q Gen(MVAR) QLoad(MVAR) Loss(MW) Loss(MVAR) 169.4256 165.0000 -7.8863 10.0000 4.4256 -17.8863 ======================================================================== Line Flow: ========================================================================================= Bus 1 to Bus 2 Bus 1 to Bus 3 Bus 1 to Bus 4 Bus 1 to Bus 5 MW MVAR MW MVAR MW MVAR MW MVAR 39.92719 1.48185 0.00000 0.00000 84.49841 -6.58984 0.00000 0.00000 ---------------------Bus 2 to Bus 1 Bus 2 to Bus 3 Bus 2 to Bus 4 Bus 2 to Bus 5 MW MVAR MW MVAR MW MVAR MW MVAR -38.77902 -3.46713 18.46534 -4.95901 -24.68632 -6.57385 0.00000 0.00000 ---------------------Bus 3 to Bus 1 Bus 3 to Bus 2 Bus 3 to Bus 4 Bus 3 to Bus 5 MW MVAR MW MVAR MW MVAR MW MVAR 0.00000 0.00000 -18.43136 2.96567 -27.76769 -5.75992 6.19905 -2.20575 ---------------------Bus 4 to Bus 1 Bus 4 to Bus 2 Bus 4 to Bus 3 Bus 4 to Bus 5 MW MVAR MW MVAR MW MVAR MW MVAR -83.2257 3.7487 25.0466 3.3656 28.2172 2.8222 54.9618 7.2852 ---------------------Bus 5 to Bus 1 Bus 5 to Bus 2 Bus 5 to Bus 3 Bus 5 to Bus 4 MW MVAR MW MVAR MW MVAR MW MVAR 0.00000 0.00000 0.00000 0.00000 -6.16955 -2.91159 -53.83045 -7.08841 ========================================================================================= octave:9> diary off

Appendix B Solving 5-bus System on Mobile Device Using Octave !

39

ENGI-0438-WA
octave:3> startupFxn();

Electrical Engineering Dept.

Lakehead University

Hello, Octave is at your disposal!! Root Folder set to: ans = /storage/sdcard0/Octave Startup Menu: [ 1] Run 5 Bus Scripts [ 2] Just use Octave pick a number, any number: 1 5-Bus Analysis: [ 1] Normal Operation [ 2] Remove a Line [ 3] Exit pick a number, any number: 2 Which Line to remove? [ [ [ [ [ [ [ 1] 2] 3] 4] 5] 6] 7] 1 1 2 2 3 3 4 2 4 3 4 4 5 5

pick a number, any number: 2 Line Between Buses 1 and 4 Removed... iter = 1 Voltages = 1.06000 1.02647 1.02571 1.04700 1.01986 iter = 2 Voltages = 1.06000 1.01122 1.01288 1.04700 1.01418 iter = 3 Voltages = 1.06000 1.01089 1.01260 1.04700 1.01407 iter = 4 0.00000 -17.73117 -18.95003 -19.82866 -22.07648 0.00000 -17.68606 -18.90185 -19.77142 -22.02148 0.00000 -16.66582 -17.84045 -18.45844 -20.83877

Appendix B Solving 5-bus System on Mobile Device Using Octave !

40

ENGI-0438-WA
Voltages = 1.06000 1.01089 1.01260 1.04700 1.01407 iter = 5 Voltages = 1.06000 1.01089 1.01260 1.04700 1.01407 0.00000 -17.73122 -18.95008 -19.82872 -22.07654 0.00000 -17.73122 -18.95008 -19.82872 -22.07654

Electrical Engineering Dept.

Lakehead University

ENGI 0438 - 5 Bus Final Answers (buses 1 thru 5): =============================================================================== V(pu) Angle(rad) P Gen(MW) Q Gen(MVAR) P Load(MW) Q Load(MVAR) =============================================================================== 1.06000 0.00000 135.24773 -8.36134 0.00000 0.00000 1.01089 -17.73122 0.00000 0.00000 45.00000 15.00000 1.01260 -18.95008 0.00000 0.00000 40.00000 5.00000 1.04700 -19.82872 45.00000 33.23364 20.00000 -20.00000 1.01407 -22.07654 0.00000 0.00000 60.00000 10.00000 =============================================================================== System Power Totals: ======================================================================== P Gen(MW) P Load(MW) Q Gen(MVAR) QLoad(MVAR) Loss(MW) Loss(MVAR) 180.2477 165.0000 24.8723 10.0000 15.2477 14.8723 ======================================================================== Line Flow: ========================================================================================= Bus 1 to Bus 2 Bus 1 to Bus 3 Bus 1 to Bus 4 Bus 1 to Bus 5 MW MVAR MW MVAR MW MVAR MW MVAR 135.24773 -4.99054 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 ---------------------Bus 2 to Bus 1 Bus 2 to Bus 3 Bus 2 to Bus 4 Bus 2 to Bus 5 MW MVAR MW MVAR MW MVAR MW MVAR -122.22053 38.70842 63.81787 -27.30989 13.40266 -26.39853 0.00000 0.00000 ---------------------Bus 3 to Bus 1 Bus 3 to Bus 2 Bus 3 to Bus 4 Bus 3 to Bus 5 MW MVAR MW MVAR MW MVAR MW MVAR 0.00000 0.00000 -63.35169 26.66114 2.34484 -22.11251 21.00686 -9.54864 ---------------------Bus 4 to Bus 1 Bus 4 to Bus 2 Bus 4 to Bus 3 Bus 4 to Bus 5 MW MVAR MW MVAR MW MVAR MW MVAR 0.00000 0.00000 -12.94892 23.52354 -2.10611 18.58553 40.05503 14.41319 ---------------------Bus 5 to Bus 1 Bus 5 to Bus 2 Bus 5 to Bus 3 Bus 5 to Bus 4 MW MVAR MW MVAR MW MVAR MW MVAR 0.00000 0.00000 0.00000 0.00000 -20.62449 5.56145 -39.37551 -15.56145 ========================================================================================= octave:4> diary off

Appendix B Solving 5-bus System on Mobile Device Using Octave !

41

ENGI-0438-WA

Electrical Engineering Dept.

Lakehead University

The code used to generate the automated user-interactive script and solutions (startupFxn()) is included below:
% startupFxn.m % used to automate 5-bus solving on octave (can be used on mobile devices) % author: Joey Mercier function startupFxn() disp(""); disp("Hello, Octave is at your disposal!!"); % display welcome message disp("Root Folder set to:"); % display mobile directory used pwd sel = menu('Startup Menu:', 'Run 5 Bus Scripts', 'Just use Octave'); if (sel == 1) disp(""); sel2 = menu('5-Bus Analysis:', 'Normal Operation', 'Remove a Line', 'Exit'); if (sel2 == 1) report_5bus(Y5bus(),1,1); % normal operation elseif (sel2 == 2) disp(""); sel3 = menu('Which Line to remove?', '1 - 2', '1 - 4', '2 - 3', '2 - 4', '3 4', '3 - 5', '4 - 5'); switch (sel3) case 1 disp("Line Between Buses 1 and 2 Removed..."); report_5bus(removeLine(1,2),1,2) % remove line between 1 and 2 case 2 disp("Line Between Buses 1 and 4 Removed..."); report_5bus(removeLine(1,4),1,4) % remove line between 1 and 4 case 3 disp("Line Between Buses 2 and 3 Removed..."); report_5bus(removeLine(2,3),2,3) % remove line between 2 and 3 case 4 disp("Line Between Buses 2 and 4 Removed..."); report_5bus(removeLine(2,4),2,4) % remove line between 2 and 4 case 5 disp("Line Between Buses 3 and 4 Removed..."); report_5bus(removeLine(3,4),3,4) % remove line between 3 and 4 case 6 disp("Line Between Buses 3 and 5 Removed..."); report_5bus(removeLine(3,5),3,5) % remove line between 3 and 5 case 7 disp("Line Between Buses 4 and 5 Removed..."); report_5bus(removeLine(5,4),5,4) % remove line between 4 and 5 otherwise disp("incorrect selection..."); return; endswitch elseif (sel2 == 3) return; endif else return; endif

Appendix B Solving 5-bus System on Mobile Device Using Octave !

42

ENGI-0438-WA

Electrical Engineering Dept.

Lakehead University

Figure 13: Screen Captures of 5-bus Code Running in Octave on an Android Powered Mobile Device

Appendix B Solving 5-bus System on Mobile Device Using Octave !

43

Você também pode gostar