Conditions | 5 |
Total Lines | 329 |
Code Lines | 214 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | """The module containing all parameters for the scenario table |
||
129 | def electricity(scenario): |
||
130 | """Returns paramaters of the electricity sector for the selected scenario. |
||
131 | |||
132 | Parameters |
||
133 | ---------- |
||
134 | scenario : str |
||
135 | Name of the scenario. |
||
136 | |||
137 | Returns |
||
138 | ------- |
||
139 | parameters : dict |
||
140 | List of parameters of electricity sector |
||
141 | |||
142 | """ |
||
143 | |||
144 | if scenario == "eGon2035": |
||
145 | |||
146 | costs = read_csv(2035) |
||
147 | |||
148 | parameters = {"grid_topology": "Status Quo"} |
||
149 | # Insert effciencies in p.u. |
||
150 | parameters["efficiency"] = { |
||
151 | "oil": read_costs(costs, "oil", "efficiency"), |
||
152 | "battery": { |
||
153 | "store": read_costs(costs, "battery inverter", "efficiency") |
||
154 | ** 0.5, |
||
155 | "dispatch": read_costs(costs, "battery inverter", "efficiency") |
||
156 | ** 0.5, |
||
157 | "standing_loss": 0, |
||
158 | "max_hours": 6, |
||
159 | }, |
||
160 | "pumped_hydro": { |
||
161 | "store": read_costs(costs, "PHS", "efficiency") ** 0.5, |
||
162 | "dispatch": read_costs(costs, "PHS", "efficiency") ** 0.5, |
||
163 | "standing_loss": 0, |
||
164 | "max_hours": 6, |
||
165 | }, |
||
166 | } |
||
167 | # Warning: Electrical parameters are set in osmTGmod, editing these values will not change the data! |
||
168 | parameters["electrical_parameters"] = { |
||
169 | "ac_line_110kV": { |
||
170 | "s_nom": 260, # [MVA] |
||
171 | "R": 0.109, # [Ohm/km] |
||
172 | "L": 1.2, # [mH/km] |
||
173 | }, |
||
174 | "ac_cable_110kV": { |
||
175 | "s_nom": 280, # [MVA] |
||
176 | "R": 0.0177, # [Ohm/km] |
||
177 | "L": 0.3, # [mH/km] |
||
178 | }, |
||
179 | "ac_line_220kV": { |
||
180 | "s_nom": 520, # [MVA] |
||
181 | "R": 0.109, # [Ohm/km] |
||
182 | "L": 1.0, # [mH/km] |
||
183 | }, |
||
184 | "ac_cable_220kV": { |
||
185 | "s_nom": 550, # [MVA] |
||
186 | "R": 0.0176, # [Ohm/km] |
||
187 | "L": 0.3, # [mH/km] |
||
188 | }, |
||
189 | "ac_line_380kV": { |
||
190 | "s_nom": 1790, # [MVA] |
||
191 | "R": 0.028, # [Ohm/km] |
||
192 | "L": 0.8, # [mH/km] |
||
193 | }, |
||
194 | "ac_cable_380kV": { |
||
195 | "s_nom": 925, # [MVA] |
||
196 | "R": 0.0175, # [Ohm/km] |
||
197 | "L": 0.3, # [mH/km] |
||
198 | }, |
||
199 | } |
||
200 | |||
201 | # Insert overnight investment costs |
||
202 | # Source for eHV grid costs: Netzentwicklungsplan Strom 2035, Version 2021, 2. Entwurf |
||
203 | # Source for HV lines and cables: Dena Verteilnetzstudie 2021, p. 146 |
||
204 | parameters["overnight_cost"] = { |
||
205 | "ac_ehv_overhead_line": 2.5e6 |
||
206 | / ( |
||
207 | 2 |
||
208 | * parameters["electrical_parameters"]["ac_line_380kV"]["s_nom"] |
||
209 | ), # [EUR/km/MW] |
||
210 | "ac_ehv_cable": 11.5e6 |
||
211 | / ( |
||
212 | 2 |
||
213 | * parameters["electrical_parameters"]["ac_cable_380kV"][ |
||
214 | "s_nom" |
||
215 | ] |
||
216 | ), # [EUR/km/MW] |
||
217 | "ac_hv_overhead_line": 0.06e6 |
||
218 | / parameters["electrical_parameters"]["ac_line_110kV"][ |
||
219 | "s_nom" |
||
220 | ], # [EUR/km/MW] |
||
221 | "ac_hv_cable": 0.8e6 |
||
222 | / parameters["electrical_parameters"]["ac_cable_110kV"][ |
||
223 | "s_nom" |
||
224 | ], # [EUR/km/MW] |
||
225 | "dc_overhead_line": 0.5e3, # [EUR/km/MW] |
||
226 | "dc_cable": 3.25e3, # [EUR/km/MW] |
||
227 | "dc_inverter": 0.3e6, # [EUR/MW] |
||
228 | "transformer_380_110": 17.33e3, # [EUR/MVA] |
||
229 | "transformer_380_220": 13.33e3, # [EUR/MVA] |
||
230 | "transformer_220_110": 17.5e3, # [EUR/MVA] |
||
231 | "battery inverter": read_costs( |
||
232 | costs, "battery inverter", "investment" |
||
233 | ), |
||
234 | "battery storage": read_costs( |
||
235 | costs, "battery storage", "investment" |
||
236 | ), |
||
237 | } |
||
238 | |||
239 | parameters["lifetime"] = { |
||
240 | "ac_ehv_overhead_line": read_costs( |
||
241 | costs, "HVAC overhead", "lifetime" |
||
242 | ), |
||
243 | "ac_ehv_cable": read_costs(costs, "HVAC overhead", "lifetime"), |
||
244 | "ac_hv_overhead_line": read_costs( |
||
245 | costs, "HVAC overhead", "lifetime" |
||
246 | ), |
||
247 | "ac_hv_cable": read_costs(costs, "HVAC overhead", "lifetime"), |
||
248 | "dc_overhead_line": read_costs(costs, "HVDC overhead", "lifetime"), |
||
249 | "dc_cable": read_costs(costs, "HVDC overhead", "lifetime"), |
||
250 | "dc_inverter": read_costs(costs, "HVDC inverter pair", "lifetime"), |
||
251 | "transformer_380_110": read_costs( |
||
252 | costs, "HVAC overhead", "lifetime" |
||
253 | ), |
||
254 | "transformer_380_220": read_costs( |
||
255 | costs, "HVAC overhead", "lifetime" |
||
256 | ), |
||
257 | "transformer_220_110": read_costs( |
||
258 | costs, "HVAC overhead", "lifetime" |
||
259 | ), |
||
260 | "battery inverter": read_costs( |
||
261 | costs, "battery inverter", "lifetime" |
||
262 | ), |
||
263 | "battery storage": read_costs( |
||
264 | costs, "battery storage", "lifetime" |
||
265 | ), |
||
266 | } |
||
267 | # Insert annualized capital costs |
||
268 | # lines in EUR/km/MW/a |
||
269 | # transfermer, inverter, battery in EUR/MW/a |
||
270 | parameters["capital_cost"] = {} |
||
271 | |||
272 | for comp in parameters["overnight_cost"].keys(): |
||
273 | parameters["capital_cost"][comp] = annualize_capital_costs( |
||
274 | parameters["overnight_cost"][comp], |
||
275 | parameters["lifetime"][comp], |
||
276 | global_settings("eGon2035")["interest_rate"], |
||
277 | ) |
||
278 | |||
279 | parameters["capital_cost"]["battery"] = ( |
||
280 | parameters["capital_cost"]["battery inverter"] |
||
281 | + parameters["efficiency"]["battery"]["max_hours"] |
||
282 | * parameters["capital_cost"]["battery storage"] |
||
283 | ) |
||
284 | |||
285 | # Insert marginal_costs in EUR/MWh |
||
286 | # marginal cost can include fuel, C02 and operation and maintenance costs |
||
287 | parameters["marginal_cost"] = { |
||
288 | "oil": global_settings(scenario)["fuel_costs"]["oil"] |
||
289 | + read_costs(costs, "oil", "VOM") |
||
290 | + global_settings(scenario)["co2_costs"] |
||
291 | * global_settings(scenario)["co2_emissions"]["oil"], |
||
292 | "other_non_renewable": global_settings(scenario)["fuel_costs"][ |
||
293 | "gas" |
||
294 | ] |
||
295 | + global_settings(scenario)["co2_costs"] |
||
296 | * global_settings(scenario)["co2_emissions"][ |
||
297 | "other_non_renewable" |
||
298 | ], |
||
299 | "lignite": global_settings(scenario)["fuel_costs"]["lignite"] |
||
300 | + read_costs(costs, "lignite", "VOM") |
||
301 | + global_settings(scenario)["co2_costs"] |
||
302 | * global_settings(scenario)["co2_emissions"]["lignite"], |
||
303 | "biomass": global_settings(scenario)["fuel_costs"]["biomass"] |
||
304 | + read_costs(costs, "biomass CHP", "VOM"), |
||
305 | "wind_offshore": read_costs(costs, "offwind", "VOM"), |
||
306 | "wind_onshore": read_costs(costs, "onwind", "VOM"), |
||
307 | "solar": read_costs(costs, "solar", "VOM"), |
||
308 | } |
||
309 | |||
310 | elif scenario == "eGon100RE": |
||
311 | |||
312 | costs = read_csv(2050) |
||
313 | |||
314 | parameters = {"grid_topology": "Status Quo"} |
||
315 | |||
316 | # Insert effciencies in p.u. |
||
317 | parameters["efficiency"] = { |
||
318 | "battery": { |
||
319 | "store": read_costs(costs, "battery inverter", "efficiency") |
||
320 | ** 0.5, |
||
321 | "dispatch": read_costs(costs, "battery inverter", "efficiency") |
||
322 | ** 0.5, |
||
323 | "standing_loss": 0, |
||
324 | "max_hours": 6, |
||
325 | }, |
||
326 | "pumped_hydro": { |
||
327 | "store": read_costs(costs, "PHS", "efficiency") ** 0.5, |
||
328 | "dispatch": read_costs(costs, "PHS", "efficiency") ** 0.5, |
||
329 | "standing_loss": 0, |
||
330 | "max_hours": 6, |
||
331 | }, |
||
332 | } |
||
333 | # Warning: Electrical parameters are set in osmTGmod, editing these values will not change the data! |
||
334 | parameters["electrical_parameters"] = { |
||
335 | "ac_line_110kV": { |
||
336 | "s_nom": 260, # [MVA] |
||
337 | "R": 0.109, # [Ohm/km] |
||
338 | "L": 1.2, # [mH/km] |
||
339 | }, |
||
340 | "ac_cable_110kV": { |
||
341 | "s_nom": 280, # [MVA] |
||
342 | "R": 0.0177, # [Ohm/km] |
||
343 | "L": 0.3, # [mH/km] |
||
344 | }, |
||
345 | "ac_line_220kV": { |
||
346 | "s_nom": 520, # [MVA] |
||
347 | "R": 0.109, # [Ohm/km] |
||
348 | "L": 1.0, # [mH/km] |
||
349 | }, |
||
350 | "ac_cable_220kV": { |
||
351 | "s_nom": 550, # [MVA] |
||
352 | "R": 0.0176, # [Ohm/km] |
||
353 | "L": 0.3, # [mH/km] |
||
354 | }, |
||
355 | "ac_line_380kV": { |
||
356 | "s_nom": 1790, # [MVA] |
||
357 | "R": 0.028, # [Ohm/km] |
||
358 | "L": 0.8, # [mH/km] |
||
359 | }, |
||
360 | "ac_cable_380kV": { |
||
361 | "s_nom": 925, # [MVA] |
||
362 | "R": 0.0175, # [Ohm/km] |
||
363 | "L": 0.3, # [mH/km] |
||
364 | }, |
||
365 | } |
||
366 | |||
367 | # Insert overnight investment costs |
||
368 | # Source for transformer costs: Netzentwicklungsplan Strom 2035, Version 2021, 2. Entwurf |
||
369 | # Source for HV lines and cables: Dena Verteilnetzstudie 2021, p. 146 |
||
370 | parameters["overnight_cost"] = { |
||
371 | "ac_ehv_overhead_line": read_costs( |
||
372 | costs, "HVAC overhead", "investment" |
||
373 | ), # [EUR/km/MW] |
||
374 | "ac_hv_overhead_line": 0.06e6 |
||
375 | / parameters["electrical_parameters"]["ac_line_110kV"][ |
||
376 | "s_nom" |
||
377 | ], # [EUR/km/MW] |
||
378 | "ac_hv_cable": 0.8e6 |
||
379 | / parameters["electrical_parameters"]["ac_cable_110kV"][ |
||
380 | "s_nom" |
||
381 | ], # [EUR/km/MW] |
||
382 | "dc_overhead_line": read_costs( |
||
383 | costs, "HVDC overhead", "investment" |
||
384 | ), |
||
385 | "dc_cable": read_costs(costs, "HVDC overhead", "investment"), |
||
386 | "dc_inverter": read_costs( |
||
387 | costs, "HVDC inverter pair", "investment" |
||
388 | ), |
||
389 | "transformer_380_110": 17.33e3, # [EUR/MVA] |
||
390 | "transformer_380_220": 13.33e3, # [EUR/MVA] |
||
391 | "transformer_220_110": 17.5e3, # [EUR/MVA] |
||
392 | "battery inverter": read_costs( |
||
393 | costs, "battery inverter", "investment" |
||
394 | ), |
||
395 | "battery storage": read_costs( |
||
396 | costs, "battery storage", "investment" |
||
397 | ), |
||
398 | } |
||
399 | |||
400 | parameters["lifetime"] = { |
||
401 | "ac_ehv_overhead_line": read_costs( |
||
402 | costs, "HVAC overhead", "lifetime" |
||
403 | ), |
||
404 | "ac_ehv_cable": read_costs(costs, "HVAC overhead", "lifetime"), |
||
405 | "ac_hv_overhead_line": read_costs( |
||
406 | costs, "HVAC overhead", "lifetime" |
||
407 | ), |
||
408 | "ac_hv_cable": read_costs(costs, "HVAC overhead", "lifetime"), |
||
409 | "dc_overhead_line": read_costs(costs, "HVDC overhead", "lifetime"), |
||
410 | "dc_cable": read_costs(costs, "HVDC overhead", "lifetime"), |
||
411 | "dc_inverter": read_costs(costs, "HVDC inverter pair", "lifetime"), |
||
412 | "transformer_380_110": read_costs( |
||
413 | costs, "HVAC overhead", "lifetime" |
||
414 | ), |
||
415 | "transformer_380_220": read_costs( |
||
416 | costs, "HVAC overhead", "lifetime" |
||
417 | ), |
||
418 | "transformer_220_110": read_costs( |
||
419 | costs, "HVAC overhead", "lifetime" |
||
420 | ), |
||
421 | "battery inverter": read_costs( |
||
422 | costs, "battery inverter", "lifetime" |
||
423 | ), |
||
424 | "battery storage": read_costs( |
||
425 | costs, "battery storage", "lifetime" |
||
426 | ), |
||
427 | } |
||
428 | # Insert annualized capital costs |
||
429 | # lines in EUR/km/MW/a |
||
430 | # transfermer, inverter, battery in EUR/MW/a |
||
431 | parameters["capital_cost"] = {} |
||
432 | |||
433 | for comp in parameters["overnight_cost"].keys(): |
||
434 | parameters["capital_cost"][comp] = annualize_capital_costs( |
||
435 | parameters["overnight_cost"][comp], |
||
436 | parameters["lifetime"][comp], |
||
437 | global_settings("eGon2035")["interest_rate"], |
||
438 | ) |
||
439 | |||
440 | parameters["capital_cost"]["battery"] = ( |
||
441 | parameters["capital_cost"]["battery inverter"] |
||
442 | + parameters["efficiency"]["battery"]["max_hours"] |
||
443 | * parameters["capital_cost"]["battery storage"] |
||
444 | ) |
||
445 | |||
446 | # Insert marginal_costs in EUR/MWh |
||
447 | # marginal cost can include fuel, C02 and operation and maintenance costs |
||
448 | parameters["marginal_cost"] = { |
||
449 | "wind_offshore": read_costs(costs, "offwind", "VOM"), |
||
450 | "wind_onshore": read_costs(costs, "onwind", "VOM"), |
||
451 | "solar": read_costs(costs, "solar", "VOM"), |
||
452 | } |
||
453 | |||
454 | else: |
||
455 | print(f"Scenario name {scenario} is not valid.") |
||
456 | |||
457 | return parameters |
||
458 | |||
828 |