Home > matpower5.0 > makeAvl.m

makeAvl

PURPOSE ^

MAKEAVL Construct linear constraints for constant power factor var loads.

SYNOPSIS ^

function [Avl, lvl, uvl, ivl] = makeAvl(baseMVA, gen)

DESCRIPTION ^

MAKEAVL Construct linear constraints for constant power factor var loads.
   [AVL, LVL, UVL, IVL]  = MAKEAVL(BASEMVA, GEN)

   Constructs parameters for the following linear constraint enforcing a
   constant power factor constraint for dispatchable loads.

        LVL <= AVL * [Pg; Qg] <= UVL

   IVL is the vector of indices of generators representing variable loads.

   Example:
       [Avl, lvl, uvl, ivl]  = makeAvl(baseMVA, gen);

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [Avl, lvl, uvl, ivl]  = makeAvl(baseMVA, gen)
0002 %MAKEAVL Construct linear constraints for constant power factor var loads.
0003 %   [AVL, LVL, UVL, IVL]  = MAKEAVL(BASEMVA, GEN)
0004 %
0005 %   Constructs parameters for the following linear constraint enforcing a
0006 %   constant power factor constraint for dispatchable loads.
0007 %
0008 %        LVL <= AVL * [Pg; Qg] <= UVL
0009 %
0010 %   IVL is the vector of indices of generators representing variable loads.
0011 %
0012 %   Example:
0013 %       [Avl, lvl, uvl, ivl]  = makeAvl(baseMVA, gen);
0014 
0015 %   MATPOWER
0016 %   $Id: makeAvl.m 1812 2011-03-14 19:24:29Z cvs $
0017 %   by Ray Zimmerman, PSERC Cornell
0018 %   and Carlos E. Murillo-Sanchez, PSERC Cornell & Universidad Autonoma de Manizales
0019 %   Copyright (c) 1996-2010 by Power System Engineering Research Center (PSERC)
0020 %
0021 %   This file is part of MATPOWER.
0022 %   See http://www.pserc.cornell.edu/matpower/ for more info.
0023 %
0024 %   MATPOWER is free software: you can redistribute it and/or modify
0025 %   it under the terms of the GNU General Public License as published
0026 %   by the Free Software Foundation, either version 3 of the License,
0027 %   or (at your option) any later version.
0028 %
0029 %   MATPOWER is distributed in the hope that it will be useful,
0030 %   but WITHOUT ANY WARRANTY; without even the implied warranty of
0031 %   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0032 %   GNU General Public License for more details.
0033 %
0034 %   You should have received a copy of the GNU General Public License
0035 %   along with MATPOWER. If not, see <http://www.gnu.org/licenses/>.
0036 %
0037 %   Additional permission under GNU GPL version 3 section 7
0038 %
0039 %   If you modify MATPOWER, or any covered work, to interface with
0040 %   other modules (such as MATLAB code and MEX-files) available in a
0041 %   MATLAB(R) or comparable environment containing parts covered
0042 %   under other licensing terms, the licensors of MATPOWER grant
0043 %   you additional permission to convey the resulting work.
0044 
0045 %% define named indices into data matrices
0046 [GEN_BUS, PG, QG, QMAX, QMIN, VG, MBASE, GEN_STATUS, PMAX, PMIN, ...
0047     MU_PMAX, MU_PMIN, MU_QMAX, MU_QMIN, PC1, PC2, QC1MIN, QC1MAX, ...
0048     QC2MIN, QC2MAX, RAMP_AGC, RAMP_10, RAMP_30, RAMP_Q, APF] = idx_gen;
0049 
0050 %% data dimensions
0051 ng = size(gen, 1);      %% number of dispatchable injections
0052 Pg   = gen(:, PG) / baseMVA;
0053 Qg   = gen(:, QG) / baseMVA;
0054 Pmin = gen(:, PMIN) / baseMVA;
0055 Qmin = gen(:, QMIN) / baseMVA;
0056 Qmax = gen(:, QMAX) / baseMVA;
0057 
0058 
0059 % Find out if any of these "generators" are actually dispatchable loads.
0060 % (see 'help isload' for details on what constitutes a dispatchable load)
0061 % Dispatchable loads are modeled as generators with an added constant
0062 % power factor constraint. The power factor is derived from the original
0063 % value of Pmin and either Qmin (for inductive loads) or Qmax (for capacitive
0064 % loads). If both Qmin and Qmax are zero, this implies a unity power factor
0065 % without the need for an additional constraint.
0066 
0067 
0068 ivl = find( isload(gen) & (Qmin ~= 0 | Qmax ~= 0) );
0069 nvl  = size(ivl, 1);  %% number of dispatchable loads
0070 
0071 %% at least one of the Q limits must be zero (corresponding to Pmax == 0)
0072 if any( Qmin(ivl) ~= 0 & Qmax(ivl) ~= 0 )
0073     error('makeAvl: either Qmin or Qmax must be equal to zero for each dispatchable load.');
0074 end
0075 
0076 % Initial values of PG and QG must be consistent with specified power factor
0077 % This is to prevent a user from unknowingly using a case file which would
0078 % have defined a different power factor constraint under a previous version
0079 % which used PG and QG to define the power factor.
0080 Qlim = (Qmin(ivl) == 0) .* Qmax(ivl) + ...
0081     (Qmax(ivl) == 0) .* Qmin(ivl);
0082 if any( abs( Qg(ivl) - Pg(ivl) .* Qlim ./ Pmin(ivl) ) > 1e-6 )
0083     error('makeAvl: %s\n         %s\n', ...
0084         'For a dispatchable load, PG and QG must be consistent', ...
0085         'with the power factor defined by PMIN and the Q limits.');
0086 end
0087 
0088 % make Avl, lvl, uvl, for lvl <= Avl * [Pg; Qg] <= uvl
0089 if nvl > 0
0090   xx = Pmin(ivl);
0091   yy = Qlim;
0092   pftheta = atan2(yy, xx);
0093   pc = sin(pftheta);
0094   qc = -cos(pftheta);
0095   ii = [ (1:nvl)'; (1:nvl)' ];
0096   jj = [ ivl; ivl+ng ];
0097   Avl = sparse(ii, jj, [pc; qc], nvl, 2*ng);
0098   lvl = zeros(nvl, 1);
0099   uvl = lvl;
0100 else
0101   Avl = sparse(0, 2*ng);
0102   lvl =[];
0103   uvl =[];
0104 end

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