Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Example 9.2. Figure 9.2 shows the one-line diagr Generators are connected at bus

ID: 2266315 • Letter: E

Question

Example 9.2. Figure 9.2 shows the one-line diagr Generators are connected at buses and while loads are indicated atall re 9.2 shows the one-line diagram of a simple power system. buses. Base values for the transmission system are 100 MVA four data of Table 9.2 give per-unit series impedances and line-charging susceptances for the nominal-r equivalents of the four lines identified by the buses at which they terminate. The bus data in Table 9.3 list values for P, Q, and V at each bus. The Q values of load are calculated from the corresponding P values assuming a power factor of 0.85. The net scheduled values, P, sch and Q,sch, are neg the load buses and . Generated Qgi is not specified where voltage 230 kV. The line ative at Birch Elm Maple Pine FIGURE 9.2 One-line diagram for Example 9.2 showing the bus names and numbers.

Explanation / Answer

%------Newton Raphson load flow program for any bus system------------

clc

clear all

load linedata4.m                %calling line data....

A=linedata4;                    %getlinedata to some variable...

nb=A(1,1);                      % bus number...

itr=A(1,2);                       %max iteration taken...

rtr=A(1,3);                     %regulating transformers taken...

nrtr=A(1,4);                    %non-regulating transformers taken...

trl=A(1,5);                     % no. of transmission lines...

sz=A(1,6);                      %no. of shunt impedances...

pq=A(2,1);                      %no. of load buses....

g=A(2,2);                       %no. of generator buses...

tol=A(2,3);                     %tolerance taken...

nl=rtr+trl+nrtr;                %total no. of transmission lines...

m11=nl+2+sz;

Ld=A(nl+sz+3:m11+pq,:);           %load data...

Gd=A(nl+sz+pq+3:m11+pq+g,:);      %generator data...

for i=1:nl

    sb(i)=A(i+2,1);             % From bus number...

    rb(i)=A(i+2,2);             % To bus number...

    R(i)=A(i+2,3);              %line resistance

    X(i)=A(i+2,4);              %line reactance...

    B(i)=A(i+2,6)/2;            %line suseptance...

    bx(i)=complex(0,B(i));

    TP(i)=A(i+2,7);             %line tapping...

    Z(i)=complex(R(i),X(i));    %line impedance...

    y(i)=1/Z(i);                %line admittance...

end

ybus=zeros(nb,nb);

% ------------FORMATION OF YBUS MATRIX-------------

% ------------OFF diagonal elements------------

for i=1:nl

    ybus(sb(i),rb(i))=ybus(sb(i),rb(i))-y(i)/TP(i);

    ybus(rb(i),sb(i))=ybus(sb(i),rb(i));

end

ybus;

% --------------diagonal elements------------

for k1=1:nb

    for i=1:nl

        if sb(i)==k1

            ybus(k1,k1)=ybus(k1,k1)+y(i)/(TP(i)^2)+bx(i);

        else if rb(i)==k1

            ybus(k1,k1)=ybus(k1,k1)+y(i)+bx(i);

            end

        end

    end

end

ybus;

Y1=zeros(nb,nb);

%--------------shunt impedance data-------------

s=A(nl+3:m11,:);

sh=s(:,1);

for j=1:sz

    if ((sz~=0)&(s(j,1)==sh(j,1)))

        Y1(sh(j,1),sh(j,1))=Y1(sh(j,1),sh(j,1))+1/complex(s(j,3),s(j,4));

    end

end

Y1;

if sz~=0

    y1=[ybus+Y1];

else

    y1=ybus;

end

y1;

G=real(y1);

B1=imag(y1);

Y=abs(ybus);

YA=angle(ybus);

%---------------UNKNOWN VOLTAGE MAGNITUDES-------------

VM=ones(nb,1);

for ii=1:g

%if Gd(k,1)==gd(k,1)

    VM(ii)=A(ii+m11+pq,5);

%end

end

VM;

%---------------UNKNOWN VOLTAGE angles-------------

DL=zeros(nb,1);

YGG=y1(1:g,1:g);

YGL=y1(1:g,g+1:nb);

YLG=y1(g+1:nb,1:g);

YLL=y1(g+1:nb,g+1:nb);

YLL1=inv(YLL);

FLG=-YLL1*YLG;

%--------------iteration starts-------------

iter=0

while iter<=0.0001

%------------calculation of inected powers---------  

Pcal=zeros(nb,1);

Qcal=zeros(nb,1);

for l=1:nb

    for k1=1:nb

        Pcal(l) = Pcal(l) + VM(l)* VM(k1)*(G(l,k1)*cos(DL(l)-DL(k1)) + B1(l,k1)*sin(DL(l)-DL(k1)));

        Qcal(l) = Qcal(l) + VM(l)* VM(k1)*(G(l,k1)*sin(DL(l)-DL(k1)) - B1(l,k1)*cos(DL(l)-DL(k1)));     

    end

end

Pcal;

Qcal;

%------------Mismatch Calculation------------------------------------------

Ps=zeros(nb,1);

% % bl=L1(:,1);

% % bg=G1(:,1);

bl=Ld(:,1);

for ii=1:g

    Ps(ii)=Ps(ii)+Gd(ii,2);

end

for pq1=1:pq

    Ps(bl(pq1))=Ps(bl(pq1))-Ld(pq1,2);

end

Qs=zeros(nb,1);

for pq1=1:pq

    Qs(bl(pq1))=Qs(bl(pq1))-Ld(pq1,3);

end

Ps;

Qs;

for l=1:nb

    DP(l)=Ps(l)-Pcal(l);

    DQ(l)=Qs(l)-Qcal(l);

end

DP;

DQ;

DPA=DP(2:nb);

DQA=DQ(g+1:nb);

DPQ=[DPA';DQA'];

if max(abs(DPQ))<=0.0001

    disp('----------------converged------------------')

    Pcal

    Qcal

    VM

    DL

    Ploss=sum(Pcal)

    Qloss=sum(Qcal);

    Ygb2=zeros(nb,nb);

%-------------required power flow---------------

for xk=1:nl

    Ygb2(sb(xk),rb(xk))=bx(xk);

    Ygb2(rb(xk),sb(xk))=Ygb2(sb(xk),rb(xk));

end

Ygb2;

g2=real(Ygb2);

b2=imag(Ygb2);

for pk=1:nb

    for qk=1:nb

        if pk~=qk

            PF(pk,qk)=-VM(pk)*VM(pk)*Y(pk,qk)*cos(YA(pk,qk))+VM(pk)*VM(qk)*Y(pk,qk)*cos(DL(pk)-DL(qk)-YA(pk,qk));

            QF(pk,qk)=VM(pk)*VM(pk)*Y(pk,qk)*sin(YA(pk,qk))+VM(pk)*VM(qk)*Y(pk,qk)*sin(DL(pk)-DL(qk)-YA(pk,qk))-VM(pk)*VM(pk)*b2(pk,qk);

        end

    end

end

PF                         

QF

LF1=complex(PF,QF);

LF=abs(LF1);        

% -----------voltage stability index--------

for l=1:nb

    VMC(l)=complex(VM(l)*cos(DL(l)),VM(l)*sin(DL(l)));

end

VMC;

F2=zeros(nb,1);

for p1=g+1:nb

    for ii=1:g

        F2(ii)=F2(ii)+FLG(p1-g,ii)*VMC(ii)/VMC(p1);

    end

        F1(p1)=sum(F2(p1));

        L(p1)=1-F1(p1);

        L1(p1)=abs(L(p1));

  

end

L1;

    break

else

%-----------------Formation of Jacobian Matrix-----------------------------

% %---------- formation of J1 MATRIX---------

% % ----------diagonal elements---------

for t1 =2:nb

    DPDD(t1,t1)=-Qcal(t1)-B1(t1,t1)*VM(t1)*VM(t1);

end

% % ---------OFF diagonal elements---------

for m1=2:nb

    for n1=2:nb

        if m1~=n1

        DPDD(m1,n1)=VM(m1)*VM(n1)*(G(m1,n1)*sin(DL(m1)-DL(n1))-B1(m1,n1)*cos(DL(m1)-DL(n1)));

        end

    end

end

% %----------- formation of J2 MATRIX----------

% % diagonal elements----------

for t2=g+1:nb

    DPDVM(t2,t2)=Pcal(t2)/VM(t2)+G(t2,t2)*VM(t2);

end

% ----------OFF diagonal elements---------

for m2=2:nb

    for n2=g+1:nb

        if m2~=n2

        DPDVM(m2,n2)=VM(m2)*(G(m2,n2)*cos(DL(m2)-DL(n2))+B1(m2,n2)*sin(DL(m2)-DL(n2)));

        end

    end

end

% --------formation of J3 MATRIX----------

% ------diagonal elements-----------

for t3 =g+1:nb

    DQDD(t3,t3)=Pcal(t3)-G(t3,t3)*VM(t3)*VM(t3);

end

% --------OFF diagonal elements-----------

for m3=g+1:nb

    for n3=2:nb

        if m3~=n3

        DQDD(m3,n3)=-VM(m3)*VM(n3)*(G(m3,n3)*cos(DL(m3)-DL(n3))+B1(m3,n3)*sin(DL(m3)-DL(n3)));

        end

    end

end

% ----------formation of J4 MATRIX-------------

% ----------diagonal elements---------

for t4 =g+1:nb

    DQDVM(t4,t4)=Qcal(t4)/VM(t4)-B1(t4,t4)*VM(t4);

end

% ----------OFF diagonal elements-----------

for m4=g+1:nb

    for n4=g+1:nb

        if m4~=n4

        DQDVM(m4,n4)=VM(m4)*(G(m4,n4)*sin(DL(m4)-DL(n4))-B1(m4,n4)*cos(DL(m4)-DL(n4)));

        end

    end

end

J1=DPDD(2:nb,2:nb);

J2=DPDVM(2:nb,g+1:nb);

J3=DQDD(g+1:nb,2:nb);

J4=DQDVM(g+1:nb,g+1:nb);

J=[J1 J2;

   J3 J4];

JI=inv(J);

DDDV=JI*DPQ;

%DDL=zeros(nb,1);

%DVM=zeros(nb,1);

DDL=DDDV(1:nb-1);

DVM=DDDV(nb:2*(nb)-1-g);

for a=1:nb-1

      DL(a+1)=DL(a+1)+DDL(a);

end

    for b=1:nb-g

        VM(b+g)=VM(b+g)+DVM(b);

end

DL;

VM;

end

iter=iter+1

end

   

   

   

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote