From e7144d70aec9dab7747f5cda5453eac5c83745bb Mon Sep 17 00:00:00 2001 From: "dugg@lab-desk" Date: Wed, 11 Feb 2015 22:08:17 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=A0=E4=BA=86=E5=BE=88=E5=A4=9A=E5=87=BD?= =?UTF-8?q?=E6=95=B0=E6=9D=A5=E7=94=BB=E5=9B=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: dugg@lab-desk --- CalTimeBar.m | 73 +++++++++++++++++++++++++++++ CreateMaxErrorFigure.m | 40 ++++++++++++++++ DrawLoadProfile.m | 20 ++++++++ MaxBoundErrorFigure.m | 9 ++++ MaxErrorFigure.m | 9 ++++ OPF.m | 8 ++-- createLoadProfileFigure.m | 49 ++++++++++++++++++++ loadprofile.txt | 96 +++++++++++++++++++++++++++++++++++++++ maxBoundError.txt | 4 ++ maxError.txt | 33 ++++++++++++++ subOPF.m | 5 +- 11 files changed, 342 insertions(+), 4 deletions(-) create mode 100644 CalTimeBar.m create mode 100644 CreateMaxErrorFigure.m create mode 100644 DrawLoadProfile.m create mode 100644 MaxBoundErrorFigure.m create mode 100644 MaxErrorFigure.m create mode 100644 createLoadProfileFigure.m create mode 100644 loadprofile.txt create mode 100644 maxBoundError.txt create mode 100644 maxError.txt diff --git a/CalTimeBar.m b/CalTimeBar.m new file mode 100644 index 0000000..1da09d5 --- /dev/null +++ b/CalTimeBar.m @@ -0,0 +1,73 @@ +function createfigure(ymatrix1) +%CREATEFIGURE(YMATRIX1) +% YMATRIX1: bar matrix data + +% Auto-generated by MATLAB on 11-Feb-2015 20:23:32 + +% Create figure +figure1 = figure('Name','最大不平衡量','Color',[1 1 1]); + +% Create axes +axes1 = axes('Parent',figure1,'XTickLabel',{'情形A','情形B','情形C'},... + 'XTick',[1 2 3],... + 'Position',[0.13 0.11 0.29654028436019 0.391061571125265],... + 'FontName','Times New Roman'); +hold(axes1,'all'); + +% Create multiple lines using matrix input to bar +bar1 = bar(ymatrix1,'BarLayout','stacked'); +set(bar1(1),... + 'FaceColor',[0.831372559070587 0.815686285495758 0.7843137383461],... + 'DisplayName','阶段1'); +set(bar1(2),... + 'FaceColor',[0.941176474094391 0.941176474094391 0.941176474094391],... + 'DisplayName','fdsfsd'); + +% Create xlabel +xlabel('情形','FontSize',12,'FontName','黑体'); + +% Create ylabel +ylabel('时间/ms','FontSize',12,'FontName','黑体'); + +% Create textbox +annotation(figure1,'textbox',... + [0.166919431279624 0.371781316348195 0.0888625592417062 0.059447983014862],... + 'String',{'29.68ms'},... + 'FontName','Times New Roman',... + 'LineStyle','none'); + +% Create textbox +annotation(figure1,'textbox',... + [0.16706161137441 0.262269639065817 0.0888625592417062 0.059447983014862],... + 'String',{'70.16ms'},... + 'FontName','Times New Roman',... + 'LineStyle','none'); + +% Create textbox +annotation(figure1,'textbox',... + [0.243791469194317 0.353904458598726 0.0888625592417062 0.059447983014862],... + 'String',{'31.66ms'},... + 'FontName','Times New Roman',... + 'LineStyle','none'); + +% Create textbox +annotation(figure1,'textbox',... + [0.243933649289103 0.244392781316348 0.0888625592417062 0.059447983014862],... + 'String',{'68.48ms'},... + 'FontName','Times New Roman',... + 'LineStyle','none'); + +% Create textbox +annotation(figure1,'textbox',... + [0.314881516587683 0.343288747346072 0.0888625592417062 0.059447983014862],... + 'String',{'30.08ms'},... + 'FontName','Times New Roman',... + 'LineStyle','none'); + +% Create textbox +annotation(figure1,'textbox',... + [0.315023696682469 0.233777070063694 0.0888625592417062 0.059447983014862],... + 'String',{'65.16ms'},... + 'FontName','Times New Roman',... + 'LineStyle','none'); + diff --git a/CreateMaxErrorFigure.m b/CreateMaxErrorFigure.m new file mode 100644 index 0000000..4af06ff --- /dev/null +++ b/CreateMaxErrorFigure.m @@ -0,0 +1,40 @@ +function createfigure(ymatrix1) +%CREATEFIGURE(YMATRIX1) +% YMATRIX1: bar matrix data + +% Auto-generated by MATLAB on 11-Feb-2015 21:08:10 + +% Create figure +figure1 = figure('Color',[1 1 1]); + +% Create axes +axes1 = axes('Parent',figure1,... + 'XTick',[0 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 35],... + 'Position',[0.127153700189753 0.112232142857143 0.430721062618596 0.385535714285714],... + 'FontName','Times New Roman'); +% Uncomment the following line to preserve the X-limits of the axes +xlim(axes1,[1 35]); +% Uncomment the following line to preserve the Y-limits of the axes +ylim(axes1,[0 0.0021]); +hold(axes1,'all'); + +% Create multiple lines using matrix input to bar +bar1 = bar(ymatrix1,'BarWidth',1,'Parent',axes1); +set(bar1(1),'FaceColor',[0 0 0],'DisplayName','电压幅值'); +set(bar1(2),... + 'FaceColor',[0.941176474094391 0.941176474094391 0.941176474094391],... + 'DisplayName','电压相角'); + +% Create xlabel +xlabel('节点号','FontSize',12,'FontName','黑体'); + +% Create ylabel +ylabel('最大绝对偏差/(p.u,弧度)','FontSize',12,'FontName','黑体'); + +% Create legend +legend1 = legend(axes1,'show'); +set(legend1,... + 'Position',[0.367488931056294 0.487351190476188 0.115749525616698 0.09375],... + 'FontSize',12,... + 'FontName','黑体'); + diff --git a/DrawLoadProfile.m b/DrawLoadProfile.m new file mode 100644 index 0000000..6446197 --- /dev/null +++ b/DrawLoadProfile.m @@ -0,0 +1,20 @@ +function [ ] = DrawLoadProfile( ) +figure(); +data=dlmread('LoadProfile.txt'); +hold on; +y1=data(:,3); +y2=data(:,4); +x=1:96; +k=1; +for i=0:96-1 + x1(k)=x(length(x)-i); + Z2(k)=y2(length(x)-i); + k=k+1; +end +h=patch([x x1],[y1' Z2],[230 230 230]./255) +set(h,'EdgeColor','None'); +plot(1:96,data(:,2),'k'); +plot(1:96,data(:,3),'--k'); +plot(1:96,data(:,4),'--k'); +end + diff --git a/MaxBoundErrorFigure.m b/MaxBoundErrorFigure.m new file mode 100644 index 0000000..c6a69c3 --- /dev/null +++ b/MaxBoundErrorFigure.m @@ -0,0 +1,9 @@ +function MaxBoundErrorFigure() +figure(); +data=dlmread('maxBoundError.txt'); +% data(1,:)=0; +maxV=data(:,1); +maxA=data(:,2); +% bar([maxV';maxA']'); +CreateMaxErrorFigure([maxV';maxA']'); +end \ No newline at end of file diff --git a/MaxErrorFigure.m b/MaxErrorFigure.m new file mode 100644 index 0000000..c8ce4d9 --- /dev/null +++ b/MaxErrorFigure.m @@ -0,0 +1,9 @@ +function MaxErrorFigure() +figure(); +data=dlmread('maxError.txt'); +data(1,:)=0; +maxV=data(:,1); +maxA=data(:,2); +% bar([maxV';maxA']'); +CreateMaxErrorFigure([maxV';maxA']'); +end \ No newline at end of file diff --git a/OPF.m b/OPF.m index a978109..82372b3 100644 --- a/OPF.m +++ b/OPF.m @@ -393,12 +393,14 @@ figure('Name',' % maxDismatchPQ = [0.3123e-10 0.1497e-10 0.7351e-10; 0.6854e-10 0.1973e-10 0.5824e-10]; % bar(maxDismatchPQ); %% 计算时间 -calTime=[87 61; 211 87; 108 59;]; +calTime=[70.16 29.68; 68.48 31.661; 65.156 30.08;]; bar(calTime,'stacked'); % figure(); % DeviationFigure(1:33,[CaseAREV;CaseBREV;CaseCREV],[CaseAREA;CaseBREA;CaseCREA],[CaseAREP,CaseBREP,CaseCREP],[CaseAREQ,CaseBREQ,CaseCREQ]);%,[CaseAREA;CaseBREA;CaseCREA],[CaseAREV;CaseBREV;CaseCREV],[CaseAREV;CaseBREV;CaseCREV]); % VoltBar(voltBarCaseAX,voltBarCaseAY,voltBarCaseBX,voltBarCaseBY,voltBarCaseCX,voltBarCaseCY); % AngelBar(angelBarCaseAX,angelBarCaseBY,angelBarCaseCX,angelBarCaseAY,angelBarCaseBX,angelBarCaseCY); % AngelBar(PDBarCaseAX,PDBarCaseAY,PDBarCaseBX,PDBarCaseBY,PDBarCaseCX,PDBarCaseCY); -QDBar(QDBarCaseAX,QDBarCaseAY,QDBarCaseBX,QDBarCaseBY,QDBarCaseCX,QDBarCaseCY); - +% QDBar(QDBarCaseAX,QDBarCaseAY,QDBarCaseBX,QDBarCaseBY,QDBarCaseCX,QDBarCaseCY); +% MaxErrorFigure() +% MaxBoundErrorFigure(); +DrawLoadProfile(); \ No newline at end of file diff --git a/createLoadProfileFigure.m b/createLoadProfileFigure.m new file mode 100644 index 0000000..47453a6 --- /dev/null +++ b/createLoadProfileFigure.m @@ -0,0 +1,49 @@ +function createfigure(VertexNormals1, YData1, XData1, Vertices1, Faces1, X1, YMatrix1) +%CREATEFIGURE(VERTEXNORMALS1,YDATA1,XDATA1,VERTICES1,FACES1,X1,YMATRIX1) +% VERTEXNORMALS1: patch vertexnormals +% YDATA1: patch ydata +% XDATA1: patch xdata +% VERTICES1: patch vertices +% FACES1: patch faces +% X1: vector of x data +% YMATRIX1: matrix of y data + +% Auto-generated by MATLAB on 11-Feb-2015 22:03:00 + +% Create figure +figure1 = figure('Color',[1 1 1]); + +% Create axes +axes1 = axes('Parent',figure1,... + 'XTickLabel',{'6:00','12:00','16:00','24:00','0:00'},... + 'XTick',[24 48 72 96 1],... + 'Position',[0.13 0.11 0.373795066413662 0.585744680851064],... + 'FontName','Times New Roman'); +% Uncomment the following line to preserve the X-limits of the axes +xlim(axes1,[1 96]); +hold(axes1,'all'); + +% Create patch +patch('Parent',axes1,'VertexNormals',VertexNormals1,'YData',YData1,... + 'XData',XData1,... + 'Vertices',Vertices1,... + 'Faces',Faces1,... + 'FaceColor',[0.901960784313726 0.901960784313726 0.901960784313726],... + 'EdgeColor','none'); + +% Create multiple lines using matrix input to plot +plot1 = plot(X1,YMatrix1,'Parent',axes1,'LineStyle','--','Color',[0 0 0]); +set(plot1(2),'DisplayName','边界'); +set(plot1(3),'DisplayName','负荷曲线','LineStyle','-'); + +% Create xlabel +xlabel('时刻/时','FontSize',12,'FontName','黑体'); + +% Create ylabel +ylabel('负荷/kW','FontSize',12,'FontName','黑体'); + +% Create legend +legend1 = legend(axes1,'show'); +set(legend1,... + 'Position',[0.155913978494625 0.517021276595745 0.108159392789374 0.168794326241135]); + diff --git a/loadprofile.txt b/loadprofile.txt new file mode 100644 index 0000000..44b6b6a --- /dev/null +++ b/loadprofile.txt @@ -0,0 +1,96 @@ +57697.32 576.9732 663.51918 490.42722 +55270.921 552.70921 635.6155915 469.8028285 +53275.549 532.75549 612.6688135 452.8421665 +51147.685 511.47685 588.1983775 434.7553225 +49132.866 491.32866 565.027959 417.629361 +47594.538 475.94538 547.337187 404.553573 +45822.028 458.22028 526.953322 389.487238 +44106.141 441.06141 507.2206215 374.9021985 +42717.381 427.17381 491.2498815 363.0977385 +42185.436 421.85436 485.132514 358.576206 +40721.922 407.21922 468.302103 346.136337 +40139.269 401.39269 461.6015935 341.1837865 +38901.576 389.01576 447.368124 330.663396 +37535.238 375.35238 431.655237 319.049523 +37234.754 372.34754 428.199671 316.495409 +36277.407 362.77407 417.1901805 308.3579595 +35705.188 357.05188 410.609662 303.494098 +35364.886 353.64886 406.696189 300.601531 +34644.62 346.4462 398.41313 294.47927 +34811.66 348.1166 400.33409 295.89911 +34473.493 344.73493 396.4451695 293.0246905 +35018.258 350.18258 402.709967 297.655193 +35782.508 357.82508 411.498842 304.151318 +35520.4 355.204 408.4846 301.9234 +37126.94 371.2694 426.95981 315.57899 +37852.994 378.52994 435.309431 321.750449 +39096.988 390.96988 449.615362 332.324398 +40615.023 406.15023 467.0727645 345.2276955 +42599.93 425.9993 489.899195 362.099405 +44509.964 445.09964 511.864586 378.334694 +49173.813 491.73813 565.4988495 417.9774105 +53864.107 538.64107 619.4372305 457.8449095 +60260.101 602.60101 692.9911615 512.2108585 +65195.266 651.95266 749.745559 554.159761 +71841.983 718.41983 826.1828045 610.6568555 +77802.345 778.02345 894.7269675 661.3199325 +88879.392 888.79392 1022.113008 755.474832 +100781.676 1007.81676 1158.989274 856.644246 +111517.636 1115.17636 1282.452814 947.899906 +119678.504 1196.78504 1376.302796 1017.267284 +126802.705 1268.02705 1458.231108 1077.822993 +131988.024 1319.88024 1517.862276 1121.898204 +134124.319 1341.24319 1542.429669 1140.056712 +137238.631 1372.38631 1578.244257 1166.528364 +138993.205 1389.93205 1598.421858 1181.442243 +140492.797 1404.92797 1615.667166 1194.188775 +141981.796 1419.81796 1632.790654 1206.845266 +142679.116 1426.79116 1640.809834 1212.772486 +143682.364 1436.82364 1652.347186 1221.300094 +144526.194 1445.26194 1662.051231 1228.472649 +146089.742 1460.89742 1680.032033 1241.762807 +146519.133 1465.19133 1684.97003 1245.412631 +144834.953 1448.34953 1665.60196 1231.097101 +145784.897 1457.84897 1676.526316 1239.171625 +144503.807 1445.03807 1661.793781 1228.28236 +145438.77 1454.3877 1672.545855 1236.229545 +145203.708 1452.03708 1669.842642 1234.231518 +143780.956 1437.80956 1653.480994 1222.138126 +142645.898 1426.45898 1640.427827 1212.490133 +143466.557 1434.66557 1649.865406 1219.465735 +141922.25 1419.2225 1632.105875 1206.339125 +145841.261 1458.41261 1677.174502 1239.650719 +144923.155 1449.23155 1666.616283 1231.846818 +145430.575 1454.30575 1672.451613 1236.159888 +145334.611 1453.34611 1671.348027 1235.344194 +146149.143 1461.49143 1680.715145 1242.267716 +146482.33 1464.8233 1684.546795 1245.099805 +147876.05 1478.7605 1700.574575 1256.946425 +149817.698 1498.17698 1722.903527 1273.450433 +150415.094 1504.15094 1729.773581 1278.528299 +154442.119 1544.42119 1776.084369 1312.758012 +158010.804 1580.10804 1817.124246 1343.091834 +160774.574 1607.74574 1848.907601 1366.583879 +162786.258 1627.86258 1872.041967 1383.683193 +161608.648 1616.08648 1858.499452 1373.673508 +159454.941 1594.54941 1833.731822 1355.366999 +158027.837 1580.27837 1817.320126 1343.236615 +157666.495 1576.66495 1813.164693 1340.165208 +156460.303 1564.60303 1799.293485 1329.912576 +155215.52 1552.1552 1784.97848 1319.33192 +152007.853 1520.07853 1748.09031 1292.066751 +149345.228 1493.45228 1717.470122 1269.434438 +147650.189 1476.50189 1697.977174 1255.026607 +145332.662 1453.32662 1671.325613 1235.327627 +142143.342 1421.43342 1634.648433 1208.218407 +136555.706 1365.55706 1570.390619 1160.723501 +134474.784 1344.74784 1546.460016 1143.035664 +131788.941 1317.88941 1515.572822 1120.205999 +125144.813 1251.44813 1439.16535 1063.730911 +116612.327 1166.12327 1341.041761 991.2047795 +105557.928 1055.57928 1213.916172 897.242388 +90041.36 900.4136 1035.47564 765.35156 +79091.837 790.91837 909.5561255 672.2806145 +68164.237 681.64237 783.8887255 579.3960145 +61305.02 613.0502 705.00773 521.09267 +55158.221 551.58221 634.3195415 468.8448785 diff --git a/maxBoundError.txt b/maxBoundError.txt new file mode 100644 index 0000000..38865aa --- /dev/null +++ b/maxBoundError.txt @@ -0,0 +1,4 @@ +0.010149012 0.000145532 +0.010613753 0.001269963 +0.010686824 0.001667111 +0.01098127 0.002552894 diff --git a/maxError.txt b/maxError.txt new file mode 100644 index 0000000..d6572c7 --- /dev/null +++ b/maxError.txt @@ -0,0 +1,33 @@ +0.001940128 0.001207832 +0.002036094 0.00080888 +0.002099042 0.000927452 +0.002424885 0.000935623 +0.001893664 0.001181456 +0.002018829 0.001257517 +0.00210676 0.000743724 +0.002013494 0.000936731 +0.002013003 0.001095999 +0.001842267 0.000931757 +0.002001811 0.000859772 +0.001866919 0.000876312 +0.001834921 0.00075514 +0.001937562 0.000923904 +0.00189722 0.000822962 +0.001933966 0.000901072 +0.001920252 0.000994934 +0.001747249 0.000857745 +0.002008556 0.000823106 +0.002093043 0.000753621 +0.001971762 0.000883769 +0.002987941 0.00129286 +0.002436167 0.000997165 +0.002037594 0.001015502 +0.002066403 0.000954605 +0.00276576 0.001295141 +0.001881581 0.001290146 +0.00193955 0.001351513 +0.002069665 0.001408808 +0.001936768 0.001467117 +0.001780607 0.001485602 +0.001861682 0.00143783 +0.001955221 0.001473342 diff --git a/subOPF.m b/subOPF.m index 5eff289..e8b4c4e 100644 --- a/subOPF.m +++ b/subOPF.m @@ -124,6 +124,7 @@ eps=1; % 第一遍,算连续的值 fprintf('第1次迭代,算连续量。\n'); +tic; while(abs(Gap)>Precision*10) if KK>kmax break; @@ -167,6 +168,7 @@ while(abs(Gap)>Precision*10) Gap=(Init_L*Init_Z'-Init_U*Init_W'); KK=KK+1; end +fprintf('第一遍计算时间:%f\n',toc) % 第二遍,算离散 % [~,~,Init_Z,Init_W,Init_L,Init_U,~,~,~,RestraintCount,~,~,~,~,~,~,~,~,~]=OPF_Init(Busnum,Balance,PG,QG,Volt,GenU,GenL,PVi,PGi,PVQU,PVQL,RealPD,RealQD,QD,PD); % Gap=(Init_L*Init_Z'-Init_U*Init_W'); @@ -180,7 +182,7 @@ fprintf('\n'); % Init_L=1*sparse(ones(1,RestraintCount)); % Init_U=1*sparse(ones(1,RestraintCount)); % Init_Y=sparse(1,2*Busnum);%与学姐一致 - +tic; fprintf('第2次迭代,算离散量。\n'); while(abs(Gap)>Precision*10) if KK>kmax @@ -228,6 +230,7 @@ while(abs(Gap)>Precision*10) Gap=(Init_L*Init_Z'-Init_U*Init_W'); KK=KK+1; end +fprintf('第二遍计算时间:%f\n',toc) %% 计算最大不平衡量 AngleIJ=sparse(r,c,UAngel(r)-UAngel(c)-Angle',Busnum,Busnum); dP=PD+diag(Volt)*Y.*cos(AngleIJ)*Volt';