Passed
Pull Request — dev (#854)
by
unknown
01:32
created

heat()   B

Complexity

Conditions 4

Size

Total Lines 104
Code Lines 52

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 52
dl 0
loc 104
rs 8.5709
c 0
b 0
f 0
cc 4
nop 1

How to fix   Long Method   

Long Method

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:

1
"""The module containing all parameters for the scenario table
2
"""
3
4
import pandas as pd
5
6
import egon.data.config
7
8
9
def read_csv(year):
10
11
    source = egon.data.config.datasets()["pypsa-technology-data"]["targets"][
12
        "data_dir"
13
    ]
14
15
    return pd.read_csv(f"{source}costs_{year}.csv")
16
17
18
def read_costs(df, technology, parameter, value_only=True):
19
20
    result = df.loc[
21
        (df.technology == technology) & (df.parameter == parameter)
22
    ].squeeze()
23
24
    # Rescale costs to EUR/MW
25
    if "EUR/kW" in result.unit:
26
        result.value *= 1e3
27
        result.unit = result.unit.replace("kW", "MW")
28
29
    if value_only:
30
        return result.value
31
    else:
32
        return result
33
34
35
def annualize_capital_costs(overnight_costs, lifetime, p):
36
    """
37
38
    Parameters
39
    ----------
40
    overnight_costs : float
41
        Overnight investment costs in EUR/MW or EUR/MW/km
42
    lifetime : int
43
        Number of years in which payments will be made
44
    p : float
45
        Interest rate in p.u.
46
47
    Returns
48
    -------
49
    float
50
        Annualized capital costs in EUR/MW/a or EUR/MW/km/a
51
52
    """
53
54
    # Calculate present value of an annuity (PVA)
55
    PVA = (1 / p) - (1 / (p * (1 + p) ** lifetime))
56
57
    return overnight_costs / PVA
58
59
60
def global_settings(scenario):
61
    """Returns global paramaters for the selected scenario.
62
63
    Parameters
64
    ----------
65
    scenario : str
66
        Name of the scenario.
67
68
    Returns
69
    -------
70
    parameters : dict
71
        List of global parameters
72
73
    """
74
75
    if scenario == "eGon2035":
76
        parameters = {
77
            "weather_year": 2011,
78
            "population_year": 2035,
79
            "fuel_costs": {  # Netzentwicklungsplan Strom 2035, Version 2021, 1. Entwurf, p. 39, table 6
80
                "oil": 73.8,  # [EUR/MWh]
81
                "gas": 25.6,  # [EUR/MWh]
82
                "coal": 20.2,  # [EUR/MWh]
83
                "lignite": 4.0,  # [EUR/MWh]
84
                "nuclear": 1.7,  # [EUR/MWh]
85
                "biomass": 40,  # Dummyvalue, ToDo: Find a suitable source
86
            },
87
            "co2_costs": 76.5,  # [EUR/t_CO2]
88
            "co2_emissions": {  # Netzentwicklungsplan Strom 2035, Version 2021, 1. Entwurf, p. 40, table 8
89
                "waste": 0.165,  # [t_CO2/MW_th]
90
                "lignite": 0.393,  # [t_CO2/MW_th]
91
                "gas": 0.201,  # [t_CO2/MW_th]
92
                "nuclear": 0.0,  # [t_CO2/MW_th]
93
                "oil": 0.288,  # [t_CO2/MW_th]
94
                "coal": 0.335,  # [t_CO2/MW_th]
95
                "other_non_renewable": 0.268,  # [t_CO2/MW_th]
96
            },
97
            "interest_rate": 0.05,  # [p.u.]
98
        }
99
100
    elif scenario == "eGon100RE":
101
        parameters = {
102
            "weather_year": 2011,
103
            "population_year": 2050,
104
            "fuel_costs": {  # Netzentwicklungsplan Strom 2035, Version 2021, 1. Entwurf, p. 39, table 6
105
                "oil": 73.8,  # [EUR/MWh]
106
                "gas": 25.6,  # [EUR/MWh]
107
                "coal": 20.2,  # [EUR/MWh]
108
                "lignite": 4.0,  # [EUR/MWh]
109
                "nuclear": 1.7,  # [EUR/MWh]
110
            },
111
            "co2_costs": 76.5,  # [EUR/t_CO2]
112
            "co2_emissions": {  # Netzentwicklungsplan Strom 2035, Version 2021, 1. Entwurf, p. 40, table 8
113
                "waste": 0.165,  # [t_CO2/MW_th]
114
                "lignite": 0.393,  # [t_CO2/MW_th]
115
                "gas": 0.201,  # [t_CO2/MW_th]
116
                "nuclear": 0.0,  # [t_CO2/MW_th]
117
                "oil": 0.288,  # [t_CO2/MW_th]
118
                "coal": 0.335,  # [t_CO2/MW_th]
119
                "other_non_renewable": 0.268,  # [t_CO2/MW_th]
120
            },
121
        }
122
123
    else:
124
        print(f"Scenario name {scenario} is not valid.")
125
126
    return parameters
0 ignored issues
show
introduced by
The variable parameters does not seem to be defined for all execution paths.
Loading history...
127
128
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
0 ignored issues
show
introduced by
The variable parameters does not seem to be defined for all execution paths.
Loading history...
458
459
460
def gas(scenario):
461
    """Returns paramaters of the gas sector for the selected scenario.
462
463
    Parameters
464
    ----------
465
    scenario : str
466
        Name of the scenario.
467
468
    Returns
469
    -------
470
    parameters : dict
471
        List of parameters of gas sector
472
473
    """
474
475
    if scenario == "eGon2035":
476
477
        costs = read_csv(2035)
478
479
        parameters = {
480
            "main_gas_carrier": "CH4",
481
            "H2_feedin_volumetric_fraction": 0.15,
482
        }
483
        # Insert effciencies in p.u.
484
        parameters["efficiency"] = {
485
            "power_to_H2": read_costs(costs, "electrolysis", "efficiency"),
486
            "H2_to_power": read_costs(costs, "fuel cell", "efficiency"),
487
            "CH4_to_H2": read_costs(costs, "SMR", "efficiency"),  # CC?
488
            "H2_feedin": 1,
489
            "H2_to_CH4": read_costs(costs, "methanation", "efficiency"),
490
            "OCGT": read_costs(costs, "OCGT", "efficiency"),
491
        }
492
        # Insert overnight investment costs
493
        parameters["overnight_cost"] = {
494
            "power_to_H2": read_costs(costs, "electrolysis", "investment"),
495
            "H2_to_power": read_costs(costs, "fuel cell", "investment"),
496
            "CH4_to_H2": read_costs(costs, "SMR", "investment"),  # CC?
497
            "H2_to_CH4": read_costs(costs, "methanation", "investment"),
498
            #  what about H2 compressors?
499
            "H2_feedin": 0,
500
            "H2_underground": read_costs(
501
                costs, "hydrogen storage underground", "investment"
502
            ),
503
            "H2_overground": read_costs(
504
                costs, "hydrogen storage tank incl. compressor", "investment"
505
            ),
506
            "H2_pipeline": read_costs(
507
                costs, "H2 (g) pipeline", "investment"
508
            ),  # [EUR/MW/km]
509
        }
510
511
        # Insert lifetime
512
        parameters["lifetime"] = {
513
            "power_to_H2": read_costs(costs, "electrolysis", "lifetime"),
514
            "H2_to_power": read_costs(costs, "fuel cell", "lifetime"),
515
            "CH4_to_H2": read_costs(costs, "SMR", "lifetime"),  # CC?
516
            "H2_to_CH4": read_costs(costs, "methanation", "lifetime"),
517
            #  what about H2 compressors?
518
            "H2_underground": read_costs(
519
                costs, "hydrogen storage underground", "lifetime"
520
            ),
521
            "H2_overground": read_costs(
522
                costs, "hydrogen storage tank incl. compressor", "lifetime"
523
            ),
524
            "H2_pipeline": read_costs(costs, "H2 (g) pipeline", "lifetime"),
525
            "H2_feedin": read_costs(costs, "CH4 (g) pipeline", "lifetime"),
526
        }
527
528
        # Insert annualized capital costs
529
        parameters["capital_cost"] = {}
530
531
        for comp in parameters["overnight_cost"].keys():
532
            parameters["capital_cost"][comp] = annualize_capital_costs(
533
                parameters["overnight_cost"][comp],
534
                parameters["lifetime"][comp],
535
                global_settings("eGon2035")["interest_rate"],
536
            )
537
538
        parameters["marginal_cost"] = {
539
            "CH4": global_settings(scenario)["fuel_costs"]["gas"]
540
            + global_settings(scenario)["co2_costs"]
541
            * global_settings(scenario)["co2_emissions"]["gas"],
542
            "OCGT": read_costs(costs, "OCGT", "VOM"),
543
            "biogas": global_settings(scenario)["fuel_costs"]["gas"],
544
            "chp_gas": read_costs(costs, "central gas CHP", "VOM"),
545
        }
546
547
        # Insert max gas production (generator) over the year
548
        parameters["max_gas_generation_overtheyear"] = {
549
            "CH4": 36000000,  # [MWh] Netzentwicklungsplan Gas 2020–2030
550
            "biogas": 10000000,  # [MWh] Netzentwicklungsplan Gas 2020–2030
551
        }
552
553
    elif scenario == "eGon100RE":
554
555
        costs = read_csv(2050)
556
557
        parameters = {
558
            "main_gas_carrier": "H2",
559
            "retrofitted_CH4pipeline-to-H2pipeline_share": 0.75,
560
            # The H2 network will be based on 75% of converted natural gas pipelines.
561
            # https://gasforclimate2050.eu/wp-content/uploads/2020/07/2020_European-Hydrogen-Backbone_Report.pdf
562
            # This value is used temporary, later on we will use the result of p-e-s
563
            "retrofitted_capacity_share": 0.8,
564
            # The volumetric energy density of pure H2 at 50 bar vs. pure CH4 at
565
            # 50 bar is at about 30 %, however due to less friction volumetric flow can
566
            # be increased for pure H2 leading to higher capacities
567
            # https://gasforclimate2050.eu/wp-content/uploads/2020/07/2020_European-Hydrogen-Backbone_Report.pdf p.10
568
        }
569
        # Insert effciencies in p.u.
570
        parameters["efficiency"] = {
571
            "power_to_H2": read_costs(costs, "electrolysis", "efficiency"),
572
            "H2_to_power": read_costs(costs, "fuel cell", "efficiency"),
573
            "CH4_to_H2": read_costs(costs, "SMR", "efficiency"),  # CC?
574
            "H2_to_CH4": read_costs(costs, "methanation", "efficiency"),
575
            "OCGT": read_costs(costs, "OCGT", "efficiency"),
576
        }
577
        # Insert overnight investment costs
578
        parameters["overnight_cost"] = {
579
            "power_to_H2": read_costs(costs, "electrolysis", "investment"),
580
            "H2_to_power": read_costs(costs, "fuel cell", "investment"),
581
            "CH4_to_H2": read_costs(costs, "SMR", "investment"),  # CC?
582
            "H2_to_CH4": read_costs(costs, "methanation", "investment"),
583
            #  what about H2 compressors?
584
            "H2_underground": read_costs(
585
                costs, "hydrogen storage underground", "investment"
586
            ),
587
            "H2_overground": read_costs(
588
                costs, "hydrogen storage tank incl. compressor", "investment"
589
            ),
590
            "H2_pipeline": read_costs(
591
                costs, "H2 (g) pipeline", "investment"
592
            ),  # [EUR/MW/km]
593
            "H2_pipeline_retrofit": read_costs(
594
                costs, "H2 (g) pipeline repurposed", "investment"
595
            ),  # [EUR/MW/km]
596
        }
597
598
        # Insert lifetime
599
        parameters["lifetime"] = {
600
            "power_to_H2": read_costs(costs, "electrolysis", "lifetime"),
601
            "H2_to_power": read_costs(costs, "fuel cell", "lifetime"),
602
            "CH4_to_H2": read_costs(costs, "SMR", "lifetime"),  # CC?
603
            "H2_to_CH4": read_costs(costs, "methanation", "lifetime"),
604
            #  what about H2 compressors?
605
            "H2_underground": read_costs(
606
                costs, "hydrogen storage underground", "lifetime"
607
            ),
608
            "H2_overground": read_costs(
609
                costs, "hydrogen storage tank incl. compressor", "lifetime"
610
            ),
611
            "H2_pipeline": read_costs(costs, "H2 (g) pipeline", "lifetime"),
612
            "H2_pipeline_retrofit": read_costs(
613
                costs, "H2 (g) pipeline repurposed", "lifetime"
614
            ),
615
        }
616
617
        # Insert costs
618
        parameters["capital_cost"] = {}
619
620
        for comp in parameters["overnight_cost"].keys():
621
            parameters["capital_cost"][comp] = annualize_capital_costs(
622
                parameters["overnight_cost"][comp],
623
                parameters["lifetime"][comp],
624
                global_settings("eGon2035")["interest_rate"],
625
            )
626
627
        parameters["marginal_cost"] = {
628
            # "CH4": global_settings(scenario)["fuel_costs"]["gas"]
629
            # + global_settings(scenario)["co2_costs"]
630
            # * global_settings(scenario)["co2_emissions"]["gas"],
631
            "OCGT": read_costs(costs, "OCGT", "VOM"),
632
            "biogas": global_settings(scenario)["fuel_costs"]["gas"],
633
            "chp_gas": read_costs(costs, "central gas CHP", "VOM"),
634
        }
635
636
    else:
637
        print(f"Scenario name {scenario} is not valid.")
638
639
    return parameters
0 ignored issues
show
introduced by
The variable parameters does not seem to be defined for all execution paths.
Loading history...
640
641
642
def mobility(scenario):
643
    """Returns parameters of the mobility sector for the selected scenario.
644
645
    Parameters
646
    ----------
647
    scenario : str
648
        Name of the scenario.
649
650
    Returns
651
    -------
652
    parameters : dict
653
        List of parameters of mobility sector
654
655
    Notes
656
    -----
657
    For a detailed description of the parameters see module
658
    :mod:`egon.data.datasets.emobility.motorized_individual_travel`.
659
    """
660
661
    if scenario == "eGon2035":
662
        parameters = {
663
            "motorized_individual_travel": {
664
                "NEP C 2035": {
665
                    "ev_count": 15100000,
666
                    "bev_mini_share": 0.1589,
667
                    "bev_medium_share": 0.3533,
668
                    "bev_luxury_share": 0.1053,
669
                    "phev_mini_share": 0.0984,
670
                    "phev_medium_share": 0.2189,
671
                    "phev_luxury_share": 0.0652,
672
                    "model_parameters": {},
673
                }
674
            }
675
        }
676
677
    elif scenario == "eGon100RE":
678
        # eGon100RE has 3 Scenario variations
679
        #   * allocation will always be done for all scenarios
680
        #   * model data will be written to tables `egon_etrago_*` only
681
        #     for the variation as speciefied in `datasets.yml`
682
        parameters = {
683
            "motorized_individual_travel": {
684
                "Reference 2050": {
685
                    "ev_count": 25065000,
686
                    "bev_mini_share": 0.1589,
687
                    "bev_medium_share": 0.3533,
688
                    "bev_luxury_share": 0.1053,
689
                    "phev_mini_share": 0.0984,
690
                    "phev_medium_share": 0.2189,
691
                    "phev_luxury_share": 0.0652,
692
                    "model_parameters": {},
693
                },
694
                "Mobility Transition 2050": {
695
                    "ev_count": 37745000,
696
                    "bev_mini_share": 0.1589,
697
                    "bev_medium_share": 0.3533,
698
                    "bev_luxury_share": 0.1053,
699
                    "phev_mini_share": 0.0984,
700
                    "phev_medium_share": 0.2189,
701
                    "phev_luxury_share": 0.0652,
702
                    "model_parameters": {},
703
                },
704
                "Electrification 2050": {
705
                    "ev_count": 47700000,
706
                    "bev_mini_share": 0.1589,
707
                    "bev_medium_share": 0.3533,
708
                    "bev_luxury_share": 0.1053,
709
                    "phev_mini_share": 0.0984,
710
                    "phev_medium_share": 0.2189,
711
                    "phev_luxury_share": 0.0652,
712
                    "model_parameters": {},
713
                },
714
            }
715
        }
716
717
    else:
718
        print(f"Scenario name {scenario} is not valid.")
719
        parameters = dict()
720
721
    return parameters
722
723
724
def heat(scenario):
725
    """Returns paramaters of the heat sector for the selected scenario.
726
727
    Parameters
728
    ----------
729
    scenario : str
730
        Name of the scenario.
731
732
    Returns
733
    -------
734
    parameters : dict
735
        List of parameters of heat sector
736
737
    """
738
739
    if scenario == "eGon2035":
740
741
        costs = read_csv(2035)
742
743
        parameters = {
744
            "DE_demand_reduction_residential": 0.854314018923104,
745
            "DE_demand_reduction_service": 0.498286864771128,
746
            "DE_district_heating_share": 0.14,
747
        }
748
749
        # Insert efficiency in p.u.
750
        parameters["efficiency"] = {
751
            "water_tank_charger": read_costs(
752
                costs, "water tank charger", "efficiency"
753
            ),
754
            "water_tank_discharger": read_costs(
755
                costs, "water tank discharger", "efficiency"
756
            ),
757
            "central_resistive_heater": read_costs(
758
                costs, "central resistive heater", "efficiency"
759
            ),
760
            "central_gas_boiler": read_costs(
761
                costs, "central gas boiler", "efficiency"
762
            ),
763
            "rural_resistive_heater": read_costs(
764
                costs, "decentral resistive heater", "efficiency"
765
            ),
766
            "rural_gas_boiler": read_costs(
767
                costs, "decentral gas boiler", "efficiency"
768
            ),
769
        }
770
771
        # Insert overnight investment costs, in EUR/MWh
772
        parameters["overnight_cost"] = {
773
            "central_water_tank": read_costs(
774
                costs, "central water tank storage", "investment"
775
            ),
776
            "rural_water_tank": read_costs(
777
                costs, "decentral water tank storage", "investment"
778
            ),
779
        }
780
781
        # Insert lifetime
782
        parameters["lifetime"] = {
783
            "central_water_tank": read_costs(
784
                costs, "central water tank storage", "lifetime"
785
            ),
786
            "rural_water_tank": read_costs(
787
                costs, "decentral water tank storage", "lifetime"
788
            ),
789
        }
790
791
        # Insert annualized capital costs
792
        parameters["capital_cost"] = {}
793
794
        for comp in parameters["overnight_cost"].keys():
795
            parameters["capital_cost"][comp] = annualize_capital_costs(
796
                parameters["overnight_cost"][comp],
797
                parameters["lifetime"][comp],
798
                global_settings("eGon2035")["interest_rate"],
799
            )
800
801
        # Insert marginal_costs in EUR/MWh
802
        # marginal cost can include fuel, C02 and operation and maintenance costs
803
        parameters["marginal_cost"] = {
804
            "central_heat_pump": read_costs(
805
                costs, "central air-sourced heat pump", "VOM"
806
            ),
807
            "central_gas_chp": read_costs(costs, "central gas CHP", "VOM"),
808
            "central_gas_boiler": read_costs(
809
                costs, "central gas boiler", "VOM"
810
            ),
811
            "central_resistive_heater": read_costs(
812
                costs, "central resistive heater", "VOM"
813
            ),
814
            "geo_thermal": 2.9,  # Danish Energy Agency
815
        }
816
817
    elif scenario == "eGon100RE":
818
        parameters = {
819
            "DE_demand_reduction_residential": 0.640720648501849,
820
            "DE_demand_reduction_service": 0.390895195300713,
821
            "DE_district_heating_share": 0.19,
822
        }
823
824
    else:
825
        print(f"Scenario name {scenario} is not valid.")
826
827
    return parameters
0 ignored issues
show
introduced by
The variable parameters does not seem to be defined for all execution paths.
Loading history...
828