Home > matpower7.0 > lib > cpf_flim_event_cb.m

cpf_flim_event_cb

PURPOSE ^

CPF_FLIM_EVENT_CB Callback to handle FLIM events

SYNOPSIS ^

function [nx, cx, done, rollback, evnts, cb_data, results] = cpf_flim_event_cb(k, nx, cx, px, done, rollback, evnts, cb_data, cb_args, results)

DESCRIPTION ^

CPF_FLIM_EVENT_CB  Callback to handle FLIM events
   [NX, CX, DONE, ROLLBACK, EVNTS, CB_DATA, RESULTS] =
       CPF_NOSE_EVENT_CB(K, NX, CX, PX, DONE, ROLLBACK, EVNTS, ...
                               CB_DATA, CB_ARGS, RESULTS)

   Callback to handle FLIM (branch flow limit violation) events,
   triggered by event function CPF_FLIM_EVENT to indicate the point at which
   a branch flow limit is reached.

   All branch flows are expected to be within limits for the base case,
   otherwise the continuation terminates.

   This function sets the msg field of the event when the flow in any branch
   reaches its limit, raises the DONE.flag and sets the DONE.msg.

   See CPF_DEFAULT_CALLBACK for details of the input and output arguments.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [nx, cx, done, rollback, evnts, cb_data, results] = cpf_flim_event_cb(...
0002         k, nx, cx, px, done, rollback, evnts, cb_data, cb_args, results)
0003 %CPF_FLIM_EVENT_CB  Callback to handle FLIM events
0004 %   [NX, CX, DONE, ROLLBACK, EVNTS, CB_DATA, RESULTS] =
0005 %       CPF_NOSE_EVENT_CB(K, NX, CX, PX, DONE, ROLLBACK, EVNTS, ...
0006 %                               CB_DATA, CB_ARGS, RESULTS)
0007 %
0008 %   Callback to handle FLIM (branch flow limit violation) events,
0009 %   triggered by event function CPF_FLIM_EVENT to indicate the point at which
0010 %   a branch flow limit is reached.
0011 %
0012 %   All branch flows are expected to be within limits for the base case,
0013 %   otherwise the continuation terminates.
0014 %
0015 %   This function sets the msg field of the event when the flow in any branch
0016 %   reaches its limit, raises the DONE.flag and sets the DONE.msg.
0017 %
0018 %   See CPF_DEFAULT_CALLBACK for details of the input and output arguments.
0019 
0020 %   MATPOWER
0021 %   Copyright (c) 2016-2017, Power Systems Engineering Research Center (PSERC)
0022 %   by Ray Zimmerman, PSERC Cornell
0023 %   and Ahmad Abubakar Sadiq, Federal University of Technology Minna, Nigeria
0024 %   and Shrirang Abhyankar, Argonne National Laboratory
0025 %
0026 %   This file is part of MATPOWER.
0027 %   Covered by the 3-clause BSD License (see LICENSE file for details).
0028 %   See https://matpower.org for more info.
0029 
0030 %% define named indices into bus, gen, branch matrices
0031 [PQ, PV, REF, NONE, BUS_I, BUS_TYPE, PD, QD, GS, BS, BUS_AREA, VM, ...
0032     VA, BASE_KV, ZONE, VMAX, VMIN, LAM_P, LAM_Q, MU_VMAX, MU_VMIN] = idx_bus;
0033 [F_BUS, T_BUS, BR_R, BR_X, BR_B, RATE_A, RATE_B, RATE_C, ...
0034     TAP, SHIFT, BR_STATUS, PF, QF, PT, QT, MU_SF, MU_ST, ...
0035     ANGMIN, ANGMAX, MU_ANGMIN, MU_ANGMAX] = idx_brch;
0036 
0037 %% base case data
0038 mpc = cb_data.mpc_base;
0039 nb = size(mpc.bus, 1);
0040 i2e_bus = mpc.order.bus.i2e;
0041 f = mpc.branch(:, F_BUS);
0042 t = mpc.branch(:, T_BUS);
0043 SrateA = mpc.branch(:,RATE_A);
0044 
0045 %% initialize
0046 if k == 0
0047     %% compute MVA flows
0048     Sf = sqrt((mpc.branch(:, PF)).^2 + (mpc.branch(:, QF)).^2);
0049     St = sqrt((mpc.branch(:, PT)).^2 + (mpc.branch(:, QT)).^2);
0050 
0051     %% check initial lines power flows exceed RATE_A limits
0052     if any(max(Sf,St) > SrateA)
0053         done.flag = 1;  %% prepare to terminate
0054         
0055         %% find the lines and which lim(s)
0056         iL = find(max(Sf,St) > SrateA);
0057         for j = 1:length(iL)
0058             L = iL(j);
0059             msg = sprintf('branch flow limit violated in base case: branch %d -- %d exceeds limit of %g MVA\n',...
0060                 i2e_bus(f(L)), i2e_bus(t(L)), SrateA(L));
0061             
0062             %% prepare to terminate
0063             done.flag = 1;
0064             done.msg = msg;
0065         end
0066     end
0067 end
0068 
0069 %% skip if finalize or done
0070 if k < 0 || done.flag
0071     return;
0072 end
0073 
0074 %% handle event
0075 for i = 1:length(evnts)
0076     if strcmp(evnts(i).name, 'FLIM') && evnts(i).zero
0077         if cb_data.mpopt.verbose > 3
0078             msg = sprintf('%s\n    ', evnts(i).msg);
0079         else
0080             msg = '';
0081         end
0082         
0083         %% find the lines and which lim(s)
0084         iL = evnts(i).idx;
0085         for j = 1:length(iL)
0086             L = iL(j);      %% index of critical branch event of interest
0087             msg = sprintf('%sbranch flow limit reached\nbranch %d -- %d at limit of %g MVA @ lambda = %.4g, in %d continuation steps',...
0088                 msg, i2e_bus(f(L)), i2e_bus(t(L)), SrateA(L), nx.lam, k);
0089         end
0090         
0091         %% prepare to terminate
0092         done.flag = 1;
0093         done.msg = msg;
0094     end
0095 end

Generated on Mon 24-Jun-2019 15:58:45 by m2html © 2005