Package pypower :: Module makeAang
[hide private]
[frames] | no frames]

Source Code for Module pypower.makeAang

 1  # Copyright (C) 1996-2011 Power System Engineering Research Center (PSERC) 
 2  # Copyright (C) 2011 Richard Lincoln 
 3  # 
 4  # PYPOWER is free software: you can redistribute it and/or modify 
 5  # it under the terms of the GNU General Public License as published 
 6  # by the Free Software Foundation, either version 3 of the License, 
 7  # or (at your option) any later version. 
 8  # 
 9  # PYPOWER is distributed in the hope that it will be useful, 
10  # but WITHOUT ANY WARRANTY; without even the implied warranty of 
11  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
12  # GNU General Public License for more details. 
13  # 
14  # You should have received a copy of the GNU General Public License 
15  # along with PYPOWER. If not, see <http://www.gnu.org/licenses/>. 
16   
17  """Construct constraints for branch angle difference limits. 
18  """ 
19   
20  from numpy import array, ones, zeros, r_, Inf, pi, arange 
21  from numpy import flatnonzero as find 
22  from scipy.sparse import csr_matrix as sparse 
23   
24  from idx_brch import F_BUS, T_BUS, ANGMIN, ANGMAX 
25   
26   
27 -def makeAang(baseMVA, branch, nb, ppopt):
28 """Construct constraints for branch angle difference limits. 29 30 Constructs the parameters for the following linear constraint limiting 31 the voltage angle differences across branches, where C{Va} is the vector 32 of bus voltage angles. C{nb} is the number of buses:: 33 34 lang <= Aang * Va <= uang 35 36 C{iang} is the vector of indices of branches with angle difference limits. 37 38 @author: Ray Zimmerman (PSERC Cornell) 39 @author: Carlos E. Murillo-Sanchez (PSERC Cornell & Universidad 40 Autonoma de Manizales) 41 @author: Richard Lincoln 42 """ 43 ## options 44 ignore_ang_lim = ppopt['OPF_IGNORE_ANG_LIM'] 45 46 if ignore_ang_lim: 47 Aang = zeros((0, nb)) 48 lang = array([]) 49 uang = array([]) 50 iang = array([]) 51 else: 52 iang = find(((branch[:, ANGMIN] != 0) & (branch[:, ANGMIN] > -360)) | 53 ((branch[:, ANGMAX] != 0) & (branch[:, ANGMAX] < 360))) 54 iangl = find(branch[iang, ANGMIN]) 55 iangh = find(branch[iang, ANGMAX]) 56 nang = len(iang) 57 58 if nang > 0: 59 ii = r_[arange(nang), arange(nang)] 60 jj = r_[branch[iang, F_BUS], branch[iang, T_BUS]] 61 Aang = sparse((r_[ones(nang), -ones(nang)], 62 (ii, jj)), (nang, nb)) 63 uang = Inf * ones(nang) 64 lang = -uang 65 lang[iangl] = branch[iang[iangl], ANGMIN] * pi / 180 66 uang[iangh] = branch[iang[iangh], ANGMAX] * pi / 180 67 else: 68 Aang = zeros((0, nb)) 69 lang = array([]) 70 uang = array([]) 71 72 return Aang, lang, uang, iang
73