Electric Power System Simulator Tool in MATLAB Electric Power System Simulator Tool in MATLAB

An electric power system is a network of electrical components used to supply, transmit, and use electric power. An example of an electric power system is the network that supplies a region ’ s homes and industry with power. Due to the complexity and nonlinearity of the power system, hand calculations may be very complicated in some cases, especially when the number of buses or inputs is very large. Here comes the role of software for convergence, time saving, and accuracy. The “ Electric Power System Simulator ” focuses on three main concepts in power system analysis, the “ Power Flow Calculation, ” “ Faults Calculation, ” and “ Economic Dispatch Calculation. ”


Introduction
There are two classes of power system simulation tools analysis: commercial and educational programs. Several commercial programs are available in the market (Power World Simulator, Power System Simulator …). These tools present efficient computational programs for analysis. However, they are inadequate for research and education intentions. This drawback is present because they do not authorize the modification of algorithms or adding new models. For research and education goals, flexibility, and simplicity are more important than computation. Due to several educational and research features, MATLAB becomes one of the efficient and adequate programs in many scientific domains and especially in power systems.
This chapter describes a new MATLAB power system analysis toolbox that uses capabilities of MATLAB in numeric computations to investigate fault calculation, power flow, and economic dispatch of a given power systems. This tool is developed to help students in their education and research studies. In addition, it was included in the curriculum for the graduate electrical engineering students in the Lebanese International University. Since its adoption, students show better understanding of these concepts. In addition, they were able to enhance their basic knowledge and improve their way of thinking.

Power system analysis methods
An electric power system is sometimes very complex to analyze using hand calculations especially, if there are nonlinear equations, and a high number of buses. Human can deal with little number of buses, and if the number of buses is high, the hand calculations are very complex. In the Newton-Raphson method, computer software may solve up to 100,000 or 150,000 buses in very short time, and more accurate when converging to the final solution obeying a specified level of tolerance. For the unbalanced faults, one must calculate the sequence and phase of voltages and currents depending on the type of fault, but computer software will calculate these values within few milliseconds and very accurately. Finally, for the economic dispatch, the value of the incremental cost and the generated powers will change as the value of the demand changes. Thus, the software performs several calculations as the load changes.
The MATLAB tool we are preparing performs several objectives through many power systems methods including: (i) the unsymmetrical faults analysis including line-to-ground fault, lineto-line fault, and double line-to-ground fault, (ii) the Newton-Raphson method, and (iii) the economic dispatch.

Unsymmetrical faults analysis
Short circuits occur in three-phase power systems as follows, in order of frequency of occurrence: single line-to-ground, double line-to-ground, and balanced three-phase faults. The path of the fault current may have either zero impedance, which is called bolted short circuit, or nonzero impedance.
When an unbalanced fault occurs in an otherwise balanced system, the sequence networks are interconnected only at the fault location ( Figure 1). As such, the computation of fault currents is greatly simplified by the use of sequence networks. As in the case of balanced three-phase faults, unsymmetrical faults have two components of fault current: an AC or symmetrical components including sub-transient, transient, and steady-state currents, and a dc component [1,2].

Unbalanced faults analysis
• Single line-ground (SLG) and line-line (LL) are the principle types of faults in a power system. In addition, other types of faults, such as double line-ground (DLG), open conductor, and balanced three phases, could be studied.
• The fault of an unbalanced system is estimated using the concept of symmetrical components [3,4].

Single line-to-ground (SLG) faults
Unbalanced faults will disturb the balancing of the network at the fault location. Therefore, the sequence network should be combined together with respect to the type of fault. A detailed derivation of these relationships will be discussed through this paragraph [3].
The terminal voltage at phase "a" can be transformed into its sequence components as: The only way that these two constraints can be satisfied is by coupling the sequence networks in series as shown in Figure 2.

Line-to-line (LL) faults
The second most common fault is line-to-line, which occurs when two of the conductors come in contact with each other [3].
To satisfy: , the positive and negative sequence networks must be connected in parallel ( Figure 3).

Double line-to-ground (DLG) faults
With a double line-to-ground (DLG) fault, two line conductors come in contact both with each other and ground [3] as shown in Figure 4.
To satisfy: the three symmetrical circuits during a double line-to-ground fault are connected as follows:

Power flow problem
The estimation of the power flow problem can be expressed using an adequate series of nonlinear equations. These equations represent both Kirchhoff's Voltage Law and network operation limits. The assessment of the power flow problem is based on four variables for each "i" bus (network node) [4]:   Depending on which of the above four variables are known (given) and which ones are unknown (to be calculated), two basic types of buses can be defined: • PQ bus: P i and Q i are specified; V i and δ i are calculated.
• PV bus: P i and V i are specified; Q i and δ i are calculated.
PQ buses are normally used to represent load buses without voltage control, and PV buses are used to represent generation buses with voltage control in power flow calculations. A third bus is also needed: • Vδ bus: V i and δ i are specified; P i and Q i are calculated.
The Vδ bus, also called reference bus or slack bus, has double functions in the basic formulation of the power flow problem: • It serves as the voltage angle reference.
• Since the active power losses are unknown in advance, the active power generation of Vδ bus is used to balance generation, load, and losses [5,6].
The polar form of the power flow equations is given by: For each line, numerical values for the series impedance Z and the total line-charging admittance Y are necessary so that the computer can determine all the elements of the N Â N bus admittance matrix of which the typical element Y ij is: The voltage at any bus of the system is given by: The net current injected to bus i is given by: The net scheduled power being injected into the network at bus i is: where P gi is the scheduled power being generated at bus i, and P di is the scheduled power demand.
The mismatch value of the power is given by: Similarly, for the reactive power at bus i: Table 1 lists the general number of equations and the state variables in function of the number of buses.

Newton-Raphson method applied to power flow study
In all realistic cases, the power flow problem cannot be solved analytically, and hence iterative solutions implemented in computers must be used. Here, we are going to discuss the Newton-Raphson method.
To apply the Newton-Raphson method to the solution of the power flow equations, we express bus voltages and line admittances in polar form as follows: Collecting all the mismatch equations into vector-matrix form yields: The solution of the above equation is found by an iterative method as follows [4][5][6]: • Estimate values δ 0 ð Þ i and jV i j 0 ð Þ for the state variables.
• Partial derivatives elements of the Jacobian matrix.
• Solve the above equation of the Jacobian matrix, the corrections, and the mismatches to find the initial corrections δ 0 ð Þ i and ΔjV i j ð0Þ =jV i j ð0Þ .
• Add the solved corrections to the initial estimates to obtain: Use the new values δ 1 ð Þ i and jV i j 1 ð Þ as starting values for iteration and then continue.
In more general terms, the updated formulas for starting values of the state variables are:

Economic dispatch
This section is dedicated to study the economic dispatch concept. For this reason, we consider the system configuration shown is Figure 5. This configuration based on N thermal units serving as a source of generation that would deliver the suitable electric power to the load.  Each unit has the cost rate F as an input and its electrical power generated as an output. Therefore, the total system cost is represented by F T , which is the sum of each unit cost rate. The fundamental condition of this system considers that the total output powers should be equal to total power demand.
The main objective from the economic dispatch concept is to minimize F T with respect to the considered constraints. Note that any transmission losses are neglected and any operating limits are not explicitly stated when formulating this problem [7,8]. That is, This type of optimization system is solved using the Lagrange concept. The extreme value condition of the objective function is determined using the multiplication of the constraint by a constant and adding this factor to the objective function as shown below: The paramount conditions needed to determine the highest value of the objective function are based on the derivative of the Lagrange function with respect to the independent variables of each unit. These derivatives should be equal to 0. Consequently, there will be N þ l variables (value of P i for each N units and λ). In addition, the constraint equation is obtained by the derivative of the Lagrange function by P i with respect to λ [9][10][11]: With respect to the above-mentioned condition, the minimum operating cost is established when all incremental unit cost are equal to λ. The final step for this procedure is pointed out by the addition of the power demand constraint and the limitation value (minimum and maximum) of each power output unit (inequality constraint) [12].
These constraints are summarized below: When we recognize the inequality constraints, then the necessary conditions may be expanded slightly as shown in the set of equations: 3. Flow chart

Unsymmetrical faults case
The implementation of the unsymmetrical faults analysis in MATLAB is based on the following flow chart ( Figure 6): • Define the zero, positive, and negative impedance matrices.
• Define the pre-fault voltage and the faulted impedance. • Select the type of fault.
• Calculate the admittance and impedance matrices of the power system.
• Calculate the sequence current and voltage for the selected fault.
• Calculate the phase voltages and currents for all buses or the faulted buses.
• Save all results in a text file.

Power flow case
Power flow solution is estimated using the Newton-Raphson method. The fulfillment of this method is achieved using an adequate flowchart ( Figure 7): • Define the number of buses.   • Determine the resistance, admittance, and the power specification of each bus.
• Assign the initial values of the variables.
• Find the mismatches and Jacobian matrix.
• Find the unknown variables.
• Verify the accuracy of the calculation.
• Calculate the real and imaginary power in each bus and line.
• Calculate the real and imaginary power losses in each bus and line.
• Save the power flow solution report in a text file.

Economic dispatch case
The execution of economic dispatch procedure depends on several parameters. Figure 8 shows the flow chart of this phenomenon.
• Precise the lower and upper bounds of each unit.
• Determine the total demand load and the fuel cost ($/MBtu).
• Compute the economic operating point using Lagrange and the efficiency.

MATLAB implementation 4.1. Main display page
The main display page of the MATLAB tool gives the choice for the user to choose between one of the three methods as shown in Figure 9 [13].

Unsymmetrical fault analysis implementation
As the user chooses the first method, which is the "Fault Calculation," the interface shown in Figure 10 appears [13].
The principle of unsymmetrical faults method throughout the "Power System Simulator" software can be made through two modes: • Mode 1: The user enters all the data manually.
• Mode 2: The user loads the data from a specified file.
Results will show the following: The Ybus and Zbus, the figure of the faults, and the output data (current and voltage) in sequence and phase domain as shown in Figure 11.  Finally, each result (Ybus, Zbus, Vbus, and Ibus) for both sequence and phase configuration is saved in a separated text file.

Power flow implementation
As the user chooses the first method, which is the "Power Flow Calculation," Figure 12 appears [13].
The principle of the Newton-Raphson method throughout the "Power System Simulator" software can be made through two modes: • Mode 1: The user enters all the data manually.
• Mode 2: The user loads the data from a specified file.
Two table results are now filled, the first one is the load flow analysis, and the second is the line flow and losses as shown in Figure 13.

Economic dispatch implementation
As the user chooses the first method, which is the "Power Flow Calculation," Figure 14 will appear [13]. The principle of the economic and optimal dispatch method throughout the "Power System Simulator" software can be made through two modes: • Mode 1: The user enters all the data manually.
• Mode 2: The user loads the data from a specified data.  In case of over or under limit estimation, the tool will provide a notification and the number or this unit to the user as shown in Figure 15.

Conclusions
This chapter considers an appropriate guide for electrical engineers students who specialized in power systems analysis and design. The above-mentioned paragraphs give to them an adequate MATLAB tool in order to facilitate the comprehension of some concept.
These concepts can solve a lot of problems such as power flow solution, unsymmetrical faults analysis, and economic dispatch with or without constraints.
They could also be adopting this tool for their practical studies without any complexity because it is related with their own theoretical knowledge.