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-2016, Power Systems Engineering Research Center (PSERC) 0022 % by Ray Zimmerman, PSERC Cornell 0023 % and Carlos E. Murillo-Sanchez, PSERC Cornell & Universidad Nacional de Colombia 0024 % 0025 % This file is part of MATPOWER. 0026 % Covered by the 3-clause BSD License (see LICENSE file for details). 0027 % See http://www.pserc.cornell.edu/matpower/ for more info. 0028 0029 %% define named indices into data matrices 0030 [F_BUS, T_BUS, BR_R, BR_X, BR_B, RATE_A, RATE_B, RATE_C, ... 0031 TAP, SHIFT, BR_STATUS, PF, QF, PT, QT, MU_SF, MU_ST, ... 0032 ANGMIN, ANGMAX, MU_ANGMIN, MU_ANGMAX] = idx_brch; 0033 0034 if mpopt.opf.ignore_angle_lim 0035 Aang = sparse(0, nb); 0036 lang = []; 0037 uang = []; 0038 iang = []; 0039 else 0040 iang = find((branch(:, ANGMIN) & branch(:, ANGMIN) > -360) | ... 0041 (branch(:, ANGMAX) & branch(:, ANGMAX) < 360)); 0042 nang = length(iang); 0043 0044 if nang > 0 0045 ii = [(1:nang)'; (1:nang)']; 0046 jj = [branch(iang, F_BUS); branch(iang, T_BUS)]; 0047 Aang = sparse(ii, jj, [ones(nang, 1); -ones(nang, 1)], nang, nb); 0048 lang = branch(iang, ANGMIN) * pi/180; 0049 uang = branch(iang, ANGMAX) * pi/180; 0050 else 0051 Aang = sparse(0, nb); 0052 lang =[]; 0053 uang =[]; 0054 end 0055 end