Vous êtes sur la page 1sur 1

2/7/2016

FileExchangeMATLABCentral

%ProgramforGaussSeidelLoadFlowAnalysis
%PravirajPG,MTechIYear,EEDept.,IITRoorkee,India,Email:pravirajpg@gmail.com
%Assumption,Bus1isconsideredasSlackbus.
ybus=ybusppg();%Callingprogram"ybusppg.m"togetYBus.
busdata=busdata6();%Calling"busdata6.m"forbusdata.
bus=busdata(:,1);%Busnumber.
type=busdata(:,2);%TypeofBus1Slack,2PV,3PQ.
V=busdata(:,3);%InitialBusVoltages.
th=busdata(:,4);%InitialBusVoltageAngles.
GenMW=busdata(:,5);%PGi,RealPowerinjectedintothebuses.
GenMVAR=busdata(:,6);%QGi,ReactivePowerinjectedintothebuses.
LoadMW=busdata(:,7);%PLi,RealPowerDrawnfromthebuses.
LoadMVAR=busdata(:,8);%QLi,ReactivePowerDrawnfromthebuses.
Qmin=busdata(:,9);%MinimumReactivePowerLimit
Qmax=busdata(:,10);%MaximumReactivePowerLimit
nbus=max(bus);%Togetno.ofbuses
P=GenMWLoadMW;%Pi=PGiPLi,RealPoweratthebuses.
Q=GenMVARLoadMVAR;%Qi=QGiQLi,ReactivePoweratthebuses.
Vprev=V;
toler=1;%Tolerence.
iteration=1;%iterationstarting
while(toler>0.00001)%Startofwhileloop
fori=2:nbus
sumyv=0;
fork=1:nbus
ifi~=k
sumyv=sumyv+ybus(i,k)*V(k);%Vk*Yik
end
end
iftype(i)==2%ComputingQiforPVbus
Q(i)=imag(conj(V(i))*(sumyv+ybus(i,i)*V(i)));
if(Q(i)>Qmax(i))||(Q(i)<Qmin(i))%CheckingforQiViolation.
ifQ(i)<Qmin(i)%Whetherviolatedthelowerlimit.
Q(i)=Qmin(i);
else%No,violatedtheupperlimit.
Q(i)=Qmax(i);
end
type(i)=3;%IfViolated,changePVbustoPQbus.
end
end
V(i)=(1/ybus(i,i))*((P(i)j*Q(i))/conj(V(i))sumyv);%ComputeBusVoltages.
iftype(i)==2%ForPVBuses,VoltageMagnituderemainssame,butAnglechanges.
V(i)=pol2rect(abs(Vprev(i)),angle(V(i)));
end
end
iteration=iteration+1;%Incrementiterationcount.
toler=max(abs(abs(V)abs(Vprev)));%Calculatetolerance.
Vprev=V;%Vprevisrequiredfornextiteration,V(i)=pol2rect(abs(Vprev(i)),angle(V(i)));
end%Endofwhileloop/Iteration
iteration%Totaliterations.
V%BusVoltagesinComplexform.
Vmag=abs(V)%FinalBusVoltages.
Ang=180/pi*angle(V)%FinalBusVoltageAnglesinDegree.

http://www.mathworks.com/matlabcentral/fileexchange/14089gaussseidelloadflowanalysis/content/gaussppg.m

1/1