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

Source Code for Module pypower.t.t_totcost

 1  # Copyright (C) 2010-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 code in C{totcost}. 
18  """ 
19   
20  from numpy import array 
21   
22  from pypower.totcost import totcost 
23   
24  from pypower.t.t_begin import t_begin 
25  from pypower.t.t_is import t_is 
26  from pypower.t.t_end import t_end 
27   
28   
29 -def t_totcost(quiet=False):
30 """Tests for code in C{totcost}. 31 32 @author: Ray Zimmerman (PSERC Cornell) 33 @author: Richard Lincoln 34 """ 35 n_tests = 22 36 37 t_begin(n_tests, quiet) 38 39 ## generator cost data 40 # 1 startup shutdown n x1 y1 ... xn yn 41 # 2 startup shutdown n c(n-1) ... c0 42 gencost = array([ 43 [2, 0, 0, 3, 0.01, 0.1, 1, 0, 0, 0, 0, 0], 44 [2, 0, 0, 5, 0.0006, 0.005, 0.04, 0.3, 2, 0, 0, 0], 45 [1, 0, 0, 4, 0, 0, 10, 200, 20, 600, 30, 1200], 46 [1, 0, 0, 4, -30, -2400, -20, -1800, -10, -1000, 0, 0] 47 ]) 48 49 t = 'totcost - quadratic' 50 t_is(totcost(gencost, array([0, 0, 0, 0])), [1, 2, 0, 0], 8, t) 51 t_is(totcost(gencost, array([1, 0, 0, 0])), [1.11, 2, 0, 0], 8, t) 52 t_is(totcost(gencost, array([2, 0, 0, 0])), [1.24, 2, 0, 0], 8, t) 53 54 t = 'totcost - 4th order polynomial' 55 t_is(totcost(gencost, array([0, 0, 0, 0])), [1, 2, 0, 0], 8, t) 56 t_is(totcost(gencost, array([0, 1, 0, 0])), [1, 2.3456, 0, 0], 8, t) 57 t_is(totcost(gencost, array([0, 2, 0, 0])), [1, 2.8096, 0, 0], 8, t) 58 59 t = 'totcost - pwl (gen)' 60 t_is(totcost(gencost, array([0, 0, -10, 0 ])), [1, 2, -200, 0], 8, t) 61 t_is(totcost(gencost, array([0, 0, 5, 0 ])), [1, 2, 100, 0], 8, t) 62 t_is(totcost(gencost, array([0, 0, 10, 0])), [1, 2, 200, 0], 8, t) 63 t_is(totcost(gencost, array([0, 0, 15, 0])), [1, 2, 400, 0], 8, t) 64 t_is(totcost(gencost, array([0, 0, 20, 0])), [1, 2, 600, 0], 8, t) 65 t_is(totcost(gencost, array([0, 0, 25, 0])), [1, 2, 900, 0], 8, t) 66 t_is(totcost(gencost, array([0, 0, 30, 0])), [1, 2, 1200, 0], 8, t) 67 t_is(totcost(gencost, array([0, 0, 35, 0])), [1, 2, 1500, 0], 8, t) 68 69 t = 'totcost - pwl (load)' 70 t_is(totcost(gencost, array([0, 0, 0, 10 ])), [1, 2, 0, 1000], 8, t) 71 t_is(totcost(gencost, array([0, 0, 0, -5 ])), [1, 2, 0, -500], 8, t) 72 t_is(totcost(gencost, array([0, 0, 0, -10])), [1, 2, 0, -1000], 8, t) 73 t_is(totcost(gencost, array([0, 0, 0, -15])), [1, 2, 0, -1400], 8, t) 74 t_is(totcost(gencost, array([0, 0, 0, -20])), [1, 2, 0, -1800], 8, t) 75 t_is(totcost(gencost, array([0, 0, 0, -25])), [1, 2, 0, -2100], 8, t) 76 t_is(totcost(gencost, array([0, 0, 0, -30])), [1, 2, 0, -2400], 8, t) 77 t_is(totcost(gencost, array([0, 0, 0, -35])), [1, 2, 0, -2700], 8, t) 78 79 t_end()
80 81 82 if __name__ == '__main__': 83 t_totcost(quiet=False) 84