⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fm_report.m

📁 一个较好的MATLAB潮流程序
💻 M
📖 第 1 页 / 共 2 页
字号:
% ---------------------------------------------------------------Vs = DAE.V(ordbus).*VB(ordbus);angs = DAE.a(ordbus);raddeg = 'rad';if Fig.stat  hdlT = findobj(Fig.stat,'Tag','PushAngle');  string = get(hdlT,'UserData');  if ~strcmp(string,'rad')    angs = angs*180/pi;    raddeg = 'deg';  endendPgs = (Pgs + Bus.Pg(ordbus))*MVA;Qgs = Bus.Qg(ordbus)*MVA;Pls = (Pls + Bus.Pl(ordbus))*MVA;Qls = (Qls + Bus.Ql(ordbus))*MVA;if Line.n,  ntrasf = length(find(Line.con(:,7) ~= 0));else  ntrasf = 0;endnline = Lines.n + Line.n-ntrasf;% network statistics% ---------------------------------------------------------------Header{2,1} = 'NETWORK STATISTICS';Matrix{2,1} = Bus.n;Rows{2,1} = {'Buses:'};Cols{2,1} = '';if nline > 0  Matrix{2,1}(2,1) = nline;  Rows{2,1}{2,1} = 'Lines:';  idx = 2;else  idx = 1;endif ntrasf > 0  idx = idx + 1;  Matrix{2,1}(idx,1) = ntrasf;  Rows{2,1}{idx,1} = 'Transformers:';endMatrix{2,1}(idx+1,1) = SW.n+PV.n+Syn.n;Rows{2,1}{idx+1,1} = 'Generators:';Matrix{2,1}(idx+2,1) = PQ.n+Pl.n+Mn.n;Rows{2,1}{idx+2,1} = 'Loads:';% statistics of the current solution algorithm% ---------------------------------------------------------------Header{3,1} = 'SOLUTION STATISTICS';Cols{3,1} = '';Rows{3,1} = {'Number of Iterations:'; ...	     ['Maximum P mismatch ',MW]; ...	     ['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 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  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.ux;  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);  for kkk = 1:Syn.n    Synnames{kkk,1} = Varname.uPm{kkk};  end  for kkk = 1:Syn.n    Synnames{kkk+Syn.n,1} = Varname.uVf{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';  Rows{nh,1} = Varname.uVref;  Cols{nh,1} = '';  Matrix{nh,1} = [Exc.vrif];end% over excitation limiter variables% ---------------------------------------------------------------if Oxl.n  nh = nh + 1;  Header{nh,1} = 'FIELD CURRENTS';  Rows{nh,1} = Varname.uIf;  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};if Settings.octave  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};  endelse  Rows{nh,1} = [{nomi_bus{line_ffrom(:,2),1}}', ...                {nomi_bus{line_ffrom(:,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};if Settings.octave  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};  endelse  Rows{nh,1} = [{nomi_bus{line_fto(:,2),1}}', ...                {nomi_bus{line_fto(:,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 = 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 = 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);  if vVtot    Header{nh,1}{2,1} = sprintf('# OF VOLTAGE LIMIT VIOLATIONS: %d',vVtot);  else    Header{nh,1}{2,1} = 'ALL VOLTAGES WITHIN LIMITS.';  end  if vQtot    Header{nh,1}{3,1} = sprintf('# OF REACTIVE POWER LIMIT VIOLATIONS: %d',vQtot);  else    Header{nh,1}{3,1} = 'ALL REACTIVE POWER WITHIN LIMITS.';  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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -