Skip to content

Commit

Permalink
Merge pull request #784 from openego/fixes/#783-add-resistive-heater-…
Browse files Browse the repository at this point in the history
…capacity

Fixes/#783 add resistive heater capacity
  • Loading branch information
ClaraBuettner committed Jun 22, 2022
2 parents ad64942 + b44593b commit 0d6e9fd
Show file tree
Hide file tree
Showing 6 changed files with 99 additions and 28 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,8 @@ Bug Fixes
`#748 <https://github.com/openego/eGon-data/issues/748>`_
* Add missing dependency to heat_etrago
`#771 <https://github.com/openego/eGon-data/issues/771>`_
* Fix distribution of resistive heaters in district heating grids
`#783 <https://github.com/openego/eGon-data/issues/783>`_

.. _PR #692: https://github.com/openego/eGon-data/pull/692
.. _#343: https://github.com/openego/eGon-data/issues/343
Expand Down
36 changes: 18 additions & 18 deletions src/egon/data/datasets/heat_etrago/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@ def insert_store(scenario, carrier):
)

water_tank_bus.to_postgis(
targets['heat_buses']['table'],
schema=targets['heat_buses']['schema'],
targets["heat_buses"]["table"],
schema=targets["heat_buses"]["schema"],
con=db.engine(),
if_exists="append",
index=False,
Expand All @@ -187,8 +187,8 @@ def insert_store(scenario, carrier):
)

water_tank_charger.to_sql(
targets['heat_links']['table'],
schema=targets['heat_links']['schema'],
targets["heat_links"]["table"],
schema=targets["heat_links"]["schema"],
con=db.engine(),
if_exists="append",
index=False,
Expand All @@ -212,8 +212,8 @@ def insert_store(scenario, carrier):
)

water_tank_discharger.to_sql(
targets['heat_links']['table'],
schema=targets['heat_links']['schema'],
targets["heat_links"]["table"],
schema=targets["heat_links"]["schema"],
con=db.engine(),
if_exists="append",
index=False,
Expand All @@ -227,9 +227,9 @@ def insert_store(scenario, carrier):
"capital_cost": get_sector_parameters("heat", "eGon2035")[
"capital_cost"
][f"{carrier.split('_')[0]}_water_tank"],
"lifetime": get_sector_parameters("heat", "eGon2035")[
"lifetime"
][f"{carrier.split('_')[0]}_water_tank"],
"lifetime": get_sector_parameters("heat", "eGon2035")["lifetime"][
f"{carrier.split('_')[0]}_water_tank"
],
"e_nom_extendable": True,
"store_id": range(
db.next_etrago_id("store"),
Expand All @@ -239,8 +239,8 @@ def insert_store(scenario, carrier):
)

water_tank_store.to_sql(
targets['heat_stores']['table'],
schema=targets['heat_stores']['schema'],
targets["heat_stores"]["table"],
schema=targets["heat_stores"]["schema"],
con=db.engine(),
if_exists="append",
index=False,
Expand Down Expand Up @@ -442,9 +442,9 @@ def insert_central_gas_boilers(scenario="eGon2035"):
central_boilers = link_geom_from_buses(central_boilers, scenario)

# Add efficiency of gas boilers
central_boilers["efficiency"] = get_sector_parameters(
"heat", "eGon2035"
)["efficiency"]["central_gas_boiler"]
central_boilers["efficiency"] = get_sector_parameters("heat", "eGon2035")[
"efficiency"
]["central_gas_boiler"]

# Transform thermal capacity to CH4 installed capacity
central_boilers["p_nom"] = central_boilers.capacity.div(
Expand Down Expand Up @@ -532,9 +532,9 @@ def insert_rural_gas_boilers(scenario="eGon2035"):
rural_boilers = link_geom_from_buses(rural_boilers, scenario)

# Add efficiency of gas boilers
rural_boilers["efficiency"] = get_sector_parameters(
"heat", "eGon2035"
)["efficiency"]["rural_gas_boiler"]
rural_boilers["efficiency"] = get_sector_parameters("heat", "eGon2035")[
"efficiency"
]["rural_gas_boiler"]

# Transform thermal capacity to CH4 installed capacity
rural_boilers["p_nom"] = rural_boilers.capacity.div(
Expand Down Expand Up @@ -601,7 +601,7 @@ class HeatEtrago(Dataset):
def __init__(self, dependencies):
super().__init__(
name="HeatEtrago",
version="0.0.8",
version="0.0.9",
dependencies=dependencies,
tasks=(buses, supply, store),
)
5 changes: 4 additions & 1 deletion src/egon/data/datasets/heat_etrago/power_to_heat.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,10 +213,13 @@ def insert_central_power_to_heat(scenario="eGon2035"):
# Select heat pumps in district heating
central_resistive_heater = db.select_geodataframe(
f"""
SELECT * FROM {sources['district_heating_supply']['schema']}.
SELECT district_heating_id, carrier, category, SUM(capacity) as capacity,
geometry, scenario
FROM {sources['district_heating_supply']['schema']}.
{sources['district_heating_supply']['table']}
WHERE scenario = '{scenario}'
AND carrier = 'resistive_heater'
GROUP BY (district_heating_id, carrier, category, geometry, scenario)
""",
geom_col="geometry",
epsg=4326,
Expand Down
16 changes: 12 additions & 4 deletions src/egon/data/datasets/heat_supply/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from egon.data.datasets.heat_supply.district_heating import (
cascade_heat_supply,
backup_gas_boilers,
backup_resistive_heaters,
)
from egon.data.datasets.heat_supply.individual_heating import (
cascade_heat_supply_indiv,
Expand Down Expand Up @@ -124,6 +125,15 @@ def district_heating():
if_exists="append",
)

backup_rh = backup_resistive_heaters("eGon2035")

backup_rh.to_postgis(
targets["district_heating_supply"]["table"],
schema=targets["district_heating_supply"]["schema"],
con=db.engine(),
if_exists="append",
)


def individual_heating():
"""Insert supply for individual heating
Expand Down Expand Up @@ -160,12 +170,10 @@ class HeatSupply(Dataset):
def __init__(self, dependencies):
super().__init__(
name="HeatSupply",
version="0.0.5",
version="0.0.6",
dependencies=dependencies,
tasks=(
create_tables,
{district_heating,
individual_heating,
potential_germany},
{district_heating, individual_heating, potential_germany},
),
)
64 changes: 61 additions & 3 deletions src/egon/data/datasets/heat_supply/district_heating.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@


def capacity_per_district_heating_category(district_heating_areas, scenario):
""" Calculates target values per district heating category and technology
"""Calculates target values per district heating category and technology
Parameters
----------
Expand Down Expand Up @@ -109,7 +109,7 @@ def set_technology_data():


def select_district_heating_areas(scenario):
""" Selects district heating areas per scenario and assigns size-category
"""Selects district heating areas per scenario and assigns size-category
Parameters
----------
Expand Down Expand Up @@ -164,7 +164,7 @@ def cascade_per_technology(
areas, technologies, capacity_per_category, size_dh, max_geothermal_costs=2
):

""" Add plants of one technology suppliing district heating
"""Add plants of one technology suppliing district heating
Parameters
----------
Expand Down Expand Up @@ -401,6 +401,64 @@ def backup_gas_boilers(scenario):
)


def backup_resistive_heaters(scenario):
"""Adds backup resistive heaters to district heating grids to
meet target values of installed capacities.
Parameters
----------
scenario : str
Name of the scenario.
Returns
-------
Geopandas.GeoDataFrame
List of gas boilers for district heating
"""

# Select district heating areas from database
district_heating_areas = select_district_heating_areas(scenario)

# Select target value
target_value = db.select_dataframe(
f"""
SELECT capacity
FROM supply.egon_scenario_capacities
WHERE carrier = 'urban_central_resistive_heater'
AND scenario_name = '{scenario}'
"""
).capacity[0]

distributed = db.select_dataframe(
f"""
SELECT SUM(capacity) as capacity
FROM supply.egon_district_heating
WHERE carrier = 'resistive_heater'
AND scenario = '{scenario}'
"""
).capacity[0]

if target_value > distributed:
df = gpd.GeoDataFrame(
data={
"district_heating_id": district_heating_areas.index,
"capacity": district_heating_areas.demand.div(
district_heating_areas.demand.sum()
).mul(target_value - distributed),
"carrier": "resistive_heater",
"category": district_heating_areas.category,
"geometry": district_heating_areas.geom.centroid,
"scenario": scenario,
}
)

else:
df = gpd.GeoDataFrame()

return df


def plot_heat_supply(resulting_capacities):

from matplotlib import pyplot as plt
Expand Down
4 changes: 2 additions & 2 deletions src/egon/data/datasets/sanity_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class SanityChecks(Dataset):
def __init__(self, dependencies):
super().__init__(
name="SanityChecks",
version="0.0.1",
version="0.0.2",
dependencies=dependencies,
tasks=(
sanitycheck_eGon2035_electricity,
Expand Down Expand Up @@ -391,7 +391,7 @@ def sanitycheck_eGon2035_heat():
)["urban_central_resistive_heater_mw"].values[0]

resistive_heater_output = db.select_dataframe(
"""SELECT carrier, SUM(p_nom::numeric), 2 as central_resistive_heater_MW
"""SELECT carrier, SUM(p_nom::numeric) as central_resistive_heater_MW
FROM grid.egon_etrago_link
WHERE carrier= 'central_resistive_heater'
AND scn_name IN ('eGon2035')
Expand Down

0 comments on commit 0d6e9fd

Please sign in to comment.