《matlab-潮流计算程序n节点》由会员分享,可在线阅读,更多相关《matlab-潮流计算程序n节点(15页珍藏版)》请在金锄头文库上搜索。
1、%=%=%=%潮流计算MATLAB 粗略程序%=%=%=%creat a new_datat=0;s=0;r=0;w=0;number=input(How many node are there=);% Convert Pq to a new arrayfor ii=1:number if data(ii,4)=1 t=t+1; for jj=1:14 new_data1(t,jj)=data(ii,jj); end; a(1,t)=ii; s=s+1; %record the number of the PQ node end;end;%Convert pv to a new arrayfo
2、r ii=1:number if data(ii,4)=2 t=t+1; for jj=1:14 new_data1(t,jj)=data(ii,jj); end; a(1,t)=ii; r=r+1; %record the number of the PV node end;end;%Convert set_v to a new arrayfor ii=1:number if data(ii,4)=3 t=t+1; for jj=1:14 new_data1(t,jj)=data(ii,jj); end; a(1,t)=ii; w=w+1; end;end;%creat a new_data
3、2x,y=size(data2)for ii=1:x for jj=1:2 for mm=1:number if data2(ii,jj)=a(1,mm) new_data2(ii,jj)=mm; end; end; end;end;for ii=1:x for jj=3:14 new_data2(ii,jj)=data2(ii,jj); end;end;%creat a YY=zeros(number,number);YY=zeros(number,number);yy=zeros(number,number);for ii=1:x % for jj=1:14 iii=new_data2(i
4、i,1); jjj=new_data2(ii,2); if new_data2(ii,5)=2 sub=new_data2(ii,6)./(new_data2(ii,7).*new_data2(ii,7)+new_data2(ii,6).*new_data2(ii,6)-new_data2(ii,7)./(new_data2(ii,7).*new_data2(ii,7)+new_data2(ii,6).*new_data2(ii,6)*i; Y(iii,jjj)=-sub./new_data2(ii,14); YY(iii,jjj)=sub./new_data2(ii,14); Y(jjj,i
5、ii)=-sub/new_data2(ii,14); YY(jjj,iii)=sub./new_data2(ii,14); yy(iii,jjj)=(1.-new_data2(ii,14)./(new_data2(ii,14).*new_data2(ii,14).*sub; yy(jjj,iii)=(new_data2(ii,14)-1)./(new_data2(ii,14).*sub; else Y(iii,jjj)=-new_data2(ii,6)./(new_data2(ii,7).*new_data2(ii,7)+new_data2(ii,6).*new_data2(ii,6)+new
6、_data2(ii,7)./(new_data2(ii,7).*new_data2(ii,7)+new_data2(ii,6).*new_data2(ii,6)*i; YY(iii,jjj)=new_data2(ii,6)./(new_data2(ii,7).*new_data2(ii,7)+new_data2(ii,6).*new_data2(ii,6)-new_data2(ii,7)./(new_data2(ii,7).*new_data2(ii,7)+new_data2(ii,6).*new_data2(ii,6)*i; Y(jjj,iii)=-new_data2(ii,6)./(new
7、_data2(ii,7).*new_data2(ii,7)+new_data2(ii,6).*new_data2(ii,6)+new_data2(ii,7)./(new_data2(ii,7).*new_data2(ii,7)+new_data2(ii,6).*new_data2(ii,6)*i; YY(jjj,iii)=new_data2(ii,6)./(new_data2(ii,7).*new_data2(ii,7)+new_data2(ii,6).*new_data2(ii,6)-new_data2(ii,7)./(new_data2(ii,7).*new_data2(ii,7)+new
8、_data2(ii,6).*new_data2(ii,6)*i; yy(iii,jjj)=new_data2(ii,8)./2.*i; yy(jjj,iii)=new_data2(ii,8)./2.*i; end; %end;end;for iii=1:number Y(iii,iii)=0;end;%for ii=1:x % for jj=1:14 for iii=1:number for jj=1:number % if iii=jj Y(iii,iii)=Y(iii,iii)+YY(iii,jj)+yy(iii,jj); % end; end;end;%creat B, Gfor ii=
9、1:number for jj=1:number G(ii,jj)= real(Y(ii,jj); B(ii,jj)= imag(Y(ii,jj); end;end;%creat Initial_P Initial_Q Initial_Vfor ii=1:(s+r) set_P(ii,1)=(new_data1(ii,9)-new_data1(ii,7)./100;end;for ii=1:s; set_Q(ii,1)=(new_data1(ii,10)-new_data1(ii,8)./100;end;for ii=1:r set_V(ii,1)=new_data1(ii+s,12).*ne
10、w_data1(ii+s,12);%try to modify for sike of correctingend;Initial_p_q_v=set_P;set_Q;set_V;disp(Initial_p_q_v);%creat Initial_e,Initial_ffor ii=1:number-1 e(ii,1)=1; f(ii,1)=0.0;%change f to test used to be 1.0end; e(number,1)=new_data1(number,12); f(number,1)=0;% e(64,1)=0.88;%test 118ieee% f(64,1)=
11、0.39395826829394; % f(14,1)=0; % e(10,1)=1.045; %e(11,1)=1.01; %e(12,1)=1.07; %e(13,1)=1.09;%/%/%/%/% Start NEWTOWN CALULATIONfor try_time=1:25%Creat every node consume P Q and Un=s;m=r;for ii=1:(n+m) sum1=0; for jj=1:(n+m+1) sum1=sum1+e(ii,1).*(G(ii,jj).*e(jj,1)-B(ii,jj).*f(jj,1)+f(ii,1).*(G(ii,jj).*f(jj,1)+B(ii,j