电力系统分析课程设计 - 牛顿拉夫逊潮流计算

武汉理工大学《电力系统分析》课程设计说明书

for i=1:n %对PV节点的处理,注意这时不可再将h初始化为0 if i~=isb&B2(i,6)==3 h=h+1; for j=1:n

OrgS(2*h-1,1)=OrgS(2*h-1,1)+real(B2(i,3))*(real(Y(i,j))*real(B2(j,3))-imag(Y(i,j))*imag(B2(j,3)))+imag(B2(i,3))*(real(Y(i,j))*imag(B2(j,3))+imag(Y(i,j))*real(B2(j,3))); OrgS(2*h,1)=OrgS(2*h,1)+imag(B2(i,3))*(real(Y(i,j))*real(B2(j,3))-imag(Y(i,j))*imag(B2(j,3)))-real(B2(i,3))*(real(Y(i,j))*imag(B2(j,3))+imag(Y(i,j))*real(B2(j,3))); end end end OrgS

%创建PVU 用于存储PV节点的初始电压 PVU=zeros(n-h-1,1); t=0; for i=1:n if B2(i,6)==3 t=t+1;

PVU(t,1)=B2(i,3); end end PVU

%创建DetaS,用于存储有功功率、无功功率和电压幅值的不平衡量 h=0;

for i=1:n %对PQ节点的处理 if i~=isb&B2(i,6)==2 h=h+1;

DetaS(2*h-1,1)=real(B2(i,2))-OrgS(2*h-1,1); DetaS(2*h,1)=imag(B2(i,2))-OrgS(2*h,1); end end t=0;

for i=1:n %对PV节点的处理,注意这时不可再将h初始化为0 if i~=isb&B2(i,6)==3 h=h+1; t=t+1;

DetaS(2*h-1,1)=real(B2(i,2))-OrgS(2*h-1,1);

DetaS(2*h,1)=real(PVU(t,1))^2+imag(PVU(t,1))^2-real(B2(i,3))^2-imag(B2(i,3))^2; end end DetaS

9

武汉理工大学《电力系统分析》课程设计说明书

%创建I,用于存储节点电流参数 i=zeros(n-1,1); h=0; for i=1:n if i~=isb h=h+1;

I(h,1)=(OrgS(2*h-1,1)-OrgS(2*h,1)*sqrt(-1))/conj(B2(i,3)); end end I

%创建Jacbi(雅可比矩阵) Jacbi=zeros(2*n-2); h=0; k=0;

for i=1:n %对PQ节点的处理 if B2(i,6)==2 h=h+1; for j=1:n if j~=isb k=k+1;

if i==j %对角元素的处理

Jacbi(2*h-1,2*k-1)=-imag(Y(i,j))*real(B2(i,3))+real(Y(i,j))*imag(B2(i,3))+imag(I(h,1));

Jacbi(2*h-1,2*k)=real(Y(i,j))*real(B2(i,3))+imag(Y(i,j))*imag(B2(i,3))+real(I(h,1)); Jacbi(2*h,2*k-1)=-Jacbi(2*h-1,2*k)+2*real(I(h,1)); Jacbi(2*h,2*k)=Jacbi(2*h-1,2*k-1)-2*imag(I(h,1)); else %非对角元素的处理

Jacbi(2*h-1,2*k-1)=-imag(Y(i,j))*real(B2(i,3))+real(Y(i,j))*imag(B2(i,3)); Jacbi(2*h-1,2*k)=real(Y(i,j))*real(B2(i,3))+imag(Y(i,j))*imag(B2(i,3)); Jacbi(2*h,2*k-1)=-Jacbi(2*h-1,2*k); Jacbi(2*h,2*k)=Jacbi(2*h-1,2*k-1); end

if k==(n-1) %将用于内循环的指针置于初始值,以确保雅可比矩阵换行 k=0; end end end end end k=0;

for i=1:n %对PV节点的处理 if B2(i,6)==3 h=h+1; for j=1:n

10

武汉理工大学《电力系统分析》课程设计说明书

if j~=isb k=k+1;

if i==j %对角元素的处理

Jacbi(2*h-1,2*k-1)=-imag(Y(i,j))*real(B2(i,3))+real(Y(i,j))*imag(B2(i,3))+imag(I(h,1));

Jacbi(2*h-1,2*k)=real(Y(i,j))*real(B2(i,3))+imag(Y(i,j))*imag(B2(i,3))+real(I(h,1)); Jacbi(2*h,2*k-1)=2*imag(B2(i,3)); Jacbi(2*h,2*k)=2*real(B2(i,3)); else %非对角元素的处理

Jacbi(2*h-1,2*k-1)=-imag(Y(i,j))*real(B2(i,3))+real(Y(i,j))*imag(B2(i,3)); Jacbi(2*h-1,2*k)=real(Y(i,j))*real(B2(i,3))+imag(Y(i,j))*imag(B2(i,3)); Jacbi(2*h,2*k-1)=0; Jacbi(2*h,2*k)=0; end

if k==(n-1) %将用于内循环的指针置于初始值,以确保雅可比矩阵换行 k=0; end end end end end Jacbi

%求解修正方程,获取节点电压的不平衡量 DetaU=zeros(2*n-2,1); DetaU=inv(Jacbi)*DetaS; DetaU

%修正节点电压 j=0;

for i=1:n %对PQ节点处理 if B2(i,6)==2 j=j+1;

B2(i,3)=B2(i,3)+DetaU(2*j,1)+DetaU(2*j-1,1)*sqrt(-1); end end

for i=1:n %对PV节点的处理 if B2(i,6)==3 j=j+1;

B2(i,3)=B2(i,3)+DetaU(2*j,1)+DetaU(2*j-1,1)*sqrt(-1); end end B2

while abs(max(DetaS))>pr

OrgS=zeros(2*n-2,1); %!!!初始功率参数在迭代过程中是不累加的,所以在这里必须将其初始化为零矩阵

11

武汉理工大学《电力系统分析》课程设计说明书

h=0; j=0; for i=1:n

if i~=isb&B2(i,6)==2 h=h+1; for j=1:n

OrgS(2*h-1,1)=OrgS(2*h-1,1)+real(B2(i,3))*(real(Y(i,j))*real(B2(j,3))-imag(Y(i,j))*imag(B2(j,3)))+imag(B2(i,3))*(real(Y(i,j))*imag(B2(j,3))+imag(Y(i,j))*real(B2(j,3))); OrgS(2*h,1)=OrgS(2*h,1)+imag(B2(i,3))*(real(Y(i,j))*real(B2(j,3))-imag(Y(i,j))*imag(B2(j,3)))-real(B2(i,3))*(real(Y(i,j))*imag(B2(j,3))+imag(Y(i,j))*real(B2(j,3))); end end end

for i=1:n

if i~=isb&B2(i,6)==3 h=h+1; for j=1:n

OrgS(2*h-1,1)=OrgS(2*h-1,1)+real(B2(i,3))*(real(Y(i,j))*real(B2(j,3))-imag(Y(i,j))*imag(B2(j,3)))+imag(B2(i,3))*(real(Y(i,j))*imag(B2(j,3))+imag(Y(i,j))*real(B2(j,3))); OrgS(2*h,1)=OrgS(2*h,1)+imag(B2(i,3))*(real(Y(i,j))*real(B2(j,3))-imag(Y(i,j))*imag(B2(j,3)))-real(B2(i,3))*(real(Y(i,j))*imag(B2(j,3))+imag(Y(i,j))*real(B2(j,3))); end end end OrgS

%创建DetaS h=0; for i=1:n

if i~=isb&B2(i,6)==2 h=h+1;

DetaS(2*h-1,1)=real(B2(i,2))-OrgS(2*h-1,1); DetaS(2*h,1)=imag(B2(i,2))-OrgS(2*h,1); end end t=0; for i=1:n

if i~=isb&B2(i,6)==3 h=h+1; t=t+1;

DetaS(2*h-1,1)=real(B2(i,2))-OrgS(2*h-1,1);

DetaS(2*h,1)=real(PVU(t,1))^2+imag(PVU(t,1))^2-real(B2(i,3))^2-imag(B2(i,3))^2; end end DetaS

12

联系客服:779662525#qq.com(#替换为@)