Code covered by the BSD License  

Highlights from
Back forward sweep algortihm for radial distribution systems (modified)

Back forward sweep algortihm for radial distribution systems (modified)

by

david (view profile)

 

Backward/ forward sweep algorithm for three-phase load-flow analysis of radial distribution systems.

b_f_modified.m
 %      BusNo   RealPower(pu) ReactivePower(pu) bdata stands for bus data
bdata=[  1          0              0
         2         1.22          0.916
         3         0.032         0.024 
         4         0.778         0.584
         5         0.673         0.595
         6         1.22          0.916
         7         0.0488        0.0366
         8         0.956         0.717
         9         0.698         0.523
         10        1.265         0.949   
         11        0.265         0.0949];
%     Inbus  Outbus Resistance(pu) Reactance(pu) ldata stands for line data
     
ldata=[  1      2       0.04997         0.06644 
         2      3       0.02332         0.03310  
         1      4       0.04664         0.06201
         1      5       0.02082         0.02768
         5      6       0.02500         0.03322
         1      7       0.02665         0.03543
         7      8       0.02748         0.03654
         1      9       0.03331         0.04430
         1      10      0.02082         0.02768   
         2      11      0.02082         0.02768];

     
%Forward Backward Sweep algorithm for Radial Distribution System
 
 
%function [] = radialforwardbackwardsweep ()
 
   c = input('Enter the central bus no.: ');
   Iterations = input('Enter the no. of iterations : ');
%   ldat;
 %  bdat;
   sizl=size(ldata);
   sizb=size(bdata);
   totalbus=sizb(1,1);                            %total no. of buses
   
   
%Find Terminal Buses by using the fact that a Terminal bus is never an inbus
   for i=1:totalbus-1
       Terminalbuses(i,1)=0;
       Intermediatebuses(i,1)=0;
   end
   co=0;in=0;
   for i=1:sizl(1,1)
     for j=1:sizl(1,1)
         if (i~=j)&&(ldata(i,2)==ldata(j,1))
             co=co+1;
         end
     end
     if co==0
         in=in+1;
         Terminalbuses(in,1)=ldata(i,2);
     else
         in=in+1;
         Intermediatebuses(in,1)=ldata(i,2);
     end
     co=0;
   end
   
   
   %Initializing Voltage and Current matrices
   for i=1:totalbus
       Busvoltage(i,1)=0;
   end
   for i=1:sizl(1,1)
       Linecurrent(i,1)=0;
   end
   for i=1:totalbus-1
       if(Terminalbuses(i,1)~=0)
           Busvoltage(Terminalbuses(i,1),1)=1;
       end
   end
   
  
   
   
   
   
   for i=1:Iterations
       
     %forward sweep
     t=0;int=0;
     for i=1:sizl(1,1)
         for j=1:totalbus-1
           if ldata(i,2)== Terminalbuses(j,1)
               t=t+1;
           end
         end
         if(t~=0)
Linecurrent(i,1)=conj(complex(bdata(ldata(i,2),2),bdata(ldata(i,2),3))/Busvoltage(ldata(i,2),1));
         end
         t=0;
     end
     for i=1:sizl(1,1)
         for j=1:totalbus-1
            if ldata(i,2) == Intermediatebuses(j,1)
                int=int+1;
            end
         end
         if(int~=0)
               Busvoltage(ldata(i,2),1)=Busvoltage(ldata(i+1,2),1)+((Linecurrent(i+1,1))*(complex(ldata(i+1,3),ldata(i+1,4))));
               Linecurrent(i,1)=(conj(complex(bdata(ldata(i,2),2),bdata(ldata(i,2),3))/Busvoltage(ldata(i,2),1)))+ Linecurrent(i+1,1);
               for i1=1:sizl(1,1)
                  if (i+1 ~=i1)&&(ldata(i,2)==ldata(i1,1))
                  Linecurrent(i,1)=Linecurrent(i,1)+Linecurrent(j,1);
                  
                  end
               end

         end
         int=0;
     end
     
     
     %backward sweep
     Busvoltage(c,1)=1;
     for i=1:sizl(1,1)
           if (ldata(i,1)==c)
Busvoltage(ldata(i,2),1)=Busvoltage(c,1)-(Linecurrent(i,1)*(complex(ldata(i,3),ldata(i,4))));
           else
Busvoltage(ldata(i,2),1)=Busvoltage(ldata(i,1),1)-(Linecurrent(i,1)*(complex(ldata(i,3),ldata(i,4))));
           end     
     end
     
   end
   
   display(Linecurrent);
   display(Busvoltage);
     
 % end

Contact us