Skip to content

Commit

Permalink
Merge branch 'features/#1067-gas_sanitycheck_eGon100RE' into continuo…
Browse files Browse the repository at this point in the history
…us-integration/run-everything-2022-11-10
  • Loading branch information
AmeliaNadal committed Mar 31, 2023
2 parents b4e54ca + 79f3fea commit 4423a68
Show file tree
Hide file tree
Showing 4 changed files with 360 additions and 177 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,8 @@ Changed
created for a single process. This fixes issue `#799`_.
* Insert rural heat per supply technology
`#1026 <https://github.com/openego/eGon-data/issues/1026>`_
* Add sanity checks for gas sector in eGon100RE
`#1067 <https://github.com/openego/eGon-data/issues/1067>`_
* Change hgv data source to use database
`#1086 <https://github.com/openego/eGon-data/issues/1086>`_
* Insert lifetime for components from p-e-s in eGon100RE
Expand Down Expand Up @@ -743,6 +745,8 @@ Bug Fixes
* Fix URL of TYNDP scenario dataset
* Automatically generated tasks now get unique :code:`task_id`\s.
Fixes issue `#985`_ via PR `#986`_.
* Bypass SSL verification
`#1102 <https://github.com/openego/eGon-data/issues/1102>`_
* Fix faulty DSM time series
`#1088 <https://github.com/openego/eGon-data/issues/1088>`_
* Set upper limit on commissioning date for units from MaStR
Expand Down
51 changes: 28 additions & 23 deletions src/egon/data/datasets/gas_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,27 +293,28 @@ def insert_CH4_nodes_list(gas_nodes_list):
dtype={"geom": Geometry()},
)


def define_gas_buses_abroad(scn_name="eGon2035"):
"""
Insert CH4 buses in neighbouring countries to database for eGon2035
Define central CH4 buses in foreign countries for eGon2035
For the scenario eGon2035, insert central CH4 buses in foreign
countries to the database. The considered foreign countries are the
direct neighbouring countries, with the addition of Russia that is
For the scenario eGon2035, define central CH4 buses in foreign
countries. The considered foreign countries are the direct
neighbouring countries, with the addition of Russia that is
considered as a source of fossil CH4.
Therefore, the following steps are executed:
* Definition of the foreign buses with the function
:py:func:`import_central_buses_egon100 <egon.data.datasets.electrical_neighbours.central_buses_egon100>` from
:py:func:`central_buses_egon100 <egon.data.datasets.electrical_neighbours.central_buses_egon100>` from
the module :py:mod:`electrical_neighbours <egon.data.datasets.electrical_neighbours>`
* Removal of the superfluous buses in order to have only one bus
in each neighbouring country
* Removal of the the irrelevant columns
* Addition of the missing information: scn_name and carrier
* Attribution of an id to each bus
* Cleaning of the database table grid.egon_etrago_bus of the
CH4 buses of the specific scenario (eGon2035) out of Germany
* Insertion of the neighbouring buses in the table grid.egon_etrago_bus.
Parameters
----------
scn_name : str
Name of the scenario
Returns
-------
Expand Down Expand Up @@ -391,10 +392,14 @@ def define_gas_buses_abroad(scn_name="eGon2035"):


def insert_gas_buses_abroad(scn_name="eGon2035"):
"""Insert central CH4 buses in foreign countries for eGon2035
"""
Insert CH4 buses in neighbouring countries to database for eGon2035
Insert central gas buses in foreign countries to db, same buses
than the foreign AC buses
* Definition of the CH4 buses abroad with the function
:py:func:`define_gas_buses_abroad`
* Cleaning of the data base table grid.egon_etrago_bus of the
CH4 buses of the specific scenario (eGon2035) out of Germany
* Insertion of the neighbouring buses in the table grid.egon_etrago_bus.
Parameters
----------
Expand Down Expand Up @@ -438,24 +443,22 @@ def define_gas_pipeline_list(
gas_nodes_list, abroad_gas_nodes_list, scn_name="eGon2035"
):
"""
Insert list of gas pipelines into the database
Define gas pipelines in Germany from SciGRID_gas IGGIELGN data
The gas pipelines, modelled as Pypsa links are red from the IGGIELGN_PipeSegments
csv file previously downloded in the function :py:func:`download_SciGRID_gas_data`,
adapted and inserted in the database for the eGon2035 scenario.
The manual corrections allows to:
* Delete gas pipelines disconnected of the rest of the gas grid
* Connect one pipeline (also connected to Norway) disconnected of
the rest of the gas grid
* Correct erroneous country of some pipelines
csv file previously downloded in the function :py:func:`download_SciGRID_gas_data`.
The capacities of the pipelines are determined by the correspondance
table given by the Parameters for the classification of gas pipelines
in `Electricity, heat, and gas sector data for modeling the German system
<https://www.econstor.eu/bitstream/10419/173388/1/1011162628.pdf>`_
related to the pipeline diameter given in the SciGRID_gas dataset.
The database is cleaned before the insertion of the pipelines.
The manual corrections allows to:
* Delete gas pipelines disconnected of the rest of the gas grid
* Connect one pipeline (also connected to Norway) disconnected of
the rest of the gas grid
* Correct erroneous country of some pipelines
Parameters
----------
Expand Down Expand Up @@ -809,9 +812,11 @@ def define_gas_pipeline_list(


def insert_gas_pipeline_list(gas_pipelines_list, scn_name="eGon2035"):
"""Insert list of gas pipelines in the database
"""
Insert list of gas pipelines in the database
Insert detailled description
Receive as argument a list of gas pipelines and insert them into the
data base after cleaning it.
Parameters
----------
Expand Down
83 changes: 54 additions & 29 deletions src/egon/data/datasets/industrial_gas_demand.py
Original file line number Diff line number Diff line change
Expand Up @@ -430,18 +430,59 @@ def insert_industrial_gas_demand_egon2035():
insert_industrial_gas_demand_time_series(industrial_gas_demand)


def calculate_total_demand_100RE():
"""
Calculate total industrial gas demands in Germany in eGon100RE
These global values are red from the p-e-s run.
Returns
-------
H2_total_PES, CH4_total_PES : floats
Total industrial gas demand in Germany in eGon100RE
"""
n = read_network()

try:
H2_total_PES = (
n.loads[n.loads["carrier"] == "H2 for industry"].loc[
"DE0 0 H2 for industry", "p_set"
]
* 8760
)
except KeyError:
H2_total_PES = 42090000
print("Could not find data from PES-run, assigning fallback number.")

try:
CH4_total_PES = (
n.loads[n.loads["carrier"] == "gas for industry"].loc[
"DE0 0 gas for industry", "p_set"
]
* 8760
)
except KeyError:
CH4_total_PES = 105490000
print("Could not find data from PES-run, assigning fallback number.")

return H2_total_PES, CH4_total_PES


def insert_industrial_gas_demand_egon100RE():
"""Insert industrial gas demands into the database for eGon100RE
"""
Insert industrial gas demands into the database for eGon100RE
Insert the industrial CH4 and H2 demands and their associated time
series into the database for the eGon100RE scenario. The data,
previously downloaded in :py:func:`download_industrial_gas_demand`
are adapted by executing the following steps:
series into the database for the eGon100RE scenario by executing the
following steps:
* Clean the database with the fonction :py:func:`delete_old_entries`
* Read and prepare the CH4 and the H2 industrial demands and their
associated time series in Germany with the fonction :py:func:`read_and_process_demand`
* Identify and adjust the total industrial CH4 and H2 loads for Germany
* Calculate total industrial CH4 and H2 demands in Germany in
eGon100RE with the function :py:func:`calculate_total_demand_100RE`
* Adjust the total industrial CH4 and H2 loads for Germany
generated by PyPSA-Eur-Sec
* For the CH4, the time serie used is the one from H2, because
the industrial CH4 demand in the opendata.ffe database is 0
Expand All @@ -455,10 +496,15 @@ def insert_industrial_gas_demand_egon100RE():
* Insert the time series associated to the loads into the database
by executing :py:func:`insert_industrial_gas_demand_time_series`
Parameters
----------
scn_name : str
Name of the scenario
Returns
-------
None
industrial_gas_demand : Dataframe containing the industrial gas demand
in Germany
"""
scn_name = "eGon100RE"
delete_old_entries(scn_name)
Expand All @@ -474,29 +520,8 @@ def insert_industrial_gas_demand_egon100RE():
# adjust H2 and CH4 total demands (values from PES)
# CH4 demand = 0 in 100RE, therefore scale H2 ts
# fallback values see https://github.com/openego/eGon-data/issues/626
n = read_network()

try:
H2_total_PES = (
n.loads[n.loads["carrier"] == "H2 for industry"].loc[
"DE0 0 H2 for industry", "p_set"
]
* 8760
)
except KeyError:
H2_total_PES = 42090000
print("Could not find data from PES-run, assigning fallback number.")

try:
CH4_total_PES = (
n.loads[n.loads["carrier"] == "gas for industry"].loc[
"DE0 0 gas for industry", "p_set"
]
* 8760
)
except KeyError:
CH4_total_PES = 105490000
print("Could not find data from PES-run, assigning fallback number.")
H2_total_PES, CH4_total_PES = calculate_total_demand_100RE()

boundary = settings()["egon-data"]["--dataset-boundary"]
if boundary != "Everything":
Expand Down
Loading

0 comments on commit 4423a68

Please sign in to comment.