e2nIEE / pandapower
 1 ```# Copyright (c) 1996-2015 PSERC. All rights reserved. ``` 2 ```# Use of this source code is governed by a BSD-style ``` 3 ```# license that can be found in the LICENSE file. ``` 4 5 1 ```"""Construct constraints for branch angle difference limits. ``` 6 ```""" ``` 7 8 1 ```from numpy import array, ones, zeros, r_, Inf, pi, arange ``` 9 1 ```from numpy import flatnonzero as find ``` 10 1 ```from scipy.sparse import csr_matrix as sparse ``` 11 12 1 ```from pandapower.pypower.idx_brch import F_BUS, T_BUS, ANGMIN, ANGMAX ``` 13 14 15 1 ```def makeAang(baseMVA, branch, nb, ppopt): ``` 16 ``` """Construct constraints for branch angle difference limits. ``` 17 18 ``` Constructs the parameters for the following linear constraint limiting ``` 19 ``` the voltage angle differences across branches, where C{Va} is the vector ``` 20 ``` of bus voltage angles. C{nb} is the number of buses:: ``` 21 22 ``` lang <= Aang * Va <= uang ``` 23 24 ``` C{iang} is the vector of indices of branches with angle difference limits. ``` 25 26 ``` @author: Ray Zimmerman (PSERC Cornell) ``` 27 ``` @author: Carlos E. Murillo-Sanchez (PSERC Cornell & Universidad ``` 28 ``` Autonoma de Manizales) ``` 29 ``` """ ``` 30 ``` ## options ``` 31 1 ``` ignore_ang_lim = ppopt['OPF_IGNORE_ANG_LIM'] ``` 32 33 1 ``` if ignore_ang_lim: ``` 34 0 ``` Aang = zeros((0, nb)) ``` 35 0 ``` lang = array([]) ``` 36 0 ``` uang = array([]) ``` 37 0 ``` iang = array([]) ``` 38 ``` else: ``` 39 1 ``` iang = find(((branch[:, ANGMIN] != 0) & (branch[:, ANGMIN] > -360)) | ``` 40 ``` ((branch[:, ANGMAX] != 0) & (branch[:, ANGMAX] < 360))) ``` 41 1 ``` iangl = find(branch[iang, ANGMIN]) ``` 42 1 ``` iangh = find(branch[iang, ANGMAX]) ``` 43 1 ``` nang = len(iang) ``` 44 45 1 ``` if nang > 0: ``` 46 0 ``` ii = r_[arange(nang), arange(nang)] ``` 47 0 ``` jj = r_[branch[iang, F_BUS], branch[iang, T_BUS]] ``` 48 0 ``` Aang = sparse((r_[ones(nang), -ones(nang)], ``` 49 ``` (ii, jj)), (nang, nb)) ``` 50 0 ``` uang = Inf * ones(nang) ``` 51 0 ``` lang = -uang ``` 52 0 ``` lang[iangl] = branch[iang[iangl], ANGMIN] * pi / 180 ``` 53 0 ``` uang[iangh] = branch[iang[iangh], ANGMAX] * pi / 180 ``` 54 ``` else: ``` 55 1 ``` Aang = zeros((0, nb)) ``` 56 1 ``` lang = array([]) ``` 57 1 ``` uang = array([]) ``` 58 59 1 ``` return Aang, lang, uang, iang ```

Read our documentation on viewing source code .