MAKEAPQ Construct linear constraints for generator capability curves. [APQH, UBPQH, APQL, UBPQL, DATA] = MAKEAPQ(BASEMVA, GEN) Constructs the parameters for the following linear constraints implementing trapezoidal generator capability curves, where Pg and Qg are the real and reactive generator injections. APQH * [Pg; Qg] <= UBPQH APQL * [Pg; Qg] <= UBPQL DATA constains additional information as shown below. Example: [Apqh, ubpqh, Apql, ubpql, data] = makeApq(baseMVA, gen); data.h [QC1MAX-QC2MAX, PC2-PC1] data.l [QC2MIN-QC1MIN, PC1-PC2] data.ipqh indices of gens with general PQ cap curves (upper) data.ipql indices of gens with general PQ cap curves (lower)
0001 function [Apqh, ubpqh, Apql, ubpql, data] = makeApq(baseMVA, gen) 0002 %MAKEAPQ Construct linear constraints for generator capability curves. 0003 % [APQH, UBPQH, APQL, UBPQL, DATA] = MAKEAPQ(BASEMVA, GEN) 0004 % 0005 % Constructs the parameters for the following linear constraints 0006 % implementing trapezoidal generator capability curves, where 0007 % Pg and Qg are the real and reactive generator injections. 0008 % 0009 % APQH * [Pg; Qg] <= UBPQH 0010 % APQL * [Pg; Qg] <= UBPQL 0011 % 0012 % DATA constains additional information as shown below. 0013 % 0014 % Example: 0015 % [Apqh, ubpqh, Apql, ubpql, data] = makeApq(baseMVA, gen); 0016 % 0017 % data.h [QC1MAX-QC2MAX, PC2-PC1] 0018 % data.l [QC2MIN-QC1MIN, PC1-PC2] 0019 % data.ipqh indices of gens with general PQ cap curves (upper) 0020 % data.ipql indices of gens with general PQ cap curves (lower) 0021 0022 % MATPOWER 0023 % Copyright (c) 1996-2015 by Power System Engineering Research Center (PSERC) 0024 % by Ray Zimmerman, PSERC Cornell 0025 % and Carlos E. Murillo-Sanchez, PSERC Cornell & Universidad Autonoma de Manizales 0026 % 0027 % $Id: makeApq.m 2644 2015-03-11 19:34:22Z ray $ 0028 % 0029 % This file is part of MATPOWER. 0030 % Covered by the 3-clause BSD License (see LICENSE file for details). 0031 % See http://www.pserc.cornell.edu/matpower/ for more info. 0032 0033 %% define named indices into data matrices 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 %% data dimensions 0039 ng = size(gen, 1); %% number of dispatchable injections 0040 0041 %% which generators require additional linear constraints 0042 %% (in addition to simple box constraints) on (Pg,Qg) to correctly 0043 %% model their PQ capability curves 0044 ipqh = find( hasPQcap(gen, 'U') ); 0045 ipql = find( hasPQcap(gen, 'L') ); 0046 npqh = size(ipqh, 1); %% number of general PQ capability curves (upper) 0047 npql = size(ipql, 1); %% number of general PQ capability curves (lower) 0048 0049 %% make Apqh if there is a need to add general PQ capability curves; 0050 %% use normalized coefficient rows so multipliers have right scaling 0051 %% in $$/pu 0052 if npqh > 0 0053 data.h = [gen(ipqh,QC1MAX)-gen(ipqh,QC2MAX), gen(ipqh,PC2)-gen(ipqh,PC1)]; 0054 ubpqh = data.h(:, 1) .* gen(ipqh,PC1) + data.h(:, 2) .* gen(ipqh,QC1MAX); 0055 for i=1:npqh, 0056 tmp = norm(data.h(i,:)); 0057 data.h(i,:) = data.h(i, :) / tmp; 0058 ubpqh(i) = ubpqh(i) / tmp; 0059 end 0060 Apqh = sparse([1:npqh, 1:npqh]', [ipqh; ipqh+ng], ... 0061 data.h(:), npqh, 2*ng); 0062 ubpqh = ubpqh / baseMVA; 0063 else 0064 data.h = []; 0065 Apqh = sparse(0, 2*ng); 0066 ubpqh = []; 0067 end 0068 0069 %% similarly Apql 0070 if npql > 0 0071 data.l = [gen(ipql,QC2MIN)-gen(ipql,QC1MIN), gen(ipql,PC1)-gen(ipql,PC2)]; 0072 ubpql= data.l(:, 1) .* gen(ipql,PC1) + data.l(:, 2) .* gen(ipql,QC1MIN) ; 0073 for i=1:npql, 0074 tmp = norm(data.l(i, : )); 0075 data.l(i, :) = data.l(i, :) / tmp; 0076 ubpql(i) = ubpql(i) / tmp; 0077 end 0078 Apql = sparse([1:npql, 1:npql]', [ipql; ipql+ng], ... 0079 data.l(:), npql, 2*ng); 0080 ubpql = ubpql / baseMVA; 0081 else 0082 data.l = []; 0083 Apql = sparse(0, 2*ng); 0084 ubpql = []; 0085 end 0086 0087 data.ipql = ipql; 0088 data.ipqh = ipqh;