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 https://matpower.org 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 ( branch(:, ANGMIN) & ~branch(:, ANGMAX)) | ... 0043 (~branch(:, ANGMIN) & branch(:, ANGMAX)) ); 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); 0051 uang = branch(iang, ANGMAX); 0052 lang(lang < -360) = -Inf; 0053 uang(uang > 360) = Inf; 0054 lang = lang * pi/180; 0055 uang = uang * pi/180; 0056 else 0057 Aang = sparse(0, nb); 0058 lang =[]; 0059 uang =[]; 0060 end 0061 end