Algorithm 1 Gauss Seidel Load Flow Algorithm
1: Read Input Data ▷ Step-1
Read n, nline
Read Lp(k), Lq(k), R(k), X(k),Ycp(k), Ycq(k), tap(k), k = 1, . . . nline
Read yshunt (i), i = 1, . . . n
Read Pgen (i), Qgen (i), Pload (i),Qload (i) i = 1, . . . n
Read Vsp (i), Btype(i), Qmax (i),Qmin (i) i = 1, . . . n
Read E(i) = Vm (i)̸ δ(i), i = 1, . . . n
2: Print Input Data and verify thoroughly ▷ Step-2
3: Calculate Pinj , Qinj , Qmaxinj , Qmininj ▷ Step-3
4: for i = 1, . . . n do
5: Pinj (i) = Pgen (i) − Pload (i)
6: Qinj (i) = Qgen (i) − Qload (i)
7: Qmaxinj (i) = Qmax (i) − Qload (i)
8: Qmininj (i) = Qmin (i) − Qload (i)
9: end for
10: Initialize YBus Matrix ▷ Step-4
11: for i = 1, . . . n do
12: for j = 1, . . . n do
13: Y [i, j] = 0
14: end for
15: end for
16: Calculate Primitive Admittance Matrix ▷ Step-5
17: for k = 1, . . . nline do
18: z=complex(R(k),X(k))
19: yline(k)= z1
20: if tap(k)̸=1 then
1
21: term1 = 1 − tap(k)
22: term2 = −term1
tap(k)
23: ycp(k)=term2 * yline(k)
24: ycq(k)=term1 * yline(k)
25: yline(k) = yline(k)
tap(k)
26: end if
27: end for
28: Formation of Ybus element ▷ Step-6
29: for k = 1, . . . nline do
30: P = Lp(k)
31: Q = Lq(k)
32: Y(P,P) = Y(P,P) + yline(k) + ycp(k)
33: Y(P,Q) = Y(P,Q) - yline(k)
34: Y(Q,Q) = Y(Q,Q) + yline(k) + ycq(k)
35: Y(Q,P) = Y(Q,P) - yline(k)
36: end for
37: Account of yshunt(i) ▷ Step-7
38: for i = 1, . . . n do
39: Y(i,i) = Y(i,i) + yshunt (i)
40: end for
2
Print Ybus matrix ▷ Step-8
Initialize the voltage and Bus type ▷ Step-9
for i = 1, . . . n do
Eold(i) = E(i)
Btype new(i)=Btype(i)
end for
Set iter=1 (iteration counter) ▷ Step-10
Set |∆Emax = 0.0| (for checking convergence |∆Emax | ≤ ϵ ) ▷ Step-11
Set the bus counteri = 1 ▷ Step-12
Is (i = nslack), YES Goto Step 15 ▷ Step-13
Now check ith bus is a PV-bus ▷ Step-14
if Btype(i)= 2 then
then PV bus treatment starts
e=real(E(i))
f=imag(E(i))
delta=atan(f/e)
enew=Vsp (i) ∗ cos(delta)
fnew=Vsp (i) ∗ sin(delta)
Enew=complex(enew,fnew)
Isum=Ybus(i,k)*Enew
for k = 1, . . . n do
if i ̸= k then
Isum=Ybus(i,k)*E(k);
end if
end for
Qnew=imag(Enew*conj(Isum));
Qinj(i)=Qnew;
if Qnew < Qmininj(i) then
Qinj(i)=Qmininj(i)
Btype new(i)=1
else if Qnew > Qmaxinj(i) then
Qinj(i)=Qmaxinj(i);
Btype new(i)=1;
end if
if Qinj(i)==Qnew then
Btype new(i)=2;
E(i)=Enew;
end if
end if
Isum=conj(complex(Pinj(i),Qinj(i))/E(i))
for k=1:n do
if i ̸= k then
Isum=Isum-(Ybus(i,k)*E(k))
end if
end for
3
Eint=Isum/Ybus(k1,k1);
if Btype new(i)==2 then
e=real(Eint)
f=imag(Eint)
delta=atan(f/e)
enew=Vsp (i) ∗ cos(delta)
fnew=Vsp (i) ∗ sin(delta)
Eint=complex(enew,fnew);
E(i)=Eint
else if Btype new(i)==1 then
E(i)=Eint;
end if
DelE(i)= E(i)- Eold(i)
if abs(DelE(i))> |∆Emax | then
|∆Emax | =abs(DelE(i))
end if
i=i+1 ▷ Step-15
if i ≤ n then
Goto Step-14
end if
One full iteration over, Check for convergence ▷ Step-16
if |∆Emax | ≤ epsillion then
Goto Step-100
end if
Advance the iter count , iter=iter+1 ▷ Step-17
if iter ≤ Itermax then
Goto Step-11
else
Print the problem is not converged in Itermax iteration
end if
Print the problem is converged in ”iter” iteration ▷ Step-100
Print the converged bus voltages
Stop ▷ Step-101