【正文】
40,2*x 3 ,2*x 2 ]。y 2 。 abs F x eps break end end ans 第 1 次迭代結(jié)果: ans +002 * ans 第 2 次迭代結(jié)果: ans ans 第 3 次迭代結(jié)果: ans ans 第 4 次迭代結(jié)果: ans ans 第 5 次迭代結(jié)果: ans ans 第 6 次迭代結(jié)果: ans 0 0 0 x 1 5 4 function y F x y 1 x 1 5*x 2 ^2+7*x 3 ^2+12。 %矩陣左除,即 b 除以 A x xdx。 x x0。y 3 ]。 y 2 x 1 ^281* x 2 + ^2+sin x 3 +。 abs F x eps2 break end end ans 第 1 次迭代結(jié)果: ans ans 第 2 次迭代結(jié)果: ans ans 第 3 次迭代結(jié)果: ans ans 第 4 次迭代結(jié)果: ans ans 第 5 次迭代結(jié)果: ans ans 第 6 次迭代結(jié)果: ans ans 第 7 次迭代結(jié)果: ans ans 第 8 次迭代結(jié)果: ans 0 0 x function J Fd x J [3,x 3 *sin x 2 *x 3 ,x 2 *sin x 2 *x 3 。 %矩 陣左除,即 b 除以 A x xdx。 x x0。 plot x,y clear format long 1 100。 end y y*4。 y pifun 100000 。 S_res k,5 S_res k,3 +S_res k,4 。 I~ 0 S_res k,3 bus I,2 ^2* conj YtYm k,3 +conj YtYm k,4 bus I,2 *bus J,2 * cos bus I,3 +j*sin bus I,3 * conj cos bus J,3 +j*sin bus J,3 *conj YtYm k,3 。 % S_res 矩陣儲存著線路潮流計算結(jié)果 S_res :,1:2 line :,1:2 。 bus_res :,3 bus :,3 *180 / pi。 YtYm k,5 Yt* K^2+K 。 YtYm k,4 Ym+Yt* K1 /K。 YtYm k,5 Ym。 K line k,7 。 J line k,2 。 YtYm zeros nl,5 。 k k + 1。 [nl,ml] size line 。 % n 為總節(jié)點數(shù) for i nPQ+1:n1 for j 1:n bus i,5 bus i,5 +bus i,2 *bus j,2 * real Y i,j *sin bus i,3 bus j,3 imag Y i,j *cos bus i,3 bus j,3 。 else L i,j Qi i,1 +imag Y i,j * bus i,2 ^2 。 else N i,j Pi i,1 real Y i,j * bus i,2 ^2 。 Qi i,1 Qi i,1 +bus i,2 *bus j,2 * real Y i,j *sin bus i,3 bus j,3 imag Y i,j *cos bus i,3 bus j,3 。 % 將雅克比矩陣分塊,即: J [H N。 H zeros nb1,nb1 。 dQ bus 1:nPQ,5 。 Y I,J Y I,J +K*Yt。 Y I,J Y I,J Yt/K。 J 0 % 對地支路 : K 0,J 0,R X 0。 Y J,J Y J,J +Yt+Ym。 K line k,7 。 %讀入線路參數(shù) J line k,2 。 break end end end end 作用為計算節(jié)點導納矩陣 [nb,mb] size bus 。 newbus [1:nb]39。 end end。 elseif type 2, nPV nPV +1。 % number of PV bus counter nPQ 0。 % 迭代結(jié)束后繼續(xù)在“ ”寫入節(jié)點計算結(jié)果和 線路計算結(jié)果 程序結(jié)束 作用為對節(jié)點重排序,并修改相應的線路數(shù)據(jù) [nb,mb] size bus 。 fprintf myf,39。,real S_res i,3 ,imag S_res i,3 。% 39。 for i 1:nl fprintf myf,39。,real bus_res i,4 ,imag bus_res i,4 。% 39。 fprintf myf,39。 。a39。 % 計算節(jié)點數(shù)據(jù)結(jié)果的子程序 S_res S_res bus,line,YtYm 。 abs dAng EPS break end % 判斷是否滿足精度誤差,如滿足則跳出,否則返回繼續(xù)迭代 end bus PQ bus,Y,nPQ,nPV 。 % 計算相角修正量 dU UD* dAngU nb:nb+nPQ1,1 。 for i 1:nPQ UD i,i bus i,2 。 % 在當前目錄下生成“ ”文件,寫入節(jié)點導納矩陣 format long EPS 。 fprintf myf,39。39。 end [nb,mb] size bus 。 if pathname 0 error 39。*.m39。 20 19 0 0 ] 。 35 22 0 0 。 31 6 0 0 。 5 0 0 0 0 0。 28 26 0 0。 23 22 0 0。 24 16 0 0。 16 15 0 0。 11 10 0 0。 11 6 0 0。 14 4 0 0。 25 2 0 0。 2 負荷數(shù)據(jù)見表 D1 表 D1 負荷 數(shù)據(jù) 節(jié)點號 有功( MW) 無功( Mvar) 節(jié)點號 有功( MW) 無功( Mvar) BUS 3 BUS 4 BUS 7 BUS 8 BUS 12 BUS 15 BUS 16 BUS 18 BUS 20 BUS 21 BUS 23 BUS 24 BUS 25 BUS 26 BUS 27 BUS 28 BUS 29 BUS 39 3)發(fā)電機數(shù)據(jù)見表 D2 表 D2 發(fā)電機數(shù)據(jù) 發(fā)電機 節(jié)點