Home > matpower5.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 %   Copyright (c) 2005-2015 by Power System Engineering Research Center (PSERC)
0026 %   by Ray Zimmerman, PSERC Cornell
0027 %
0028 %   $Id: hasPQcap.m 2644 2015-03-11 19:34:22Z ray $
0029 %
0030 %   This file is part of MATPOWER.
0031 %   Covered by the 3-clause BSD License (see LICENSE file for details).
0032 %   See http://www.pserc.cornell.edu/matpower/ for more info.
0033 
0034 [GEN_BUS, PG, QG, QMAX, QMIN, VG, MBASE, GEN_STATUS, PMAX, PMIN, ...
0035     MU_PMAX, MU_PMIN, MU_QMAX, MU_QMIN, PC1, PC2, QC1MIN, QC1MAX, ...
0036     QC2MIN, QC2MAX, RAMP_AGC, RAMP_10, RAMP_30, RAMP_Q, APF] = idx_gen;
0037 
0038 %% default value
0039 if nargin < 2
0040     hilo = 'B';     %% look at both top and bottom by default
0041 end
0042 
0043 %% for which gens is it specified
0044 k = find( gen(:, PC1) | gen(:, PC2) );
0045 ng = size(gen, 1);
0046 
0047 if isempty(k)
0048     TorF = zeros(ng, 1);
0049 else
0050     %% check for errors in capability curve data
0051     if any( gen(k, PC1) >= gen(k, PC2) )
0052         error('hasPQcap: must have Pc1 < Pc2');
0053     end
0054     if any( gen(k, QC2MAX) <= gen(k, QC2MIN) & gen(k, QC1MAX) <= gen(k, QC1MIN) )
0055         error('hasPQcap: capability curve defines an empty set');
0056     end
0057 
0058     %% for which gens is it specified
0059     k = find( gen(:, PC1) ~= gen(:, PC2) );
0060     L = zeros(ng, 1);
0061     U = zeros(ng, 1);
0062     dPc = gen(k, PC2) - gen(k, PC1);
0063 
0064     if ~strcmp(hilo, 'U')       %% include lower constraint
0065         dQc = gen(k, QC2MIN) - gen(k, QC1MIN);
0066         Qmin_at_Pmin = gen(k, QC1MIN) + (gen(k, PMIN) - gen(k, PC1)) .* ...
0067             dQc ./ dPc;
0068         Qmin_at_Pmax = gen(k, QC1MIN) + (gen(k, PMAX) - gen(k, PC1)) .* ...
0069             dQc ./ dPc;
0070         L(k) = Qmin_at_Pmin > gen(k, QMIN) | Qmin_at_Pmax > gen(k, QMIN);
0071     end
0072 
0073     if ~strcmp(hilo, 'L')       %% include upper constraint
0074         dQc = gen(k, QC2MAX) - gen(k, QC1MAX);
0075         Qmax_at_Pmin = gen(k, QC1MAX) + (gen(k, PMIN) - gen(k, PC1)) .* ...
0076             dQc ./ dPc;
0077         Qmax_at_Pmax = gen(k, QC1MAX) + (gen(k, PMAX) - gen(k, PC1)) .* ...
0078             dQc ./ dPc;
0079         U(k) = Qmax_at_Pmin < gen(k, QMAX) | Qmax_at_Pmax < gen(k, QMAX);
0080     end
0081 
0082     TorF = L | U;
0083 end

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