-
Notifications
You must be signed in to change notification settings - Fork 42
/
compile_cost_assumptions.py
2338 lines (1960 loc) · 115 KB
/
compile_cost_assumptions.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
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Script creates cost csv for choosen years from different source (source_dict).
The data is standardized for uniform:
- cost years (depending on the rate of inflation )
- technology names
- units
Technology data from the Danish Energy Agency Technology Database are preferred.
If data are missing from all sources, these are taken from the old PyPSA cost
assumptions (with a printed warning)
The script is structured as follows:
(1) DEA data:
(a) read + convert units to same base
(b) specify assumptions for certain technologies
(c) convert to pypsa cost syntax (investment, FOM, VOM, efficiency)
(2) read data from other sources which need additional formatting:
(a) old pypsa cost assumptions
(b) Fraunhofer ISE cost assumptions
(3) merge data from all sources for every year and save it as a csv
@author: Marta, Lisa
"""
import pandas as pd
import numpy as np
try:
pd.set_option('future.no_silent_downcasting', True)
except Exception:
pass
# ---------- sources -------------------------------------------------------
source_dict = {
'DEA': 'Danish Energy Agency',
# solar utility
'Vartiaien': 'Impact of weighted average cost of capital, capital expenditure, and other parameters on future utility‐scale PV levelised cost of electricity',
# solar rooftop
'ETIP': 'European PV Technology and Innovation Platform',
# fuel cost
'zappa': 'Is a 100% renewable European power system feasible by 2050?',
# co2 intensity
"co2" :'Entwicklung der spezifischen Kohlendioxid-Emissionen des deutschen Strommix in den Jahren 1990 - 2018',
# gas pipeline costs
"ISE": "WEGE ZU EINEM KLIMANEUTRALEN ENERGIESYSEM, Anhang zur Studie, Fraunhofer-Institut für Solare Energiesysteme ISE, Freiburg",
# Water desalination costs
"Caldera2016": "Caldera et al 2016: Local cost of seawater RO desalination based on solar PV and windenergy: A global estimate. (https://doi.org/10.1016/j.desal.2016.02.004)",
"Caldera2017": "Caldera et al 2017: Learning Curve for Seawater Reverse Osmosis Desalination Plants: Capital Cost Trend of the Past, Present, and Future (https://doi.org/10.1002/2017WR021402)",
# home battery storage and inverter investment costs
"EWG": "Global Energy System based on 100% Renewable Energy, Energywatchgroup/LTU University, 2019",
"HyNOW" : "Zech et.al. DBFZ Report Nr. 19. Hy-NOW - Evaluierung der Verfahren und Technologien für die Bereitstellung von Wasserstoff auf Basis von Biomasse, DBFZ, 2014",
# efficiencies + lifetime SMR / SMR + CC
"IEA": "IEA Global average levelised cost of hydrogen production by energy source and technology, 2019 and 2050 (2020), https://www.iea.org/data-and-statistics/charts/global-average-levelised-cost-of-hydrogen-production-by-energy-source-and-technology-2019-and-2050",
# SMR capture rate
"Timmerberg": "Hydrogen and hydrogen-derived fuels through methane decomposition of natural gas – GHG emissions and costs Timmerberg et al. (2020), https://doi.org/10.1016/j.ecmx.2020.100043",
# geothermal (enhanced geothermal systems)
"Aghahosseini2020": "Aghahosseini, Breyer 2020: From hot rock to useful energy: A global estimate of enhanced geothermal systems potential, https://www.sciencedirect.com/science/article/pii/S0306261920312551",
# review of existing deep geothermal projects
"Breede2015": "Breede et al. 2015: Overcoming challenges in the classification of deep geothermal potential, https://eprints.gla.ac.uk/169585/",
# Study of deep geothermal systems in the Northern Upper Rhine Graben
"Frey2022": "Frey et al. 2022: Techno-Economic Assessment of Geothermal Resources in the Variscan Basement of the Northern Upper Rhine Graben",
# vehicles
"vehicles" : "PATHS TO A CLIMATE-NEUTRAL ENERGY SYSTEM The German energy transformation in its social context. https://www.ise.fraunhofer.de/en/publications/studies/paths-to-a-climate-neutral-energy-system.html"
}
# [DEA-sheet-names]
sheet_names = {'onwind': '20 Onshore turbines', # 2015
'offwind': '21 Offshore turbines', # 2020
'solar-utility': '22 Utility-scale PV', #2020
'solar-utility single-axis tracking': '22 Utility-scale PV tracker', # 2020
'solar-rooftop residential': '22 Rooftop PV residential', # 2020
'solar-rooftop commercial': '22 Rooftop PV commercial', # 2020
'OCGT': '52 OCGT - Natural gas', # 2015?
'CCGT': '05 Gas turb. CC, steam extract.', # 2015
'oil': '50 Diesel engine farm', # 2015?
'biomass CHP': '09c Straw, Large, 40 degree', # 2015
'biomass EOP': '09c Straw, Large, 40 degree', # 2015
'biomass HOP': '09c Straw HOP', # 2015
'central coal CHP': '01 Coal CHP', # 2015
'central gas CHP': '04 Gas turb. simple cycle, L', # 2015
'central gas CHP CC': '04 Gas turb. simple cycle, L', # 2015
'central solid biomass CHP': '09a Wood Chips, Large 50 degree', # 2015
'central solid biomass CHP CC': '09a Wood Chips, Large 50 degree', # 2015
'central solid biomass CHP powerboost CC': '09a Wood Chips, Large 50 degree', # 2015
# 'solid biomass power': '09a Wood Chips extract. plant',
# 'solid biomass power CC': '09a Wood Chips extract. plant',
'central air-sourced heat pump': '40 Comp. hp, airsource 3 MW', # 2015
'central ground-sourced heat pump': '40 Absorption heat pump, DH', # 2015
'central resistive heater': '41 Electric Boilers', # 2015
'central gas boiler': '44 Natural Gas DH Only', # 2015
'decentral gas boiler': '202 Natural gas boiler', # <2018
'direct firing gas': '312.a Direct firing Natural Gas', # 2019
'direct firing gas CC': '312.a Direct firing Natural Gas', # 2019
'direct firing solid fuels': '312.b Direct firing Sold Fuels', # 2019
'direct firing solid fuels CC': '312.b Direct firing Sold Fuels', # 2019
'decentral ground-sourced heat pump': '207.7 Ground source existing', # <2018
'decentral air-sourced heat pump': '207.3 Air to water existing', # <2018
# 'decentral resistive heater': '216 Electric heating',
'central water tank storage': '140 PTES seasonal', # 2015
# 'decentral water tank storage': '142 Small scale hot water tank',
'fuel cell': '12 LT-PEMFC CHP', # 2015
'hydrogen storage underground': '151c Hydrogen Storage - Caverns', # 2015
'hydrogen storage tank type 1 including compressor': '151a Hydrogen Storage - Tanks', # 2015
'micro CHP': '219 LT-PEMFC mCHP - natural gas', # 2015
'biogas' : '81 Biogas, Basic plant, small', # 2020
'biogas CC' : '81 Biogas, Basic plant, small', # 2020
'biogas upgrading': '82 Upgrading 3,000 Nm3 per h', # 2020
'battery': '180 Lithium Ion Battery', # 2015
'industrial heat pump medium temperature': '302.a High temp. hp Up to 125 C', # 2019
'industrial heat pump high temperature': '302.b High temp. hp Up to 150', # 2019
'electric boiler steam': '310.1 Electric boiler steam ', # 2019
'gas boiler steam': '311.1c Steam boiler Gas', # 2019
'solid biomass boiler steam': '311.1e Steam boiler Wood', # 2019
'solid biomass boiler steam CC': '311.1e Steam boiler Wood', # 2019
'biomass boiler': '204 Biomass boiler, automatic', # <2018
'electrolysis': '86 AEC 100 MW', # 2020
'direct air capture': '403.a Direct air capture', # 2020
'biomass CHP capture': '401.a Post comb - small CHP', # 2020
'cement capture': '401.c Post comb - Cement kiln', # 2020
'BioSNG': '84 Gasif. CFB, Bio-SNG', # 2020
'BtL': '85 Gasif. Ent. Flow FT, liq fu ', # 2020
'biomass-to-methanol': '97 Methanol from biomass gasif.', # 2020
'biogas plus hydrogen': '99 SNG from methan. of biogas', # 2020
'methanolisation': '98 Methanol from hydrogen', # 2020
'Fischer-Tropsch': '102 Hydrogen to Jet', # 2020
'central hydrogen CHP': '12 LT-PEMFC CHP', # 2015
'Haber-Bosch': '103 Hydrogen to Ammonia', # 2020
'air separation unit': '103 Hydrogen to Ammonia', # 2020
'waste CHP': '08 WtE CHP, Large, 50 degree', # 2015
'waste CHP CC': '08 WtE CHP, Large, 50 degree', # 2015
# 'electricity distribution rural': '101 2 el distri Rural',
# 'electricity distribution urban': '101 4 el distri city',
# 'gas distribution rural': '102 7 gas Rural',
# 'gas distribution urban': '102 9 gas City',
# 'DH distribution rural': '103_12 DH_Distribu Rural',
# 'DH distribution urban': '103_14 DH_Distribu City',
# 'DH distribution low T': '103_16 DH_Distr New area LTDH',
# 'gas pipeline': '102 6 gas Main distri line',
# "DH main transmission": "103_11 DH transmission",
}
# [DEA-sheet-names]
uncrtnty_lookup = {'onwind': 'J:K',
'offwind': 'J:K',
'solar-utility': 'J:K',
'solar-utility single-axis tracking': 'J:K',
'solar-rooftop residential': 'J:K',
'solar-rooftop commercial': 'J:K',
'OCGT': 'I:J',
'CCGT': 'I:J',
'oil': 'I:J',
'biomass CHP': 'I:J',
'biomass EOP': 'I:J',
'biomass HOP': 'I:J',
'central coal CHP': '',
'central gas CHP': 'I:J',
'central gas CHP CC': 'I:J',
'central hydrogen CHP': 'I:J',
'central solid biomass CHP': 'I:J',
'central solid biomass CHP CC': 'I:J',
'central solid biomass CHP powerboost CC': 'I:J',
# 'solid biomass power': 'J:K',
# 'solid biomass power CC': 'J:K',
'solar': '',
'central air-sourced heat pump': 'J:K',
'central ground-sourced heat pump': 'I:J',
'central resistive heater': 'I:J',
'central gas boiler': 'I:J',
'decentral gas boiler': 'I:J',
'direct firing gas': 'H:I',
'direct firing gas CC': 'H:I',
'direct firing solid fuels': 'H:I',
'direct firing solid fuels CC': 'H:I',
'decentral ground-sourced heat pump': 'I:J',
'decentral air-sourced heat pump': 'I:J',
'central water tank storage': 'J:K',
'fuel cell': 'I:J',
'hydrogen storage underground': 'J:K',
'hydrogen storage tank type 1 including compressor': 'J:K',
'micro CHP': 'I:J',
'biogas': 'I:J',
'biogas CC': 'I:J',
'biogas upgrading': 'I:J',
'electrolysis': 'I:J',
'battery': 'L,N',
'direct air capture': 'I:J',
'cement capture': 'I:J',
'biomass CHP capture': 'I:J',
'BioSNG' : 'I:J',
'BtL' : 'J:K',
'biomass-to-methanol' : 'J:K',
'biogas plus hydrogen' : 'J:K',
'industrial heat pump medium temperature':'H:I',
'industrial heat pump high temperature':'H:I',
'electric boiler steam':'H:I',
'gas boiler steam':'H:I',
'solid biomass boiler steam':'H:I',
'solid biomass boiler steam CC':'H:I',
'biomass boiler': 'I:J',
'Fischer-Tropsch': 'I:J',
'Haber-Bosch': 'I:J',
'air separation unit': 'I:J',
'methanolisation': 'J:K',
'waste CHP': 'I:J',
'waste CHP CC': 'I:J',
}
# since February 2022 DEA uses a new format for the technology data
# all excel sheets of updated technologies have a different layout and are
# given in EUR_2020 money (instead of EUR_2015)
new_format = ['solar-utility',
'solar-utility single-axis tracking',
'solar-rooftop residential',
'solar-rooftop commercial',
'offwind',
'electrolysis',
'biogas',
'biogas CC',
'biogas upgrading',
'direct air capture',
'biomass CHP capture',
'cement capture',
'BioSNG',
'BtL',
'biomass-to-methanol',
'biogas plus hydrogen',
'methanolisation',
'Fischer-Tropsch',
'Haber-Bosch',
'air separation unit']
# %% -------- FUNCTIONS ---------------------------------------------------
def get_excel_sheets(excel_files):
""""
read all excel sheets and return
them as a dictionary (data_in)
"""
data_in = {}
for entry in excel_files:
if entry[-5:] == ".xlsx":
data_in[entry] = pd.ExcelFile(entry).sheet_names
print("found ", len(data_in), " excel sheets: ")
for key in data_in.keys():
print("* ", key)
return data_in
def get_sheet_location(tech, sheet_names, data_in):
"""
looks up in which excel file technology is saved
"""
for key in data_in:
if sheet_names[tech] in data_in[key]:
return key
print("******* warning *************")
print("tech ", tech, " with sheet name ", sheet_names[tech],
" not found in excel sheets.")
print("****************************")
return None
#
def get_data_DEA(tech, data_in, expectation=None):
"""
interpolate cost for a given technology from DEA database sheet
uncertainty can be "optimist", "pessimist" or None|""
"""
excel_file = get_sheet_location(tech, sheet_names, data_in)
if excel_file is None:
print("excel file not found for tech ", tech)
return None
if tech=="battery":
usecols = "B:J"
elif tech in ['direct air capture', 'cement capture', 'biomass CHP capture']:
usecols = "A:F"
elif tech in ['industrial heat pump medium temperature', 'industrial heat pump high temperature',
'electric boiler steam', "gas boiler steam", "solid biomass boiler steam", "solid biomass boiler steam CC", "direct firing gas", "direct firing gas CC", "direct firing solid fuels", "direct firing solid fuels CC"]:
usecols = "A:E"
elif tech in ['Fischer-Tropsch', 'Haber-Bosch', 'air separation unit']:
usecols = "B:F"
else:
usecols = "B:G"
usecols += f",{uncrtnty_lookup[tech]}"
if (tech in new_format) or ("renewable_fuels" in excel_file):
skiprows = [0]
else:
skiprows = [0,1]
excel = pd.read_excel(excel_file,
sheet_name=sheet_names[tech],
index_col=0,
usecols=usecols,
skiprows=skiprows,
na_values="N.A")
# print(excel)
excel.dropna(axis=1, how="all", inplace=True)
excel.index = excel.index.fillna(" ")
excel.index = excel.index.astype(str)
excel.dropna(axis=0, how="all", inplace=True)
# print(excel)
if 2020 not in excel.columns:
selection = excel[excel.isin([2020])].dropna(how="all").index
excel.columns = excel.loc[selection].iloc[0, :].fillna("Technology", limit=1)
excel.drop(selection, inplace=True)
uncertainty_columns = ["2050-optimist", "2050-pessimist"]
if uncrtnty_lookup[tech]:
# hydrogen storage sheets have reverse order of lower/upper estimates
if tech in ["hydrogen storage tank type 1 including compressor", "hydrogen storage cavern"]:
uncertainty_columns.reverse()
excel.rename(columns={excel.columns[-2]: uncertainty_columns[0],
excel.columns[-1]: uncertainty_columns[1]
}, inplace=True)
else:
for col in uncertainty_columns:
excel.loc[:,col] = excel.loc[:,2050]
swap_patterns = ["technical life", "efficiency", "Hydrogen output, at LHV"] # cases where bigger is better
swap = [any(term in idx.lower() for term in swap_patterns) for idx in excel.index]
tmp = excel.loc[swap, "2050-pessimist"]
excel.loc[swap, "2050-pessimist"] = excel.loc[swap, "2050-optimist"]
excel.loc[swap, "2050-optimist"] = tmp
if expectation:
excel.loc[:,2050] = excel.loc[:,f"2050-{expectation}"].combine_first(excel.loc[:,2050])
excel.drop(columns=uncertainty_columns, inplace=True)
# fix for battery with different excel sheet format
if tech == "battery":
excel.rename(columns={"Technology":2040}, inplace=True)
if expectation:
excel = excel.loc[:,[2020,2050]]
parameters = ["efficiency", "investment", "Fixed O&M",
"Variable O&M", "production capacity for one unit",
"Output capacity expansion cost",
"Hydrogen Output",
"Hydrogen (% total input_e (MWh / MWh))",
"Hydrogen [% total input_e",
" - hereof recoverable for district heating (%-points of heat loss)",
"Cb coefficient",
"Cv coefficient",
"Distribution network costs", "Technical life",
"Energy storage expansion cost",
'Output capacity expansion cost (M€2015/MW)',
'Heat input', 'Heat input', 'Electricity input', 'Eletricity input', 'Heat out',
'capture rate',
"FT Liquids Output, MWh/MWh Total Input",
" - hereof recoverable for district heating [%-points of heat loss]",
" - hereof recoverable for district heating (%-points of heat loss)",
"Bio SNG Output [% of fuel input]",
"Methanol Output",
"District heat Output",
"Electricity Output",
"Total O&M"]
df = pd.DataFrame()
for para in parameters:
# attr = excel[excel.index.str.contains(para)]
attr = excel[[para in index for index in excel.index]]
if len(attr) != 0:
df = pd.concat([df, attr])
df.index = df.index.str.replace('€', 'EUR')
df = df.reindex(columns=df.columns[df.columns.isin(years)])
df = df[~df.index.duplicated(keep='first')]
# replace missing data
df.replace("-", np.nan, inplace=True)
# average data in format "lower_value-upper_value"
df = df.apply(lambda row: row.apply(lambda x: (float(x.split("-")[0])
+ float(x.split("-")[1]))
/ 2 if isinstance(x, str) and "-" in x else x),
axis=1)
# remove symbols "~", ">", "<" and " "
for sym in ["~", ">", "<", " "]:
df = df.apply(lambda col: col.apply(lambda x: x.replace(sym, "")
if isinstance(x, str) else x))
df = df.astype(float)
df = df.mask(df.apply(pd.to_numeric, errors='coerce').isnull(), df.astype(str).apply(lambda x: x.str.strip()))
# print(df)
## Modify data loaded from DEA on a per-technology case
if (tech == "offwind") and snakemake.config['offwind_no_gridcosts']:
df.loc['Nominal investment (*total) [MEUR/MW_e, 2020]'] -= excel.loc['Nominal investment (installation: grid connection) [M€/MW_e, 2020]']
# Exlucde indirect costs for centralised system with additional piping.
if tech.startswith('industrial heat pump'):
df = df.drop('Indirect investments cost (MEUR per MW)')
if tech == 'biogas plus hydrogen':
df.drop(df.loc[df.index.str.contains("GJ SNG")].index, inplace=True)
if tech == 'BtL':
df.drop(df.loc[df.index.str.contains("1,000 t FT Liquids")].index, inplace=True)
if tech == "biomass-to-methanol":
df.drop(df.loc[df.index.str.contains("1,000 t Methanol")].index, inplace=True)
if tech == 'methanolisation':
df.drop(df.loc[df.index.str.contains("1,000 t Methanol")].index, inplace=True)
if tech == 'Fischer-Tropsch':
df.drop(df.loc[df.index.str.contains("l FT Liquids")].index, inplace=True)
if tech == 'biomass boiler':
df.drop(df.loc[df.index.str.contains("Possible additional")].index, inplace=True)
df.drop(df.loc[df.index.str.contains("Total efficiency")].index, inplace=True)
if tech == "Haber-Bosch":
df.drop(df.loc[df.index.str.contains("Specific investment mark-up factor optional ASU")].index, inplace=True)
df.drop(df.loc[df.index.str.contains("Specific investment (MEUR /TPD Ammonia output", regex=False)].index, inplace=True)
df.drop(df.loc[df.index.str.contains("Fixed O&M (MEUR /TPD Ammonia", regex=False)].index, inplace=True)
df.drop(df.loc[df.index.str.contains("Variable O&M (EUR /t Ammonia)", regex=False)].index, inplace=True)
if tech == "air separation unit":
divisor = ((df.loc["Specific investment mark-up factor optional ASU"] - 1.0)
/ excel.loc["N2 Consumption, [t/t] Ammonia"]).astype(float)
# Calculate ASU cost separate to HB facility in terms of t N2 output
df.loc[[
"Specific investment [MEUR /TPD Ammonia output]",
"Fixed O&M [kEUR /TPD Ammonia]",
"Variable O&M [EUR /t Ammonia]"
]] *= divisor
# Convert output to hourly generation
df.loc[[
"Specific investment [MEUR /TPD Ammonia output]",
"Fixed O&M [kEUR /TPD Ammonia]",
]] *= 24
# Rename costs for correct units
df.index = df.index.str.replace("MEUR /TPD Ammonia output", "MEUR/t_N2/h")
df.index = df.index.str.replace("kEUR /TPD Ammonia", "kEUR/t_N2/h/year")
df.index = df.index.str.replace("EUR /t Ammonia", "EUR/t_N2")
df.drop(df.loc[df.index.str.contains("Specific investment mark-up factor optional ASU")].index, inplace=True)
df.drop(df.loc[df.index.str.contains("Specific investment [MEUR /MW Ammonia output]", regex=False)].index, inplace=True)
df.drop(df.loc[df.index.str.contains("Fixed O&M [kEUR/MW Ammonia/year]", regex=False)].index, inplace=True)
df.drop(df.loc[df.index.str.contains("Variable O&M [EUR/MWh Ammonia]", regex=False)].index, inplace=True)
if "solid biomass power" in tech:
df.index = df.index.str.replace("EUR/MWeh", "EUR/MWh")
df_final = pd.DataFrame(index=df.index, columns=years)
# [RTD-interpolation-example]
for index in df_final.index:
values = np.interp(x=years, xp=df.columns.values.astype(float), fp=df.loc[index, :].values.astype(float))
df_final.loc[index, :] = values
# if year-specific data is missing and not fixed by interpolation fill forward with same values
df_final = df_final.ffill(axis=1)
df_final["source"] = source_dict["DEA"] + ", " + excel_file.replace("inputs/","")
if tech in new_format and (tech!="electrolysis"):
for attr in ["investment", "Fixed O&M"]:
to_drop = df[df.index.str.contains(attr) &
~df.index.str.contains("\(\*total\)")].index
df_final.drop(to_drop, inplace=True)
df_final["unit"] = (df_final.rename(index=lambda x:
x[x.rfind("[")+1: x.rfind("]")]).index.values)
else:
df_final.index = df_final.index.str.replace("\[", "(", regex=True).str.replace("\]", ")", regex=True)
df_final["unit"] = (df_final.rename(index=lambda x:
x[x.rfind("(")+1: x.rfind(")")]).index.values)
df_final.index = df_final.index.str.replace(r" \(.*\)","", regex=True)
return df_final
def add_desalinsation_data(costs):
"""
add technology data for sea water desalination (SWRO) and water storage.
"""
# Interpolate cost based on historic costs/cost projection to fitting year
cs = [2070,1917,1603,1282,1025] # in USD/(m^3/d)
ys = [2015,2022,2030,2040,2050]
c = np.interp(year, ys, cs)
c *= 24 # in USD/(m^3/h)
c /= 1.17 # in EUR/(m^3/h)
tech = "seawater desalination"
costs.loc[(tech, 'investment'), 'value'] = c
costs.loc[(tech, 'investment'), 'unit'] = "EUR/(m^3-H2O/h)"
costs.loc[(tech, 'investment'), 'source'] = source_dict['Caldera2017'] + ", Table 4."
costs.loc[(tech, 'investment'), 'currency_year'] = 2015
costs.loc[(tech, 'FOM'), 'value'] = 4.
costs.loc[(tech, 'FOM'), 'unit'] = "%/year"
costs.loc[(tech, 'FOM'), 'source'] = source_dict['Caldera2016'] + ", Table 1."
costs.loc[(tech, 'lifetime'), 'value'] = 30
costs.loc[(tech, 'lifetime'), 'unit'] = "years"
costs.loc[(tech, 'lifetime'), 'source'] = source_dict['Caldera2016'] + ", Table 1."
salinity = snakemake.config['desalination']['salinity']
costs.loc[(tech, 'electricity-input'), 'value'] = (0.0003*salinity**2+0.0018*salinity+2.6043)
costs.loc[(tech, 'electricity-input'), 'unit'] = "kWh/m^3-H2O"
costs.loc[(tech, 'electricity-input'), 'source'] = source_dict['Caldera2016'] + ", Fig. 4."
tech = "clean water tank storage"
costs.loc[(tech, 'investment'), 'value'] = 65
costs.loc[(tech, 'investment'), 'unit'] = "EUR/m^3-H2O"
costs.loc[(tech, 'investment'), 'source'] = source_dict['Caldera2016'] + ", Table 1."
costs.loc[(tech, 'investment'), 'currency_year'] = 2013
costs.loc[(tech, 'FOM'), 'value'] = 2
costs.loc[(tech, 'FOM'), 'unit'] = "%/year"
costs.loc[(tech, 'FOM'), 'source'] = source_dict['Caldera2016'] + ", Table 1."
costs.loc[(tech, 'lifetime'), 'value'] = 30
costs.loc[(tech, 'lifetime'), 'unit'] = "years"
costs.loc[(tech, 'lifetime'), 'source'] = source_dict['Caldera2016'] + ", Table 1."
return costs
def add_co2_intensity(costs):
""""
add CO2 intensity for the carriers
"""
TJ_to_MWh = 277.78
costs.loc[('gas', 'CO2 intensity'), 'value'] = 55827 / 1e3 / TJ_to_MWh # Erdgas
costs.loc[('coal', 'CO2 intensity'), 'value'] = 93369 / 1e3 / TJ_to_MWh # Steinkohle
costs.loc[('lignite', 'CO2 intensity'), 'value'] = 113031 / 1e3 / TJ_to_MWh # Rohbraunkohle Rheinland
costs.loc[('oil', 'CO2 intensity'), 'value'] = 74020 / 1e3 / TJ_to_MWh # Heizöl, leicht
costs.loc[('methanol', 'CO2 intensity'), 'value'] = 0.2482 # t_CO2/MWh_th, based on stochiometric composition.
costs.loc[('solid biomass', 'CO2 intensity'), 'value'] = 0.3
oil_specific_energy = 44 #GJ/t
CO2_CH2_mass_ratio = 44/14 #kg/kg (1 mol per mol)
CO2_C_mass_ratio = 44/12 #kg/kg
methane_specific_energy = 50 #GJ/t
CO2_CH4_mass_ratio = 44/16 #kg/kg (1 mol per mol)
biomass_specific_energy = 18 #GJ/t LHV
biomass_carbon_content = 0.5
costs.loc[('oil', 'CO2 intensity'), 'value'] = (1/oil_specific_energy) * 3.6 * CO2_CH2_mass_ratio #tCO2/MWh
costs.loc[('gas', 'CO2 intensity'), 'value'] = (1/methane_specific_energy) * 3.6 * CO2_CH4_mass_ratio #tCO2/MWh
costs.loc[('solid biomass', 'CO2 intensity'), 'value'] = biomass_carbon_content * (1/biomass_specific_energy) * 3.6 * CO2_C_mass_ratio #tCO2/MWh
costs.loc[('oil', 'CO2 intensity'), 'source'] = "Stoichiometric calculation with 44 GJ/t diesel and -CH2- approximation of diesel"
costs.loc[('gas', 'CO2 intensity'), 'source'] = "Stoichiometric calculation with 50 GJ/t CH4"
costs.loc[('solid biomass', 'CO2 intensity'), 'source'] = "Stoichiometric calculation with 18 GJ/t_DM LHV and 50% C-content for solid biomass"
costs.loc[('coal', 'CO2 intensity'), 'source'] = source_dict["co2"]
costs.loc[('lignite', 'CO2 intensity'), 'source'] = source_dict["co2"]
costs.loc[pd.IndexSlice[:, "CO2 intensity"], "unit"] = "tCO2/MWh_th"
return costs
def add_solar_from_other(costs):
""""
add solar from other sources than DEA (since the life time assumed in
DEA is very optimistic)
"""
# solar utility from Vartiaian 2019
data = np.interp(x=years, xp=[2020, 2030, 2040, 2050],
fp=[431, 275, 204, 164])
# the paper says 'In this report, all results are given in real 2019
# money.'
data = data / (1 + snakemake.config['rate_inflation'])**(2019 - snakemake.config['eur_year'])
solar_uti = pd.Series(data=data, index=years)
# solar rooftop from ETIP 2019
data = np.interp(x=years, xp=[2020, 2030, 2050], fp=[1150, 800, 550])
# using 2016 money in page 10
data = data / (1 + snakemake.config['rate_inflation'])**(2016 - snakemake.config['eur_year'])
solar_roof = pd.Series(data=data, index=years)
# solar utility from Vartiaian 2019
if snakemake.config['solar_utility_from_vartiaien']:
costs.loc[('solar-utility', 'investment'), 'value'] = solar_uti[year]
costs.loc[('solar-utility', 'investment'), 'source'] = source_dict['Vartiaien']
costs.loc[('solar-utility', 'investment'), 'currency_year'] = 2019
costs.loc[('solar-utility', 'lifetime'), 'value'] = 30
costs.loc[('solar-utility', 'lifetime'), 'source'] = source_dict['Vartiaien']
costs.loc[('solar-utility', 'lifetime'), 'currency_year'] = 2019
if snakemake.config['solar_rooftop_from_etip']:
# solar rooftop from ETIP 2019
costs.loc[('solar-rooftop', 'investment'), 'value'] = solar_roof[year]
costs.loc[('solar-rooftop', 'investment'), 'source'] = source_dict['ETIP']
costs.loc[('solar-rooftop', 'investment'), 'currency_year'] = 2019
costs.loc[('solar-rooftop', 'lifetime'), 'value'] = 30
costs.loc[('solar-rooftop', 'lifetime'), 'source'] = source_dict['ETIP']
costs.loc[('solar-rooftop', 'lifetime'), 'currency_year'] = 2019
# lifetime&efficiency for solar
costs.loc[('solar', 'lifetime'), 'value'] = costs.loc[(
['solar-rooftop', 'solar-utility'], 'lifetime'), 'value'].mean()
costs.loc[('solar', 'lifetime'), 'unit'] = 'years'
costs.loc[('solar', 'lifetime'), 'currency_year'] = 2019
costs.loc[('solar', 'lifetime'),
'source'] = 'Assuming 50% rooftop, 50% utility'
# costs.loc[('solar', 'efficiency'), 'value'] = 1
# costs.loc[('solar', 'efficiency'), 'unit'] = 'per unit'
return costs
# [add-h2-from-other]
def add_h2_from_other(costs):
"""
assume higher efficiency for electrolysis(0.8) and fuel cell(0.58)
"""
costs.loc[('electrolysis', 'efficiency'), 'value'] = 0.8
costs.loc[('fuel cell', 'efficiency'), 'value'] = 0.58
costs.loc[('electrolysis', 'efficiency'), 'source'] = 'budischak2013'
costs.loc[('electrolysis', 'efficiency'), 'currency_year'] = 2013
costs.loc[('fuel cell', 'efficiency'), 'source'] = 'budischak2013'
costs.loc[('fuel cell', 'efficiency'), 'currency_year'] = 2013
return costs
# [unify-diw-inflation]
def unify_diw(costs):
""""
add currency year for the DIW costs from 2010
"""
costs.loc[('PHS', 'investment'), 'currency_year'] = 2010
costs.loc[('ror', 'investment'), 'currency_year'] = 2010
costs.loc[('hydro', 'investment'), 'currency_year'] = 2010
return costs
def get_data_from_DEA(data_in, expectation=None):
"""
saves technology data from DEA in dictionary d_by_tech
"""
d_by_tech = {}
for tech, dea_tech in sheet_names.items():
print(f'{tech} in PyPSA corresponds to {dea_tech} in DEA database.')
df = get_data_DEA(tech, data_in, expectation).fillna(0)
d_by_tech[tech] = df
return d_by_tech
def adjust_for_inflation(inflation_rate, costs, techs, ref_year, col):
"""
adjust the investment costs for the specified techs for inflation.
techs: str or list
One or more techs in costs index for which the inflation adjustment is done.
ref_year: int
Reference year for which the costs are provided and based on which the inflation adjustment is done.
costs: pd.Dataframe
Dataframe containing the costs data with multiindex on technology and one index key 'investment'.
"""
def get_factor(inflation_rate, ref_year, eur_year):
if (pd.isna(ref_year)) or (ref_year<1900): return np.nan
if ref_year == eur_year: return 1
mean = inflation_rate.mean()
if ref_year< eur_year:
new_index = np.arange(ref_year+1, eur_year+1)
df = 1 + inflation_rate.reindex(new_index).fillna(mean)
return df.cumprod().loc[eur_year]
else:
new_index = np.arange(eur_year+1, ref_year+1)
df = 1 + inflation_rate.reindex(new_index).fillna(mean)
return 1/df.cumprod().loc[ref_year]
inflation = costs.currency_year.apply(lambda x: get_factor(inflation_rate, x, snakemake.config['eur_year']))
paras = ["investment", "VOM", "fuel"]
filter_i = costs.index.get_level_values(0).isin(techs) & costs.index.get_level_values(1).isin(paras)
costs.loc[filter_i, col] = costs.loc[filter_i, col].mul(inflation.loc[filter_i], axis=0)
return costs
def clean_up_units(tech_data, value_column="", source=""):
"""
converts units of a pd.Dataframe tech_data to match:
power: Mega Watt (MW)
energy: Mega-Watt-hour (MWh)
currency: Euro (EUR)
clarifies if MW_th or MW_e
"""
from currency_converter import CurrencyConverter
from datetime import date
from currency_converter import ECB_URL
# Currency conversion
REPLACEMENTS = [
('€', 'EUR'),
('$', 'USD'),
('₤', 'GBP'),
]
# Download the full history, this will be up to date. Current value is:
# https://www.ecb.europa.eu/stats/eurofxref/eurofxref-hist.zip
c = CurrencyConverter(ECB_URL)
c = CurrencyConverter(fallback_on_missing_rate=True)
for old, new in REPLACEMENTS:
tech_data.unit = tech_data.unit.str.replace(old, new, regex=False)
tech_data.loc[tech_data.unit.str.contains(new), value_column] *= c.convert(1, new, "EUR", date=date(2020, 1, 1))
tech_data.unit = tech_data.unit.str.replace(new, "EUR")
tech_data.unit = tech_data.unit.str.replace(" per ", "/")
tech_data.unit = tech_data.unit.str.replace(" / ", "/")
tech_data.unit = tech_data.unit.str.replace(" /", "/")
tech_data.unit = tech_data.unit.str.replace("J/s", "W")
# units
tech_data.loc[tech_data.unit.str.contains("MEUR"), value_column] *= 1e6
tech_data.unit = tech_data.unit.str.replace("MEUR", "EUR")
tech_data.loc[tech_data.unit.str.contains("mio EUR"), value_column] *= 1e6
tech_data.unit = tech_data.unit.str.replace("mio EUR", "EUR")
tech_data.loc[tech_data.unit.str.contains("mill. EUR"), value_column] *= 1e6
tech_data.unit = tech_data.unit.str.replace("mill. EUR", "EUR")
tech_data.loc[tech_data.unit.str.contains("1000EUR"), value_column] *= 1e3
tech_data.unit = tech_data.unit.str.replace("1000EUR", "EUR")
tech_data.unit = tech_data.unit.str.replace("k EUR", "kEUR")
tech_data.loc[tech_data.unit.str.contains("kEUR"), value_column] *= 1e3
tech_data.unit = tech_data.unit.str.replace("kEUR", "EUR")
tech_data.loc[tech_data.unit.str.contains("/kW"), value_column] *= 1e3
tech_data.loc[tech_data.unit.str.contains("kW") & ~tech_data.unit.str.contains("/kW"), value_column] /= 1e3
tech_data.unit = tech_data.unit.str.replace("kW", "MW")
tech_data.loc[tech_data.unit.str.contains("/GWh"), value_column] /= 1e3
tech_data.unit = tech_data.unit.str.replace("/GWh", "/MWh")
tech_data.loc[tech_data.unit.str.contains("/GJ"), value_column] *= 3.6
tech_data.unit = tech_data.unit.str.replace("/GJ", "/MWh")
# Harmonise individual units so that they can be handled later
tech_data.unit = tech_data.unit.str.replace(" a year", "/year")
tech_data.unit = tech_data.unit.str.replace("2015EUR", "EUR")
tech_data.unit = tech_data.unit.str.replace("2015-EUR", "EUR")
tech_data.unit = tech_data.unit.str.replace("2020-EUR", "EUR")
tech_data.unit = tech_data.unit.str.replace("EUR2015", "EUR")
tech_data.unit = tech_data.unit.str.replace("EUR-2015", "EUR")
tech_data.unit = tech_data.unit.str.replace("MWe", "MW_e")
tech_data.unit = tech_data.unit.str.replace("EUR/MW of total input_e", "EUR/MW_e")
tech_data.unit = tech_data.unit.str.replace("MWh/MWh\)", "MWh_H2/MWh_e", regex=True)
tech_data.unit = tech_data.unit.str.replace("MWth", "MW_th")
tech_data.unit = tech_data.unit.str.replace("MWheat", "MW_th")
tech_data.unit = tech_data.unit.str.replace("MWhth", "MWh_th")
tech_data.unit = tech_data.unit.str.replace("MWhheat", "MWh_th")
tech_data.unit = tech_data.unit.str.replace("MWH Liquids", "MWh_FT")
tech_data.unit = tech_data.unit.str.replace("MW Liquids", "MW_FT")
tech_data.unit = tech_data.unit.str.replace("MW Methanol", "MW_MeOH")
tech_data.unit = tech_data.unit.str.replace("MW output", "MW")
tech_data.unit = tech_data.unit.str.replace("MW/year FT Liquids/year", "MW_FT/year")
tech_data.unit = tech_data.unit.str.replace("MW/year Methanol", "MW_MeOH/year")
tech_data.unit = tech_data.unit.str.replace("MWh FT Liquids/year", "MWh_FT")
tech_data.unit = tech_data.unit.str.replace("MWh methanol", "MWh_MeOH")
tech_data.unit = tech_data.unit.str.replace("MW/year SNG", "MW_CH4/year")
tech_data.unit = tech_data.unit.str.replace("MWh SNG", "MWh_CH4")
tech_data.unit = tech_data.unit.str.replace("MW SNG", "MW_CH4")
tech_data.unit = tech_data.unit.str.replace("EUR/MWh of total input", "EUR/MWh_e")
tech_data.unit = tech_data.unit.str.replace("EUR/MWeh", "EUR/MWh_e")
tech_data.unit = tech_data.unit.str.replace("% -points of heat loss", "MWh_th/MWh_el")
tech_data.unit = tech_data.unit.str.replace("FT Liquids Output, MWh/MWh Total Inpu", "MWh_FT/MWh_H2")
# biomass-to-methanol-specific
if isinstance(tech_data.index, pd.MultiIndex):
tech_data.loc[tech_data.index.get_level_values(1)=="Methanol Output,", "unit"] = "MWh_MeOH/MWh_th"
tech_data.loc[tech_data.index.get_level_values(1)=='District heat Output,', "unit"] = "MWh_th/MWh_th"
tech_data.loc[tech_data.index.get_level_values(1)=='Electricity Output,', "unit"] = "MWh_e/MWh_th"
# Ammonia-specific
tech_data.unit = tech_data.unit.str.replace("MW Ammonia output", "MW_NH3") #specific investment
tech_data.unit = tech_data.unit.str.replace("MW Ammonia", "MW_NH3") #fom
tech_data.unit = tech_data.unit.str.replace("MWh Ammonia", "MWh_NH3") #vom
tech_data.loc[tech_data.unit=='EUR/MW/y', "unit"] = 'EUR/MW/year'
# convert per unit costs to MW
cost_per_unit = tech_data.unit.str.contains("/unit")
tech_data.loc[cost_per_unit, value_column] = tech_data.loc[cost_per_unit, value_column].apply(
lambda x: (x / tech_data.loc[(x.name[0],
"Heat production capacity for one unit")][value_column]).iloc[0,:],
axis=1)
tech_data.loc[cost_per_unit, "unit"] = tech_data.loc[cost_per_unit,
"unit"].str.replace("/unit", "/MW_th")
if source == "dea":
# clarify MW -> MW_th
# see on p.278 of docu: "However, the primary purpose of the heat pumps in the
# technology catalogue is heating. In this chapter the unit MW is referring to
# the heat output (also MJ/s) unless otherwise noted"
techs_mwth = ['central air-sourced heat pump', 'central gas boiler',
'central resistive heater', 'decentral air-sourced heat pump',
'decentral gas boiler', 'decentral ground-sourced heat pump' ]
tech_data.loc[techs_mwth, "unit"] = (tech_data.loc[techs_mwth, "unit"]
.replace({"EUR/MW": "EUR/MW_th",
"EUR/MW/year": "EUR/MW_th/year",
'EUR/MWh':'EUR/MWh_th',
"MW": "MW_th"}))
# clarify MW -> MW_e
techs_e = ['fuel cell']
tech_data.loc[techs_e, "unit"] = (tech_data.loc[techs_e, "unit"]
.replace({"EUR/MW": "EUR/MW_e",
"EUR/MW/year": "EUR/MW_e/year",
'EUR/MWh':'EUR/MWh_e',
"MW": "MW_e"}))
if "methanolisation" in tech_data.index:
tech_data = tech_data.sort_index()
tech_data.loc[('methanolisation', 'Variable O&M'), "unit"] = "EUR/MWh_MeOH"
tech_data.unit = tech_data.unit.str.replace("\)", "")
return tech_data
def set_specify_assumptions(tech_data):
"""
for following technologies more specific investment and efficiency
assumptions are taken:
- central resistive heater (investment costs for large > 10 MW
generators are assumed)
- decentral gas boiler (grid connection costs)
- biogas upgrading (include grid connection costs)
- heat pumps (efficiencies for radiators assumed)
to avoid duplicates some investment + efficiency data is dropped for:
- decentral gas boilers (drop duplicated efficiency)
- PV module (drop efficiency)
"""
# for central resistive heater there are investment costs for small (1-5MW)
# and large (>10 MW) generators, assume the costs for large generators
to_drop = [("central resistive heater", 'Nominal investment, 400/690 V; 1-5 MW')]
# for decentral gas boilers total and heat efficiency given, the values are
# the same, drop one of the rows to avoid duplicates
to_drop.append(("decentral gas boiler", "Heat efficiency, annual average, net"))
# for decentral gas boilers there are investment costs and possible
# additional investments which apply for grid connection if the house is
# not connected yet those costs are added as an extra row since the
# lifetime of the branchpipe is assumed to be 50 years (see comment K in
# excel sheet)
boiler_connect = tech_data.loc[[("decentral gas boiler",
"Possible additional specific investment"),
("decentral gas boiler",
"Technical lifetime")]]
boiler_connect.loc[("decentral gas boiler", "Technical lifetime"), years] = 50
boiler_connect.rename(index={"decentral gas boiler":
"decentral gas boiler connection"}, inplace=True)
tech_data = pd.concat([tech_data, boiler_connect])
to_drop.append(("decentral gas boiler", "Possible additional specific investment"))
# biogas upgrading investment costs should include grid injection costs
index = tech_data.loc["biogas upgrading"].index.str.contains("investment")
name = 'investment (upgrading, methane redution and grid injection)'
inv = tech_data.loc["biogas upgrading"].loc[index].groupby(["unit", "source"]).sum().reset_index()
new = pd.concat([tech_data.loc["biogas upgrading"].loc[~index],
inv]).rename({0:name})
new.index = pd.MultiIndex.from_product([["biogas upgrading"],
new.index.to_list()])
tech_data.drop("biogas upgrading", level=0, inplace=True)
tech_data = pd.concat([tech_data, new])
# drop PV module conversion efficiency
tech_data = tech_data.drop("PV module conversion efficiency [p.u.]", level=1)
# heat pump efficiencies are assumed the one's for existing building,
# in the DEA they do differ between heating the floor area or heating with
# radiators, since most households heat with radiators and there
# efficiencies are lower (conservative approach) those are assumed
# furthermore the total efficiency is assumed which includes auxilary electricity
# consumption
name = 'Heat efficiency, annual average, net, radiators'
techs_radiator = tech_data.xs(name, level=1).index
for tech in techs_radiator:
df = tech_data.loc[tech]
df = df[(~df.index.str.contains("efficiency")) | (df.index==name)]
df.rename(index={name: name + ", existing one family house"}, inplace=True)
df.index = pd.MultiIndex.from_product([[tech], df.index.to_list()])
tech_data.drop(tech, level=0, inplace=True)
tech_data = pd.concat([tech_data, df])
tech_data = tech_data.drop(to_drop)
return tech_data.sort_index()
def set_round_trip_efficiency(tech_data):
"""
get round trip efficiency for hydrogen and battery storage
assume for battery sqrt(DC efficiency) and split into inverter + storage
rename investment rows for easier sorting
"""
# hydrogen storage
to_drop = [("hydrogen storage tank type 1 including compressor", ' - Charge efficiency')]
to_drop.append(("hydrogen storage tank type 1 including compressor", ' - Discharge efficiency'))
to_drop.append(("hydrogen storage underground", ' - Charge efficiency'))
to_drop.append(("hydrogen storage underground", ' - Discharge efficiency'))
tech_data.loc[("hydrogen storage underground", "Round trip efficiency"), years] *= 100
tech_data.loc[("hydrogen storage tank type 1 including compressor", "Round trip efficiency"), years] *= 100
# battery split into inverter and storage, assume for efficiency sqr(round trip DC)
df = tech_data.loc["battery"]
inverter = df.loc[['Round trip efficiency DC',
'Output capacity expansion cost',
'Technical lifetime', 'Fixed O&M']]
inverter.rename(index ={'Output capacity expansion cost':
'Output capacity expansion cost investment'},
inplace=True)
# Manual correction based on footnote.
inverter.loc['Technical lifetime', years] = 10.
inverter.loc['Technical lifetime', 'source'] += ', Note K.'
inverter.index = pd.MultiIndex.from_product([["battery inverter"],
inverter.index.to_list()])
storage = df.reindex(index=['Technical lifetime',
'Energy storage expansion cost'])
storage.rename(index={'Energy storage expansion cost':
'Energy storage expansion cost investment'}, inplace=True)
storage.index = pd.MultiIndex.from_product([["battery storage"],
storage.index.to_list()])
tech_data.drop("battery", level=0, inplace=True)
tech_data = pd.concat([tech_data, inverter, storage])
return tech_data.sort_index()
def order_data(tech_data):
"""
check if the units of different variables are conform
-> print warning if not
return a pd.Dataframe 'data' in pypsa tech data syntax (investment, FOM,
VOM, efficiency)
"""
clean_df = {}
for tech in tech_data.index.get_level_values(0).unique():
clean_df[tech] = pd.DataFrame()
switch = False
df = tech_data.loc[tech]
# --- investment ----
investment = df[(df.index.str.contains("investment") |
df.index.str.contains("Distribution network costs"))
& ((df.unit=="EUR/MW")|
(df.unit=="EUR/MW_e")|
(df.unit=="EUR/MW_th - heat output")|
(df.unit=="EUR/MW_th excluding drive energy")|
(df.unit=="EUR/MW_th") |
(df.unit=="EUR/MW_MeOH") |
(df.unit=="EUR/MW_FT/year") |
(df.unit=="EUR/MW_NH3") |
(df.unit=="EUR/MWhCapacity") |
(df.unit=="EUR/MWh") |
(df.unit=="EUR/MW_CH4") |
(df.unit=="EUR/MWh/year") |
(df.unit=="EUR/MW_e, 2020") |
(df.unit=="EUR/MW input") |
(df.unit=='EUR/MW-methanol') |
(df.unit=="EUR/t_N2/h")) # air separation unit
].copy()
if len(investment)!=1:
switch = True
print("check investment: ", tech, " ",