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

Source Code for Module pypower.makeLODF

 1  # Copyright (C) 2008-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  """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   
26 -def makeLODF(branch, PTDF):
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