1
|
|
|
""" |
2
|
|
|
Main module for preparation of model data (static and timeseries) for |
3
|
|
|
heavy duty transport. |
4
|
|
|
|
5
|
|
|
**Contents of this module** |
6
|
|
|
|
7
|
|
|
* Creation of DB tables |
8
|
|
|
* Download and preprocessing of vehicle registration data from BAST |
9
|
|
|
* Calculation of hydrogen demand based on a Voronoi distribution of counted |
10
|
|
|
truck traffic among NUTS 3 regions. |
11
|
|
|
* Writing results to DB |
12
|
|
|
* Mapping demand to H2 buses and writing to DB |
13
|
|
|
|
14
|
|
|
""" |
15
|
|
|
from pathlib import Path |
16
|
|
|
import csv |
17
|
|
|
|
18
|
|
|
from loguru import logger |
19
|
|
|
import requests |
20
|
|
|
|
21
|
|
|
from egon.data import config, db |
22
|
|
|
from egon.data.datasets import Dataset |
23
|
|
|
from egon.data.datasets.emobility.heavy_duty_transport.create_h2_buses import ( |
24
|
|
|
insert_hgv_h2_demand, |
25
|
|
|
) |
26
|
|
|
from egon.data.datasets.emobility.heavy_duty_transport.db_classes import ( |
27
|
|
|
EgonHeavyDutyTransportVoronoi, |
28
|
|
|
) |
29
|
|
|
from egon.data.datasets.emobility.heavy_duty_transport.h2_demand_distribution import ( # noqa: E501 |
30
|
|
|
run_egon_truck, |
31
|
|
|
) |
32
|
|
|
|
33
|
|
|
WORKING_DIR = Path(".", "heavy_duty_transport").resolve() |
34
|
|
|
DATASET_CFG = config.datasets()["mobility_hgv"] |
35
|
|
|
TESTMODE_OFF = ( |
36
|
|
|
config.settings()["egon-data"]["--dataset-boundary"] == "Everything" |
37
|
|
|
) |
38
|
|
|
|
39
|
|
|
|
40
|
|
|
def create_tables(): |
41
|
|
|
""" |
42
|
|
|
Drops existing :py:class:`demand.egon_heavy_duty_transport_voronoi <egon.data.datasets.emobility.heavy_duty_transport.db_classes.EgonHeavyDutyTransportVoronoi>` is extended |
43
|
|
|
table and creates new one. |
44
|
|
|
|
45
|
|
|
""" |
46
|
|
|
engine = db.engine() |
47
|
|
|
EgonHeavyDutyTransportVoronoi.__table__.drop(bind=engine, checkfirst=True) |
48
|
|
|
EgonHeavyDutyTransportVoronoi.__table__.create( |
49
|
|
|
bind=engine, checkfirst=True |
50
|
|
|
) |
51
|
|
|
|
52
|
|
|
logger.debug("Created tables.") |
53
|
|
|
|
54
|
|
|
|
55
|
|
|
def download_hgv_data(): |
56
|
|
|
""" |
57
|
|
|
Downloads BAST data. |
58
|
|
|
|
59
|
|
|
The data is downloaded to file specified in *datasets.yml* in section |
60
|
|
|
*mobility_hgv/original_data/sources/BAST/file*. |
61
|
|
|
|
62
|
|
|
""" |
63
|
|
|
sources = DATASET_CFG["original_data"]["sources"] |
64
|
|
|
|
65
|
|
|
# Create the folder, if it does not exist |
66
|
|
|
WORKING_DIR.mkdir(parents=True, exist_ok=True) |
67
|
|
|
|
68
|
|
|
url = sources["BAST"]["url"] |
69
|
|
|
file = WORKING_DIR / sources["BAST"]["file"] |
70
|
|
|
|
71
|
|
|
response = requests.get(url) |
72
|
|
|
|
73
|
|
|
with open(file, "w") as f: |
74
|
|
|
writer = csv.writer(f) |
75
|
|
|
for line in response.iter_lines(): |
76
|
|
|
writer.writerow(line.decode("ISO-8859-1").split(";")) |
77
|
|
|
|
78
|
|
|
logger.debug("Downloaded BAST data.") |
79
|
|
|
|
80
|
|
|
|
81
|
|
|
class HeavyDutyTransport(Dataset): |
82
|
|
|
""" |
83
|
|
|
Class for preparation of static and timeseries data for heavy duty transport. |
84
|
|
|
|
85
|
|
|
*Dependencies* |
86
|
|
|
* :py:class:`Vg250 <egon.data.datasets.vg250.Vg250>` |
87
|
|
|
* :py:class:`EtragoSetup <egon.data.datasets.etrago_setup.EtragoSetup>` |
88
|
|
|
* :py:class:`GasAreaseGon2035 <egon.data.datasets.gas_areas.GasAreaseGon2035>` |
89
|
|
|
|
90
|
|
|
*Resulting tables* |
91
|
|
|
* :py:class:`demand.egon_heavy_duty_transport_voronoi |
92
|
|
|
<egon.data.datasets.emobility.heavy_duty_transport.db_classes.EgonHeavyDutyTransportVoronoi>` |
93
|
|
|
is created and filled |
94
|
|
|
* :py:class:`grid.egon_etrago_load<egon.data.datasets.etrago_setup.EgonPfHvLoad>` |
95
|
|
|
is extended |
96
|
|
|
* :py:class:`grid.egon_etrago_load_timeseries |
97
|
|
|
<egon.data.datasets.etrago_setup.EgonPfHvLoadTimeseries>` is extended |
98
|
|
|
|
99
|
|
|
*Configuration* |
100
|
|
|
|
101
|
|
|
The config of this dataset can be found in *datasets.yml* in section |
102
|
|
|
*mobility_hgv*. |
103
|
|
|
|
104
|
|
|
*Scenarios and variations* |
105
|
|
|
|
106
|
|
|
Assumptions can be changed within the *datasets.yml*. |
107
|
|
|
|
108
|
|
|
In the context of the eGon project, it is assumed that e-trucks will be |
109
|
|
|
completely hydrogen-powered and in both scenarios the hydrogen consumption is |
110
|
|
|
assumed to be 6.68 kg H2 per 100 km with an additional |
111
|
|
|
`supply chain leakage rate of 0.5 % |
112
|
|
|
<https://www.energy.gov/eere/fuelcells/doe-technical-targets-hydrogen-delivery>`_. |
113
|
|
|
|
114
|
|
|
### Scenario NEP C 2035 |
115
|
|
|
|
116
|
|
|
The ramp-up figures are taken from |
117
|
|
|
`Scenario C 2035 Grid Development Plan 2021-2035 |
118
|
|
|
<https://www.netzentwicklungsplan.de/sites/default/files/paragraphs-files/ |
119
|
|
|
NEP_2035_V2021_2_Entwurf_Teil1.pdf>`_. According to this, 100,000 e-trucks are |
120
|
|
|
expected in Germany in 2035, each covering an average of 100,000 km per year. |
121
|
|
|
In total this means 10 billion km. |
122
|
|
|
|
123
|
|
|
### Scenario eGon100RE |
124
|
|
|
|
125
|
|
|
In the case of the eGon100RE scenario it is assumed that the HGV traffic is |
126
|
|
|
completely hydrogen-powered. The total freight traffic with 40 Billion km is |
127
|
|
|
taken from the |
128
|
|
|
`BMWK Langfristszenarien GHG-emission free scenarios (SNF > 12 t zGG) |
129
|
|
|
<https://www.langfristszenarien.de/enertile-explorer-wAssets/docs/ |
130
|
|
|
LFS3_Langbericht_Verkehr_final.pdf#page=17>`_. |
131
|
|
|
|
132
|
|
|
*Methodology* |
133
|
|
|
|
134
|
|
|
Using a Voronoi interpolation, the censuses of the BASt data is distributed |
135
|
|
|
according to the area fractions of the Voronoi fields within each mv grid or |
136
|
|
|
any other geometries like NUTS-3. |
137
|
|
|
|
138
|
|
|
""" |
139
|
|
|
#: |
140
|
|
|
name: str = "HeavyDutyTransport" |
141
|
|
|
#: |
142
|
|
|
version: str = "0.0.2" |
143
|
|
|
def __init__(self, dependencies): |
144
|
|
|
super().__init__( |
145
|
|
|
name=self.name, |
146
|
|
|
version=self.version, |
147
|
|
|
dependencies=dependencies, |
148
|
|
|
tasks=( |
149
|
|
|
{ |
150
|
|
|
create_tables, |
151
|
|
|
download_hgv_data, |
152
|
|
|
}, |
153
|
|
|
run_egon_truck, |
154
|
|
|
insert_hgv_h2_demand, |
155
|
|
|
), |
156
|
|
|
) |
157
|
|
|
|