1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 """Builds the line outage distribution factor matrix.
18 """
19
20 from numpy import ones, diag, eye, r_, arange
21 from scipy.sparse import csr_matrix as sparse
22
23 from idx_brch import F_BUS, T_BUS
24
25
27 """Builds the line outage distribution factor matrix.
28
29 Returns the DC line outage distribution factor matrix for a given PTDF.
30 The matrix is C{nbr x nbr}, where C{nbr} is the number of branches.
31
32 Example::
33 H = makePTDF(baseMVA, bus, branch)
34 LODF = makeLODF(branch, H)
35
36 @see: L{makePTDF}
37
38 @author: Ray Zimmerman (PSERC Cornell)
39 @author: Richard Lincoln
40 """
41 nl, nb = PTDF.shape
42 f = branch[:, F_BUS]
43 t = branch[:, T_BUS]
44 Cft = sparse((r_[ones(nl), -ones(nl)],
45 (r_[f, t], r_[arange(nl), arange(nl)])), (nb, nl))
46
47 H = PTDF * Cft
48 h = diag(H, 0)
49 LODF = H / (ones((nl, nl)) - ones((nl, 1)) * h.T)
50 LODF = LODF - diag(diag(LODF)) - eye(nl, nl)
51
52 return LODF
53