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

Source Code for Module pypower.runopf_w_res

 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  """Runs an optimal power flow with fixed zonal reserves. 
18  """ 
19   
20  from pypower.loadcase import loadcase 
21  from pypower.toggle_reserves import toggle_reserves 
22  from pypower.runopf import runopf 
23   
24   
25 -def runopf_w_res(*args):
26 """Runs an optimal power flow with fixed zonal reserves. 27 28 Runs an optimal power flow with the addition of reserve requirements 29 specified as a set of fixed zonal reserves. See L{runopf} for a 30 description of the input and output arguments, which are the same, 31 with the exception that the case file or dict C{casedata} must define 32 a 'reserves' field, which is a dict with the following fields: 33 - C{zones} C{nrz x ng}, C{zone(i, j) = 1}, if gen C{j} belongs 34 to zone C{i} 0, otherwise 35 - C{req} C{nrz x 1}, zonal reserve requirement in MW 36 - C{cost} (C{ng} or C{ngr}) C{x 1}, cost of reserves in $/MW 37 - C{qty} (C{ng} or C{ngr}) C{x 1}, max quantity of reserves 38 in MW (optional) 39 where C{nrz} is the number of reserve zones and C{ngr} is the number of 40 generators belonging to at least one reserve zone and C{ng} is the total 41 number of generators. 42 43 In addition to the normal OPF output, the C{results} dict contains a 44 new 'reserves' field with the following fields, in addition to those 45 provided in the input: 46 - C{R} - C{ng x 1}, reserves provided by each gen in MW 47 - C{Rmin} - C{ng x 1}, lower limit on reserves provided by 48 each gen, (MW) 49 - C{Rmax} - C{ng x 1}, upper limit on reserves provided by 50 each gen, (MW) 51 - C{mu.l} - C{ng x 1}, shadow price on reserve lower limit, ($/MW) 52 - C{mu.u} - C{ng x 1}, shadow price on reserve upper limit, ($/MW) 53 - C{mu.Pmax} - C{ng x 1}, shadow price on C{Pg + R <= Pmax} 54 constraint, ($/MW) 55 - C{prc} - C{ng x 1}, reserve price for each gen equal to 56 maximum of the shadow prices on the zonal requirement constraint 57 for each zone the generator belongs to 58 59 See L{t.t_case30_userfcns} for an example case file with fixed reserves, 60 and L{toggle_reserves} for the implementation. 61 62 Calling syntax options:: 63 results = runopf_w_res(casedata) 64 results = runopf_w_res(casedata, ppopt) 65 results = runopf_w_res(casedata, ppopt, fname) 66 results = runopf_w_res(casedata, [popt, fname, solvedcase) 67 results, success = runopf_w_res(...) 68 69 Example:: 70 results = runopf_w_res('t_case30_userfcns') 71 72 @see: L{runopf}, L{toggle_reserves}, L{t.t_case30_userfcns} 73 74 @author: Ray Zimmerman (PSERC Cornell) 75 @author: Richard Lincoln 76 """ 77 ppc = loadcase(args[0]) 78 ppc = toggle_reserves(ppc, 'on') 79 80 r = runopf(ppc, *args[1:]) 81 r = toggle_reserves(r, 'off') 82 83 return r
84