Home > matpower4.1 > hasPQcap.m

hasPQcap

PURPOSE ^

HASPQCAP Checks for P-Q capability curve constraints.

SYNOPSIS ^

function TorF = hasPQcap(gen, hilo)

DESCRIPTION ^

HASPQCAP  Checks for P-Q capability curve constraints.
   TORF = HASPQCAP(GEN, HILO) returns a column vector of 1's and 0's. The 1's
   correspond to rows of the GEN matrix which correspond to generators which
   have defined a capability curve (with sloped upper and/or lower bound on
   Q) and require that additional linear constraints be added to the OPF.

   The GEN matrix in version 2 of the MATPOWER case format includes columns
   for specifying a P-Q capability curve for a generator defined as the
   intersection of two half-planes and the box constraints on P and Q. The
   two half planes are defined respectively as the area below the line
   connecting (Pc1, Qc1max) and (Pc2, Qc2max) and the area above the line
   connecting (Pc1, Qc1min) and (Pc2, Qc2min).

   If the optional 2nd argument is 'U' this function returns true only for
   rows corresponding to generators that require the upper constraint on Q.
   If it is 'L', only for those requiring the lower constraint. If the 2nd
   argument is not specified or has any other value it returns true for rows
   corresponding to gens that require either or both of the constraints.

   It is smart enough to return true only if the corresponding linear
   constraint is not redundant w.r.t the box constraints.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function TorF = hasPQcap(gen, hilo)
0002 %HASPQCAP  Checks for P-Q capability curve constraints.
0003 %   TORF = HASPQCAP(GEN, HILO) returns a column vector of 1's and 0's. The 1's
0004 %   correspond to rows of the GEN matrix which correspond to generators which
0005 %   have defined a capability curve (with sloped upper and/or lower bound on
0006 %   Q) and require that additional linear constraints be added to the OPF.
0007 %
0008 %   The GEN matrix in version 2 of the MATPOWER case format includes columns
0009 %   for specifying a P-Q capability curve for a generator defined as the
0010 %   intersection of two half-planes and the box constraints on P and Q. The
0011 %   two half planes are defined respectively as the area below the line
0012 %   connecting (Pc1, Qc1max) and (Pc2, Qc2max) and the area above the line
0013 %   connecting (Pc1, Qc1min) and (Pc2, Qc2min).
0014 %
0015 %   If the optional 2nd argument is 'U' this function returns true only for
0016 %   rows corresponding to generators that require the upper constraint on Q.
0017 %   If it is 'L', only for those requiring the lower constraint. If the 2nd
0018 %   argument is not specified or has any other value it returns true for rows
0019 %   corresponding to gens that require either or both of the constraints.
0020 %
0021 %   It is smart enough to return true only if the corresponding linear
0022 %   constraint is not redundant w.r.t the box constraints.
0023 
0024 %   MATPOWER
0025 %   $Id: hasPQcap.m,v 1.6 2010/04/26 19:45:26 ray Exp $
0026 %   by Ray Zimmerman, PSERC Cornell
0027 %   Copyright (c) 2005-2010 by Power System Engineering Research Center (PSERC)
0028 %
0029 %   This file is part of MATPOWER.
0030 %   See http://www.pserc.cornell.edu/matpower/ for more info.
0031 %
0032 %   MATPOWER is free software: you can redistribute it and/or modify
0033 %   it under the terms of the GNU General Public License as published
0034 %   by the Free Software Foundation, either version 3 of the License,
0035 %   or (at your option) any later version.
0036 %
0037 %   MATPOWER is distributed in the hope that it will be useful,
0038 %   but WITHOUT ANY WARRANTY; without even the implied warranty of
0039 %   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0040 %   GNU General Public License for more details.
0041 %
0042 %   You should have received a copy of the GNU General Public License
0043 %   along with MATPOWER. If not, see <http://www.gnu.org/licenses/>.
0044 %
0045 %   Additional permission under GNU GPL version 3 section 7
0046 %
0047 %   If you modify MATPOWER, or any covered work, to interface with
0048 %   other modules (such as MATLAB code and MEX-files) available in a
0049 %   MATLAB(R) or comparable environment containing parts covered
0050 %   under other licensing terms, the licensors of MATPOWER grant
0051 %   you additional permission to convey the resulting work.
0052 
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 %% default value
0058 if nargin < 2
0059     hilo = 'B';     %% look at both top and bottom by default
0060 end
0061 
0062 %% check for errors capability curve data
0063 if any( gen(:, PC1) > gen(:, PC2) )
0064     error('hasPQcap: Pc1 > Pc2');
0065 end
0066 if any( gen(:, QC2MAX) > gen(:, QC1MAX) )
0067     error('hasPQcap: Qc2max > Qc1max');
0068 end
0069 if any( gen(:, QC2MIN) < gen(:, QC1MIN) )
0070     error('hasPQcap: Qc2min < Qc1min');
0071 end
0072 
0073 L = zeros(size(gen, 1), 1);
0074 U = zeros(size(gen, 1), 1);
0075 k = find( gen(:, PC1) ~= gen(:, PC2) );
0076 
0077 if ~strcmp(hilo, 'U')       %% include lower constraint
0078     Qmin_at_Pmax = gen(k, QC1MIN) + (gen(k, PMAX) - gen(k, PC1)) .* ...
0079         (gen(k, QC2MIN) - gen(k, QC1MIN)) ./ (gen(k, PC2) - gen(k, PC1));
0080     L(k) = Qmin_at_Pmax > gen(k, QMIN);
0081 end
0082 
0083 if ~strcmp(hilo, 'L')       %% include upper constraint
0084     Qmax_at_Pmax = gen(k, QC1MAX) + (gen(k, PMAX) - gen(k, PC1)) .* ...
0085         (gen(k, QC2MAX) - gen(k, QC1MAX)) ./ (gen(k, PC2) - gen(k, PC1));
0086     U(k) = Qmax_at_Pmax < gen(k, QMAX);
0087 end
0088 
0089 TorF = L | U;

Generated on Mon 26-Jan-2015 15:00:13 by m2html © 2005