forked from MATPOWER/matpower
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcpf_vlim_event.m
43 lines (37 loc) · 1.52 KB
/
cpf_vlim_event.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
function ef = cpf_vlim_event(cb_data, cx)
%CPF_VLIM_EVENT Event function to detect bus voltage limit violations
% EF = CPF_VLIM_EVENT(CB_DATA, CX)
%
% CPF event function to detect bus voltage limits violations,
% i.e. Vm <= Vmin or Vm >= Vmax.
%
% Inputs:
% CB_DATA : struct of data for callback functions
% CX : struct containing info about current point (continuation soln)
%
% Outputs:
% EF : event function value
% MATPOWER
% Copyright (c) 2016-2017, Power Systems Engineering Research Center (PSERC)
% by Ray Zimmerman, PSERC Cornell
% and Ahmad Abubakar Sadiq, Federal University of Technology Minna, Nigeria
% and Shrirang Abhyankar, Argonne National Laboratory
%
% This file is part of MATPOWER.
% Covered by the 3-clause BSD License (see LICENSE file for details).
% See http://www.pserc.cornell.edu/matpower/ for more info.
%% event function value is 2 nb x 1 vector equal to:
%% [ Vmin - Vm ]
%% [ Vm - Vmax ]
%% define named indices into bus, gen, branch matrices
[PQ, PV, REF, NONE, BUS_I, BUS_TYPE, PD, QD, GS, BS, BUS_AREA, VM, ...
VA, BASE_KV, ZONE, VMAX, VMIN, LAM_P, LAM_Q, MU_VMAX, MU_VMIN] = idx_bus;
%% get updated MPC
d = cb_data;
mpc = cpf_current_mpc(d.mpc_base, d.mpc_target, ...
d.Ybus, d.Yf, d.Yt, d.ref, d.pv, d.pq, cx.V, cx.lam, d.mpopt);
%% voltage magnitude violations
v_Vmin = mpc.bus(:, VMIN) - mpc.bus(:, VM);
v_Vmax = mpc.bus(:, VM) - mpc.bus(:, VMAX);
%% assemble event function value
ef = [v_Vmin;v_Vmax];