CPF_QLIM_EVENT Event function to detect the generator reactive power limits EF = CPF_QLIM_EVENT(CB_DATA, CX) CPF event function to detect a generator reactive power limits, 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
0001 function ef = cpf_qlim_event(cb_data, cx) 0002 %CPF_QLIM_EVENT Event function to detect the generator reactive power limits 0003 % EF = CPF_QLIM_EVENT(CB_DATA, CX) 0004 % 0005 % CPF event function to detect a generator reactive power limits, 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 http://www.pserc.cornell.edu/matpower/ 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 ng = size(mpc.gen, 1); 0042 v_Qmax = NaN(ng, 1); 0043 v_Qmin = v_Qmax; 0044 on = find(mpc.gen(:, GEN_STATUS) > 0 & ... %% which generators are on? 0045 mpc.bus(mpc.gen(:, GEN_BUS), BUS_TYPE) ~= PQ); %% ... and are not PQ buses 0046 v_Qmax(on) = mpc.gen(on, QG) - mpc.gen(on, QMAX); 0047 v_Qmin(on) = mpc.gen(on, QMIN) - mpc.gen(on, QG); 0048 0049 %% assemble event function value 0050 ef = [v_Qmax; v_Qmin];