You are on page 1of 77

REGISTER NUMBER

Certified that this is the bonafide record of work done by


Selvan / Selvi_____________________________________ of the ______________________ semester
________________________________________________________ branch during the year ___________
in the _______________________________________________________________ laboratory

STAFF IN CHARGE HEAD OF THE DEPARTMENT

Submitted for the university Practical Examinations on _________________________

INTERNAL EXAMINER EXTERNAL EXAMINER


PAGE MARKS
S.No DATE NAME OF THE EXPERIMENT SIGNATURE
No AWARDED
EX. No: 01
FORMATION OF Y-BUS MATRIX BY THE METHOD OF INSPECTION
DATE:
AIM:

To develop a program to compute bus admittance matrix for the given power system network by
inspection method

ALGORITHM

1. Intially Y-Bus matrix i.e. replace all entries as zeros. It means that Yij=Yij-Yij=Yii
2. Read the number of buses [NB], Number of Lines [NL] and line data
3. Consider line l=1
n
4. Compute Yii= ∑ Yij = diagonal element
J=1
5. Let Y(I,j)= Y(i,i)+Y series (l)+ 0.5 Ysh(l)
Y(j,i)= Y(i,i)+Yseries (l)+0.5 Ysh(l)
Y(i,j)=Yseries (i,j)
Y(j,j)=Y(i,j)
6. Is l=NL?
If Yes , Print Y-bus
If no, l=l+1
7. Stop the program
Line Data

LINE START SERIES IMPENDNCE LINE CHARGING ADMITTANCE


END BUS
No BUS (P.u) (P.U)
1 1 2 0.1+j0.3 0.0+j0.02
2 2 3 0.15+j0.5 0.0+j0.0125
3 3 1 0.2+j0.6 0.0+j0.028

One Line Diagram

Impedance Diagram
Program:

#include<conio.h>
#include<complex.h>
#include<iostream.h>
#include<fstream.h>
#include<stdio.h>
#include<math.h>
#define NB 3+1
#define NL 3+1
complex y_bus[NB][NB],line_Z[NL],halfline_y[NL];
int i,j,k1,k2,line[NL],sb[NL],eb[NL],nl,nb;
void main()
{
ifstream infile;
infile.open("ybus.dat");
ofstream outfile;
outfile.open("ybus.out");
outfile.precision(4);
outfile.setf(ios::showpoint);
outfile.fill('0');
outfile<<"\t\t\t Y-BUS FORMATION BY INSPECTION METHOD \n";
infile>>nl>>nb;
outfile<<"\t"<<"NUMBER OF LINES:"<<nl<<" \n";
outfile<<"\t"<<"NUMBER OF BUSES:"<<nb<<"\n";
outfile<< "LINE No\t\tse\teb \t\tline_Z \t\t\t halfline_y\n";
for(i=1;i<=nl;i++)
{
infile>>line[i]>>sb[i]>>eb[i]>>line_Z[i]>>halfline_y[i];
outfile<<line[i]<<"\t\t"<<sb[i]<<"\t"<<eb[i]<<"\t\t"<<line_Z[i]<<"\t"<<halfline_y[i]<<"\n";
k1=sb[i];
k2=eb[i];
y_bus[k1][k1]+= (1.0/line_Z[i])+halfline_y[i];
y_bus[k2][k2]+= (1.0/line_Z[i])+halfline_y[i];
y_bus[k1][k2]+= -1.0/line_Z[i];
y_bus[k2][k1] = y_bus[k1][k2];
}
outfile<<"\n\t\t\t Y-BUS MATRIX \n";
for(i=1;i<=nb;i++)
{
outfile<<"\n";
for(j=1;j<=nb;j++)
{
outfile<<y_bus[i][j]<<"\t";
}
}
}
INPUT

File Name: [“YBUS.DAT”]

3
3
1 1 2 (0.1,0.3)(0.0,0.01)
2 2 3 (0.15,0.5)(0.0,0.0625)
3 3 1 (0.2,0.6)(0.0,0.014)
OUTPUT

File Name: [“YBUS.OUT”]

Y-BUS FORMATION BY INSPECTION METHOD

NUMBER OF LINES:3

NUMBER OF BUSES:3

LINE No se eb line_Z halfline_y

1 1 2 (0.1000, 0.3000) (0.0000, 0.0100)

2 2 3 (0.1500, 0.5000) (0.0000, 0.0625)

3 3 1 (0.2000, 0.6000) (0.0000, 0.0140)

Y-BUS MATRIX

(1.5000, -4.4760) (-1.0000, 3.0000) (-0.5000, 1.5000)

(-1.0000, 3.0000) (1.5505, -4.7624) (-0.5505, 1.8349)

(-0.5000, 1.5000) (-0.5505, 1.8349) (1.0505, -3.2584)

Result
EX. No: 02
FORMATION OF Z-BUS MATRIX
DATE:

AIM:

To develop a program to obtain bus impendance matrix for the given power system network

ALGORITHM

1. Read the values of such as no of lines, no of buses & line data, generator data and Transformer
data
2. Intialize Y-Bus matrix, Y bus[i][j]=complex (0.0,0.0)
3. Compute Y-bus matrix, by considering only line data
4. Modify Y-Bus matrix by adding the transformer and generator admittance to respective
diagonal element of Y-Bus matrix
5. Compare Z-bus matrix by inverting the modified Y-bus matrix
6. Check the inversion by multiplying modified y-bus & z-bus matrix to see whether the
resultingmatrix is unity or not
7. Print the Z-bus matrix
Data

No of lines No of Buses No of generator No of Transformer


5 4 2 2
Generator1: 0.0+j0.02

Generator 2: 0.0+0.08

Transformer 1: 0.0+j0.25

Transformer2: 0.0+j0.1

LINE No START END SERIES IMPENDNCE LINE CHARGING


BUS BUS (P.u) ADMITTANCE (P.U)
1 1 2 0.0+j0.4 0.0+j0.0075
2 2 3 0.15+j0.6 0.0+j0.01
3 3 4 0.18+j0.55 0.0+j0.009
4 4 1 0.1+j0.35 0.0+j0.006
5 4 2 0.25+j0.7 0.0+j0.015
Program

#include<complex.h>
#include<conio.h>
#include<fstream.h>
#include<math.h>
#define NL 5+1
#define NB 4+1
#define NG 2+1
#define NT 2+1
complex zg[NG],zt[NT],linez[NL],halfliney[NL];
complex ybus[NB][NB],zbus[NB][NB],check[NB][NB];
int nl,line[NL],sb[NL],eb[NL],nb,i,j,m,k1,k2,k,ng,nt;
void cinver(complex [NB][NB],int);
void main()
{
ifstream infile;
infile.open("ZBUS.dat");
ofstream outfile;
outfile.open("ZBUS.out");
outfile.precision(4);
outfile.setf(ios::showpoint);
outfile.fill('0');
outfile<<"\t\t ZBUS FORMATION AFTER Y BUS MODIFICATION \n";
infile>>nl>>nb>>ng>>nt;
outfile<<"----------------------------------------------------\n";
outfile<<"\t\t Number of lines :"<<nl<<"\n";
outfile<<"\t\t number of buses :"<<nb<<"\n";
outfile<<"\t\t number of gen :"<<ng<<"\n";
outfile<<"\t\t number of trans :"<<nt<<"\n";
for(i=1;i<=ng;i++)
infile>>zg[i]>>zt[i];
outfile<<" line starting ending line halfline\n";
outfile<<" No. bus bus imp adm \n\n";
for(i=1;i<=nl;i++)
{
infile>>line[i]>>sb[i]>>eb[i]>>linez[i]>>halfliney[i];
outfile<<line[i]<<"\t"<<sb[i]<<"\t"<<eb[i]<<"\t"<<linez[i]<<"\t"<<halfliney[i]<<"\n";
k1=sb[i];
k2=eb[i];
ybus[k1][k1]+=(1.0/linez[i])+halfliney[i];
ybus[k2][k2]+=(1.0/linez[i])+halfliney[i];
ybus[k1][k2]+=-1.0/linez[i];
ybus[k2][k1]+=ybus[k1][k2];
}
for(i=1;i<=ng;i++)
ybus[i][i]+=1.0/(zg[i]+zt[i]);
outfile<<"\n modified y bus matrix: \n\n";
for(i=1;i<=nb;i++)
{
for(j=1;j<=nb;j++)
{
outfile<<ybus[i][j]<<"";
zbus[i][j]=ybus[i][j];
}
outfile<<"\n";
}
cinver(zbus,nb);
outfile<<"\n Zbus matrix:\n\n";
for(i=1;i<=nb;i++)
{
for(j=1;j<=nb;j++)
outfile<<zbus[i][j]<<"";
outfile<<"\n";
}
for(i=1;i<=nb;i++)
{
for(j=1;j<=nb;j++)
{
check[i][j]=complex(0.0,0.0);
for(k=1;k<=nb;k++)
check[i][j]+=zbus[i][k]*ybus[k][j];
}
}
outfile<<"\n check matrix\n\n";
for(i=1;i<=nb;i++)
{
for(j=1;j<=nb;j++)
outfile<<check[i][j]<<"";
outfile<<"\n";
}
}
void cinver(complex xxyy[NB][NB],int nnn)
{
complex x;
m=nnn+1;
for(i=1;i<=nnn;i++)
{
for(j=1;j<=nnn;j++)
xxyy[j][m]=complex(0.0,0.0);
xxyy[i][m]=complex(1.0,0.0);
x=xxyy[i][i];
for(j=1;j<=m;j++)
xxyy[i][j]=xxyy[i][j]/x;
for(k=1;k<=nnn;k++)
{
if(k==i)goto zz;
x=xxyy[k][i];
for(j=1;j<=m;j++)
xxyy[k][j]=xxyy[k][j]-x*xxyy[i][j];
zz:;
}
for(j=1;j<=nnn;j++)
xxyy[j][i]=xxyy[j][m];
}
}
INPUT

[“ZBUS.DAT”]

5422
(0.0,0.2) (0.0,0.08) (0.0,0.25) (0.0,0.1)
1 1 2 (0.1,0.4) (0.0,0.0075)
2 2 3 (0.15,0.6)(0.0,0.01)
3 3 4 (0.18,0.55)(0.0,0.009)
4 4 1 (0.1,0.35)(0.0,0.006)
5 4 2 (0.25,0.7)(0.0,0.015)
OUTPUT

[“ZBUS.OUT”]

ZBUS FORMATION AFTER Y BUS MODIFICATION


----------------------------------------------------
Number of lines :5
number of buses :4
number of gen : 2
number of trans :2
line starting ending line halfline
No. bus bus imp adm
1 1 2 (0.1000, 0.4000) (0.0000, 0.0075)
2 2 3 (0.1500, 0.6000) (0.0000, 0.0100)
3 3 4 (0.1800, 0.5500) (0.0000, 0.0090)
4 4 1 (0.1000, 0.3500) (0.0000, 0.0060)
5 4 2 (0.2500, 0.7000) (0.0000, 0.0150)
modified y bus matrix:
(1.3430, -8.5524)(-0.5882, 2.3529)(0.0000, 0.0000)(-0.7547, 2.6415)
(-0.5882, 2.3529)(1.4329, -8.0132)(-0.3922, 1.5686)(-0.4525, 1.2670)
(0.0000, 0.0000)(-0.3922, 1.5686)(0.9296, -3.1919)(-0.5375, 1.6423)
(-0.7547, 2.6415)(-0.4525, 1.2670)(-0.5375, 1.6423)(1.7447, -5.5208)
Zbus matrix:
(0.0069, 0.1950)(-0.0087, 0.1111)(-0.0043, 0.1367)(0.0012, 0.1589)
(-0.0087, 0.1111)(0.0110, 0.2171)(0.0064, 0.1881)(-0.0007, 0.1595)
(-0.0043, 0.1367)(0.0064, 0.1881)(0.1008, 0.5174)(0.0282, 0.2633)
(0.0012, 0.1589)(-0.0007, 0.1595)(0.0282, 0.2633)(0.0608, 0.3557)
check matrix
(1.0000, 4.1633e-17)(1.3878e-16, 4.1633e-17)(0.0000, -1.3878e-17)(0.0000, 0.0000)
(2.7756e-16, 2.7756e-17)(1.0000, 2.7756e-17)(5.5511e-17, -1.3878e-17)(-1.1102e-16, 0.0000)
(2.2204e-16, 5.5511e-17)(2.2204e-16, 4.1633e-17)(1.0000, -5.5511e-17)(0.0000, -5.5511e-17)
(2.2204e-16, 5.5511e-17)(2.2204e-16, 0.0000)(0.0000, 0.0000)(1.0000, 0.0000)

RESULT
EX. No: 03
LOAD FREQUENCY DYNAMICS OF SINGLE AREA & TWO AREA SYSTEMS
DATE:

AIM:

To find The Load Frequency Dynamics of Single & Two Area Power Systems

ALGORITHM

1. Start the program


2. Read all the variables
3. Chech whether the system is single area or two area systems
4. If it is single area system calculate the change in frequency by using the following formulas
D=Pd/(f*Pr )
Kp=1/D
Tp=2h/(f*D)
B=D+(1/R)
Df=-M/B
5. If it is two area system, calculate the change in frequency and tie line power by using the
following formulaes
R1=(r1+100)*(f/(g1*sr1)
R2=(r2+100)*(f/(g2*sr2)
D1=d1(l1-m1)/f
D2=d2(l2-m2)/f
B1=D1+(1/R1)
B2=D2+(1/R2)
Df=(M1+M2)/(B1+B2)
Static Frequency = f+Df
6. Print all the values
7. Stop the program
Problem for Single Area system

For an isolated single area system considered the following data

Total rated area Capacity Pr=2000 MW

Normal operating load Pd=1000MW

Inertia constant H=5 sec

Regulation R=2.4 Hz/P.u.M.w

Normal frequency F=60 Hz

assume that the load frequency charcteristic is linear meaning that the load will increase 1% for
1% frequency increase . Find 1.Gain & Time constant of power system 2. Change in frequency
under static condition . Also verify the obtained result with the calculated value

Problem for two area system

Considering the two area system, find the new steady state frequency and change in tie
line flow for a load change of area 2. For both areas each percent change in frequency causes 1%
change in load. Also verify the obtained result.

Assume the following data

Value of Generator 1& 2 =19000 & 41000

Value of generator 1& 2 = 2000 & 40000

Spinning reserves area 1 & 2 = 5 & 5

Regulation of Area 1 & 2 = 1000 & 60

Exchange in load area = 1.0000 & 1.0000

Frequency = 60 Hz
Program

#include<conio.h>
#include<stdio.h>
#include<complex.h>
#include<fstream.h>
#include<math.h>
float pg1,pg2,load1,load2,pd1,pd2,gen1,gen2,tie,x1,x2,c,pr,pd,r,l,h,f,x,D;
float D1,D2,b,b1,b2,r1,r2,m,m1,m2,kp,tp,df,g1,g2,l1,l2,sr1,sr2,R,R1,R2,d1,d2;
void main()
{
ifstream infile;
infile.open("load.dat");
ofstream outfile;
outfile.open("load.out");
outfile.precision(4);
outfile.setf(ios::showpoint);
outfile.fill('0');
outfile<<"\n\n\n load frequency dyanmics of single area and two area system \n\n";
outfile<<"\n------------------------------------------------";
outfile<<"\n\t\t SINGLE AREA SYSTEM";
outfile<<"\n------------------------------------------------";
infile>>pr;
outfile<<"\n\t AREA CAPACITY :"<<pr;
infile>>pd;
outfile<<"\n\t Normal Operating system :"<<pd;
infile>>h;
outfile<<"\n\t Inertia constant :"<<h;
infile>>R;
outfile<<"\n\t Regulation :"<<R;
infile>>f;
outfile<<"\n\t operating frequency(given/assume) :"<<f;
infile>>m;
outfile<<"\n\t Increase in total load :"<<m;
D=pd/(f*pr);
kp= 1/D;
tp=(2*h)/(f*D);
outfile<<"\n\t kp :"<<kp;
outfile<<"\n\t tp :"<<tp;
b=D+(1/R);
df=-(m/b);
outfile<<"\n\t change in frequency :"<<df;
outfile<<"\n--------------------------------------------------";
outfile<<"\n\t\t TWO AREA SYSTEM :";
outfile<<"\n --------------------------------------------------";
infile>>g1>>g2;
outfile<<"\n\t value of gen1 & gen 2 :"<<g1<<"\t\t"<<g2;
infile>>l1>>l2;
outfile<<"\n\t value of load 1 & 2 :"<< l1<<"\t\t"<<l2;
infile>>sr1>>sr2;
outfile<<"\n\t the spring reverse of area2 :"<< sr1<<"\t\t"<<sr2;
infile>>r1>>r2;
outfile<<"\n\t the regulation of area2 :"<<r1<<"\t\t"<< r2;
infile>>m1>>m2;
outfile<<"\n\t the exchange in the load of area :"<< m1<<"\t\t"<<m2;
infile>>f;
outfile<<"\n\t frequency :"<<f;
infile>>d1>>d2;
outfile<<"\n\t the percentage of load :"<<d1<<"\t\t"<<d2;
R1=(r1/100)*(f/(g1+sr1));
outfile<< "\n\t R1 :"<<R1;
R2=(r1/100)*(f/(g2+sr2));
outfile<< "\n\t R2 :"<<R2;
D1=d1*((l1-m1)/f);
D2=d2*((l2-m2)/f);
outfile<<"\n\t D1 :"<<D1;
outfile<<"\n\t D2 :"<<D2;
b1=D1+(1/R1);
b2=D2+(1/R2);
outfile<<"\n\t b1 :"<<b1;
outfile<<"\n\t b2 :"<<b2;
df=(m1+m2)/(b1+b2);
x=f+df;
outfile<<"\n\t DF :"<<df;
outfile<<"\n\t Static frequency :"<<x;
pg1=(-df)/R1;
pg2=(-df)/R2;
outfile<<"\n\t pg1 :"<<pg1;
outfile<<"\n\t pg2 :"<<pg2;
pd1=D1*df;
pd2=D2*df;
outfile<<"\n\t pd1 :"<<pd1;
outfile<<"\n\t pd2 :"<<pd2;
gen1=g1+pg1;
gen2=g2+pg2;
load1=(11-m1)+pd1;
load2=(12-m2)+pd2;
tie=gen2-load2;
outfile<<"\n\t Tie Line power :"<<tie;
}
Input data

[“Load.DAT”]
2000
1000
5
2.4
60
0.01
19000 41000
2000 40000
55
1000
60
11
OUTPUT

[“Load.OUT”]
Load Frequency Dynamics of Single Area And Two Area System
------------------------------------------------
SINGLE AREA SYSTEM
------------------------------------------------
AREA CAPACITY :2000.0000
Normal Operating system :1 000.0000
Inertia constant :5 .0 000
Regulation : 2. 4 000
operating frequency(given/assume) :6 0.0000
Increase in total load : 0. 0100
kp :120.0000
tp :20.0000
change in frequency :-0.0235
--------------------------------------------------
TWO AREA SYSTEMS:
--------------------------------------------------
value of gen1 & gen 2 :19000.0000 41000.0000
value of load 1 & 2 :2000.0000 40000.0000
the spring reverse of area2 :5 .0 000 5.0000
the regulation of area2 : 1 00 0 .0 000 60.0000
the exchange in the load of area :1.0000 1.0000
frequency :6 0 . 0 000
the percentage of load :0 .0 00 0 0.0000
R1 :0 . 0 3 16
R2 : 0 . 0 1 4 6
D1 :0 . 0000
D2 :0 . 0000
b1 : 31 .6750
b2 : 68 .3417
DF : 0 .0 200
Static frequency :6 0 . 0 200
pg1 : -0 .6 334
pg2 : -1 .3 666
pd1 : 0 .0 000
pd2 : 0 .0 000
Tie Line power :999.6328

Result
EX. No: 04
PERFORMANCE OF SHORT TRANSMISSION LINE
DATE:

AIM

To find the performance parameters of short transmission line

ALGORITHM

1. Start the program


2. Get the power delivered, reactive end voltage, total line impendance, power factor & total
resistance of short transmission line
3. Calculate the follwing
4. Line current I1= (Pr)/(Vr*Pf)
5. Receiving end current Ir= (I1*fi)
6. Sending end voltage Vs=(Vr*1000)+(Ir*Z)
7. Magnitude of sending end voltage Vsm=(abs(Vs)/1000)
8. Line losses L1=((I1*I1*R)/1000)
9. Power sent Ps=Pr+L1
10. Transmission Efficiency Ty=((Pr/Ps)*100)
11. %Regulation =(Vsm-Vr)/Vr)*100
12. Print all the calculated parameters
13. Stop the program
PROGRAM

#include<stdio.h>
#include<fstream.h>
#include<complex.h>
#include<conio.h>
#include<math.h>
float I1,L1,Vr,Vsm,Ps,Ty,PF,Reg;
complex Z,Ir,Vs,FI;
int pr,R;
void main()
{
ifstream infile;
infile.open("ST.dat");
ofstream outfile;
outfile.open("ST.out");
outfile.precision(2);
outfile.setf(ios::showpoint);
outfile.fill('0');
outfile<<"\t\t PERFORMANCE OF SHORT TRANSMISSION LINE \n";
infile>>pr>>Vr>>FI>>Z>>PF>>R;
outfile<<"\n power delivered ="<<pr<<"KW";
outfile<<"\n the receiving end voltage ="<<Vr<<"KV";
outfile<<"\n FI ="<<FI<< "ohm";
outfile<<"\n total line impendance ="<<Z<<"ohm";
outfile<<"\n power factor ="<<PF<<"\t Lagging";
outfile<<"\n the total resistance ="<<R<<"ohm";
outfile<<"\n calculation for Ir,Vs,Trans.eff1,%Reg"<<"\n";
I1=(pr)/(Vr*PF);
o utfile<<"\n Line current = " <<I1<<"Amperes";
Ir=(I1*FI);
outfile<<"\n Receiving End Current ="<<Ir<<"Amperes";
Vs=(Vr*1000)+(Ir*Z);
outfile<<"\n Sending End Voltage ="<<Vs<<"Volt";
Vsm=(abs(Vs)/1000);
outfile<<"\n The magnitude of sending end voltage ="<<Vsm;
L1=((I1*I1*R)/1000);
o utfile<<"\n Line Losses = "<<L1<<"KV";
Ps=pr+L1;
o utfile<<"\n Power sent =" < <P s<<"KW";
Ty=((pr/Ps)*100);
outfile<<"\n The transmission Efficiency ="<<Ty<<"%";
Reg=((Vsm-Vr)/Vr)*100;
outfile<<"\n P ercentage Regulation ="<<Reg<<"%";
}
INPUT DATA
[“ST.DAT”]
1100
11
(0.8,-0.6)
(8,16)
0.8
8
OUTPUT
[“ST.OUT”]
PERFORMANCE OF SHORT TRANSMISSION LINE
Power delivered =1100KW
The receiving end voltage =11.00KV
F I =(0.80, -0.60)ohm
Total line impendance =(8.00, 16.00)ohm
Power factor =0.80 Lagging
The total resistance =8ohm
calculation for Ir,Vs,Trans.eff1,%Reg
Line current = 1 25 .00Amperes
Receiving End Current = (100.00, -75.00) Amperes
Sending End Voltage = (1.30e+04, 1000.00) Volt
The magnitude of sending end voltage =13.04
Line Losses =125.00KV
Power sent = 1. 23 e+0 3KW
The transmission Efficiency =89.80%
Pe rc entage Regulation =18.53%

RESULT
EX. No: 05
ECONOMIC DISPTACH WITH AND WITHOUT LOSSES
DATE:

AIM

To find the optimum generation by considering with & without losses.

ALGORITHM

1. Start the program


2. Get the cost inputs of generating units
3. Get the value of load demand and incremental cost transmission loss coefficient
4. Calculate the optimum generator P1 & p2
5. P1=(λ-b1)/2a1; P2=(λ-b2)/2a2;
6. Calculate the toalpower generation P=p1+p2
7. Check whether total power generation is equal to demand
8. If the power & demand value not equal , then the incremental cost or decremental cost value
9. If they are equal , then display P1 &P2
10. When there is Presence of loss , then get the Value of transmission loss and co-efficient &
incremental cost (λ)
11. Calculate PL
12. PL= P2B11 + P2B22+ P1P2B12
13. Calculate the total generation and the received power Ptg=P1+P2
14. Total power demand Pd=Pg-P1
15. Print all the values
16. Stop the Program
Problem

The fuel cost of the two units are given by

F1=0.05 P12+2 P1+100 Rs/Hr

F2=0.05 P22+1.5 P2+120 Rs/Hr

Without Losses

Determine the economic schedule for the incremental cost of received power is Rs.220 /MWhr.
Also find the total generation and demand. Also verify the calculated result

With Losses

Determine the economic schedule for the incremental cost of received power is Rs.220 /MWhr.
Also find the total generation & losses and demand. Also verify the calculated result

The Transmission co-effficient B11=0.0015, B12=-0.00050,B22=0.0025

Incremental cost e=10


PROGRAM

#include<conio.h>
#include<complex.h>
#include<iostream.h>
#include<fstream.h>
#include<stdio.h>
#include<math.h>
float l,m,i,j,n,td,x1,x2,y1,y2,z1,z2,e,pg,pd,p,p1,p2,b11,b12,b22;
void main()
{
ifstream infile;
infile.open("Economic.dat");
ofstream outfile;
outfile.open("Economic.out");
outfile.precision(4);
outfile.setf(ios::showpoint);
outfile.fill('0');
outfile<<"\n\t\t Calcultion of optimum generation with and without losses";
outfile<<"\n the fuel cost function-1 :";
infile>>x1>>y1>>z1;
outfile<<"\n f1="<<x1<<"p1(pow)2+"<<y1<<"p1+"<<z1;
o u tfile<<"\n the fuel cost function-2 :";
infile>>x2>>y2>>z2;
outfile<<"\n f2="<<x2<<"p2(pow)2+"<<y2<<"p2+"<<z2;
outfile<<"\n-----------------------------------------------------------";
outfile<<"\n Calculation of p1 & p2 with and without losses";
outfile<<"\n-----------------------------------------------------------";
infile>>td;
outfile<<"\n total demand ="<<td;
infile>>e;
outfile<<"\n the incremental cost ="<< e;
do
{
if(p>td)
e--;
else
e++;
p1=(e-y1)/(2*x1);
p2=(e-y2)/(2*x2);
p=p1+p2;
}while(p!=td);
outfile<<"\n optimum generation\n p1="<<p1<<"\n p2="<<p2;
outfile<<"\n the total demand =" <<td<<"\n incremental cost ="<<e;
outfile<<"\n-----------------------------------------------------------";
outfile<<"\n\t\t calculation of p1 & p2 with losses";
outfile<<"\n-----------------------------------------------------------";
infile>>b11>>b12>>b22;
outfile<<"\n The transmission coefficient:"<<b11<<b12<<b22;
infile>>e;
outfile<<"\n the incremental cost:"<<e;
i=((2*x1)+(e*b11*2));
l=(2*x2)+(e*b22*2);
j=(2*e*b12);
m=e-y1;
n=e-y2;
outfile<<"\n"<<i<<"p1"<<j<<"p2="<<m;
outfile<<"\n"<<j<<"p1+"<<i<<"p2="<<n;
p1=(((m*l)-(n*j))/((i*l)-(j*j)));
outfile<<"\n p1="<<p1;
p2=(((n*i)-(m*j))/((i*l)-(j*j)));
outfile<<"\n p2="<<p2;
pg=p1+p2;
outfile<<"\n the total generation pg="<<pg<<"mw";
p1=((p1*p1*b11)+(p1*p2*b12*2)+(p2*p2*b22));
outfile<<"\n the transmission losses p1="<<p1<<"mw";
pd=pg-p1;
outfile<<"\n the demand pd="<<pd<<"mw";
}
INPUT
[“ECONOMIC.DAT”]
0.05 2 100
0.075 1.5 120
220
50
0.0015 -0.00050 0.0025
10
OUTPUT
[“ECONOMIC.OUT”]
CALCULTION OF OPTIMUM GENERATION WITH AND WITHOUT LOSSES
the fuel cost function-1 :
f1=0.0500p1(pow)2+2.0000p1+100.0000
the fuel cost function-2 :
f2=0.0750p2(pow)2+1.5000p2+120.0000
-----------------------------------------------------------
Calculation of p1 & p2 without losses
-----------------------------------------------------------
total demand =220.0000
the incremental cost =50.0000
optimum generation
p1=130.0000
p2=90.0000
the total demand =220.0000
incremental cost =15.0000
-----------------------------------------------------------
calculation of p1 & p2 with losses
-----------------------------------------------------------
The transmission coefficient:0.0015-0.00050.0025
the incremental cost:10.0000
0.1300p1-0.0100p2=8.0000
-0.0100p1+0.1300p2=8.5000
p1=65.0579
p2=45.7529
the total generation pg=110.8108mw
the transmission losses p1=8.6055mw
the demand pd=102.2053mw

RESULT
EX. No: 06
SYMMETRICAL SHORT CIRCUIT ANALYSIS
DATE:

AIM

To develop a computer program to carryout simulation study of symmetrical three phase short
circuit on a given three phase system

ALGORITHM

1. Start the program


2. Read line data, machine & Transformer data & fault impendence etc
3. Compute y-bus & calculate modified y-bus matrix
4. Compute y-bus & calcuate modified y-bus matrix
5. Form z-bus by inverting the modified y-bus matrix
6. Intialize count i=0
7. i=i+1 this means fault occurs at ‘I’th bus
8. compute fault current at faulted bus and bus voltage at all buses
9. compute fault current at faulted bus and bus volatges at all buses
10. compute all line currents & generator currents
11. check whether I it is less than the number of buses, go to step 6, otherwise go to the next
step
12. print the result
13. stop the program
PROGRAM

#include<stdio.h>
#include<complex.h>
#include<iostream.h>
#include<fstream.h>
#include<math.h>
#include<stdio.h>
#define NB 3+1
#define NL 4+1
int nl,nb,ng,nt,i,j,k,l,m,ln[NL],sb[NB],eb[NL],p,tag[NB];
complex y[NB][NB],z[NB][NB],chk[NB][NB],lz[NL],g_z[NB],t_z[NB],voa,lf,zf,v[NB],genr_cur,lc;
void cinver(complex[NB][NB],int nnn);
void main()
{
ifstream infile;
infile.open("sca.dat");
ofstream outfile;
outfile.open("sca.out");
outfile.precision(4);
outfile.setf(ios::showpoint);
outfile<<" symmetrical short circuit analysis \n";
infile>>nb>>nl>>ng>>nt>>zf;
outfile<<"\n NB \t NL \t NG \t NT \t ZF \n";
outfile<<nb<<"\t"<<nl<<"\t"<<ng<<"\t"<<nt<<"\t"<<zf;
outfile<<"\n line data\n";
outfile<<"LNo\tSB\t EB \t LINE IMP \n";
for(i=1;i<=nl;i++)
{
infile>>ln[i]>>sb[i]>>eb[i]>>lz[i];
outfile<<"\n"<<ln[i]<<"\t"<<sb[i]<<"\t"<<eb[i]<<"\t"<<lz[i];
l=sb[i];
m=eb[i];
y[l][l]+=1.0/lz[i];
y[m][m]+=1.0/lz[i];
y[l][m]+=-1.0/lz[i];
y[m][l]=y[l][m];
}
outfile<<"\n Y BUS MATRIX \n";
for(i=1;i<=nb;i++)
{
outfile<<"\n";
for(j=1;j<=nb;j++)
outfile<<y[i][j]<<"\t";
}
outfile<<"\n BUS no \t gen_z \t tran_z \t tag \n";
for(i=1;i<=nb;i++)
{
infile>>g_z[i]>>t_z[i]>>tag[i];
if(tag[i]==1)
{
outfile<<"\n"<<i<<"\t"<<g_z[i]<<"\t"<<t_z[i]<<"\t"<<tag[i];
y[i][i]+=1.0/(g_z[i]+t_z[i]);
}
}
outfile<<"\n modified bus matrix:\n";
for(i=1;i<=nb;i++)
{
outfile<<"\n";
for(j=1;j<=nb;j++)
{
outfile<<y[i][j]<<"\t";
z[i][j]=y[i][j];
}
}
cinver(z,nb);
outfile<<"\n zbus matrix";
for(i=1;i<=nb;i++)
{
outfile<<"\n";
for(j=1;j<=nb;j++)
outfile<<z[i][j]<<"\t";
}
outfile<<"\n check matrix \n";
for(i=1;i<=nb;i++)
{
outfile<<"\n";
for(j=1;j<=nb;j++)
{
chk[i][j]=complex(0.0,0.0);
for(k=1;k<=nb;k++)
chk[i][j]+=y[i][k]*z[k][j];
outfile<<chk[i][j]<<"\t";
}
}
voa=complex(1.0,0.0);
for(p=1;p<=nb;p++)
{
lf=voa/(z[p][p]+zf);
outfile<<"\n fault current due to the fault bus"<<p<<"is :"<<lf;
outfile<<"\n BUs voltage under faulted condition";
for(i=1;i<=nb;i++)
{
v[i]=voa-(lf*z[i][p]);
outfile<<"\n voltage at bus"<<i<<" due to fault bus"<<p<<"is:"<<v[i];
}
outfile<<"\n line currents under faulted condition \n:";
outfile<< "LN \t SB \t EB \t LC \n";
for(i=1;i<=nl;i++)
{
l=sb[i];
m=eb[i];
lc=(v[l]-v[m])/lz[i];
outfile<<"\n"<<i<<"\t"<<l<<"\t"<<m<<"\t"<<lc;
}
outfile<<" \n generator current under faulted condition: \n";
for(i=1;i<=nb;i++)
{
if(tag[i]==1)
{
genr_cur=(voa-v[i])/(g_z[i]+t_z[i]);
outfile<<"\n generator current due to fault at bus"<<p<<"is:"<<genr_cur;
}
}
}
}
void cinver(complex xxx[NB][NB],int n)
{
int m;
complex yyy;
m=n+1;
for(i=1;i<=n;i++)
{
for(j=1;j<=n;j++)
xxx[j][m]=complex(0.0,0.0);
xxx[i][m]=complex(1.0,0.0);
yyy=xxx[i][i];
for(j=1;j<=m;j++)
xxx[i][j]=xxx[i][j]/yyy;
for(j=1;j<=n;j++)
{
if(i==j)goto abcd;
yyy=xxx[j][i];
for(k=1;k<=m;k++)
xxx[j][k]=xxx[j][k]-yyy*xxx[i][k];
abcd:;
}
for(j=1;j<=n;j++)
xxx[j][i]=xxx[j][m];
}
}
Input

3 4 2 2 (0.1,0.05)
1 1 2 (0.0,0.05)
2 1 2 (0.0,0.05)
3 2 3 (0.0,0.06)
4 1 3 (0.0,0.1)
(0.0,0.25) (0.0,0.1) 1
(0.0,0.0) (0.0,0.0) 0
(0.0,0.2) (0.0,0.08) 1
OUTPUT
Symmetrical Short Circuit Analysis
NB NL NG NT ZF
3 4 2 2 (0.1000, 0.0500)
line data
LNo SB EB LINE IMP
1 1 2 (0.0000, 0.0500)
2 1 2 (0.0000, 0.0500)
3 2 3 (0.0000, 0.0600)
4 1 3 (0.0000, 0.1000)
Y BUS MATRIX
(0.0000, -50.0000) (0.0000, 40.0000) (0.0000, 10.0000)
(0.0000, 40.0000) (0.0000, -56.6667) (0.0000, 16.6667)
(0.0000, 10.0000) (0.0000, 16.6667) (0.0000, -26.6667)
BUS no gen_z t ran_z tag
1 (0.0000, 0.2500) (0.0000, 0.1000) 1
3 (0.0000, 0.2000) (0.0000, 0.0800) 1
modified bus matrix:
(0.0000, -52.8571) (0.0000, 40.0000) (0.0000, 10.0000)
(0.0000, 40.0000) (0.0000, -56.6667) (0.0000, 16.6667)
(0.0000, 10.0000) (0.0000, 16.6667) (0.0000, -30.2381)
zbus matrix
(0.0000, 0.1688) (0.0000, 0.1618) (0.0000, 0.1450)
(0.0000, 0.1618) (0.0000, 0.1761) (0.0000, 0.1506)
(0.0000, 0.1450) (0.0000, 0.1506) (0.0000, 0.1640)
check matrix
(1.0000, 0.0000) (-1.1102e-15, 0.0000) (-8.8818e-16, 0.0000)
(-1.7764e-15, 0.0000) (1.0000, 0.0000) (4.4409e-16, 0.0000)
(-8.8818e-16, 0.0000) (0.0000, 0.0000) (1.0000, 0.0000)
fault current due to the fault bus1is :(1.7283, -3.7810)
BUs voltage under faulted condition
voltage at bus1 due to fault bus1is:(0.3619, -0.2917)
voltage at bus2 due to fault bus1is:(0.3883, -0.2796)
voltage at bus3 due to fault bus1is:(0.4518, -0.2506)
line currents under faulted condition
LN SB EB LC
1 1 2 (-0.2419, 0.5291)
2 1 2 (-0.2419, 0.5291)
3 2 3 (-0.4837, 1.0582)
4 1 3 (-0.4112, 0.8995)
generator current under faulted condition:
generator current due to fault at bus1is:(0.8334, -1.8232)
generator current due to fault at bus1is:(0.8949, -1.9578)
fault current due to the fault bus2is :(1.6357, -3.6989)
BUs voltage under faulted condition
voltage at bus1 due to fault bus2is:(0.4016, -0.2646)
voltage at bus2 due to fault bus2is:(0.3485, -0.2881)
voltage at bus3 due to fault bus2is:(0.4430, -0.2463)
line currents under faulted condition
LN SB EB LC
1 1 2 (0.4696, -1.0619)
2 1 2 (0.4696, -1.0619)
3 2 3 (-0.6965, 1.5751)
4 1 3 (-0.1831, 0.4141)
generator current under faulted condition:
generator current due to fault at bus2is:(0.7561, -1.7097)
generator current due to fault at bus2is:(0.8797, -1.9892)
fault current due to the fault bus3is :(1.7920, -3.8352)
BUs voltage under faulted condition
voltage at bus1 due to fault bus3is:(0.4440, -0.2598)
voltage at bus2 due to fault bus3is:(0.4225, -0.2698)
voltage at bus3 due to fault bus3is:(0.3710, -0.2939)
line currents under faulted condition
LN SB EB LC
1 1 2 (0.2006, -0.4294)
2 1 2 (0.2006, -0.4294)
3 2 3 (0.4013, -0.8587)
4 1 3 (0.3411, -0.7299)
generator current under faulted condition:
generator current due to fault at bus3is:(0.7423, -1.5887)
generator current due to fault at bus3is:(1.0497, -2.2465)
RESULT
EX. No: 07
FORMATION OF BUS INCIDENCE AND LOOP INCIDENCE MATRIX
DATE:

AIM

To obtain the bus incidence and loop incidence matrix by using C++ program.

ALGORITHM

1. Start the program


2. Intilaize the variables
3. Enter the number of nodes, number of elements and a number of branches
4. Check whether there is connection or not. If there is no connection go to loop and enter
the direction and bus incidence mtrix is calculated.
5. Calculate the number of loops
6. Check whether is connection or not. If there is connection means go inside the loop . if the
direction is same then C[i][j]=1, else C[i][j]=-1
7. Loop incidence matrix is calculated
8. Stop the program
PROGRAM

#include<stdio.h>

#include<conio.h>

#include<fstream.h>

#include<iostream.h>

int e,n,b,l,m,r,s,lo,i,j;

float a[10][10],lp[10][10];

void main()

ifstream infile;

infile.open("loop.dat");

ofstream outfile;

outfile.open("loop.out");

outfile<<"\n\n/* formation of buses incidence & loop incidence matrix */";

infile>>e;

outfile<<"\n No of elements:"<<e;

infile>>n;

outfile<<"\n No of Nodes:"<<n;

infile>>b;

outfile<<"\n No of branches:"<<b;

for(i=1;i<=e;i++)

for(j=1;j<=n;j++)

infile>>l;

outfile<<"\n\n the elements"<<i<<"is connected to node"<<j<<"connected to enter


node"<<j<<"connected to enter 1 (or) Not connected enter 0:"<<l;

if(l==0)

a[i][j]=0;
else

infile>>m;

outfile<<"\n whether the direction is towards 1 (pr) outwards 0:"<<m;

if(m==1)

a[i][j]=-1;

else

a[i][j]=1;

outfile<<"\n\n Bus Incidence matrix:\n";

for(i=1;i<=e;i++)

for(j=1;j<=n;j++)

outfile<<"\t"<<a[i][j];

outfile<<"\n";

lo=e-b;

outfile<<"\n No of loops="<<lo;

for(i=1;i<=lo;i++)

for(j=1;j<=e;j++)

infile>>r;

outfile<<"\n\n The Loop"<<i<<"The element"<<j<<"is connection enter 1 or not 0:"<<r;

if(r==0)

lp[i][j]=0;
else

infile>>s;

outfile<<"\n whether the direction is towards (or) outwards 0:"<<s;

if(s==1)

lp[i][j]=1;

else

lp[i][j]=-1;

outfile<<"\n \n The loop incidence matrix:\n";

for(i=1;i<=lo;i++)

for(j=1;j<=e;j++)

outfile<<"\n"<<lp[i][j];

outfile<<"\n";

}
INPUT

433

10

10

10

11

10

11

10

11

11

11
OUTPUT

/* formation of buses incidence & loop incidence matrix */

No of elements:4

No of Nodes:3

No of branches:3

the elements1is connected to node1connected to enter node1connected to enter 1 (or) Not


connected enter 0:1

whether the direction is towards 1 (pr) outwards 0:0

the elements1is connected to node2connected to enter node2connected to enter 1 (or) Not


connected enter 0:0

the elements1is connected to node3connected to enter node3connected to enter 1 (or) Not


connected enter 0:0

the elements2is connected to node1connected to enter node1connected to enter 1 (or) Not


connected enter 0:0

the elements2is connected to node2connected to enter node2connected to enter 1 (or) Not


connected enter 0:0

the elements2is connected to node3connected to enter node3connected to enter 1 (or) Not


connected enter 0:1

whether the direction is towards 1 (pr) outwards 0:0

the elements3is connected to node1connected to enter node1connected to enter 1 (or) Not


connected enter 0:0

the elements3is connected to node2connected to enter node2connected to enter 1 (or) Not


connected enter 0:1

whether the direction is towards 1 (pr) outwards 0:0


the elements3is connected to node3connected to enter node3connected to enter 1 (or) Not
connected enter 0:1

whether the direction is towards 1 (pr) outwards 0:1

the elements4is connected to node1connected to enter node1connected to enter 1 (or) Not


connected enter 0:1

whether the direction is towards 1 (pr) outwards 0:0

the elements4is connected to node2connected to enter node2connected to enter 1 (or) Not


connected enter 0:1

whether the direction is towards 1 (pr) outwards 0:1

the elements4is connected to node3connected to enter node3connected to enter 1 (or) Not


connected enter 0:0

Bus Incidence matrix:

1 0 0

0 0 1

0 1 -1

1 -1 0

No of loops=1

The Loop1The element1is connection enter 1 or not 0:1

whether the direction is towards (or) outwards 0:0

The Loop1The element2is connection enter 1 or not 0:1

whether the direction is towards (or) outwards 0:1

The Loop1The element3is connection enter 1 or not 0:1

whether the direction is towards (or) outwards 0:1


The Loop1The element4is connection enter 1 or not 0:1

whether the direction is towards (or) outwards 0:1

The loop incidence matrix:

-1

RESULT
EX. No: 08
LOAD FLOW ANALYSIS USING FAST DECOUPLED METHOD
DATE:

AIM

To conduct the load flow study on the given power system using Fast decoupled method

ALGORITHM

1. Read the slack bus voltage , real bus powers & reactive bus powers , bus voltage magnitudes
& reactive power limits
2. Form the Ybus matrix without line charging admittances & shunt admittances
3. Form B’ matrix from Ybus matrix obtained in step 2
4. Form Y bus matrix with double the line charging admittance
5. Form B’’ matrix from Y bus matrix obtained in step 4
6. Calculate the inverse of B’ and B’’ matrices
7. Calculate [ΔP / |V| ] & [ΔQ / |V| ]
8. If [ΔP / |V|] and [ΔQ / |V| ] are less than or equal to tolerance limit , solution has converged
and go to step 12 . Otherwise, increase iteration count and go to step 10
9. Calculate [Δδ] =[B’]-1 [ΔP / |V| ] and [Δ|V|] = [B’’]-1[ΔQ / |V| ]
10. Update [δ], [|v|]
11. [δ}new=[δ]old+[Δδ] at all the buses except slack bus
12. [|V|]new=|V|old+Δ|V| at all PQ buses
13. Then go to step -8
14. Compute the slack bus power, line flows, real power loss, reactive power loss etc.
One Line Diagram

Bus data

Line data
PROGRAM:

#include<conio.h>
#include<math.h>
#include<complex.h>
#include<fstream.h>
#include<iostream.h>
#define NB 5+ 1
#define NL 7+ 1
#define MB 2+ 1
int iter,i,i 1 ,j,j 1 ,k,l,m,mb,nb,nl,ln[NL ],sb[NL ],eb[NL];
float b[NB] [NB],b 1 [NB] [NB],b2[NB] [NB],b3 [NB] [NB],chk[NB] [NB],
delp [NB] ,delv[NB] ,delq[NB] ,deldelta[NB] ,deltaold[NB], deltanew[NB] ,p[NB]
,pcal[NB] ,psp [NB] ,q[NB] ,qsp[NB] ,qcal [NB], vsp[MB],g,ploss,qloss,vnew 1 ,temp
1 ,temp2,tol;
complex y[NB] [NB],lz[NL ],hly[NL], vnew[NB],vold[NB],sum,ctemp;
void float inverse(float x[NB][NB],int n);
void main( )
{
Clrscr( );
ifstream infile;
infile.open( "fdlf.dat");
ofstream outfile;
outfile. open(" fdlf. out");
outfile.setf(ios: :shmypoint);
outfile.precision( 4);
outfile«"\nPrograme for FDLF method\n";
infile> >nb> >mb> >nl> >tol;
outfile< <"\nNB\tMB\tNL \tTOL \n";
outfile< <nb< <"\t"< <mb< <"\t"< <nl< <"\t"< <tol< <"\n";
outfile«"\nLine Data\n";
outfile< <"\nLN o\tSB\tEB\tLZ\t\t\tHL Y\n";
for(i=1 ;i<=nl;i++)
{
infile> > In[i]> >sb[i]> >eb[i]> >lz[i]> >hly[ i];
outfile< <In[i]< <"\t"< <sb[ i]< <"\t"< <eb[i]< <"\t"< <lz[i]< <"\t"< <hly[ i] < <" \n";
j=sb[i];
k=eb[i] ;
y[j][j]+=1.0/1z[i]+hly[i];
y[k][k]+=1.0/lz[i]+hly[i] ;
y[j] [k]+=-1.0/1z[i];
y[k] [j]=y[j][k];
}
outfile< <"\n Y Matrix\n";
for(i= I ;i<=nb;i++)
{
outfile< <"\n";
for(j=1 ;j<= nb; j++)
outfile«y[i][j]«" ";
}
outfile< <"\nSpecified voltages\n";
for(i= 1 ;i<= mb; i++)
{
Infile>>vsp[i];
Outfile<<vsp[i]«" ";
}
Outfile<<"\nSpecified Real Bus Power\n";
for(i=2;i<=nb; i++ )
{
Infile>>psp[i];
Outfile<<psp[i]«" ";
}
outfile«"\nSpecified Reactive Bus Power\n";
for(i=mb+ 1 ;i<=nb; i++)
{
Infile>>qsp[i];
Outfile<< qsp[i]«" ";
}
outfile< <"\n initial Angles\n";
for(i=2;i<=nb; i++ )
{
infile> >deltanew[ i];
outfile<<deltanew[i]<<" ";
}
outfile«"\nB'Matrix\n";
for(i=2;i<=nb; i++ )
{
l=i- l;
outfile<<"\n";
for(j=2;j<= nb; j++ )
{
m=j- l;
b[l][ m ]= - imag (y[i] [j]);
bl [l][m]=b[l][m];
outfile<<b[l][m]<<" ";
}
}
float_inverse (b1, nb-l);
outfile<<"\n inverse of B' Matrix\n";
for(i=1 ;i<=nb-l ;i++)
{
outfile< <"\n ";
for(j=1 ;j<=nb-l ;j++)
outfile<<bl[i][j]<<" ";
}
Outfile<<"\nCheck Matrix\n";
for(i= 1 ;i<= nb-l ; i++)
{
outfile< <"\n";
for(j= 1 ;j<=nb-l ;j++)
{
chk[i] [j]=O.O;
for(k= 1 ;k<=nb-l ;k++ )
chk[i] [j]+= b[i] [k] *b1 [k] [j];
outfile<<chk[i][j]<<" ";
}
}
Outfile<<"\nB" Matrix \n";
for(i=mb+ 1 ;i<=nb; i++)
{
l= i- mb;
outfile<<"\n:”;
for(j=mb+ 1 ;j<=nb; j++)
{
m= j- mb; ,/
b2[1][m ]= -imag(y[i] [i]);
b3 [1][m]= b2[1][m];
outfile<< b2[1][m]<<" ";
}
}
float_inverse (b3, nb-l);
outfile<<"\n inverse of B" Matrix \n";
for(i=1 ; i<=nb-mb; i++)
{
outfile<<"\n";
outfile<< b[l][m]<<" ";
}
}
f1oat_ inverse(b1 ,nb-l);
outfile<<"\n Inverse of B' Matrix\n";
for(i= 1 ; i<=nb-l ; i++)
{
Outfile<<"\n";
for(j=1 ; j<=nb-1 ;j++)
outfile<<bl[i] [j]<<" ";
}
Outfile<<"\nCheck Matrix\n";
for(i=1 ;i<= nb-l ; i++)
{
Outfile<<"\n" ;
for(j = 1 ;j <= nb-l ; j ++ )
{
chk[i][j]=0.0;
for(k= 1 ;k<=nb-l ;k++)
chk[i] [j]+=b[i] [k]*b1 [k] [j];
outfile<<chk[i][j]<<" ";
}
}
Olltfile<<"\nB" Matrix \n";
for(i= mb+ 1 ;i<=nb; i++)
{
l=i-mb;
outfile<<”\n";
for(j=mb+ 1 ;j<=nb; j++)
{
m=j-mb;
b2[1] [m ]=- imag(y[i] [j]);
b3 [1][ m ]=b2[I][m];
outfile<<b2[1][m]<<" ";
}
}
f1oat_ inverse(b3 ,nb-mb);
outfilc<<"\n Inverse of B" Matrix \n";
for(i= 1 ; i<=nb-mb; i++)
{
outfile<<"\n";
for(j= 1 ;j<= nb-mb; j+-+)
outfile<<b3[i][j]<<" ";
}
outfile<<"\nCheck Matrix\n";
for(i= 1 ;i<=nb-mb;i++)
{
Outfile<<\n";
17
For(j = 1 ;j<=nb-mb; j++)
{
chk[i] [j]=0.0;
for(k= 1 ;k<=nb-mb; k++)
chk[i] [j]+=b2[i] [k] *b3 [k][j];
outfile<<chk[i][j]<<" ";
}
}
//intialization of bus voltages
for(i= 1 ;i<=mb; i++)
vnew[i ]=complex( vsp [i], 0. 0);
for(i=mb+ 1 ;i<=nb; i++)
vnew[i]=complex( 1.0,0.0);
iter=0;
ll: ;
iter+= 1;
outfile< <"\niter: "<<iter;
for(i= 1 ;i<=nb: i++)
{
vold[i]=vnew[i];
deltaold[i]=deltanew[i] ;
}
outfile< <"\nDelP values";
for(i=2;i<=nb; i++ )
{
il=i-l;
sum=complex(0.0,0.0);
for(j= 1 ;j<=nb; j++)
sum+=y[i] [j] *vold[j];
pcal[i]=real( conj(vold[i])*sum);
delp[il]= (psp[i]-pcal[i])/abs(vold[i]);
outfile<<"\n"<<delp[i1];
}
Outfile<<"\nDelQ values\n";
for(i=mb+ 1 ;i<=nb; i++)
{
il =i-mb;
sum=complex(0.0,0.0);
for(j= 1 ;j<=nb; j++)
sum+=y(i] [j] *vold[j];
qcal (i ]=- image (sum * conj( vold[ i]));
delq(i1]=(qsp(i]-qcal[i])/abs(vold[i]);
outfile<<"\n"<<delq(i1];
}
for(i= 1 ;i<=nb-l ;i++)
{
g=fabs( delp[i]);
if(g>tol) goto jj;
}
for(i=mb+ 1 ;i<=nb; i++)
{
g=fabs( delq[i]);
if(g>tol) goto jj;
}
goto hh;
jj:;
outfile< <"\nDelDelta \n";
for(i=2;i<=nb; i++ )
{
il= i-l;
deldelta[i]=0.0;
for(j=2;j<=nb;j++)
{
j1 = j - 1;
deldelta[i]+=b1[i1] [j1] *delp[j1];
}
outfile< <"\n "< <deldelta[i];
}
Outfile<<"\nDEL V\n";
for(i=mb+ 1 ;i<=nb;i++)
{
i1 =i-mb;
delv(i]=0.0;
for(j=2;j<=nb; j++ )
{
j1 = j-mb;
delv[i]+=b3 [i1] [j1] *delq[j1];
}
outfile< <"\n "< <delv(i];
}
Outfile<<"\nDelta values (new)\n";
for(i=2;i<=nb; i++ )
{
deltanew[ i ]=deltaold[i]+deldelta[ i];
outfile< <"\n "< <deltanew[i];
}
Outfile<<\nvoltage values(new)\n";
for(i=2;i<=nb;i++ )
{
vnewl =abs(vold(i))+delv[i];
vnew[i]=polar( vnew1 ,deltanew[i]);
outfile< <"\n "< <vnew[i];
}
goto 11;
hh:;
outfile<<"\nSolution is obtained at: "<<iter<<"-th iteration\n";
outfile< <"\nBusNo\tV new(mag)\t Vnew angle(radians )\tReal power\tReactive
Power\n";
for(i= 1;i<=nb;i++)
{
sum=complex(0.0,0.0);
for(j=1 ;j<=nb;j++)
sum+=conj( vnew[i])*y[i] [j] *vnew[j];
p[i]=real(sum);
q[i]=-imag(sum);
outfile< <"\n" < <i < <"\t" < <abs( vnew[i])< <"\t\t" < <deltanew[i]< <"\t\t\t" < <
p[i]«"\t\t"«q[i] ;
}
outfile< <"\nPl oss\tQ loss\n";
ploss=0.0;
qloss=0.0;
for(i=1 ;i<=nb; i++)
{
ploss+=p[i];
qloss+=q[i];
}
outfile<<ploss<<"\t"<<qloss;
outfile<<"\nLine flows";
outfile<<"\nLNo\tSB\tEB\tReal power\tReactive Power\n";
for(i=l;i<=nl;i++)
{
j=sb[i];
k=eb[i];
ctemp=vnew[j]-vnew[k] ;
ctemp=ctemp*( -y[j] [k])+(hly[i]*vnew[j]);
ctemp=ctemp * conj (vnew[j]);
temp 1 =real( ctemp);
temp2=-imag( ctemp);
outfile< <"\n"< <i< <"\t"< <j< <"\t"< <k< <"\t"< <temp1 < <"\t\t"< <temp2;
}
}
void float_ inverse(float x[NB] [NB],int n)
{
int m;
float y;
m=n+ 1 ;
for(i=1 ;i<=n;i++)
{
for(j= 1 ;j<=n;j++)
x[j] [m]=0.0;
x[i][m]=1.0;
y=x[i][i];
for(j= 1 ;j<=m; j++)
x[i] [j]=x[i][j]/y;
for(j= 1 ;j<=n; j++)
{
if(i= = j)goto a;
y=x[j] [i];
for(k=1 ;k<=m;k++)
x[j] [k]=x[j] [k ]-y*x[i] [k];
a:;
}
for(j=1;j<=n; j++)
x[j][i]=x[j][m];
}
}
RESULT
Ex. No: 09
GAUSS SEIDEL LOAD FLOW ANALYSIS
DATE:

AIM

To carry out the load flow analysis of the given power system by gauss seidel method

ALGORITHM

1. Read the line data , specified power & voltage

2. Compute Y-bus matrix

3. Intialize all bus voltages

4. Iteration=1

5. Consider i=2

6. Check the bus is PV or PQ. If PQ go to step 8 , otherwise go to next step

7. Compute Qi and check Q limits

8. Calculate the new value of bus voltage

9. If all the buses are considered go to step 10, otherwise go to step 6

10. Check for the convergence , if no go to step 11, else step 12

11. Update the bus voltage with acceleration factor α=1.4 & iteration =iteration+1

12. Calculate slack bus power Q at PV buses, real & reactive power flow & line losses

13. Print all the result

14. Stop the program


ONE LINE DIAGRAM

Acceleration factor=1.2 AND TOLERANCE=0.0001

BUS SPECIFICATION

BUS BUS GENERATING LOAD IN P.U


VSPECIFIED Qmin Qmax
No TYPE P Q P Q
1 SLACK 1.06 - - - - - -
2 P-Q 1.00 0.6 - 0.0 0.0 -1.0 1.5
3 P-V - - - 0.45 0.15 - -
4 P-V - - - 0.40 0.05 - -
5 P-V - - - 0.60 0.1 - -

LINE DATA

LINE No STARTING BUS ENDING SERIES IMPEDANCE HALF LINE CHARGING


BUS ADMITTANCE (P.U)
1 1 2 (0.02,0.06) (0.0,0.03)

2 1 3 (0.08,0.24) (0.0,0.025)

3 2 3 (0.06,0.18) (0.0,0.02)

4 2 4 (0.02,0.08) (0.0,0.02)

5 2 5 (0.04,0.12) (0.0,0.015)

6 3 4 (0.01,0.03) (0.0,0.01)

7 4 5 (0.08,0.24) (0.0,0.035)
PROGRAM

#include<iostream.h>

#include<fstream.h>

#include<complex.h>

#include<conio.h>

#include<math.h>

#include<stdio.h>

#define NB 5+1

#define NL 7+1

complex y_bus[NB][NB],line_z[NL],halfline_y[NL],sum,a,b,c,vold[NB],vnew[NB],ctemp;

int line[NL],sb[NL],eb[NL],nb,nl,mb,nt,iter,i,j,k,l,m;

float p[NB],psp[NB],qsp[NB],vsp[NB],ql[NB],qg[NB],qbus[NB],tag[NB],alpha;

float pline[NB],qmin[NB],qmax[NB],xx,tol,ploss,qloss,delta[NB],q[NB],vabs[NB],temp1,temp2;

void main()

ifstream infile;

infile.open("gs.dat");

ofstream outfile;

outfile.open("gs.out");

outfile.precision(4);

outfile.setf(ios::showpoint);

outfile.fill('0');

outfile<<"\t\t\t Program For Gauss Seidal Method \n";

outfile<<"\n NB \t NL \t MB \t ALPHA \t TOL \n";


infile>>nb>>nl>>mb>>alpha>>tol;

outfile<<nb<<"\t"<<nl<<"\t"<<mb<<"\t"<<alpha<<"\t"<<tol<<"\n";

outfile<<"\t Line No. \t SB \t Eb \t LINE_Z \t Halfline_y\n\n";

for(i=1;i<=nl;i++)

infile>>line[i]>>sb[i]>>eb[i]>>line_z[i]>>halfline_y[i];

outfile<<line[i]<<"\t"<<sb[i]<<"\t"<<eb[i]<<"\t"<<line_z[i]<<"\t"<<halfline_y[i]<<"\n";

l=sb[i];

m=eb[i];

y_bus[l][l]+=(1.0/line_z[i])+halfline_y[i];

y_bus[m][m]+=(1.0/line_z[i])+halfline_y[i];

y_bus[l][m]+=-1.0/line_z[i];

y_bus[m][l] =y_bus[l][m];

outfile<<"\t\t\t YBus Matrix \n";

for(i=1;i<=nb;i++)

outfile<<"\n";

for(j=1;j<=nb;j++)

outfile<<y_bus[i][j]<<"\t";

outfile<<"\n Specified Voltages \n";

for(i=1;i<=mb;i++)
{

infile>>vsp[i];

outfile<<vsp[i]<<"\t";

outfile<<"\n Specified Real Bus Power \n";

for(i=2;i<=nb;i++)

infile>>psp[i];

outfile<<psp[i]<<"\t";

outfile<<"\n Specified Reactive Bus Power \n";

for(i=mb+1;i<=nb;i++)

infile>>qsp[i];

outfile<<qsp[i]<<"\t";

outfile<<"\n Local Load \n";

for(i=2;i<=mb;i++)

infile>>ql[i];

outfile<<ql[i]<<"\t";

outfile<<"\n Q_Min \n";

for(i=2;i<=mb;i++)

{
infile>>qmin[i];

outfile<<qmin[i]<<"\t";

outfile<<"\n Q_Max \n";

for(i=2;i<=mb;i++)

infile>>qmax[i];

outfile<<qmax[i]<<"\t";

outfile<<"\n TAG \n";

for(i=2;i<=mb;i++)

infile>>tag[i];

outfile<<tag[i]<<"\t";

for(i=1;i<=mb;i++)

vold[i]=complex(vsp[i],0.0);

vnew[i]=vold[i];

for(i=mb+1;i<=nb;i++)

vold[i]=complex(1.0,0.0);

vnew[i]=vold[i];

}
iter=0;

ll:;

iter+=1;

outfile<<"\n ITER \t"<<iter<<"\n";

outfile<<"\n GENERATOR REACTIVE POWER \n";

for(i=2;i<=nb;i++)

if(i>mb) goto dd;

sum=complex(0.0,0.0);

for(j=1;j<=nb;j++)

sum+=y_bus[i][j]*vold[j];

qbus[i]=-imag(conj(vold[i])*sum);

qg[i]=qbus[i]+ql[i];

outfile<<qg[i]<<"\n";

if(qg[i]<qmin[i]) goto bb;

if(qg[i]>qmax[i]) goto cc;

qsp[i]=qbus[i];

goto dd;

bb:;

qsp[i]=qmin[i]-ql[i];

tag[i]=1.0;

goto dd;

cc:;

qsp[i]=qmax[i]-ql[i];

tag[i]=1.0;
dd:;

a=complex(psp[i],-qsp[i])/conj(vold[i]);

b=complex(0.0,0.0);

for(j=1;j<=i-1;j++)

b+=y_bus[i][j]*vnew[j];

c=complex(0.0,0.0);

for(j=i+1;j<=nb;j++)

c+=y_bus[i][j]*vold[j];

vnew[i]=(a-b-c)/y_bus[i][i];

for(i=2;i<=mb;i++)

if(tag[i]==1) goto gg;

vnew[i]=vnew[i]*vsp[i]/abs(vnew[i]);

gg:;

outfile<<"\n DEL V VALUES \n";

for(i=2;i<=nb;i++)

xx=abs(vnew[i]-vold[i]);

outfile<<xx<<"\n";

for(i=2;i<=nb;i++)

xx=abs(vnew[i]-vold[i]);
if(xx>tol) goto ff;

goto hh;

ff:;

for(i=2;i<=nb;i++)

vnew[i]=vold[i]+(alpha*(vnew[i]-vold[i]));

vold[i]=vnew[i];

for(i=2;i<=mb;i++)

tag[i]=0.0;

goto ll;

hh:;

outfile<<"\n Solution Is Obtained At \t"<<iter<<"_th"<<"\t Iteration \n";

outfile <<"\n VOLTAGE AT ALL THE BUSES \n";

for(i=1;i<=nb;i++)

outfile<<vnew[i]<<"\n";

outfile<<"\n Voltage Magnitude At All Buses \n";

for(i=1;i<=nb;i++)

vabs[i]=abs(vnew[i]);

outfile<<vabs[i]<<"\n";

outfile<<"\n Delta Values In Degrees \n";

for(i=1;i<=nb;i++)
{

delta[i]=atan(imag(vnew[i])/real(vnew[i]))*180/3.14;

outfile<<delta[i]<<"\n";

outfile<<"\n Bus No Real \t Reactive \n";

for(i=1;i<=nb;i++)

sum=complex(0.0,0.0);

for(j=1;j<=nb;j++)

sum+=conj(vnew[i])*y_bus[i][j]*vnew[j];

p[i]=real(sum);

q[i]=-imag(sum);

outfile<<i<<"\t"<<p[i]<<"\t"<<q[i]<<"\n";

outfile<<"\n Ploss \t Qloss \n";

ploss=0.0;

qloss=0.0;

for(i=1;i<=nb;i++)

ploss+=p[i];

qloss+=q[i];

outfile<<ploss<<"\t"<<qloss<<"\n";

outfile<<"\n Line Flows \n";

outfile<<"\n"<<"Line\t Sb \tEb\t Real Reactive \n";


outfile<<"No\t\t\t Power\t Power\n";

for(i=1;i<=nl;i++)

j=sb[i];

k=eb[i];

ctemp=vnew[j]-vnew[k];

ctemp=ctemp*(-(y_bus[j][k]))+(halfline_y[i]*vnew[j]);

ctemp=ctemp*conj(vnew[j]);

temp1=real(ctemp);

temp2=-imag(ctemp);

outfile<<i<<"\t"<<sb[i]<<"\t"<<eb[i]<<"\t"<<temp1<<"\t"<<temp2<<"\n";

}
INPUT

5 7 2 1.2 0.0001

1 1 2 (0.02,0.06) (0.0,0.03)

2 1 3 (0.08,0.24) (0.0,0.025)

3 2 3 (0.06,0.18) (0.0,0.02)

4 2 4 (0.02,0.08) (0.0,0.02)

5 2 5 (0.04,0.12) (0.0,0.015)

6 3 4 (0.01,0.03) (0.0,0.01)

7 4 5 (0.08,0.24) (0.0,0.035)

1.06 1.0

0.6 -0.45 -0.4 -0.6

-0.15 -0.05 -0.1

0.1

-1.0 1.5

0.0
OUTPUT

Program for Gauss Seidel Method

NB NL MB ALPHA TOL
5 7 2 1.2000 1.0000e-04
Line No. SB Eb LINE_Z Halfline_y

1 1 2 (0.0200, 0.0600) (0.0000, 0.0300)


2 1 3 (0.0800, 0.2400) (0.0000, 0.0250)
3 2 3 (0.0600, 0.1800) (0.0000, 0.0200)
4 2 4 (0.0200, 0.0800) (0.0000, 0.0200)
5 2 5 (0.0400, 0.1200) (0.0000, 0.0150)
6 3 4 (0.0100, 0.0300) (0.0000, 0.0100)
7 4 5 (0.0800, 0.2400) (0.0000, 0.0350)
YBus Matrix

(6.2500, -18.6950) (-5.0000, 15.0000) (-1.2500, 3.7500) (0.0000, 0.0000) (0.0000,


0.0000)
(-5.0000, 15.0000) (12.1078, -39.1797) (-1.6667, 5.0000) (-2.9412, 11.7647) (-2.5000,
7.5000)
(-1.2500, 3.7500) (-1.6667, 5.0000) (12.9167, -38.6950) (-10.0000, 30.0000) (0.0000,
0.0000)
(0.0000, 0.0000) (-2.9412, 11.7647) (-10.0000, 30.0000) (14.1912, -45.4497) (-1.2500,
3.7500)
(0.0000, 0.0000) (-2.5000, 7.5000) (0.0000, 0.0000) (-1.2500, 3.7500) (3.7500,
-11.2000)
Specified Voltages
1.0600 1.0000
Specified Real Bus Power
0.6000 -0.4500 -0.4000 -0.6000
Specified Reactive Bus Power
-0.1500 -0.0500 -0.1000
Local Load
0.1000
Q_Min
-1.0000
Q_Max
1.5000
TAG
0.0000
ITER 1

GENERATOR REACTIVE POWER


-0.8850

DEL V VALUES
0.0208
0.0071
0.0075
0.0386

ITER 2

GENERATOR REACTIVE POWER


-1.1861

DEL V VALUES
0.0157
0.0071
0.0111
0.0066

ITER 3

GENERATOR REACTIVE POWER


-0.9355

DEL V VALUES
0.0027
0.0097
0.0072
0.0062

ITER 4

GENERATOR REACTIVE POWER


-0.8987

DEL V VALUES
0.0049
0.0055
0.0055
0.0046

ITER 5

GENERATOR REACTIVE POWER


-0.8303

DEL V VALUES
0.0031
0.0045
0.0041
0.0034

ITER 6

GENERATOR REACTIVE POWER


-0.8066

DEL V VALUES
0.0024
0.0033
0.0030
0.0025

ITER 7

GENERATOR REACTIVE POWER


-0.7910

DEL V VALUES
0.0017
0.0024
0.0022
0.0018
ITER 8

GENERATOR REACTIVE POWER


-0.7831

DEL V VALUES
0.0013
0.0018
0.0016
0.0013

ITER 9

GENERATOR REACTIVE POWER


-0.7782

DEL V VALUES
0.0009
0.0013
0.0012
0.0010

ITER 10

GENERATOR REACTIVE POWER


-0.7752

DEL V VALUES
0.0007
0.0010
0.0009
0.0007

ITER 11

GENERATOR REACTIVE POWER


-0.7733

DEL V VALUES
0.0005
0.0007
0.0006
0.0005

ITER 12

GENERATOR REACTIVE POWER


-0.7721

DEL V VALUES
0.0004
0.0005
0.0005
0.0004

ITER 13

GENERATOR REACTIVE POWER


-0.7712
DEL V VALUES
0.0003
0.0004
0.0003
0.0003

ITER 14

GENERATOR REACTIVE POWER


-0.7706

DEL V VALUES
0.0002
0.0003
0.0002
0.0002

ITER 15

GENERATOR REACTIVE POWER


-0.7701

DEL V VALUES
0.0001
0.0002
0.0002
0.0001

ITER 16

GENERATOR REACTIVE POWER


-0.7698

DEL V VALUES
0.0001
0.0001
0.0001
0.0001

ITER 17

GENERATOR REACTIVE POWER


-0.7696

DEL V VALUES
7.3310e-05
0.0001
9.6077e-05
7.8040e-05

ITER 18

GENERATOR REACTIVE POWER


-0.7694

DEL V VALUES
5.3362e-05
7.6210e-05
6.9938e-05
5.6806e-05
Solution Is Obtained At 18_th Iteration

VOLTAGE AT ALL THE BUSES


(1.0600, 0.0000)
(0.9999, -0.0170)
(0.9919, -0.0537)
(0.9902, -0.0544)
(0.9723, -0.0755)

Voltage Magnitude At All Buses


1.0600
1.0000
0.9934
0.9917
0.9752

Delta Values In Degrees


0.0000
-0.9768
-3.0990
-3.1436
-4.4436

Bus No Real Reactive


1 0.8932 1.0037
2 0.6018 -0.8693
3 -0.4480 -0.1509
4 -0.3999 -0.0502
5 -0.6001 -0.1001

Ploss Qloss
0.0471 -0.1669

Line Flows

Line Sb Eb Real Reactive


No Power Power
1 1 2 0.5897 0.8323
2 1 3 0.3036 0.1714
3 2 3 0.1960 -0.0448
4 2 4 0.4674 -0.0241
5 2 5 0.5085 0.0370
6 3 4 0.0398 0.0330
7 4 5 0.1030 0.0004
RESULT

You might also like