Skip to content

Commit

Permalink
Merge branch 'features/#790-simplified-H2-restriction' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
fwitte committed Jul 12, 2022
2 parents 992e4a1 + dda5c60 commit b23a5e9
Show file tree
Hide file tree
Showing 4 changed files with 110 additions and 7 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -363,10 +363,12 @@ Changed
`#581 <https://github.com/openego/eGon-data/issues/581>`_
* Update deposit id to access v0.7 of the zenodo repository
`#736 <https://github.com/openego/eGon-data/issues/736>`_
* Include simplified restrictions for H2 feed-in into CH4 grid
`#790 <https://github.com/openego/eGon-data/issues/790>`_
* Update hh electricity profiles
`#735 <https://github.com/openego/eGon-data/issues/735>`_
* Improve CH4 stores and productions aggregation by removing dedicated task
`#PR775 <https://github.com/openego/eGon-data/pull/775>`_
`#775 <https://github.com/openego/eGon-data/pull/775>`_
* Add CH4 stores in Germany for eGon100RE
`#779 <https://github.com/openego/eGon-data/issues/779>`_
* Assigment of H2 and CH4 capacitites for pipelines in eGon100RE
Expand Down
2 changes: 1 addition & 1 deletion src/egon/data/datasets/hydrogen_etrago/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class HydrogenMethaneLinkEtrago(Dataset):
def __init__(self, dependencies):
super().__init__(
name="HydrogenMethaneLinkEtrago",
version="0.0.4",
version="0.0.5",
dependencies=dependencies,
tasks=(insert_h2_to_ch4_to_h2, insert_h2_to_ch4_eGon100RE),
)
Expand Down
106 changes: 102 additions & 4 deletions src/egon/data/datasets/hydrogen_etrago/h2_to_ch4.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,42 @@ def insert_h2_to_ch4_to_h2():

scn_params = get_sector_parameters("gas", scn_name)

pipeline_capacities = db.select_dataframe(
f"""
SELECT bus0, bus1, p_nom FROM grid.egon_etrago_link
WHERE scn_name = '{scn_name}' AND carrier = 'CH4'
AND (
bus0 IN (
SELECT bus_id FROM grid.egon_etrago_bus
WHERE scn_name = '{scn_name}' AND country = 'DE'
) OR bus1 IN (
SELECT bus_id FROM grid.egon_etrago_bus
WHERE scn_name = '{scn_name}' AND country = 'DE'
)
);
"""
)

feed_in["p_nom"] = 0
feed_in["p_nom_extendable"] = False
# calculation of H2 energy share via volumetric share outsourced
# in a mixture of H2 and CH4 with 15 %vol share
H2_share = scn_params["H2_feedin_volumetric_fraction"]
H2_energy_share = H2_CH4_mix_energy_fractions(H2_share)

for bus in feed_in["bus1"].values:
# calculate the total pipeline capacity connected to a specific bus
nodal_capacity = pipeline_capacities.loc[
(pipeline_capacities["bus0"] == bus)
| (pipeline_capacities["bus1"] == bus),
"p_nom",
].sum()
# multiply total pipeline capacity with H2 energy share corresponding
# to volumetric share
feed_in.loc[feed_in["bus1"] == bus, "p_nom"] = (
nodal_capacity * H2_energy_share
)

# Write new entries
for table, carrier in zip(
[methanation, SMR, feed_in], ["H2_to_CH4", "CH4_to_H2", "H2_feedin"]
Expand All @@ -61,10 +97,7 @@ def insert_h2_to_ch4_to_h2():
# set parameters according to carrier name
table["carrier"] = carrier
table["efficiency"] = scn_params["efficiency"][carrier]
if carrier == "H2_feedin":
table["p_nom_extendable"] = False
table["p_nom"] = 1e9
else:
if carrier != "H2_feedin":
table["p_nom_extendable"] = True
table["capital_cost"] = scn_params["capital_cost"][carrier]
table["lifetime"] = scn_params["lifetime"][carrier]
Expand All @@ -88,3 +121,68 @@ def insert_h2_to_ch4_eGon100RE():
copy_and_modify_links(
"eGon2035", "eGon100RE", ["H2_to_CH4", "CH4_to_H2"], "gas"
)


def H2_CH4_mix_energy_fractions(x, T=25, p=50):
"""
Calculate the fraction of H2 with respect to energy in a H2 CH4 mixture.
Given the volumetric fraction of H2 in a H2 and CH4 mixture, the fraction
of H2 with respect to energy is calculated with the ideal gas mixture law.
Beware, that changing the fraction of H2 changes the overall energy within
a specific volume of the mixture. If H2 is fed into CH4, the pipeline
capacity (based on energy) therefore decreases if the volumetric flow
does not change. This effect is neglected in eGon. At 15 vol% H2 the
decrease in capacity equals about 10 % if volumetric flow does not change.
Parameters
----------
x : float
Volumetric fraction of H2 in the mixture
T : int, optional
Temperature of the mixture in °C, by default 25
p : int, optional
Pressure of the mixture in bar, by default 50
Returns
-------
float
Fraction of H2 in mixture with respect to energy (LHV)
"""

# molar masses
M_H2 = 0.00201588
M_CH4 = 0.0160428

# universal gas constant (fluid independent!)
R_u = 8.31446261815324
# individual gas constants
R_H2 = R_u / M_H2
R_CH4 = R_u / M_CH4

# volume is fixed: 1m^3, use ideal gas law at 25 °C, 50 bar
V = 1
T += 273.15
p *= 1e5
# volumetric shares of gases (specify share of H2)
V_H2 = x
V_CH4 = 1 - x

# calculate data of mixture
M_mix = V_H2 * M_H2 + V_CH4 * M_CH4
R_mix = R_u / M_mix
m_mix = p * V / (R_mix * T)

# calulate masses with volumetric shares at mixture pressure
m_H2 = p * V_H2 / (R_H2 * T)
m_CH4 = p * V_CH4 / (R_CH4 * T)

msg = (
"Consistency check faild, individual masses are not equal to sum of "
"masses. Residual is: " + str(m_mix - m_H2 - m_CH4)
)
assert round(m_mix - m_H2 - m_CH4, 6) == 0.0, msg

LHV = {"CH4": 50e6, "H2": 120e6}

return m_H2 * LHV["H2"] / (m_H2 * LHV["H2"] + m_CH4 * LHV["CH4"])
5 changes: 4 additions & 1 deletion src/egon/data/datasets/scenario_parameters/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,10 @@ def gas(scenario):

costs = read_csv(2035)

parameters = {"main_gas_carrier": "CH4"}
parameters = {
"main_gas_carrier": "CH4",
"H2_feedin_volumetric_fraction": 0.15,
}
# Insert effciencies in p.u.
parameters["efficiency"] = {
"power_to_H2": read_costs(costs, "electrolysis", "efficiency"),
Expand Down

0 comments on commit b23a5e9

Please sign in to comment.