📄 fm_report.m
字号:
line_q_losses([idx_to;idx_fr])]; % check flow violations if strcmp(violations,'on') idx_ln = [line_ffr(idx_to,1);line_fto(idx_fr,1)]; for jjj = 1:length(idx_ln) kkk = idx_ln(jjj); hhh = vIs(kkk) + vPs(kkk) + vSs(kkk); if hhh nh = nh + 1; Header{nh} = cell(hhh,1); end hh = 1; if vIs(kkk) Header{nh,1}{hh,1} = sprintf(' * Maximum current limit violation [I = %g > I_max = %g]\n',Is(kkk),Imaxs(kkk)); hh = hh + 1; end if vPs(kkk) Header{nh,1}{hh,1} = sprintf(' * Maximum real power limit violation [P_max = %g]\n',Pmax(kkk)); hh = hh + 1; end if vSs(kkk) Header{nh,1}{hh,1} = sprintf( ' * Maximum apparent power limit violation [S = %g > S_max = %g]\n', space,Ss(kkk),Smax(kkk)); end end end % get state and algebraic variables related to the current bus [x_idx,y_idx] = fm_getxy(i); if ~isempty(x_idx) x_idx = sort(x_idx); nh = nh + 1; Header{nh,1} = ' STATE VARIABLES'; Rows{nh,1} = cell(length(x_idx),1); for jhk = 1:length(x_idx) Rows{nh,1}{jhk,1} = [' ',Varname.uvars{x_idx(jhk)}]; end Cols{nh,1} = ''; Matrix{nh,1} = DAE.x(x_idx); end if ~isempty(y_idx) y_idx = sort(y_idx); nh = nh + 1; Header{nh,1} = ' OTHER ALGEBRAIC VARIABLES'; Rows{nh,1} = cell(length(y_idx),1); for jhk = 1:length(y_idx) Rows{nh,1}{jhk,1} = [' ',Varname.uvars{y_idx(jhk)+DAE.n}]; end Cols{nh,1} = ''; Matrix{nh,1} = DAE.y(y_idx); end end else % classic report style 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]; nh = 4;end% check violations% --------------------------------------------------------------------if strcmp(violations,'on') & ~Settings.report idx = 1; nh = nh + 1; for i = 1:Bus.n if vVmin(i) Header{nh,1}{idx,1} = sprintf('Minimum voltage limit violation at bus <%s> [V_min = %g]',Bus.names{i},Vmin(i)); idx = idx + 1; end if vVmax(i) Header{nh,1}{idx,1} = sprintf('Maximum voltage limit violation at bus <%s> [V_max = %g]',Bus.names{i},Vmax(i)); idx = idx + 1; end if vVmaxabs(i) Header{nh,1}{idx,1} = sprintf('Maximum voltage at bus <%s>',Bus.names{i}); idx = idx + 1; end if vVminabs(i) Header{nh,1}{idx,1} = sprintf('Minimum voltage at bus <%s>',Bus.names{i}); idx = idx + 1; end if vQgmax(i) Header{nh,1}{idx,1} = sprintf('Maximum reactive power limit violation at bus <%s> [Qg_max = %g]',Bus.names{i},Qgmax(i)); idx = idx + 1; end if vQgmin(i) Header{nh,1}{idx,1} = sprintf('Minimum reactive power limit violation at bus <%s> [Qg_min = %g]',Bus.names{i},Qgmin(i)); idx = idx + 1; end if vQgmaxabs(i) Header{nh,1}{idx,1} = sprintf('Maximum reactive power at bus <%s>',Bus.names{i}); idx = idx + 1; end if vQgminabs(i) Header{nh,1}{idx,1} = sprintf('Minimum reactive power at bus <%s>',Bus.names{i}); idx = idx + 1; end end Rows{nh,1} = ''; Cols{nh,1} = ''; Matrix{nh,1} = [];end% state variables% --------------------------------------------------------------------if DAE.n & ~Settings.report nh = nh + 1; Header{nh,1} = 'STATE VARIABLES'; Rows{nh,1} = Varname.uvars([1:DAE.n]); Cols{nh,1} = ''; Matrix{nh,1} = DAE.x;end% other algebraic variables% --------------------------------------------------------------------if DAE.m > 2*Bus.n & ~Settings.report nh = nh + 1; Header{nh,1} = 'OTHER ALGEBRAIC VARIABLES'; Algnames = cell(DAE.m-2*Bus.n,1); idx0 = DAE.n+2*Bus.n; for kkk = 1:(DAE.m-2*Bus.n) Algnames{kkk,1} = Varname.uvars{idx0+kkk}; end Rows{nh,1} = Algnames; Cols{nh,1} = ''; Matrix{nh,1} = DAE.y(2*Bus.n:DAE.m);end% line flows are printed out only for conventional reports% --------------------------------------------------------------------if ~Settings.report % line flows (i -> j) 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_ffr(:,2)),2); for iii = 1:length(line_fto(:,2)) Rows{nh,1}{iii,1} = nomi_bus{line_ffr(iii,2),1}; Rows{nh,1}{iii,2} = nomi_bus{line_ffr(iii,3),1}; end Matrix{nh,1} = [line_ffr(:,1),line_ffr(:,4),line_ffr(:,5), ... line_p_losses,line_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; end end % 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}; end Matrix{nh,1} = [line_fto(:,1),line_fto(:,4),line_fto(:,5), ... line_p_losses,line_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; end endend % end of the code for writing line flows % global summary% --------------------------------------------------------------------Pg_tot = sum(Pgs);Qg_tot = sum(Qgs);Pl_tot = sum(Pls);Ql_tot = sum(Qls);total_p_loss = Pg_tot - Pl_tot;total_q_loss = Qg_tot - Ql_tot;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 LOSSES';Matrix{nh,1} = [total_p_loss;total_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}{3,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...% --------------------------------------------------------------------fm_write(Matrix,Header,Cols,Rows)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -