Home > matpower5.0 > load2disp.m

load2disp

PURPOSE ^

LOAD2DISP Converts fixed loads to dispatchable.

SYNOPSIS ^

function mpc1 = load2disp(mpc0, fname, idx, voll)

DESCRIPTION ^

LOAD2DISP Converts fixed loads to dispatchable.
   MPC = LOAD2DISP(MPC0);
   MPC = LOAD2DISP(MPC0, FNAME);
   MPC = LOAD2DISP(MPC0, FNAME, IDX);
   MPC = LOAD2DISP(MPC0, FNAME, IDX, VOLL);

   Takes a MATPOWER case file or struct and converts fixed loads to
   dispatchable loads and returns the resulting case struct. Inputs
   are as follows:

   MPC0 - File name or struct with initial MATPOWER case.

   FNAME (optional) - Name to use to save resulting MATPOWER case. If empty,
       the case will not be saved to a file.

   IDX (optional) - Vector of bus indices of loads to be converted. If empty
       or not supplied, it will convert all loads with positive real
       power demand.

   VOLL (optional) - Scalar or vector specifying the value of lost
       load to use as the value for the dispatchable loads. If it is
       a scalar it is used for all loads, if a vector, the dimension
       must match that of IDX. Default is $5000 per MWh.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function mpc1 = load2disp(mpc0, fname, idx, voll)
0002 %LOAD2DISP Converts fixed loads to dispatchable.
0003 %   MPC = LOAD2DISP(MPC0);
0004 %   MPC = LOAD2DISP(MPC0, FNAME);
0005 %   MPC = LOAD2DISP(MPC0, FNAME, IDX);
0006 %   MPC = LOAD2DISP(MPC0, FNAME, IDX, VOLL);
0007 %
0008 %   Takes a MATPOWER case file or struct and converts fixed loads to
0009 %   dispatchable loads and returns the resulting case struct. Inputs
0010 %   are as follows:
0011 %
0012 %   MPC0 - File name or struct with initial MATPOWER case.
0013 %
0014 %   FNAME (optional) - Name to use to save resulting MATPOWER case. If empty,
0015 %       the case will not be saved to a file.
0016 %
0017 %   IDX (optional) - Vector of bus indices of loads to be converted. If empty
0018 %       or not supplied, it will convert all loads with positive real
0019 %       power demand.
0020 %
0021 %   VOLL (optional) - Scalar or vector specifying the value of lost
0022 %       load to use as the value for the dispatchable loads. If it is
0023 %       a scalar it is used for all loads, if a vector, the dimension
0024 %       must match that of IDX. Default is $5000 per MWh.
0025 
0026 %   MATPOWER
0027 %   $Id: load2disp.m 2089 2012-10-01 16:53:09Z cvs $
0028 %   by Alberto Lamadrid, PSERC Cornell
0029 %   modified by Ray Zimmerman, PSERC Cornell
0030 %   Copyright (c) 2010 by Power System Engineering Research Center (PSERC)
0031 %
0032 %   This file is part of MATPOWER.
0033 %   See http://www.pserc.cornell.edu/matpower/ for more info.
0034 %
0035 %   MATPOWER is free software: you can redistribute it and/or modify
0036 %   it under the terms of the GNU General Public License as published
0037 %   by the Free Software Foundation, either version 3 of the License,
0038 %   or (at your option) any later version.
0039 %
0040 %   MATPOWER is distributed in the hope that it will be useful,
0041 %   but WITHOUT ANY WARRANTY; without even the implied warranty of
0042 %   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0043 %   GNU General Public License for more details.
0044 %
0045 %   You should have received a copy of the GNU General Public License
0046 %   along with MATPOWER. If not, see <http://www.gnu.org/licenses/>.
0047 %
0048 %   Additional permission under GNU GPL version 3 section 7
0049 %
0050 %   If you modify MATPOWER, or any covered work, to interface with
0051 %   other modules (such as MATLAB code and MEX-files) available in a
0052 %   MATLAB(R) or comparable environment containing parts covered
0053 %   under other licensing terms, the licensors of MATPOWER grant
0054 %   you additional permission to convey the resulting work.
0055 
0056 %% define constants
0057 [PQ, PV, REF, NONE, BUS_I, BUS_TYPE, PD, QD, GS, BS, BUS_AREA, VM, ...
0058     VA, BASE_KV, ZONE, VMAX, VMIN, LAM_P, LAM_Q, MU_VMAX, MU_VMIN] = idx_bus;
0059 [GEN_BUS, PG, QG, QMAX, QMIN, VG, MBASE, GEN_STATUS, PMAX, PMIN, ...
0060     MU_PMAX, MU_PMIN, MU_QMAX, MU_QMIN, PC1, PC2, QC1MIN, QC1MAX, ...
0061     QC2MIN, QC2MAX, RAMP_AGC, RAMP_10, RAMP_30, RAMP_Q, APF] = idx_gen;
0062 [PW_LINEAR, POLYNOMIAL, MODEL, STARTUP, SHUTDOWN, NCOST, COST] = idx_cost;
0063 
0064 mpc = loadcase(mpc0);
0065 
0066 %% which loads will be converted?
0067 if nargin < 3 || isempty(idx)
0068     idx = find(mpc.bus(:, PD) > 0); %% by default, all with PD > 0
0069 end
0070 
0071 %% set some defaults
0072 voll0   = 5000;             %% default value of lost load
0073 mBase   = 100;              %% generator MVA base
0074 nld     = length(idx);
0075 v1      = ones(nld, 1);     %% vector of ones
0076 v0      = zeros(nld, 1);    %% vector of zeros
0077 
0078 %% gen table
0079 gen = [
0080     mpc.bus(idx, BUS_I), ...        %% GEN_BUS
0081     -mpc.bus(idx, PD), ...          %% PG
0082     -mpc.bus(idx, QD), ...          %% QG
0083     max(0, -mpc.bus(idx, QD)), ...  %% QMAX
0084     min(0, -mpc.bus(idx, QD)), ...  %% QMIN
0085     mpc.bus(idx, VM), ...           %% VG
0086     mBase * v1, ...                 %% MBASE
0087     v1, ...                         %% GEN_STATUS
0088     max(0, -mpc.bus(idx, PD)), ...  %% PMAX
0089     min(0, -mpc.bus(idx, PD)), ...  %% PMIN
0090     zeros(nld, 6), ...              %% capability curve
0091     Inf * ones(nld, 4), ...         %% ramp rates
0092     zeros(nld, 1), ...              %% participation factor
0093 ];
0094 mpc.gen =  [mpc.gen; gen];  %% add dispatchable loads
0095 
0096 %% bus table
0097 mpc.bus(idx, [PD, QD]) = 0; %% zero out fixed loads
0098 
0099 %% gencost table
0100 nc = size(mpc.gencost, 2);
0101 if nargin < 4
0102     voll = voll0 * v1;
0103 elseif length(voll) == 1
0104     voll = voll * v1;
0105 end
0106 gencost = [             %% use a linear, polynomial cost format
0107     POLYNOMIAL*v1, ...      %% MODEL
0108     zeros(nld, 2), ...      %% STARTUP, SHUTDOWN
0109     2 * v1, ...             %% NCOST
0110     voll, ...               %% COST, linear term
0111     zeros(nld, nc-5) ...    %% constant term and zero-padding
0112 ];
0113 mpc.gencost = [mpc.gencost; gencost];
0114 
0115 %% save case, if filename is given
0116 if nargin > 1 && ~isempty(fname)
0117     savecase(fname, mpc, '2');
0118 end
0119 if nargout > 0
0120     mpc1 = mpc;
0121 end

Generated on Mon 26-Jan-2015 15:21:31 by m2html © 2005