forked from PyPSA/PyPSA
-
Notifications
You must be signed in to change notification settings - Fork 1
/
unit-commitment.py
241 lines (155 loc) · 4.25 KB
/
unit-commitment.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
## Demonstrate PyPSA unit commitment with a one-bus two-generator example
#
#
#To enable unit commitment on a generator, set its attribute committable = True.
#
#
#Available as a Jupyter notebook at http://www.pypsa.org/examples/unit-commitment.ipynb.
import pypsa
### Minimum part load demonstration
#
#In final hour load goes below part-load limit of coal gen (30%), forcing gas to commit.
nu = pypsa.Network()
nu.set_snapshots(range(4))
nu.add("Bus","bus")
nu.add("Generator","coal",bus="bus",
committable=True,
p_min_pu=0.3,
marginal_cost=20,
p_nom=10000)
nu.add("Generator","gas",bus="bus",
committable=True,
marginal_cost=70,
p_min_pu=0.1,
p_nom=1000)
nu.add("Load","load",bus="bus",p_set=[4000,6000,5000,800])
nu.lopf(nu.snapshots)
nu.generators_t.status
nu.generators_t.p
### Minimum up time demonstration
#
#Gas has minimum up time, forcing it to be online longer
nu = pypsa.Network()
nu.set_snapshots(range(4))
nu.add("Bus","bus")
nu.add("Generator","coal",bus="bus",
committable=True,
p_min_pu=0.3,
marginal_cost=20,
p_nom=10000)
nu.add("Generator","gas",bus="bus",
committable=True,
marginal_cost=70,
p_min_pu=0.1,
initial_status=0,
min_up_time=3,
p_nom=1000)
nu.add("Load","load",bus="bus",p_set=[4000,800,5000,3000])
nu.lopf(nu.snapshots)
nu.generators_t.status
nu.generators_t.p
### Minimum down time demonstration
#
#Coal has a minimum down time, forcing it to go off longer.
nu = pypsa.Network()
nu.set_snapshots(range(4))
nu.add("Bus","bus")
nu.add("Generator","coal",bus="bus",
committable=True,
p_min_pu=0.3,
marginal_cost=20,
min_down_time=2,
p_nom=10000)
nu.add("Generator","gas",bus="bus",
committable=True,
marginal_cost=70,
p_min_pu=0.1,
initial_status=0,
p_nom=4000)
nu.add("Load","load",bus="bus",p_set=[3000,800,3000,8000])
nu.lopf(nu.snapshots)
nu.objective
nu.generators_t.status
nu.generators_t.p
### Start up and shut down costs
#
#Now there are associated costs for shutting down, etc
nu = pypsa.Network()
nu.set_snapshots(range(4))
nu.add("Bus","bus")
nu.add("Generator","coal",bus="bus",
committable=True,
p_min_pu=0.3,
marginal_cost=20,
min_down_time=2,
start_up_cost=5000,
p_nom=10000)
nu.add("Generator","gas",bus="bus",
committable=True,
marginal_cost=70,
p_min_pu=0.1,
initial_status=0,
shut_down_cost=25,
p_nom=4000)
nu.add("Load","load",bus="bus",p_set=[3000,800,3000,8000])
nu.lopf(nu.snapshots)
nu.objective
nu.generators_t.status
nu.generators_t.p
## Ramp rate limits
import pypsa
nu = pypsa.Network()
nu.set_snapshots(range(6))
nu.add("Bus","bus")
nu.add("Generator","coal",bus="bus",
marginal_cost=20,
ramp_limit_up=0.1,
ramp_limit_down=0.2,
p_nom=10000)
nu.add("Generator","gas",bus="bus",
marginal_cost=70,
p_nom=4000)
nu.add("Load","load",bus="bus",p_set=[4000,7000,7000,7000,7000,3000])
nu.lopf(nu.snapshots)
nu.generators_t.p
import pypsa
nu = pypsa.Network()
nu.set_snapshots(range(6))
nu.add("Bus","bus")
nu.add("Generator","coal",bus="bus",
marginal_cost=20,
ramp_limit_up=0.1,
ramp_limit_down=0.2,
p_nom_extendable=True,
capital_cost=1e2)
nu.add("Generator","gas",bus="bus",
marginal_cost=70,
p_nom=4000)
nu.add("Load","load",bus="bus",p_set=[4000,7000,7000,7000,7000,3000])
nu.lopf(nu.snapshots)
nu.generators.p_nom_opt
nu.generators_t.p
import pypsa
nu = pypsa.Network()
nu.set_snapshots(range(7))
nu.add("Bus","bus")
#Can get bad interactions if SU > RU and p_min_pu; similarly if SD > RD
nu.add("Generator","coal",bus="bus",
marginal_cost=20,
committable=True,
p_min_pu=0.05,
initial_status=0,
ramp_limit_start_up=0.1,
ramp_limit_up=0.2,
ramp_limit_down=0.25,
ramp_limit_shut_down=0.15,
p_nom=10000.)
nu.add("Generator","gas",bus="bus",
marginal_cost=70,
p_nom=10000)
nu.add("Load","load",bus="bus",p_set=[0.,200.,7000,7000,7000,2000,0])
nu.lopf(nu.snapshots)
nu.generators_t.p
nu.generators_t.status
nu.generators.initial_status
nu.generators.loc["coal"]