MAKEAANG Construct constraints for branch angle difference limits. [AANG, LANG, UANG, IANG] = MAKEAANG(BASEMVA, BRANCH, NB, MPOPT) Constructs the parameters for the following linear constraint limiting the voltage angle differences across branches, where Va is the vector of bus voltage angles. NB is the number of buses. LANG <= AANG * Va <= UANG IANG is the vector of indices of branches with angle difference limits. The limits are given in the ANGMIN and ANGMAX columns of the branch matrix. Voltage angle differences are taken to be unbounded below if ANGMIN < -360 and unbounded above if ANGMAX > 360. If both ANGMIN and ANGMAX are zero, the angle difference is assumed to be unconstrained. Example: [Aang, lang, uang, iang] = makeAang(baseMVA, branch, nb, mpopt);
0001 function [Aang, lang, uang, iang] = makeAang(baseMVA, branch, nb, mpopt) 0002 %MAKEAANG Construct constraints for branch angle difference limits. 0003 % [AANG, LANG, UANG, IANG] = MAKEAANG(BASEMVA, BRANCH, NB, MPOPT) 0004 % 0005 % Constructs the parameters for the following linear constraint limiting 0006 % the voltage angle differences across branches, where Va is the vector 0007 % of bus voltage angles. NB is the number of buses. 0008 % 0009 % LANG <= AANG * Va <= UANG 0010 % 0011 % IANG is the vector of indices of branches with angle difference limits. 0012 % The limits are given in the ANGMIN and ANGMAX columns of the branch 0013 % matrix. Voltage angle differences are taken to be unbounded below if 0014 % ANGMIN < -360 and unbounded above if ANGMAX > 360. If both ANGMIN and 0015 % ANGMAX are zero, the angle difference is assumed to be unconstrained. 0016 % 0017 % Example: 0018 % [Aang, lang, uang, iang] = makeAang(baseMVA, branch, nb, mpopt); 0019 0020 % MATPOWER 0021 % Copyright (c) 1996-2015 by Power System Engineering Research Center (PSERC) 0022 % by Ray Zimmerman, PSERC Cornell 0023 % and Carlos E. Murillo-Sanchez, PSERC Cornell & Universidad Autonoma de Manizales 0024 % 0025 % $Id: makeAang.m 2644 2015-03-11 19:34:22Z ray $ 0026 % 0027 % This file is part of MATPOWER. 0028 % Covered by the 3-clause BSD License (see LICENSE file for details). 0029 % See http://www.pserc.cornell.edu/matpower/ for more info. 0030 0031 %% define named indices into data matrices 0032 [F_BUS, T_BUS, BR_R, BR_X, BR_B, RATE_A, RATE_B, RATE_C, ... 0033 TAP, SHIFT, BR_STATUS, PF, QF, PT, QT, MU_SF, MU_ST, ... 0034 ANGMIN, ANGMAX, MU_ANGMIN, MU_ANGMAX] = idx_brch; 0035 0036 if mpopt.opf.ignore_angle_lim 0037 Aang = sparse(0, nb); 0038 lang = []; 0039 uang = []; 0040 iang = []; 0041 else 0042 iang = find((branch(:, ANGMIN) & branch(:, ANGMIN) > -360) | ... 0043 (branch(:, ANGMAX) & branch(:, ANGMAX) < 360)); 0044 nang = length(iang); 0045 0046 if nang > 0 0047 ii = [(1:nang)'; (1:nang)']; 0048 jj = [branch(iang, F_BUS); branch(iang, T_BUS)]; 0049 Aang = sparse(ii, jj, [ones(nang, 1); -ones(nang, 1)], nang, nb); 0050 lang = branch(iang, ANGMIN) * pi/180; 0051 uang = branch(iang, ANGMAX) * pi/180; 0052 else 0053 Aang = sparse(0, nb); 0054 lang =[]; 0055 uang =[]; 0056 end 0057 end