Open access peer-reviewed chapter

Electric Power System Simulator Tool in MATLAB

By Mohamad Arnaout, Rabih Rammal and Samih Abdulnabi

Submitted: October 4th 2016Reviewed: April 3rd 2017Published: October 11th 2017

DOI: 10.5772/intechopen.68955

Downloaded: 1399


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.”


  • GUI
  • Newton‐Raphson
  • unsymmetrical faults
  • economic dispatch

1. 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.


2. 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, line‐to‐line fault, and double line‐to‐ground fault, (ii) the Newton‐Raphson method, and (iii) the economic dispatch.

2.1. 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.

Figure 1.

Schematic representation of unsymmetrical fault.

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].

2.1.1. 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].

2.1.2. 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.

Figure 2.

Coupling sequence network for line‐to‐ground fault.

2.1.3. 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: Ia=Ia+,Va+=Va+Ia+Zf,Ia0=0, the positive and negative sequence networks must be connected in parallel (Figure 3).

Figure 3.

Coupling sequence network for line‐to‐line fault.

2.1.4. 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.

Figure 4.

Coupling sequence network for a double line‐to‐ground fault.


To satisfy: Ia=Ia0+Ia++Ia=0, and Va+=Va, the three symmetrical circuits during a double line‐to‐ground fault are connected as follows:

2.2. 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]:

  • Vi: voltage magnitude

  • δi: voltage angle

  • Pi: net active power

  • Qi: net reactive power

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: Piand Qiare specified; Viand δiare calculated.

  • PV bus: Piand Viare specified; Qiand δiare 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: Viand δiare specified; Piand Qiare 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 Zand the total line‐charging admittance Yare necessary so that the computer can determine all the elements of the N× Nbus admittance matrix of which the typical element Yijis:


The voltage at any bus of the system is given by:


The net current injected to bus iis given by:


The net scheduled power being injected into the network at bus iis:


where Pgiis the scheduled power being generated at bus i, and Pdiis 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.

Bus typeNumber of busesQuantities specifiedNumber of available equationsNumber of δi, |Vi|state variables
Slack (i= 1)1δi, |Vi|00
PV (i= 2,…, Ng + 1)NgPi, |Vi|NgNg
PQ (i= Ng + 2,…,N)N‐Ng‐1Pi, Qi2(N‐Ng‐1)2(N‐Ng‐1)

Table 1.

The number of equations and state variables of power flow problem.

2.2.1. 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 [46]:

  • Estimate values δi(0)and |Vi|(0)for the state variables.

  • Use the estimates to calculate: Pi,calc.(0)and Qi,calc.(0), from (5) and (6).

  • Mismatches ΔPi(0)and ΔQi(0)from (11) and (12).

  • 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 δi(0)and Δ|Vi|(0)/|Vi|(0).

  • Add the solved corrections to the initial estimates to obtain:


Use the new values δi(1)and |Vi|(1)as starting values for iteration and then continue.

In more general terms, the updated formulas for starting values of the state variables are:


2.3. 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 Fas an input and its electrical power generated as an output. Therefore, the total system cost is represented by FT, 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.

Figure 5.

Thermal units committed to serve electrical load.

The main objective from the economic dispatch concept is to minimize FTwith 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 Pifor each Nunits and λ). In addition, the constraint equation is obtained by the derivative of the Lagrange function by Piwith respect to λ[911]:




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:

dFidPi=λ     Ngen equationsE26
Pi,minPiPi,max       2Ngen equationsE27
i=1NPi=Pload        1 constraintE28

When we recognize the inequality constraints, then the necessary conditions may be expanded slightly as shown in the set of equations:

dFidPi=λforPi,minPiPi,max E29

3. Flow chart

3.1. 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.

Figure 6.

Flow chart for the unsymmetrical faults.

3.2. 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.

Figure 7.

Flow chart for the power flow calculation.

3.3. Economic dispatch case

The execution of economic dispatch procedure depends on several parameters. Figure 8 shows the flow chart of this phenomenon.

  • Define the number of units (P1,P2,P3Pn).

  • Precise the lower and upper bounds of each unit.

  • Determine the total demand load and the fuel cost ($/MBtu).

  • Introduce the cost function ($/h) or heat rate function (MBtu/h).

  • Calculate the incremental cost rate λ($/MWhr).

  • Estimate the cost function ($/h) or heat rate function (MBtu/h).

  • Compute the economic operating point using Lagrange and the efficiency.

Figure 8.

Flow chart for the economic dispatch.

4. 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].

Figure 9.

Main display page of the electric power simulator tool.

4.2. Unsymmetrical fault analysis implementation

As the user chooses the first method, which is the “Fault Calculation,” the interface shown in Figure 10 appears [13].

Figure 10.

Unsymmetrical faults interface.

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.

Figure 11.

Unsymmetrical faults output interface.

Finally, each result (Ybus, Zbus, Vbus, and Ibus) for both sequence and phase configuration is saved in a separated text file.

4.3. Power flow implementation

As the user chooses the first method, which is the “Power Flow Calculation,” Figure 12 appears [13].

Figure 12.

Power flow solution interface.

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.

Figure 13.

Power flow solution output interface.

4.4. Economic dispatch implementation

As the user chooses the first method, which is the “Power Flow Calculation,” Figure 14 will appear [13].

Figure 14.

Economic dispatch interface.

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.

Figure 15.

Economic dispatch output interface.

5. 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.

© 2017 The Author(s). Licensee IntechOpen. This chapter is distributed under the terms of the Creative Commons Attribution 3.0 License, which permits unrestricted use, distribution, and reproduction in any medium, provided the original work is properly cited.

How to cite and reference

Link to this chapter Copy to clipboard

Cite this chapter Copy to clipboard

Mohamad Arnaout, Rabih Rammal and Samih Abdulnabi (October 11th 2017). Electric Power System Simulator Tool in MATLAB, Science Education - Research and New Technologies, Antonio Vanderlei Dos Santos and Joao Carlos Krause, IntechOpen, DOI: 10.5772/intechopen.68955. Available from:

chapter statistics

1399total chapter downloads

1Crossref citations

More statistics for editors and authors

Login to your personal dashboard for more detailed statistics on your publications.

Access personal reporting

Related Content

This Book

Next chapter

Software for Simulation of Static Switch Controllers

By Marius-Daniel Marcu, Popescu Florin Gabriel and Niculescu Titu

Related Book

First chapter

Introduction to Infrared Spectroscopy

By Theophile Theophanides

We are IntechOpen, the world's leading publisher of Open Access books. Built by scientists, for scientists. Our readership spans scientists, professors, researchers, librarians, and students, as well as business professionals. We share our knowledge and peer-reveiwed research papers with libraries, scientific and engineering societies, and also work with corporate R&D departments and government entities.

More About Us