1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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
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