Professional Documents
Culture Documents
Power Systems Computation Lab Manual PDF
Power Systems Computation Lab Manual PDF
List of Experiments
Aim: To find solution of set of simultaneous linear equation AX=B using gauss elimination
method.
[A:B]=
[A:B]=
This elimination process is also called forward elimination method. Now these new set of equations
can be solved using backward substitution method.
ALGORITHM
STEP 1: Read n //system size
Read A(i,j)
for i=1 to n
for j=1 to n
Read b(i) for i=1 to n
STEP 2: for i=1 to n
fact =1/A(i,i)
A(i,i)=1
for j=i+1 to n
A(i,j)=A(i,j)*fact
//end of jth loop
B(i)=B(i)*fact
//end of ith loop
STEP 3: k= i+1 to n
fact=A(k,i)
A(k,i)=0
STEP 4: For j=i+1 to n
A(k,j)=A(k,j)-A(i,j)*fact
//End of jth loop
B(k)=B(k)-fact*B(i)
// End of kth loop
//End of ith loop
Note: Gauss-elimination approach is widely used for real square symmetric 'or' unsymmetric
matrices case where the matrix A is calculated in each iteration like Jacobian matrix of Newton-
Raphson load flow studies. Inverse takes N3 operations Gauss-elimination needs N3/3 operations .
Thus, for all power system studies with Newton-Raphson technique are usually solved by using
Gauss-elimination technique.
b) Solution of set of Simultaneous Linear Algebraic Equations by
Cholesky Method
AIM: To write a program to solve a set of simultaneous linear equation Ax=B, using Cholesky
decomposition.
APPARATUS REQUIRED: Computer with installed MATLAB and TURBO C++ software.
THEORY: Cholesky decomposition method is used to solve a set of linear equations AX=B. In this
method any symmetric, positive definite matrix ‘A’ can be decomposed into a product of lower
triangular and upper triangular matrix form by elementary operations of matrix as A=U TU.
Let us suppose a 3x3 matrix A= a11 a12 a13
a21 a22 a23
a31 a32 a33
= UTU.
where, l11 =
or lkk
After the decomposition the system can be easily solved by further doing forward and backward
substitution method.
ALGORITHM
Theory : A matrix is said to be sparse if it contains more number of zero elements than that
of non-zero elements .A good example of sparse matrix is Ybus.
If there are 500 buses and 750 buses,these area a total elements of 500x500.The number of non-
zero elements are elements are 1500+500=2000
=( 500x500-200)/(500x500)
= 99.2%
As the power system size increases,the % sparsity increases to 99.5% or more.In computer
applications of power systems,there is no need to store and operate on zero elements,if at all
we store and operate on zero elements,memory requirements go very high,and cpu time increases
enormously to overcome the disadvantage we use sparsity test.
ALGORITHM
d) for i =l to n
nlcont(i) =0 // initialization
end // end of i th loop.
e) for k =1 to nline
p =lp(k)
q =lq(k)
lpq =itagf(p) + nlcont(p)
lqp = itagf(q) + nlcont( q)
nlcont(p) = nlcont(p)+1 // update nlcont vector
nlcont(q) = nlcont(q)+ I
adjq(lpq) = q // Column no. of Ypq
adjl(lpq) = k // Line no. associated with ypq
adjq(lqp) = p //Column no. of yqp
adjl(1qp) =k // Line no. associated with yqp
end // end of kth loop
a)For i= 1 to n
Ypp(i)=0
//end ith loop // initializationEnd
b) For k=1 to nline
p =lp(k)
q= lq(k)
Ypp(p) =Ypp(p) + yline(k) + ycp (k)
Ypp(q) =Ypp(q) +yline (k) +ycq(k)
// end of kth loop
c) For i= 1 to n
Ypp(i) =Ypp(i) + Yshunt(i)
// end of ith loop
Theory : In Gauss seidel method we take initial guess voltage which are assumed.
In Gauss-approach we calculate Epk+1 voltage but do not update till all buses are completed.
Seidel observed and suggested to obtain E pk+1 immediately and use the updated values in
subsequent calculations.
At (k+1)th iteration
α-acceleration factor is used in GS method to improve the rate of convergence and the best range is
fixed by experimentation,of different systems studies & is found to be 1.4-1.7.
For load bus or PQ bus above calculations are sufficient but for PV bus we have to convert Q-
limits into injection based.
k+1 k
Inew = YppEnew + +
Ep* = Enew
ALGORITHM :
Step 1 : Read system data:
a) Read n,nline,nslack,itermax,epsilon,alpha
b) Read lp(k), lq(k), r(k), x(k), ycp(k), ycq(k),tap(k) for k=1 to
nline
c) Read yshunt(i) for i=1to n
d) Read Pgen(i),Qgen(i),Pload(i),Qload(i) for i=1 to n
e) Read ITYPE(i), Vsp(i), Qmin(i),Qmax(i) for i=1 to n
f) Read E(i) for i=1 to n
Step 2: Verify the input data
Step 3: Form the sparsity vectors ITAGF,ITAGTO,ADJL,ADJQ
vectors
Step 4: Form Ybus using sparsity vectors.
Step 5: Calculate Pshed(i)=Pgen(i)-Pload(i)
Qshed(i)=Qgen(i)-Qload(i) for i=1 to n
Step 6: //Modify Q-limits as Qinjections
for i=l to n
Qmininj(i)=qrnin(i) - qload(i)
Q maxinj(i)=qmax(i) – qload(i)
end //end of ith loop
for i=l to n
E(i)=complex(e(i),f(i) ) //initialize the initial bus voltage to flat
Eold(i)=e(i) //voltage profile except slack bus
end //end of ith loop
Set iter=0
Theory : Due to the slow convergence of Gauss seidel and complexity of power system NR
method is used. N.R is based on Taylor’s series expansion.
Modified NR with ∆V replaced by ∆v/V to reduce cpu time. Now look at NR-Polar version---
Pp+jQp = Ep Ip*
=( Vp )[ ]*
Pp=
Qp =
Pp = YppVp2Cos(δ pp-øpp)+
Qp = YppVp2Sin(δ pp-øpp)+
Pp = GppVp2+
Qp = -BppVp2+
Lpp =Qp-BppVp2
Lpq=
= [ Vp.Ypqsin (δpq-ϕpq)]Vq
Lpq =Qp+BppVp2
Npp =
=[ 2GppVp + VqYpq Cos(δpq – ϕpq)]Vp
=2GppVp2 +VpVqYpqCos(δpq – ϕpq)
Npq = Pp-GppVp2
Mpp = Pp –GppVp2
Algorithm
Step 1: a)read n, nline,nslack, epsilon, itermax //system size
b)read lp(k),lq(k),r(k),x(k),ycp(k),ycq(k),tap(k) for k=1 to nline
c)read yshunt(i) for i=1 to n
d)read pgen(i),qgen(i),pload(i),qload(i) for i=1 to n
e)read itype(i),vsp(i),qmin(i),qmax(i) for i=1 to n
f)read vmag(i),del(i),e(i),f(i) for i=1 to n
Step 2: form sparsity vectors ITAGF,ITAGTO,ADJL,ADJQ vectors.
Step 3: form Ybus using sparsity technique.
Step 4: calculate pshed(i)=pgen(i)-pload(i).
Qshed(i)=qgen(i)-qload(i) for i=1 to n.
Step 5: //as we are attempting NR Q-unadjusted polar load flow,
set voltage magnitude of pv buses as V specified .
also take epv=vsp+j0 form
for i=1 to n
if (itype(i)=2)
set vmag(i)=vsp(i)
E(i)=complex(vsp(i),0)
//end of ith loop
Step 6: set iter=0
Step 7: set |delpmax|=0 and |delqmax|=0
Step 8: //Now calculate pcal(i),qcal(i) as below
for i=1 to n
sum=ypp(i)*E(i)
jstart=ITAGF(i)
jstop=ITAGTO(i)
for j=jstart to jstop
q=ADJQ(j)
sum=sum+ypq(j)*E(q)
//end of jth loop
S=E(i) * conj(sum)
pcal(i)=real(S)
qcal(i)=imag(S)
//end of ith loop
for i=1 to n
delp(i)=pshed(i)-pcal(i)
delq(i)=qshed(i)-qcal(i)
delp(nslack)=0
delq(nslack)=0
if(ITYPE(i)==2)
set delq(i)=0
//as pv bus is maintaining its vsp
if(abs(delp(i)>|delpmax|)
set |delpmax|=abs(delp(i))
if(abs(delq(i)>|delqmax|)
set |delqmax|=abs(delq(i))
//1 bus calculations are over
//end of loop i
Step 9: //check for convergence
if(|delpmax|<=epsilon and |delqmax|<=epsilon)
go to step 16
usually epsilon=0.0001
Step 10: //now form the jacobian matrix
first form the diagonals
Hpp=-BppVp2 - Qp
Lpp=-BppVp2 + Qp
Npp=GppVp2 + Pp
Mpp=-GppVp2 + Pp
for i=1 to n
A(i,i)=A(i,i) -Qcal(i)-imag(Ypp(i)*vmag(i)*vmag(i))
A(i+n,i+n)=A(i+n,i+n) +Qcal(i))-imag(Ypp(i)*vmag(i)*vmag(i))
A(i+n,i)=A(i+n,i) +Pcal(i)-real (Ypp(i)*vmag(i)*vmag(i))
A(i,i+n)=A(i,i+n) +Pcal(i)+real(Ypp(i)*vmag(i)*vmag(i))
//end of loop i
//diagonals over
set A(nslack,nslack)=10^20 //for phase angle correction of
slack bus=0
set A(nslack+n,nslack+n)=10^20 //for voltage magnitude correction of slack
bus=0
//formation of off diagonals
Hpq=Gpq(fpeq-fqep)-Bpq(epeq+fpfq)
Lpq=Hpq
Npq=Bpq(fpeq-fqep)+Gpq(epeq+fpfq)
Mpq=Npq
for k=1 to nline
p=lp(k)
q=lq(k)
A(p,q)=Hpq’s expression
A(p+n,q+n)=Lpq’s expression
A(p,q+n)=Npq’s expression
A(n+p,q)=A(p,n+q)
//end of loop k
//formation of jacobian is over
//form mismatch vector
for i=1 to n
delpq(i)=delp(i)
delpq(i+n)=delq(i)
//end of loop i
Step 11: //use Gauss elimination AX=B form where
A=jacobian matrix
B=delpq vector
X=correction vector(delx)
delx=delpq
solve it by gauss elimination
Step 12: //now update the voltage phase angles and magnitude
for i=1 to n
delta(i)=delta(i)+delx(i)
vmag(i)=vmag(i)+delx(i+n)*vmag(i)
e(i)=vmag(i)*cos(delta(i))
f(i)=vmag(i)*sin(delta(i))
E(i)=complex(e(i),f(i))
end of loop i
//one iteration is over
Step 13: iter=iter+1
Step 14: if iter<itermax then go to step 7
Where |delpmax|,|delqmax| are zero
Step 15: problem not converged in itermax iterations
Stop
Step 16: problem converged in ‘iter’ iterations
Calculate line flows, line losses, slack bus power and stop.
5 b. Load Flow Study by Newton-Raphson (Polar) Method (Q-Adjusted case)
Step 1 : Read system data :
a) Read n,nline,nslack,epsilon,itermax
b) Read lp(k), lq(k), r(k), x(k), ycp(k), ycq(k),tap(k) for k=1 to
nline
c) Read yshunt(i) for i=1to n
d) Read Pgen(i),Qgen(i),Pload(i),Qload(i) for i=1 to n
e) Read ITYPE(i), Vsp(i), Qmin(i),Qmax(i) for i=1 to n
f) Read E(i) for i=1 to n
Step 2: Verify the input data
Step 3: Form the sparsity vectors ITAGF,ITAGTO,ADJL,ADJQ
vectors
Step 4: Form Ybus using sparsity vectors.
Step 5: Calculate Pshed(i)=Pgen(i)-Pload(i)
Qshed(i)=Qgen(i)-Qload(i) for i=1 to n
Step 6: //Modify Q-limits as Qinjections
for i=l to n
Qmininj(i)=qmin(i) - qload(i)
Q maxinj(i)=qmax(i) – qload(i)
end //end of ith loop
for i=l to n
E(i)=complex(e(i),f(i) ) //initialize E(i) to flat voltage profile
Eold(i)=e(i) //for all buses except slack bus
end //end of ith loop
Step6: Set iter=0
Step7: set |delPmax|=0 and |delQmax|=0
Set i=1 //bus count
Step 8: If i=nslack then go to step 10
If ITYPE(i)=1 then go to 8(a)
Else
e=real(e(i)) //PV bus calculations
f=imag(f(i))
delnew=tan-1(f/e)
enew=Vsp(i)*cos(delnew)
fnew=Vsp(i)*sin(delnew)
Enew=complex(enew,fnew)
//Calculate Inew and Qnew
Inew=Ypp(i)*Enew
jstart=ITAGF(i)
jstop=ITAGTO(i)
for j=jstart to jstop
q=ADJQ(j)
Inew=Inew+Ypq(j)*E(q)
end //end of jth loop
Pnew=real(Enew*conj(Inew)) //Pnew=Pcal
Qnew=imag(Enew*conj(Inew)) //Qnew=Qcal
Qnew=imag(Enew* conj (sum))
Set Qshed(i)=Qnew
if Qnew<Qmininj(i)
then Qshed(i)=Qmininj(i)
E(i)=Eold(i) //guess voltage
Apparatus Required :
Theory:
NR –Polar version :
[∆P] = [H][∆δ]
[∆Q] =[L][∆V/V] ------------------ NDC equations
b)δpq =δp-δq=0
cosδpq =1
sinδpq 0
[∆Pp/Vp] =[-Bpq][∆δ]
[∆P/Vp] =[B1][∆δ]
[∆Q] =[Vp(-Bpq)Vq][∆Vq/Vq]
B2 couples ∆Q & ∆V
Algorithm:
Step 1: Read the input data
Step 2: Form Ybus by sparsity technique
Step 3: calculate for k=1 to nline
bline(k)=1/x(k)
//end of loop i
Step 4: initialize B1(i,j) and B2(i,j) matrices to zero for i=1 to n and
for j=1 to n
Step 5: form B1 and B2 matrices
//formation of B1 matrix
for i=1:n
for j=1:n
B1(i,j)=0
B2(i,j)=0
end of ith loop
end of jth loop
for k=1:nline
p=lp(k)
q=lq(k)
temp=bline(k)
B1(p,q)=B1(p,q)-temp;
B1(q,p)=B1(p,q);
B1(p,p)=B1(p,p)+temp;
B1(q,q)=B1(q,q)+temp;
end of kth loop
B1(nslack,nslack)=10^20
//formation of B1 matrix is over
//formation of B2 matrix
for i=1:n %diagonal elements
B2(i,i)= -imag(ypp(i));
//end of ith loop
for i=1:n
jstart=itagf(i);
jstop=itagto(i);
for j=jstart:jstop
q=adjq(j);
k=adjl(j);
B2(i,q)=B2(i,q)+imag(yline(k)); %off diagonal elements
//or B2(i,q)=B2(i,q)-imag(Ypq(j)) since Ypq= -yline(k)
//end of jth loop
//end of ith loop
for i=1:n
if(itype(i)=2)
B2(i,i)=10^20; //pv bus
//end of loop i
B2(nslack,nslack)=10^20;
Step 6: Apply cholesky decomposition for B1 and B2 matrices
Step 7: calculate pshed(i) and qshed(i) for i=1 to n
delp(i)=pshed(i)-pcal(i)
delq(i)=qshed(i)-qcal(i)
Step 8: set iter=0
Step 9: set |depmax|=0 and |delqmax|=0
Step 10: //now calculate pcal(i),qcal(i) as below
for i=1 to n
sum=ypp(i)*E(i)
jstart=ITAGF(i)
jstop=ITAGTO(i)
for j= jstart to jstop
q=ADJQ(j)
sum=sum+ypq(j)*E(q)
//end of jth loop
S=E(i)*conj(sum)
pcal(i)= real(S)
qcal(i)= imag(S)
//end of loop i
for i=1 to n
delp(i)=pshed(i)-pcal(i)
delq(i)=qshed-qcal(i)
if(ITYPE(i)==2)
set delq(i)=0 //as pv bus is maintains its Vsp in Q-unadjusted case
//end of loop i
delp(nslack)=0;
delq(nslack)=0;
for i=1:n
if(abs(delp(i))>|delpmax|)
set |delpmax|=abs(delp(i))
if(abs(delq(i)>|delqmax|)
set |delqmax|=abs(delq(i))
//end of loop i
Step 11: //check for convergence
if(|delpmax|<=epsilon and |delqmax|<=epsilon)
go to step 23 //problem is converged
usually epsilon=0.0001
Step 12: calculate [delp(i)/v(i)] vector for i=1:n
then solve [delp/v] =[B1][deldelta]
using forward and backward substitution on components of B1 matrix
Step 13: update phase angles and bus voltages
for i=1 to n
delta(i)=delta(i)+deldelta(i)
E(i)=complex(v(i)cos(delta(i)),v(i)sin(delta(i)))
Step 14: set iter=iter+0.5
Step 15: calculate pcal(i),qcal(i) for i=1 to n
also calculate delp(i),delq(i) for i=1 to n
set delp(nslack,nslack)=0;
delq(nslack,nslack)=0;
also set delq(pv bus)=0;
Step 16: determine |delpmax| and |delqmax|
Step 17: //check for convergence
if(|delpmax|<=epsilon and |delqmax|<=epsilon)
go to step 23 //problem is converged
usually epsilon=0.0001;
Step 18: calculate [delq(i)/v(i)] vector for i=1 to n
Step 19: then solve [delq/v]=[B2][delv]
using forward and backward substitution on components of B2 matrix
Step 20: update voltage magnitudes and recompute complex bus voltages
for i=1 to n
Delv(i)=v(i)+delv(i)
E(i)=complex(v(i)cos(delta(i)),v(i)sin(delta(i)))
Step 21: set iter =iter+0.5
if iter<itermax
go to step 10
Step 22: problem not converged in itermax iterations,stop
Step 23: problem converged in ‘iter’ iterations.
Calculate line flows, line losses and slack bus power. stop.
6b. Load Flow Study by Fast-Decoupled Method (Q-Adjusted case)
Step 1: Read the input data
Step 2: Form Ybus by sparsity technique
Step 3: Form B1 and B2 as in FDC unadjusted studies
Decompose them using cholesky method
Step 4: Calculate pshed(i) and qshed(i) for i=1:n //psehd(i)=Pgen(i)-Pload(i)
For i=1:n //qshed(i)=Qgen(i)-Qload(i)
Qmininj(i)=qmin(i)-qload(i)
Qmaxinj(i)=qmax(i)-qload(i)
//q limits enforcement is to be done after first iteration//i.e first iteration is unadjusted
Step 5: Set iter=0
Step 6: Set |delpmax|=0 and |delqmax|=0
Step 7: //Now calculate pcal(i),qcal(i) as below
for i=1:n
sum=ypp(i)*E(i)
jstart=ITAGF(i)
jstop=ITAGTO(i)
for j=jstart to jstop
q=ADJQ(j)
sum=sum+ypq(j)*E(q)
//end of jth loop
sum=E(i)*conj(sum)
pcal(i)=real(sum)
qcal(i)=imag(sum)
//end of ith loop
Step 8: if(iter>=1)
//then enforce Q-limits.
//else go to step 9 (Q-unadjusted case)
for i=1:n
ipv(i)=itype(i)//end of ith loop
this vector indicates which pv bus is violating Q-limits
for i=1:n
if(ITYPE(i)=2)
then calculate,
deltanew=tan-1(f(i)/e(i))
enew=vsp(i)*cos(deltanew)
fnew=vsp(i)*sin(deltanew)
Enew=complex(enew,fnew)
sum=ypp(i)*E(i)
jstart=ITAGF(i)
jstop=ITAGTO(i)
for j=jstart to jstop
q=ADJQ(j)
sum=sum+ypq(j)*E(q)
//end of jth loop
Sum=E(i)*conj(sum)
qnew=imag(sum)
set qshed(i)=qnew
if qnew<qmininj(i)
then qshed(i)=qmininj(i)
//pv bus is converted in to PQ bus
ipv(i)=1
//this additional vector is required in Q-adjusted NR load flow
if qnew>qmaxinj(i)
qshed(i)=qmaxinj(i)
//PV bus is converted into PQ bus
ipv(i)=1
if(qshed(i)=qnew(i))
E(i)=Enew
ipv(i)=2
//PV bus treatment is over
//end of ith loop
Step 9: a)//now calculate for i=1to n
delp(i)=pshed(i)-pcal(i)
delq(i)=qshed(i)-qcal(i)
//end of loop i
delp(nslack)=0
delq(nslack)=0
b)if iter<=1 then for i=1to n
if(ITYPE(i)=2)
set delq(i)=0
//unadjusted study,where itype(i)=2 is a PV bus
c)if iter>1
then for i=1to n
if(ipv(i)=2)
set delq(i)=0
//end of loop i
//with Q-enforcement we look at ipv-vector
Step 10: determine delpmax,delqmax
//check for convergence
if(|delpmax|<=epsilon and |delqmax|<=epsilon)
go to step 21
usually epsilon=0.0001
Step 11: calculate [delp(i)/v(i)] vector for i=1:n
then solve [delp/v]=[B1][deldelta]
//using forward and backward substitution on components of B1 matrix
update phase angles and bus voltages
delta(i)=delta(i)+deldelta(i)
E(i)=complex(v(i)cos(delta(i)),v(i)sin(delta(i)))
half iteration is over
Step 12: iter=iter+0.5
Step 13: if(iter<itermax) then
Set |delpmax|=0 and |delqmax|=0
Step 14: calculate pcal(i),qcal(i) for i=1:n
//pv bus treatment then repeat above statements starting from step 8 to step 9c
Step 15: determine delpmax and delqmax
//check for convergence as in step(10)
Step 16: cal [delq(i)/v(i)] vector for i=1:n
if(iter>1)
then reform the B2 matrix and modify its B2(pv,pv)=10^20 if pv bus falls within Q-limits
then redecompose B2 matrix using cholesky decomposition technique.
Step 17: solve [delq/v]=[B2][deltav]
update voltage magnitudes and recalculate their complex voltages
Step 18: iter=iter+0.5
Step 19: if(iter<itermax) go to step 6
Step 20: problem not converged in itermax iterations and stop
Step 21: problem converged in ‘iter’ iterations. Calculate line flows, line losses,
slack bus power and stop.