Professional Documents
Culture Documents
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
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
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
NUMBER OF LINES:3
NUMBER OF BUSES:3
Y-BUS MATRIX
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
Generator 2: 0.0+0.08
Transformer 1: 0.0+j0.25
Transformer2: 0.0+j0.1
#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”]
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
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
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.
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
ALGORITHM
#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
ALGORITHM
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
#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
#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
#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");
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;
if(l==0)
a[i][j]=0;
else
infile>>m;
if(m==1)
a[i][j]=-1;
else
a[i][j]=1;
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;
if(r==0)
lp[i][j]=0;
else
infile>>s;
if(s==1)
lp[i][j]=1;
else
lp[i][j]=-1;
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
No of elements:4
No of Nodes:3
No of branches:3
1 0 0
0 0 1
0 1 -1
1 -1 0
No of loops=1
-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
4. Iteration=1
5. Consider i=2
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
BUS SPECIFICATION
LINE DATA
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<<nb<<"\t"<<nl<<"\t"<<mb<<"\t"<<alpha<<"\t"<<tol<<"\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];
for(i=1;i<=nb;i++)
outfile<<"\n";
for(j=1;j<=nb;j++)
outfile<<y_bus[i][j]<<"\t";
for(i=1;i<=mb;i++)
{
infile>>vsp[i];
outfile<<vsp[i]<<"\t";
for(i=2;i<=nb;i++)
infile>>psp[i];
outfile<<psp[i]<<"\t";
for(i=mb+1;i<=nb;i++)
infile>>qsp[i];
outfile<<qsp[i]<<"\t";
for(i=2;i<=mb;i++)
infile>>ql[i];
outfile<<ql[i]<<"\t";
for(i=2;i<=mb;i++)
{
infile>>qmin[i];
outfile<<qmin[i]<<"\t";
for(i=2;i<=mb;i++)
infile>>qmax[i];
outfile<<qmax[i]<<"\t";
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;
for(i=2;i<=nb;i++)
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";
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++)
vnew[i]=vnew[i]*vsp[i]/abs(vnew[i]);
gg:;
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:;
for(i=1;i<=nb;i++)
outfile<<vnew[i]<<"\n";
for(i=1;i<=nb;i++)
vabs[i]=abs(vnew[i]);
outfile<<vabs[i]<<"\n";
for(i=1;i<=nb;i++)
{
delta[i]=atan(imag(vnew[i])/real(vnew[i]))*180/3.14;
outfile<<delta[i]<<"\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";
ploss=0.0;
qloss=0.0;
for(i=1;i<=nb;i++)
ploss+=p[i];
qloss+=q[i];
outfile<<ploss<<"\t"<<qloss<<"\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.1
-1.0 1.5
0.0
OUTPUT
NB NL MB ALPHA TOL
5 7 2 1.2000 1.0000e-04
Line No. SB Eb LINE_Z Halfline_y
DEL V VALUES
0.0208
0.0071
0.0075
0.0386
ITER 2
DEL V VALUES
0.0157
0.0071
0.0111
0.0066
ITER 3
DEL V VALUES
0.0027
0.0097
0.0072
0.0062
ITER 4
DEL V VALUES
0.0049
0.0055
0.0055
0.0046
ITER 5
DEL V VALUES
0.0031
0.0045
0.0041
0.0034
ITER 6
DEL V VALUES
0.0024
0.0033
0.0030
0.0025
ITER 7
DEL V VALUES
0.0017
0.0024
0.0022
0.0018
ITER 8
DEL V VALUES
0.0013
0.0018
0.0016
0.0013
ITER 9
DEL V VALUES
0.0009
0.0013
0.0012
0.0010
ITER 10
DEL V VALUES
0.0007
0.0010
0.0009
0.0007
ITER 11
DEL V VALUES
0.0005
0.0007
0.0006
0.0005
ITER 12
DEL V VALUES
0.0004
0.0005
0.0005
0.0004
ITER 13
ITER 14
DEL V VALUES
0.0002
0.0003
0.0002
0.0002
ITER 15
DEL V VALUES
0.0001
0.0002
0.0002
0.0001
ITER 16
DEL V VALUES
0.0001
0.0001
0.0001
0.0001
ITER 17
DEL V VALUES
7.3310e-05
0.0001
9.6077e-05
7.8040e-05
ITER 18
DEL V VALUES
5.3362e-05
7.6210e-05
6.9938e-05
5.6806e-05
Solution Is Obtained At 18_th Iteration
Ploss Qloss
0.0471 -0.1669
Line Flows