Sei sulla pagina 1di 17

Power System Design Lab BTEE_806

Name:-Ajay Kumar University Reg. No.-1604372 Class Roll No. 304/16


Experiment No. 1
NAME: Introduction to MATLAB & Simulink

MATLAB is a programming language developed by MathWorks. It started out as a matrix


programming language where linear algebra programming was simple. MATLAB (matrix
laboratory) is a fourth-generation high-level programming language and interactive
environment for numerical computation, visualization and programming. It allows matrix
manipulations; plotting of functions and data; implementation of algorithms; creation of user
interfaces; interfacing with programs written in other languages, including C, C++, Java, and
FORTRAN; analyze data; develop algorithms; and create models and applications. It has
numerous built-in commands and math functions that help you in mathematical calculations,
generating plots, and performing numerical methods.
Features of MATLAB
 It is a high-level language for numerical computation, visualization and application
development.
 It also provides an interactive environment for iterative exploration, design and
problem solving.
 It provides vast library of mathematical functions for linear algebra, statistics, Fourier
analysis, filtering, optimization, numerical integration and solving ordinary
differential equations.
 It provides built-in graphics for visualizing data and tools for creating custom plots.
 MATLAB's programming interface gives development tools for improving code
quality maintainability and maximizing performance.
 It provides tools for building applications with custom graphical interfaces.
 It provides functions for integrating MATLAB based algorithms with external
applications and languages such as C, Java, .NET and Microsoft Excel.

Uses of MATLAB
MATLAB is widely used as a computational tool in science and engineering encompassing
the fields of physics, chemistry, math and all engineering streams. It is used in a range of
applications including −

 Signal Processing and Communications


 Image and Video Processing
 Control Systems
 Test and Measurement
 Computational Biology

B.TECH(Electrical Engineering) 2 DAVIET


Power System Design Lab BTEE_806
Name:-Ajay Kumar University Reg. No.-1604372 Class Roll No. 304/16
MATLAB has evolved over a period of years with input from many users. In university
environments, it is the standard instructional tool for introductory and advanced courses
in mathematics, engineering, and science. In industry, MATLAB is the tool of choice
for high-productivity research, development, and analysis. It has excellent
programming features and graphics capability – easy to learn and flexible. Available in
many operating systems – Windows, Macintosh, Unix, DOSIt has several tooboxes to
solve specific problems.

Example of MATLAB Desktop View

MATLAB is an interactive program for numerical computation and data visualization. We


can enter a command by typing it at the MATLAB prompt '>>' on the Command Window.
Commands for Managing a Session
MATLAB provides various commands for managing a session. The following table provides
all such commands −

Command Purpose

clc Clears command window.

clear Removes variables from memory.

exist Checks for existence of file or variable.

help Searches for a help topic.

Vector, Matrix and Array Commands

B.TECH(Electrical Engineering) 3 DAVIET


Power System Design Lab BTEE_806
Name:-Ajay Kumar University Reg. No.-1604372 Class Roll No. 304/16
The following table shows various commands used for working with arrays, matrices and
vectors −

Command Purpose

max Returns largest element.

min Returns smallest element.

prod Product of each column.

size Computes array size.

sum Sums each column.

eye Creates an identity matrix.

ones Creates an array of ones.

zeros Creates an array of zeros.

cross Computes matrix cross products.

dot Computes matrix dot products.

det Computes determinant of an array.

inv Computes inverse of a matrix.

Plotting Commands
MATLAB provides numerous commands for plotting graphs. The following table shows
some of the commonly used commands for plotting −

Command Purpose

axis Sets axis limits.

B.TECH(Electrical Engineering) 4 DAVIET


Power System Design Lab BTEE_806
Name:-Ajay Kumar University Reg. No.-1604372 Class Roll No. 304/16

fplot Intelligent plotting of functions.

grid Displays gridlines.

plot Generates xy plot.

print Prints plot or saves plot to a file.

title Puts text at top of plot.

figure Opens a new figure window.

The M Files
MATLAB allows writing two kinds of program files −
 Scripts − script files are program files with .m extension. In these files, you write
series of commands, which you want to execute together. Scripts do not accept inputs
and do not return any outputs. They operate on data in the workspace.
 Functions − functions files are also program files with .m extension. Functions can
accept inputs and return outputs. Internal variables are local to the function.

Experiment No. 2

B.TECH(Electrical Engineering) 5 DAVIET


Power System Design Lab BTEE_806
Name:-Ajay Kumar University Reg. No.-1604372 Class Roll No. 304/16
NAME:-Introduction to MATLAB & Simulink
Simulink (Simulation and link) is developed by MathWorks as an add-on with MATLAB. It
is a graphical programming language which offers modelling, simulation and analyzing
of multi domain dynamic systems under Graphical User Interface (GUI) environment.
The Simulink have tight integration with the MATLAB environment and have a
comprehensive block libraries and toolboxes for linear and nonlinear analyses. The
system models can be so easily constructed via just click and drag operations. The
Simulink comes handy while dealing with control theory and model based design.
After the MATLAB is opened Simulink session can be started in 2 ways
 In the MATLAB command window enter the command >> simulink

 The alternate method is to click the Simulink icon in the MATLAB toolbar

A Simulink library window will pop up as shown below :

 The Library Browser contains various toolboxes in left side and corresponding
utilities and blocks on the right side

To start creating a model go to File –> New or alternatively Ctrl+N. A Work space / Model
window will pop up as shown below :

B.TECH(Electrical Engineering) 6 DAVIET


Power System Design Lab BTEE_806
Name:-Ajay Kumar University Reg. No.-1604372 Class Roll No. 304/16

Model window
This is the place where you work on with. Creating models and simulating it, all this will be
done here. The user just have to click and drag appropriate blocks from the library browser on
to the Work space/Model window.

Creating a Model - To create a simple model of integrating a sine wave and display both the
input sine wave and the integral form. To create this model we need,

1. A sine wave signal source


2. Integrator
3. A Multiplexer, as i need to display the 2 signals in the Display screen. Note that the
display screen called ‘scope’ has only 1 channel. So either to show 2 signals we have
to use a mux or we have to use 2 screen blocks
4. A display screen

STEP 1 : Selecting Blocks

 For a sine wave sources

Simulink –>Sources –> Select sine wave from the list

 For Integrator

Simulink –>Continuous–>Select integrator from the block list

 For Multiplexer

Simulink –>Signal routing –> Select Mux from the list

B.TECH(Electrical Engineering) 7 DAVIET


Power System Design Lab BTEE_806
Name:-Ajay Kumar University Reg. No.-1604372 Class Roll No. 304/16
 For Display - Simulink –>Sink –> Scope

STEP 2: Block Creation & Making Connections

Select and drag all components to the model window and make connections:

 For making connections first select the input port and ‘+’ symbol will appear and drag
the cursor to the output port ‘>’ symbol on the block.

 Sine Wave Integrator Model

STEP 3: Running Simulation

As the connections are made now your model is ready for running. Click on play button in
the model window. Alternatively Ctrl+T or Simulation –>Start in the model window can be
used to run the simulation model. To view the result double click on the Scope block which is
our display screen.

OUTPUT :

B.TECH(Electrical Engineering) 8 DAVIET


Power System Design Lab BTEE_806
Name:-Ajay Kumar University Reg. No.-1604372 Class Roll No. 304/16

EXPERIMENT NO:- 3
NAME: To Formulate YBUS Matrix By Singular Transformation.

SOFTWARE USED: MATLAB 7.9.0 (R 2009b)

THEORY: Y Bus is called the short circuit admittance matrix or the nodal admittance
matrix, with the elements of the matrix known as the driving point and transfer admittance. It
is also known as bus admittance matrix.
Since in a power network each bus is connected only to a few other buses (two or three), the
Y bus of a large network is very sparse ,i.e, it has a large number of zeroes. The Y bus is often
used in solving load flow problems. It has gained widespread applications due to its
simplicity in data preparation, ease of formation and modification for network changes. Due
to its scarcity it heavily reduces computer memory and time requirements.
Flow Chart:-

MATLAB CODE:

B.TECH(Electrical Engineering) 9 DAVIET


Power System Design Lab BTEE_806
Name:-Ajay Kumar University Reg. No.-1604372 Class Roll No. 304/16

ydata=[1 1 2 1/(0.05+j*0.15) 0 0
2 1 3 1/(90.1+j*0.30) 0 0
3 2 3 1/(0.15+j*0.45) 0 0
4 2 4 1/(0.10+j*0.30) 0 0
5 3 4 1/(0.05+j*0.15) 0 0];
elements=max( ydata(:,1));
yprimitive=zeros(elements,elements);
for i=1:elements
yprimitive(i,i)=ydata(i,4);
if(ydata(i,5)~=0)
j=ydata(i,5);
ymutual=ydata(i,6);
yprimitive(i,j)=ymutual;
end
end
buses=max(max(ydata(2,:)),max(ydata(3,:)));
A=zeros(elements,buses);
for i=1:elements
if ydata(i,2)~=0
A(i,ydata(i,2))=1;
end
if ydata(i,3)~=0
A(i,ydata(i,3))=-1;
end
end
YBUS=A'*yprimitive*A

OUTPUT :

B.TECH(Electrical Engineering) 10 DAVIET


Power System Design Lab BTEE_806
Name:-Ajay Kumar University Reg. No.-1604372 Class Roll No. 304/16

RESULT:
The MATLAB program has been written to form the Bus Admittance Matrix (Y BUS) of a
given network.

B.TECH(Electrical Engineering) 11 DAVIET


Power System Design Lab BTEE_806
Name:-Ajay Kumar University Reg. No.-1604372 Class Roll No. 304/16

EXPERIMENT NO: 4

NAME: To Formulate ZBUS Matrix By Singular Transformation.

SOFTWARE USED: MATLAB 7.9.0 (R 2009b)

THEORY:

Rule 1: Addition of a tree branch to the reference

Start with the branches connected to the reference node. Addition of a branch ‘zqo’ between a
node ‘q’ and the reference node ‘o’ to the given Z newbus matrix of order (m*m), results in the
Znewbus matrix of order (m+1)*(m+1).

Z11 …. Z1m 0

Znewbus = : …. 0 0

0 …. Zmm 0

0 …. 0 zqo

Where,

z= impedance of an element.

This matrix is diagonal with the impedances values of the branch on the diagonal.

Rule 2: Addition of a tree branch from a new bus to an old bus

Continue with the remaining branches of the tree connecting a new node to the existing node.
Addition of a branch zpq between a node ‘q’ and the existing node ‘p’ to the given zoldbus matrix
of order (m*m), results in the Znewbus matrix of order (m+1)*(m+1).

Z11 …. Z1p …. Z1m …. Z1p

: : : : : : :

Znewbus = Zp1 …. Zpp …. Zpm …. Zpp

B.TECH(Electrical Engineering) 12 DAVIET


Power System Design Lab BTEE_806
Name:-Ajay Kumar University Reg. No.-1604372 Class Roll No. 304/16
: : : : : : :

Zm1 …. Zmp …. Zmm …. Zmp

Zp1 …. Zpp …. Zpm …. Zpp+zpq

Rule 3: Addition of a Co-tree link between two existing buses

When a link with impedances zpq is added between two existing nodes ‘p’ and ‘q’, we
augment the Zoldbus matrix with a new row and a new column.

Z11 Z1p Z1q .…. Z1m Z1q - Z1p

: : : : : :

Znewbus = Zp1 Zpp Zpq .…. Zpm Zpq - Zpp

: : : : : :

Zm1 Zmp Zmq .…. Zmm Zmq - Zmp

Zq1 - Zp1 Zqp - Zpp Zqq - Zpq .…. Zqm – Zpm Z11

Where ,

Z11= Zpq + Zpp + Zqq - 2Zpq

The new row and column is eliminated using the relation,

Znewbus = Zoldbus – (∆Z∆ZT/Z11)

and ∆Z is defined as,

Z1q – Z1p

Zpq – Zqp

∆Z = Zqq – Zqp

Zmq – Zmp

When bus ‘q’ , is the reference bus, Zqi = Ziq = 0 (for i = 1,m) and the above matrix reduces to
Znewbus as shown ahead:

B.TECH(Electrical Engineering) 13 DAVIET


Power System Design Lab BTEE_806
Name:-Ajay Kumar University Reg. No.-1604372 Class Roll No. 304/16

Z11 …. Z1p …. Z1m –Z1p

: : : : : :

Zp1 …. Zpp …. Zpm –Zpp

Znewbus = : : : : : :

Zm1 …. Zmp …. Zmm –Zmp

–Zp1 ….. –Zpp …… –Zpm Z11

Where, Z11 = zpq +Zpp, and

-Z1p

∆Z = -Zpp

-Zmp

ALGORITHM:

 Start with the branches connected to the reference node using Rule 1.

 Continue with the remaining branches of the tree connecting a new node to the
existing node using Rule 2.

 Add the link with impedance zpq between two existing nodes ‘p’ and ‘q’ using Rule 3.

 Check whether all elements connected, if not go to step (1) and continue.

 Print the ZBUS Matrix.

MATLAB CODE:

clc;
clear all;
close all;
% From To R X Link identification
% Bus Bus p.u p.u Link=1 branch=0
linedata= [0 2 0 0.2 0
3 0 0 0.4 0

B.TECH(Electrical Engineering) 14 DAVIET


Power System Design Lab BTEE_806
Name:-Ajay Kumar University Reg. No.-1604372 Class Roll No. 304/16
2 2 0 0.8 1
1 1 0 0.4 0
3 2 0 0.4 1];

nl=linedata(:,1);
nr=linedata(:,2);
R=linedata(:,3);
X=linedata(:,4);
l1=linedata(:,5);
nbr=length(nl);
nbus=max(max(nl),max(nr));
ZB=R+1i*X;
Zbus=zeros(nbus,nbus);
% Rule-1
for I=1:nbr
if nl(I)==0 || nr(I)==0
if nl(I)==0
K=nr(I);
elseif nr(I)==0

OUTPUT:

RESULT:

The MATLAB program has been written to form the Bus Impedance Matrix (Z BUS) for a
given network.

B.TECH(Electrical Engineering) 15 DAVIET


Power System Design Lab BTEE_806
Name:-Ajay Kumar University Reg. No.-1604372 Class Roll No. 304/16

EXPERIMENT NO: 5

NAME: Load flow analysis by Newton-Raphson Method.

SOFTWARE USED: MATLAB 7.9.0 (R 2009b)

THEORY:

Load flow study in power system parlance is the steady state solution of the power system
network. The main information obtained from this study comprises the magnitudes and phase
angles of load bus voltages, reactive powers at generator buses, real and reactive power flows
on transmission lines, other variables being specified. This information is essential for the
continuous monitoring of current state of the system and for analyzing the effectiveness of
alternative plans for future system expansion to meet increased load demanded.

Newton-Raphson method is an iterative method that approximates the set of non linear
simultaneous equations to a set of linear simultaneous equations using Taylor’s series
expansion and the terms are limited to first approximation. The rate of convergence is fast as
compared to the FDLF program and also it is suitable for large size system. So we go for N-R
method.

The non-linear equations governing the power system network are,

= for all p

Where is the current injected into bus p.

PROBLEM STATEMENT:

Consider a three phase system of fig.1 .each of the three lines has a series impedance of
0.02+j0.08 pu and a total shunt admittance of j0.02pu. The specified quantities at the bus are
tabulated below ,

B.TECH(Electrical Engineering) 16 DAVIET


Power System Design Lab BTEE_806
Name:-Ajay Kumar University Reg. No.-1604372 Class Roll No. 304/16

Fig.1 Three phase system

Bus Real load Reactive load Real power Reactive power Voltage
demand demand generation generation specification

1 2.0 1.0 Unspecified Unspecified = 1.04+j0

(Slack bus)

2 0.0 0.0 0.5 1.0 Unspecified

(PQ bus)

3 1.5 0.6 0.0 =? =1.04

(PV bus)

Controllable reactive power source is available at bus 3 with the constraint.Find the load flow
solution using the NR method. Use a tolerance of 0.01 for power mismatch.

MATLAB CODE:

clear;
% n stands for no. of buses
n=3;
% V, voltages at those buses are initialized
V=[1.04 1.0 1.04];
% Y is Ybus
Y=[ 5.88228-1i*23.50514 -2.9427+1i*11.7676 -2.9427+1i*11.7676
-2.9427+1i*11.7676 5.88228-1i*23.50514 -2.9427+1i*11.7676
-2.9427+1i*11.7676 -2.9427+1i*11.7676 5.88228-1i*23.50514 ];
% Bus types are initialized in type array to code 1 which stands for PQ bus.
% code 2 stands for PV bus
type= ones(n,1);
% when Q limits are exceeded for a PV bus, bus type is changed to PQ
% temporarily

B.TECH(Electrical Engineering) 17 DAVIET


Power System Design Lab BTEE_806
Name:-Ajay Kumar University Reg. No.-1604372 Class Roll No. 304/16
% an element i of typechanged is set to 1 in case its bus status
% is temporarily changed from PQ to PV. Otherwise it is zero
typechanged= zeros(n,1);
% since max and min Q limits are checked only for PV buses.
% max and min Q limits for other types of buses
% here we set them zero for convenience
Qlimitmax=zeros(n,1);
Qlimitmin=zeros(n,1);
Vmagfixed=zeros(n,1);
% here we change type of PV buses to 2 and also set the Q limits for them
type(3)=2;
Qlimitmax(3)=1.5;
Qlimitmin(2)=0;
Vmagfixed(2)= 1.04;
diff=10;
noofiter=1;
Pspec=[inf 0.5 -1.5];
Qspec=[inf 1 0];
S= [inf+1i*inf (0.5-1i*0.2) (-1.0+1i*05) (0.3-1i*0.1)]

OUTPUT:

RESULT:

The MATLAB code for the above problem has been executed.

B.TECH(Electrical Engineering) 18 DAVIET

Potrebbero piacerti anche