Home > matpower5.1 > 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 %   Copyright (c) 1996-2015 by Power System Engineering Research Center (PSERC)
0017 %   by Ray Zimmerman, PSERC Cornell
0018 %   and Carlos E. Murillo-Sanchez, PSERC Cornell & Universidad Autonoma de Manizales
0019 %
0020 %   $Id: makeAvl.m 2644 2015-03-11 19:34:22Z ray $
0021 %
0022 %   This file is part of MATPOWER.
0023 %   Covered by the 3-clause BSD License (see LICENSE file for details).
0024 %   See http://www.pserc.cornell.edu/matpower/ for more info.
0025 
0026 %% define named indices into data matrices
0027 [GEN_BUS, PG, QG, QMAX, QMIN, VG, MBASE, GEN_STATUS, PMAX, PMIN, ...
0028     MU_PMAX, MU_PMIN, MU_QMAX, MU_QMIN, PC1, PC2, QC1MIN, QC1MAX, ...
0029     QC2MIN, QC2MAX, RAMP_AGC, RAMP_10, RAMP_30, RAMP_Q, APF] = idx_gen;
0030 
0031 %% data dimensions
0032 ng = size(gen, 1);      %% number of dispatchable injections
0033 Pg   = gen(:, PG) / baseMVA;
0034 Qg   = gen(:, QG) / baseMVA;
0035 Pmin = gen(:, PMIN) / baseMVA;
0036 Qmin = gen(:, QMIN) / baseMVA;
0037 Qmax = gen(:, QMAX) / baseMVA;
0038 
0039 
0040 % Find out if any of these "generators" are actually dispatchable loads.
0041 % (see 'help isload' for details on what constitutes a dispatchable load)
0042 % Dispatchable loads are modeled as generators with an added constant
0043 % power factor constraint. The power factor is derived from the original
0044 % value of Pmin and either Qmin (for inductive loads) or Qmax (for capacitive
0045 % loads). If both Qmin and Qmax are zero, this implies a unity power factor
0046 % without the need for an additional constraint.
0047 
0048 
0049 ivl = find( isload(gen) & (Qmin ~= 0 | Qmax ~= 0) );
0050 nvl  = size(ivl, 1);  %% number of dispatchable loads
0051 
0052 %% at least one of the Q limits must be zero (corresponding to Pmax == 0)
0053 if any( Qmin(ivl) ~= 0 & Qmax(ivl) ~= 0 )
0054     error('makeAvl: either Qmin or Qmax must be equal to zero for each dispatchable load.');
0055 end
0056 
0057 % Initial values of PG and QG must be consistent with specified power factor
0058 % This is to prevent a user from unknowingly using a case file which would
0059 % have defined a different power factor constraint under a previous version
0060 % which used PG and QG to define the power factor.
0061 Qlim = (Qmin(ivl) == 0) .* Qmax(ivl) + ...
0062     (Qmax(ivl) == 0) .* Qmin(ivl);
0063 if any( abs( Qg(ivl) - Pg(ivl) .* Qlim ./ Pmin(ivl) ) > 1e-6 )
0064     error('makeAvl: %s\n         %s\n', ...
0065         'For a dispatchable load, PG and QG must be consistent', ...
0066         'with the power factor defined by PMIN and the Q limits.');
0067 end
0068 
0069 % make Avl, lvl, uvl, for lvl <= Avl * [Pg; Qg] <= uvl
0070 if nvl > 0
0071   xx = Pmin(ivl);
0072   yy = Qlim;
0073   pftheta = atan2(yy, xx);
0074   pc = sin(pftheta);
0075   qc = -cos(pftheta);
0076   ii = [ (1:nvl)'; (1:nvl)' ];
0077   jj = [ ivl; ivl+ng ];
0078   Avl = sparse(ii, jj, [pc; qc], nvl, 2*ng);
0079   lvl = zeros(nvl, 1);
0080   uvl = lvl;
0081 else
0082   Avl = sparse(0, 2*ng);
0083   lvl =[];
0084   uvl =[];
0085 end

Generated on Fri 20-Mar-2015 18:23:34 by m2html © 2005