1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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
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