Home > matpower7.1 > lib > cpf_qlim_event.m

cpf_qlim_event

PURPOSE ^

CPF_QLIM_EVENT Event function to detect gen reactive power limit violations

SYNOPSIS ^

function ef = cpf_qlim_event(cb_data, cx)

DESCRIPTION ^

CPF_QLIM_EVENT  Event function to detect gen reactive power limit violations
   EF = CPF_QLIM_EVENT(CB_DATA, CX)

   CPF event function to detect generator reactive power limit violations,
   i.e. Qg <= Qmin or Qg >= Qmax.

   Inputs:
       CB_DATA : struct of data for callback functions
       CX : struct containing info about current point (continuation soln)

   Outputs:
       EF : event function value

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function ef = cpf_qlim_event(cb_data, cx)
0002 %CPF_QLIM_EVENT  Event function to detect gen reactive power limit violations
0003 %   EF = CPF_QLIM_EVENT(CB_DATA, CX)
0004 %
0005 %   CPF event function to detect generator reactive power limit violations,
0006 %   i.e. Qg <= Qmin or Qg >= Qmax.
0007 %
0008 %   Inputs:
0009 %       CB_DATA : struct of data for callback functions
0010 %       CX : struct containing info about current point (continuation soln)
0011 %
0012 %   Outputs:
0013 %       EF : event function value
0014 
0015 %   MATPOWER
0016 %   Copyright (c) 2016, Power Systems Engineering Research Center (PSERC)
0017 %   by Ray Zimmerman, PSERC Cornell
0018 %   and Shrirang Abhyankar, Argonne National Laboratory
0019 %
0020 %   This file is part of MATPOWER.
0021 %   Covered by the 3-clause BSD License (see LICENSE file for details).
0022 %   See https://matpower.org for more info.
0023 
0024 %% event function value is 2 ng x 1 vector equal to:
0025 %%      [ Qg - Qmax ]
0026 %%      [ Qmin - Qg ]
0027 
0028 %% define named indices into bus, gen, branch matrices
0029 [PQ, PV, REF, NONE, BUS_I, BUS_TYPE, PD, QD, GS, BS, BUS_AREA, VM, ...
0030     VA, BASE_KV, ZONE, VMAX, VMIN, LAM_P, LAM_Q, MU_VMAX, MU_VMIN] = idx_bus;
0031 [GEN_BUS, PG, QG, QMAX, QMIN, VG, MBASE, GEN_STATUS, PMAX, PMIN, ...
0032     MU_PMAX, MU_PMIN, MU_QMAX, MU_QMIN, PC1, PC2, QC1MIN, QC1MAX, ...
0033     QC2MIN, QC2MAX, RAMP_AGC, RAMP_10, RAMP_30, RAMP_Q, APF] = idx_gen;
0034 
0035 %% get updated MPC
0036 d = cb_data;
0037 mpc = cpf_current_mpc(d.mpc_base, d.mpc_target, ...
0038     d.Ybus, d.Yf, d.Yt, d.ref, d.pv, d.pq, cx.V, cx.lam, d.mpopt);
0039 
0040 %% compute Qg violations for on-line gens, not at PQ buses
0041 nb = size(mpc.bus, 1);
0042 ng = size(mpc.gen, 1);
0043 on = find(mpc.gen(:, GEN_STATUS) > 0 & ...  %% which generators are on?
0044           mpc.bus(mpc.gen(:, GEN_BUS), BUS_TYPE) ~= PQ);  %% ... and are not PQ buses
0045 gbus = mpc.gen(on, GEN_BUS);                %% what buses are they at?
0046 ngon = size(on, 1);
0047 
0048 %% build connection matrix, element i, j is 1 if gen on(i) at bus j is ON
0049 Cg = sparse((1:ngon)', gbus, ones(ngon, 1), ngon, nb);
0050 C = Cg * Cg';
0051 
0052 %% violations are based on total violation at bus, not individual violations
0053 %% (see https://github.com/MATPOWER/matpower/issues/26)
0054 v_Qmax = NaN(ng, 1);
0055 v_Qmin = v_Qmax;
0056 v_Qmax(on) = C * (mpc.gen(on, QG) - mpc.gen(on, QMAX));
0057 v_Qmin(on) = C * (mpc.gen(on, QMIN) - mpc.gen(on, QG));
0058 
0059 %% assemble event function value
0060 ef = [v_Qmax; v_Qmin];

Generated on Fri 09-Oct-2020 11:21:31 by m2html © 2005