Package pypower :: Package t :: Module t_makeLODF
[hide private]
[frames] | no frames]

Source Code for Module pypower.t.t_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  """Tests for C{makeLODF}. 
18  """ 
19   
20  from os.path import dirname, join 
21   
22  from numpy import arange, r_ 
23   
24  from pypower.loadcase import loadcase 
25  from pypower.ppoption import ppoption 
26  from pypower.rundcopf import rundcopf 
27  from pypower.ext2int import ext2int1 
28  from pypower.makePTDF import makePTDF 
29  from pypower.makeLODF import makeLODF 
30  from pypower.rundcpf import rundcpf 
31   
32  from pypower.idx_brch import BR_STATUS, PF 
33   
34  from pypower.t.t_begin import t_begin 
35  from pypower.t.t_is import t_is 
36  from pypower.t.t_end import t_end 
37   
38   
39 -def t_makeLODF(quiet=False):
40 """Tests for C{makeLODF}. 41 42 @author: Ray Zimmerman (PSERC Cornell) 43 @author: Richard Lincoln 44 """ 45 ntests = 31 46 t_begin(ntests, quiet) 47 48 tdir = dirname(__file__) 49 casefile = join(tdir, 't_auction_case') 50 verbose = 0#not quiet 51 52 ## load case 53 ppc = loadcase(casefile) 54 ppopt = ppoption(VERBOSE=verbose, OUT_ALL=0) 55 r = rundcopf(ppc, ppopt) 56 baseMVA, bus, gen, branch = r['baseMVA'], r['bus'], r['gen'], r['branch'] 57 _, bus, gen, branch = ext2int1(bus, gen, branch) 58 59 ## compute injections and flows 60 F0 = branch[:, PF] 61 62 ## create some PTDF matrices 63 H = makePTDF(baseMVA, bus, branch, 0) 64 65 ## create some PTDF matrices 66 try: 67 LODF = makeLODF(branch, H) 68 except ZeroDivisionError: 69 pass 70 71 ## take out non-essential lines one-by-one and see what happens 72 ppc['bus'] = bus 73 ppc['gen'] = gen 74 branch0 = branch 75 outages = r_[arange(12), arange(13, 15), arange(16, 18), 76 [19], arange(26, 33), arange(34, 41)] 77 for k in outages: 78 ppc['branch'] = branch0.copy() 79 ppc['branch'][k, BR_STATUS] = 0 80 r, _ = rundcpf(ppc, ppopt) 81 baseMVA, bus, gen, branch = \ 82 r['baseMVA'], r['bus'], r['gen'], r['branch'] 83 F = branch[:, PF] 84 85 t_is(LODF[:, k], (F - F0) / F0[k], 6, 'LODF[:, %d]' % k) 86 87 t_end()
88 89 90 if __name__ == '__main__': 91 t_makeLODF(quiet=False) 92