Home > matpower7.1 > most > lib > plot_uc.m

plot_uc

PURPOSE ^

PLOT_UC Plot generator commitment summary

SYNOPSIS ^

function hh = plot_uc(md, varargin)

DESCRIPTION ^

PLOT_UC   Plot generator commitment summary

   PLOT_UC(MD)
   PLOT_UC(MD, IDX)
   PLOT_UC(MD, IDX, '<option1_name>', '<option1_value', ...)
   PLOT_UC(MD, IDX, OPT)
   PLOT_UC(MD, IDX, OPT, '<option1_name>', '<option1_value', ...)
   PLOT_UC(MD, MD2)
   PLOT_UC(MD, MD2, IDX, )
   PLOT_UC(MD, MD2, IDX, '<option1_name>', '<option1_value', ...)
   PLOT_UC(MD, MD2, IDX, OPT)
   PLOT_UC(MD, MD2, IDX, OPT, '<option1_name>', '<option1_value', ...)
   H = PLOT_UC(MD, ...)

   IDX is a vector of gen indices, if empty, it includes all generators in
   MD. Options can be specified as an OPT struct or as individual pairs of
   'name' and 'value' arguments. The possible options include the following,
   where the default is shown in parenthesis:
       'title'         ('Unit Commitment - %s') title for the plot, where
                       %s is an optional placeholder for the subtitle
       'subtitle'      ({'First', 'Second', 'Both'}) cell array of labels
                       to use for legend (if two schedules are provided)
                       and to replace a placeholder in the title (based
                       on which commitment schedule(s) is(are) provided in
                       UC1 and/or UC2); can also be a simple string, in
                       which case no legend will be displayed even if both
                       UC1 and UC2 are supplied
       'xlabel'        ('Period') label for horizontal axis
       'ylabel'        (<empty>) label for vertical axis
       'rowlabels'     ({'1', '2', '3', ...) labels for rows (top to bottom)
       'saveit'        (false) flag to indicate whether to create PDF file
       'saveall'       (false) flag to indicate whether to create a single
                       PDF file or, if both MD and MD2 are supplied, three
                       PFF files, one for MD, one for MD2 and one for both.
       'savepath'      ('') path to directory to save files in
       'savename'      ('uc-%s.pdf') name of PDF file
                       %s is optional placeholder for storage unit index
       'size_factor'   (1) to scale font/marker sizes in case you want to
                       do sub-plots or something

   Returns handle to current figure window.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function hh = plot_uc(md, varargin)
0002 %PLOT_UC   Plot generator commitment summary
0003 %
0004 %   PLOT_UC(MD)
0005 %   PLOT_UC(MD, IDX)
0006 %   PLOT_UC(MD, IDX, '<option1_name>', '<option1_value', ...)
0007 %   PLOT_UC(MD, IDX, OPT)
0008 %   PLOT_UC(MD, IDX, OPT, '<option1_name>', '<option1_value', ...)
0009 %   PLOT_UC(MD, MD2)
0010 %   PLOT_UC(MD, MD2, IDX, )
0011 %   PLOT_UC(MD, MD2, IDX, '<option1_name>', '<option1_value', ...)
0012 %   PLOT_UC(MD, MD2, IDX, OPT)
0013 %   PLOT_UC(MD, MD2, IDX, OPT, '<option1_name>', '<option1_value', ...)
0014 %   H = PLOT_UC(MD, ...)
0015 %
0016 %   IDX is a vector of gen indices, if empty, it includes all generators in
0017 %   MD. Options can be specified as an OPT struct or as individual pairs of
0018 %   'name' and 'value' arguments. The possible options include the following,
0019 %   where the default is shown in parenthesis:
0020 %       'title'         ('Unit Commitment - %s') title for the plot, where
0021 %                       %s is an optional placeholder for the subtitle
0022 %       'subtitle'      ({'First', 'Second', 'Both'}) cell array of labels
0023 %                       to use for legend (if two schedules are provided)
0024 %                       and to replace a placeholder in the title (based
0025 %                       on which commitment schedule(s) is(are) provided in
0026 %                       UC1 and/or UC2); can also be a simple string, in
0027 %                       which case no legend will be displayed even if both
0028 %                       UC1 and UC2 are supplied
0029 %       'xlabel'        ('Period') label for horizontal axis
0030 %       'ylabel'        (<empty>) label for vertical axis
0031 %       'rowlabels'     ({'1', '2', '3', ...) labels for rows (top to bottom)
0032 %       'saveit'        (false) flag to indicate whether to create PDF file
0033 %       'saveall'       (false) flag to indicate whether to create a single
0034 %                       PDF file or, if both MD and MD2 are supplied, three
0035 %                       PFF files, one for MD, one for MD2 and one for both.
0036 %       'savepath'      ('') path to directory to save files in
0037 %       'savename'      ('uc-%s.pdf') name of PDF file
0038 %                       %s is optional placeholder for storage unit index
0039 %       'size_factor'   (1) to scale font/marker sizes in case you want to
0040 %                       do sub-plots or something
0041 %
0042 %   Returns handle to current figure window.
0043 
0044 %   MOST
0045 %   Copyright (c) 2015-2016, Power Systems Engineering Research Center (PSERC)
0046 %   by Ray Zimmerman, PSERC Cornell
0047 %
0048 %   This file is part of MOST.
0049 %   Covered by the 3-clause BSD License (see LICENSE file for details).
0050 %   See https://github.com/MATPOWER/most for more info.
0051 
0052 %% define named indices into data matrices
0053 [GEN_BUS, PG, QG, QMAX, QMIN, VG, MBASE, GEN_STATUS, PMAX, PMIN, ...
0054     MU_PMAX, MU_PMIN, MU_QMAX, MU_QMIN, PC1, PC2, QC1MIN, QC1MAX, ...
0055     QC2MIN, QC2MAX, RAMP_AGC, RAMP_10, RAMP_30, RAMP_Q, APF] = idx_gen;
0056 
0057 %% gather data
0058 nt = md.idx.nt;
0059 ng = size(md.mpc.gen, 1);
0060 nj_max = max(md.idx.nj);
0061 nc_max = max(max(md.idx.nc));
0062 
0063 %% default optional args
0064 idx = [];
0065 md2 = [];
0066 k = 1;
0067 if nargin > 1                   %% 2nd arg is ...
0068     if isstruct(varargin{k})    %% ... md2
0069         md2 = varargin{k};
0070     else                        %% ... idx
0071         idx = varargin{k};
0072     end
0073     k = k + 1;
0074 end
0075 if isempty(idx) && nargin > 2   %% 3rd arg is ...
0076     if isnumeric(varargin{k})
0077         idx = varargin{k};      %% ... idx
0078         k = k + 1;
0079     end
0080 end
0081 
0082 %% default idx
0083 if isempty(idx)
0084     idx = find(any(md.UC.CommitKey == 0, 2) | any(md.UC.CommitKey == 1, 2));
0085 end
0086 nidx = length(idx);
0087 if nidx > 1 && size(idx, 1) == 1
0088     idx = idx';     %% convert row vector to column vector
0089 end
0090 b = md.mpc.gen(idx, GEN_BUS);
0091 
0092 %% default options
0093 opt = struct( ...
0094     'title', 'Unit Commitment - %s', ...
0095     'subtitle', {{'First', 'Second', 'Both'}}, ...
0096     'xlabel', 'Period', ...
0097     'ylabel', '', ...
0098     'rowlabels', [], ...
0099     'saveit', false, ...
0100     'saveall', false, ...
0101     'savepath', '', ...
0102     'savename', 'uc-%s.pdf', ...
0103     'size_factor', 1 );
0104 
0105 %% process options
0106 vargs = varargin(k:end); %% remaining arguments
0107 if mod(length(vargs), 2)    %% odd number of options, first must be OPT struct
0108     if ~isstruct(vargs{1})
0109         error('plot_uc: Single OPT argument must be a struct');
0110     end
0111     myopt = vargs{1};
0112     k = 2;
0113 else                        %% even number of options
0114     myopt = struct;
0115     k = 1;
0116 end
0117 while k < length(vargs)
0118     opt_name = vargs{k};
0119     opt_val  = vargs{k+1};
0120     if ~isfield(opt, opt_name)
0121         error('plot_uc: ''%s'' is not a valid option name', opt_name);
0122     end
0123     myopt.(opt_name) = opt_val;
0124     k = k + 2;
0125 end
0126 fields = fieldnames(myopt);
0127 for f = 1:length(fields)
0128     opt.(fields{f}) = myopt.(fields{f});
0129 end
0130 
0131 %% check CommitKey match
0132 uc1 = md.UC.CommitSched(idx, :);
0133 if ~isempty(md2)
0134     uck2 = md2.UC.CommitKey(idx, :);
0135     if any(any( uck2 ~= md.UC.CommitKey(idx, :) & (uck2 == 2 | uck2 == 0) ))
0136         error('plot_uc: CommitKey fields in MD and MD2 do not match');
0137     end
0138     uc2 = md2.UC.CommitSched(idx, :);
0139 else
0140     uc2 = [];
0141 end
0142 
0143 %% generator labels
0144 m = size(uc1, 1);
0145 opt.rowlabels = cell(m, 1);
0146 if isfield(md.mpc, 'genfuel')
0147     for i = 1:m
0148         opt.rowlabels{i} = sprintf('Gen %d @ Bus %d, %s', idx(i), b(i), md.mpc.genfuel{idx(i)});
0149     end
0150 else
0151     for i = 1:m
0152         opt.rowlabels{i} = sprintf('Gen %d @ Bus %d', idx(i), b(i));
0153     end
0154 end
0155 
0156 %% do the plots
0157 if opt.saveall
0158     opt.saveit = 1;
0159 end
0160 if opt.saveall || isempty(uc2)
0161     clf;
0162     h = plot_uc_data(uc1, [], opt);
0163 end
0164 if ~isempty(uc2)
0165     if opt.saveall || isempty(uc1)
0166         clf;
0167         h = plot_uc_data([], uc2, opt);
0168     end
0169     if opt.saveall || ~isempty(uc1)
0170         clf;
0171         h = plot_uc_data(uc1, uc2, opt);
0172     end
0173 end
0174 
0175 if nargout
0176     hh = h;
0177 end

Generated on Fri 09-Oct-2020 11:21:31 by m2html © 2005