fm_report.m
来自「基于PSAT 软件的多目标最优潮流计算用于中小型电力系统的分析和管理」· M 代码 · 共 728 行 · 第 1/2 页
M
728 行
['Maximum Q mismatch ',MVar]};mgp = max(abs(DAE.gp));mgq = max(abs(DAE.gq));Matrix{3,1} = [Settings.iter; mgp*MVA; mgq*MVA];if strcmp(checkabs,'off') Matrix{3,1}(4,1) = Settings.mva; Rows{3,1}{4,1} = 'Power rate [MVA]';end% power flow results% ---------------------------------------------------------------Header{4,1} = 'POWER FLOW RESULTS';Cols{4,1} = {'Bus','V','phase','P gen','Q gen','P load','Q load'; ... ' ', kV, ['[',raddeg,']'],MW,MVar,MW,MVar};Rows{4,1} = {nomi_bus{ordbus}}';Matrix{4,1} = [Vs,angs,Pgs,Qgs,Pls,Qls];% check violations% ---------------------------------------------------------------nh = 4;idx = 1;if strcmp(violations,'on') for i = 1:Bus.n if vVmin(i) Header{5,1}{idx,1} = sprintf(['Minimum voltage limit violation at bus <%s>' ... ' [V_min = %g]'],Varname.bus{i},Vmin(i)); idx = idx + 1; end if vVmax(i) Header{5,1}{idx,1} = sprintf(['Maximum voltage limit violation at bus <%s>' ... ' [V_max = %g]'],Varname.bus{i},Vmax(i)); idx = idx + 1; end if vVmaxabs(i) Header{5,1}{idx,1} = sprintf('Voltage at its limits at bus <%s>', ... Varname.bus{i}); idx = idx + 1; end if vVminabs(i) Header{5,1}{idx,1} = sprintf('Voltage at its limits at bus <%s>', ... Varname.bus{i}); idx = idx + 1; end if vQgmax(i) Header{5,1}{idx,1} = sprintf(['Maximum reactive power limit violation at bus <%s>' ... ' [Qg_max = %g]'],Varname.bus{i},Qgmax(i)); idx = idx + 1; end if vQgmin(i) Header{5,1}{idx,1} = sprintf(['Minimum reactive power limit violation at bus <%s>' ... ' [Qg_min = %g]'],Varname.bus{i},Qgmin(i)); idx = idx + 1; end if vQgmaxabs(i) Header{5,1}{idx,1} = sprintf('Maximum reactive power at bus <%s>', ... Varname.bus{i}); idx = idx + 1; end if vQgminabs(i) Header{5,1}{idx,1} = sprintf('Minimum reactive power at bus <%s>', ... Varname.bus{i}); idx = idx + 1; end end Rows{5,1} = ''; Cols{5,1} = ''; Matrix{5,1} = []; nh = nh + 1;end% state variables% ---------------------------------------------------------------if DAE.n nh = nh + 1; Header{nh,1} = 'STATE VECTOR'; Rows{nh,1} = Varname.uvars([1:DAE.n]); Cols{nh,1} = ''; Matrix{nh,1} = DAE.x;end% synchronous machine variables% ---------------------------------------------------------------if Syn.n nh = nh + 1; Header{nh,1} = 'MECHANICAL POWERS & FIELD VOLTAGES'; Synnames = cell(2*Syn.n,1); idx0 = DAE.n+2*Bus.n; for kkk = 1:Syn.n Synnames{kkk,1} = Varname.uvars{idx0+kkk}; end idx0 = DAE.n+2*Bus.n+Syn.n; for kkk = 1:Syn.n Synnames{kkk+Syn.n,1} = Varname.uvars{idx0+kkk}; end Rows{nh,1} = Synnames; Cols{nh,1} = ''; Matrix{nh,1} = [Syn.pm;Syn.vf];end% exciter variables% ---------------------------------------------------------------if Exc.n nh = nh + 1; Header{nh,1} = 'EXCITER REFERENCE VOLTAGES'; idx0 = DAE.n+2*Bus.n+2*Syn.n; Rows{nh,1} = Varname.uvars([idx0+1:idx0+Exc.n]); Cols{nh,1} = ''; Matrix{nh,1} = [Exc.vrif];end% over excitation limiter variables% ---------------------------------------------------------------if Oxl.n nh = nh + 1; Header{nh,1} = 'FIELD CURRENTS'; idx0 = DAE.n+2*Bus.n+2*Syn.n+Exc.n; Rows{nh,1} = Varname.uvars([idx0+1:idx0+Oxl.n]); Cols{nh,1} = ''; Matrix{nh,1} = [Oxl.If];end% line flows (i -> j)% ---------------------------------------------------------------p_losses = (abs(line_ffrom(:,4)+line_fto(:,4)));q_losses = (line_ffrom(:,5)+line_fto(:,5));nh = nh + 1;Header{nh,1} = 'LINE FLOWS';Cols{nh,1} = {'From Bus','To Bus','Line','P Flow', ... 'Q Flow','P Loss','Q Loss'; ... ' ',' ',' ',MW,MVar,MW,MVar};Rows{nh,1} = cell(length(line_ffrom(:,2)),2);for iii = 1:length(line_fto(:,2)) Rows{nh,1}{iii,1} = nomi_bus{line_ffrom(iii,2),1}; Rows{nh,1}{iii,2} = nomi_bus{line_ffrom(iii,3),1};endMatrix{nh,1} = [line_ffrom(:,1),line_ffrom(:,4),line_ffrom(:,5), ... p_losses,q_losses];% check flow violations% ---------------------------------------------------------------if strcmp(violations,'on') idx = 0; nh = nh + 1; for i = 1:Line.n if vIs(i) idx = idx + 1; Header{nh,1}{idx,1} = sprintf( ... ['%sMaximum current limit violation [I = %g > I_max = ' ... '%g]\n'], space,Is(i),Imaxs(i)); end if vPs(i) idx = idx + 1; Header{nh,1}{idx,1} = sprintf( ... '%sMaximum real power limit violation [P_max = %g]\n', ... space,Pmax(i)); end if vSs(i) idx = idx + 1; Header{nh,1}{idx,1} = sprintf( ... ['%sMaximum apparent power limit violation [S = %g > ' ... 'S_max = %g]\n'], space,Ss(i),Smax(i)); end end if idx Matrix{nh,1} = []; Cols{nh,1} = ''; Rows{nh,1} = ''; else nh = nh - 1; endend% line flows (j -> i)% ---------------------------------------------------------------nh = nh + 1;Header{nh,1} = 'LINE FLOWS';Cols{nh,1} = {'From Bus','To Bus','Line','P Flow', ... 'Q Flow','P Loss','Q Loss'; ... ' ',' ',' ',MW,MVar,MW,MVar};Rows{nh,1} = cell(length(line_fto(:,2)),2);for iii = 1:length(line_fto(:,2)) Rows{nh,1}{iii,1} = nomi_bus{line_fto(iii,2),1}; Rows{nh,1}{iii,2} = nomi_bus{line_fto(iii,3),1};endMatrix{nh,1} = [line_fto(:,1),line_fto(:,4),line_fto(:,5), ... p_losses,q_losses];% check flow violations% ---------------------------------------------------------------if strcmp(violations,'on') idx = 0; nh = nh + 1; for i = 1:Line.n if vIr(i) idx = idx + 1; Header{nh,1}{idx,1} = sprintf( ... ['%sMaximum current limit violation [I = %g > I_max = ' ... '%g]\n'], space,Ir(i),Imaxr(i)); end if vPr(i) idx = idx + 1; Header{nh,1}{idx,1} = sprintf( ... '%sMaximum real power limit violation [P_max = %g]\n', ... space,Pmax(i)); end if vSr(i) idx = idx + 1; Header{nh,1}{idx,1} = sprintf( ... ['%sMaximum apparent power limit violation [S = %g > ' ... 'S_max = %g]\n'], space,Sr(i),Smax(i)); end end if idx Matrix{nh,1} = []; Cols{nh,1} = ''; Rows{nh,1} = ''; else nh = nh -1; endend% check for additional variables% ---------------------------------------------------------------%hdl_serv = findobj(gcf,'Tag','ListboxServ');%Cella = get(hdl_serv,'String');%if ~isempty(Cella)% nh = nh + 1;% Header{nh,1} = {'OTHER VARIABLES';' '};% if ischar(Cella)% Header{nh,1} = [Header{nh,1}; Cella];% end% if iscell(Cella)% if strcmp(Cella{1,1}(1:7),'Pmech_1')% Cella = Cella(2*Syn.n+1:end);% end% Header{nh,1} = [Header{nh,1}; Cella];% end% Matrix{nh,1} = [];% Cols{nh,1} = '';% Rows{nh,1} = '';%end% global summary% ---------------------------------------------------------------Pg_tot = sum(Pgs);Qg_tot = sum(Qgs);Pl_tot = sum(Pls);Ql_tot = sum(Qls);idx_i = find(Shunt.b < 0);if ~isempty(idx_i) Qsi_tot = abs(sum(Shunt.b(idx_i).*DAE.V(idx_i).*DAE.V(idx_i)).*MVA);else Qsi_tot = 0;endidx_c = find(Shunt.b > 0);if ~isempty(idx_c) Qsc_tot = -abs(sum(Shunt.b(idx_c).*DAE.V(idx_c).*DAE.V(idx_c)).*MVA);else Qsc_tot = 0;endPs_tot = sum(Shunt.g.*DAE.V.*DAE.V).*MVA;nh = nh + 1;Header{nh,1} = 'GLOBAL SUMMARY REPORT';Matrix{nh,1} = [];Cols{nh,1} = '';Rows{nh,1} = '';nh = nh + 1;Header{nh,1} = 'TOTAL GENERATION';Matrix{nh,1} = [Pg_tot;Qg_tot];Cols{nh,1} = '';Rows{nh,1} = {['REAL POWER ',MW];['REACTIVE POWER ',MVar]};nh = nh + 1;Header{nh,1} = 'TOTAL LOAD';Matrix{nh,1} = [Pl_tot;Ql_tot];Cols{nh,1} = '';Rows{nh,1} = {['REAL POWER ',MW];['REACTIVE POWER ',MVar]};nh = nh + 1;Header{nh,1} = 'TOTAL SHUNT';Matrix{nh,1} = [Ps_tot;Qsi_tot;Qsc_tot];Cols{nh,1} = '';Rows{nh,1} = {['REAL POWER ',MW]; ... ['REACTIVE POWER (IND) ',MVar]; ... ['REACTIVE POWER (CAP) ',MVar]};nh = nh + 1;Header{nh,1} = 'TOTAL LOSSES';Matrix{nh,1} = [P_loss;Q_loss];Cols{nh,1} = '';Rows{nh,1} = {['REAL POWER ',MW];['REACTIVE POWER ',MVar]};% violation summary% ---------------------------------------------------------------if strcmp(violations,'on') nh = nh + 1; Header{nh,1}{1,1} = 'LIMIT VIOLATION STATISTICS'; vVtot = sum(vVmax)+sum(vVmin); vQtot = sum(vQgmax)+sum(vQgmin); vVabs = sum(vVmaxabs)+sum(vVminabs); vQabs = sum(vQgmaxabs)+sum(vQgminabs); if vVtot Header{nh,1}{2,1} = sprintf('# OF VOLTAGE LIMIT VIOLATIONS: %d',vVtot); else if vVabs Header{nh,1}{2,1} = sprintf(['ALL VOLTAGES WITHIN LIMITS (%d ' ... 'BINDING).'],vVabs); else Header{nh,1}{2,1} = 'ALL VOLTAGES WITHIN LIMITS.'; end end if vQtot Header{nh,1}{3,1} = sprintf('# OF REACTIVE POWER LIMIT VIOLATIONS: %d',vQtot); else if vQabs Header{nh,1}{2,1} = sprintf(['ALL REACTIVE POWERS WITHIN LIMITS (%d ' ... 'BINDING).'],vQabs); else Header{nh,1}{3,1} = 'ALL REACTIVE POWER WITHIN LIMITS.'; end end if Line.n vItot = sum(vIs & vIr); if vItot Header{nh,1}{4,1} = sprintf('# OF CURRENT FLOW LIMIT VIOLATIONS: %d',vItot); else Header{nh,1}{4,1} = 'ALL CURRENT FLOWS WITHIN LIMITS.'; end vPtot = sum(vPs & vPr); if vPtot Header{nh,1}{5,1} = sprintf('# OF ACTIVE POWER FLOW LIMIT VIOLATIONS: %d',vPtot); else Header{nh,1}{5,1} = 'ALL REAL POWER FLOWS WITHIN LIMITS.'; end vStot = sum(vSs & vSr); if vStot Header{nh,1}{6,1} = sprintf('# OF APPARENT POWER FLOW LIMIT VIOLATIONS: %d',vStot); else Header{nh,1}{6,1} = 'ALL APPARENT POWER FLOWS WITHIN LIMITS.'; end end Matrix{nh,1} = []; Cols{nh,1} = ''; Rows{nh,1} = '';end% writing data...filename = [fm_filenum(Settings.export),['.',Settings.export]];switch Settings.export case 'txt' fm_writetxt(Matrix,Header,Cols,Rows,filename) case 'xls' fm_writexls(Matrix,Header,Cols,Rows,filename) case 'tex' fm_writetex(Matrix,Header,Cols,Rows,filename)end
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?