www.pudn.com > OPF.zip > opf.m, change:2013-03-31,size:2963b


%% *************************************************************** 
%             作者:陆镛 
%             原创日期:2012年11月26号 
%             修改日期:2012年11月26号 
%             函数说明:简单最优潮流主函数(完全极坐标) 
%% *************************************************************** 
function opf(FileName) 
%% 变量说明:****************************************************** 
% 输入参数说明: FileName:潮流数据文件名 
% 子程序输入参数、输出参数说明详见各子程序变量说明。 
%% *************************************************************** 
tic; 
[NodeNum,BranchNum,CapacityRef,IterationMax,Center,Precision,BalanceI,LineI... 
    ,LineJ,LineR,LineX,LineB,GroundI,GroundB,TransformerI,TransformerJ,... 
    TransformerR,TransformerX,TransformerK,NodeI,NodePg,NodeQg,NodePl,... 
    NodeQl,PvI,PvV,PvQmin,PvQmax,GenI,GenC,GenB,GenA,GenPmin,GenPmax,PvNum... 
    ,GenNum] = ReadData(FileName); 
%% 变量初始化 
[l,u,z,w,y,Pg,Qr,AmplitudeU,AngleU] = Initialization(NodeNum,PvNum,PvQmin... 
    ,PvQmax,GenNum,GenPmin,GenPmax,CapacityRef); 
%% 节点导纳矩阵 
[AmplitudeY,AngleY,I,J,LineY,TransformerY] = Ymatrix(NodeNum,LineI,LineJ,... 
    LineR,LineX,LineB,GroundI,GroundB,TransformerI,TransformerJ,TransformerR... 
    ,TransformerX,TransformerK); 
%% 开始迭代 
for Iteration=1:IterationMax 
Gap=l'*z-u'*w; 
miu=Center*Gap/2/(NodeNum+GenNum+PvNum); 
 
%% ************************************************************** 
n=GenNum+PvNum+NodeNum; 
L=sparse(1:n,1:n,l,n,n); 
U=sparse(1:n,1:n,u,n,n); 
W=sparse(1:n,1:n,w,n,n); 
Z=sparse(1:n,1:n,z,n,n); 
%% 雅可比 
[InequalityJmatrix,EqualityJmatrix,Jmatrix,Ycos,Ysin] = Jacobi(PvNum,PvI,GenNum,... 
    GenI,GenA,NodeNum,y,L,U,Z,W,AngleU,AmplitudeU,AmplitudeY,AngleY,I,J); 
%% 变量不平衡量 
[Ly,Lz,Lw,Lxx,Llu,Luu,Lx] = Imbalance(miu,NodeNum,GenNum,GenI,GenA,GenB,... 
    GenPmin,GenPmax,PvNum,PvI,PvQmin,PvQmax,NodePl,NodeQl,NodePg,NodeQg,... 
    EqualityJmatrix,InequalityJmatrix,Ycos,Ysin,Pg,Qr,AmplitudeU,... 
    l,u,w,z,y,CapacityRef); 
 
if Gap<Precision 
    break 
end 
 
%% 置0置1 
Jmatrix(BalanceI+GenNum+PvNum,:)=0;                                                   
Jmatrix(:,BalanceI+GenNum+PvNum)=0;                                                    
Jmatrix=Jmatrix+sparse(BalanceI+GenNum+PvNum,BalanceI+GenNum+PvNum,100,... 
    4*NodeNum+GenNum+PvNum,4*NodeNum+GenNum+PvNum); 
Lxx(BalanceI+GenNum+PvNum)=0;  
InequalityJmatrix(BalanceI+GenNum+PvNum,:)=0;  
%% 修正各变量 
[Pg,Qr,AngleU,AmplitudeU,y,l,u,w,z] = Correction(Jmatrix,Lxx,Ly,Lz,Lw,Pg,... 
    Qr,AngleU,AmplitudeU,y,l,u,w,z,InequalityJmatrix,PvNum,GenNum,NodeNum,... 
    Luu,Llu,L,U,W,Z); 
end 
[AmplitudeU AngleU] 
toc; 
Iteration 
%% 损耗 
% [BalanceP,BalanceQ,LineLoss,TransformerLoss,GroundLoss,LineSij,... 
%     LineSji,TransformerSij,TransformerSji] = Loss(BalanceI,AmplitudeU,... 
%     AngleU,Ysin,Ycos,LineI,LineJ,LineY,LineB,TransformerI,TransformerJ,... 
%     TransformerY,TransformerK,GroundI,GroundB);  
end