refactor naming
This commit is contained in:
parent
4a6dd2fe33
commit
318e05c9fb
@ -7,23 +7,35 @@ import numpy as np
|
|||||||
import pandas as pd
|
import pandas as pd
|
||||||
import xarray as xr
|
import xarray as xr
|
||||||
from _helpers import set_scenario_config
|
from _helpers import set_scenario_config
|
||||||
|
import sys; sys.path.append("..")
|
||||||
|
from scripts._entities import HeatSystemType
|
||||||
from CentralHeatingCopApproximator import CentralHeatingCopApproximator
|
from CentralHeatingCopApproximator import CentralHeatingCopApproximator
|
||||||
from DecentralHeatingCopApproximator import DecentralHeatingCopApproximator
|
from DecentralHeatingCopApproximator import DecentralHeatingCopApproximator
|
||||||
|
|
||||||
|
|
||||||
def get_cop(
|
def get_cop(
|
||||||
heat_system_category: str,
|
heat_system_type: str,
|
||||||
heat_source: str,
|
heat_source: str,
|
||||||
source_inlet_temperature_celsius: xr.DataArray,
|
source_inlet_temperature_celsius: xr.DataArray,
|
||||||
) -> xr.DataArray:
|
) -> xr.DataArray:
|
||||||
if heat_system_category in ["urban decentral", "rural"]:
|
"""
|
||||||
return DecentralHeatingCopApproximator(
|
Calculate the coefficient of performance (COP) for a heating system.
|
||||||
forward_temperature_celsius=snakemake.params.heat_pump_sink_T_decentral_heating,
|
|
||||||
source_inlet_temperature_celsius=source_inlet_temperature_celsius,
|
|
||||||
source_type=heat_source,
|
|
||||||
).approximate_cop()
|
|
||||||
|
|
||||||
elif heat_system_category == "urban central":
|
Parameters
|
||||||
|
----------
|
||||||
|
heat_system_type : str
|
||||||
|
The type of heating system.
|
||||||
|
heat_source : str
|
||||||
|
The heat source used in the heating system.
|
||||||
|
source_inlet_temperature_celsius : xr.DataArray
|
||||||
|
The inlet temperature of the heat source in Celsius.
|
||||||
|
|
||||||
|
Returns
|
||||||
|
-------
|
||||||
|
xr.DataArray
|
||||||
|
The calculated coefficient of performance (COP) for the heating system.
|
||||||
|
"""
|
||||||
|
if HeatSystemType(heat_system_type).is_central:
|
||||||
return CentralHeatingCopApproximator(
|
return CentralHeatingCopApproximator(
|
||||||
forward_temperature_celsius=snakemake.params.forward_temperature_central_heating,
|
forward_temperature_celsius=snakemake.params.forward_temperature_central_heating,
|
||||||
return_temperature_celsius=snakemake.params.return_temperature_central_heating,
|
return_temperature_celsius=snakemake.params.return_temperature_central_heating,
|
||||||
@ -31,10 +43,14 @@ def get_cop(
|
|||||||
source_outlet_temperature_celsius=source_inlet_temperature_celsius
|
source_outlet_temperature_celsius=source_inlet_temperature_celsius
|
||||||
- snakemake.params.heat_source_cooling_central_heating,
|
- snakemake.params.heat_source_cooling_central_heating,
|
||||||
).approximate_cop()
|
).approximate_cop()
|
||||||
|
|
||||||
else:
|
else:
|
||||||
raise ValueError(
|
return DecentralHeatingCopApproximator(
|
||||||
f"Invalid heat system type '{heat_system_category}'. Must be one of ['urban decentral', 'urban central', 'rural]"
|
forward_temperature_celsius=snakemake.params.heat_pump_sink_T_decentral_heating,
|
||||||
)
|
source_inlet_temperature_celsius=source_inlet_temperature_celsius,
|
||||||
|
source_type=heat_source,
|
||||||
|
).approximate_cop()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
@ -50,14 +66,14 @@ if __name__ == "__main__":
|
|||||||
set_scenario_config(snakemake)
|
set_scenario_config(snakemake)
|
||||||
|
|
||||||
cop_all_system_types = []
|
cop_all_system_types = []
|
||||||
for heat_system_category, heat_sources in snakemake.params.heat_pump_sources.items():
|
for heat_system_type, heat_sources in snakemake.params.heat_pump_sources.items():
|
||||||
cop_this_system_type = []
|
cop_this_system_type = []
|
||||||
for heat_source in heat_sources:
|
for heat_source in heat_sources:
|
||||||
source_inlet_temperature_celsius = xr.open_dataarray(
|
source_inlet_temperature_celsius = xr.open_dataarray(
|
||||||
snakemake.input[f"temp_{heat_source.replace('ground', 'soil')}_total"]
|
snakemake.input[f"temp_{heat_source.replace('ground', 'soil')}_total"]
|
||||||
)
|
)
|
||||||
cop_da = get_cop(
|
cop_da = get_cop(
|
||||||
heat_system_category=heat_system_category,
|
heat_system_type=heat_system_type,
|
||||||
heat_source=heat_source,
|
heat_source=heat_source,
|
||||||
source_inlet_temperature_celsius=source_inlet_temperature_celsius,
|
source_inlet_temperature_celsius=source_inlet_temperature_celsius,
|
||||||
)
|
)
|
||||||
|
@ -1829,7 +1829,6 @@ def add_heat(n, costs):
|
|||||||
|
|
||||||
cop = xr.open_dataarray(snakemake.input.cop_profiles)
|
cop = xr.open_dataarray(snakemake.input.cop_profiles)
|
||||||
for heat_system in HeatSystem: #this loops through all heat systems defined in _entities.HeatSystem
|
for heat_system in HeatSystem: #this loops through all heat systems defined in _entities.HeatSystem
|
||||||
# system_type = "central" if heat_system == "urban central" else "decentral"
|
|
||||||
|
|
||||||
if heat_system == HeatSystem.URBAN_CENTRAL:
|
if heat_system == HeatSystem.URBAN_CENTRAL:
|
||||||
nodes = dist_fraction.index[dist_fraction > 0]
|
nodes = dist_fraction.index[dist_fraction > 0]
|
||||||
@ -1886,15 +1885,15 @@ def add_heat(n, costs):
|
|||||||
nodes,
|
nodes,
|
||||||
suffix=f" {heat_system} heat",
|
suffix=f" {heat_system} heat",
|
||||||
bus=nodes + f" {heat_system} heat",
|
bus=nodes + f" {heat_system} heat",
|
||||||
carrier=heat_system.value + " heat",
|
carrier=f"{heat_system} heat",
|
||||||
p_set=heat_load,
|
p_set=heat_load,
|
||||||
)
|
)
|
||||||
|
|
||||||
## Add heat pumps
|
## Add heat pumps
|
||||||
for heat_source in snakemake.params.heat_pump_sources[heat_system.system_category]:
|
for heat_source in snakemake.params.heat_pump_sources[heat_system.system_type.value]:
|
||||||
costs_name = heat_system.heat_pump_costs_name(heat_source)
|
costs_name = heat_system.heat_pump_costs_name(heat_source)
|
||||||
efficiency = (
|
efficiency = (
|
||||||
cop.sel(heat_system=heat_system.system_category, heat_source=heat_source, name=nodes)
|
cop.sel(heat_system=heat_system.system_type.value, heat_source=heat_source, name=nodes)
|
||||||
.to_pandas()
|
.to_pandas()
|
||||||
.reindex(index=n.snapshots)
|
.reindex(index=n.snapshots)
|
||||||
if options["time_dep_hp_cop"]
|
if options["time_dep_hp_cop"]
|
||||||
@ -1917,13 +1916,13 @@ def add_heat(n, costs):
|
|||||||
)
|
)
|
||||||
|
|
||||||
if options["tes"]:
|
if options["tes"]:
|
||||||
n.add("Carrier", heat_system.value + " water tanks")
|
n.add("Carrier", f"{heat_system} water tanks")
|
||||||
|
|
||||||
n.madd(
|
n.madd(
|
||||||
"Bus",
|
"Bus",
|
||||||
nodes + f" {heat_system} water tanks",
|
nodes + f" {heat_system} water tanks",
|
||||||
location=nodes,
|
location=nodes,
|
||||||
carrier=heat_system.value + " water tanks",
|
carrier=f"{heat_system} water tanks",
|
||||||
unit="MWh_th",
|
unit="MWh_th",
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -1933,7 +1932,7 @@ def add_heat(n, costs):
|
|||||||
bus0=nodes + f" {heat_system} heat",
|
bus0=nodes + f" {heat_system} heat",
|
||||||
bus1=nodes + f" {heat_system} water tanks",
|
bus1=nodes + f" {heat_system} water tanks",
|
||||||
efficiency=costs.at["water tank charger", "efficiency"],
|
efficiency=costs.at["water tank charger", "efficiency"],
|
||||||
carrier=heat_system.value + " water tanks charger",
|
carrier=f"{heat_system} water tanks charger",
|
||||||
p_nom_extendable=True,
|
p_nom_extendable=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -1942,12 +1941,12 @@ def add_heat(n, costs):
|
|||||||
nodes + f" {heat_system} water tanks discharger",
|
nodes + f" {heat_system} water tanks discharger",
|
||||||
bus0=nodes + f" {heat_system} water tanks",
|
bus0=nodes + f" {heat_system} water tanks",
|
||||||
bus1=nodes + f" {heat_system} heat",
|
bus1=nodes + f" {heat_system} heat",
|
||||||
carrier=heat_system.value + " water tanks discharger",
|
carrier=f"{heat_system} water tanks discharger",
|
||||||
efficiency=costs.at["water tank discharger", "efficiency"],
|
efficiency=costs.at["water tank discharger", "efficiency"],
|
||||||
p_nom_extendable=True,
|
p_nom_extendable=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
tes_time_constant_days = options["tes_tau"][heat_system.system_type]
|
tes_time_constant_days = options["tes_tau"][heat_system.central_or_decentral]
|
||||||
|
|
||||||
n.madd(
|
n.madd(
|
||||||
"Store",
|
"Store",
|
||||||
@ -1955,21 +1954,21 @@ def add_heat(n, costs):
|
|||||||
bus=nodes + f" {heat_system} water tanks",
|
bus=nodes + f" {heat_system} water tanks",
|
||||||
e_cyclic=True,
|
e_cyclic=True,
|
||||||
e_nom_extendable=True,
|
e_nom_extendable=True,
|
||||||
carrier=heat_system.value + " water tanks",
|
carrier=f"{heat_system} water tanks",
|
||||||
standing_loss=1 - np.exp(-1 / 24 / tes_time_constant_days),
|
standing_loss=1 - np.exp(-1 / 24 / tes_time_constant_days),
|
||||||
capital_cost=costs.at[heat_system.system_type + " water tank storage", "fixed"],
|
capital_cost=costs.at[heat_system.central_or_decentral + " water tank storage", "fixed"],
|
||||||
lifetime=costs.at[heat_system.system_type + " water tank storage", "lifetime"],
|
lifetime=costs.at[heat_system.central_or_decentral + " water tank storage", "lifetime"],
|
||||||
)
|
)
|
||||||
|
|
||||||
if options["resistive_heaters"]:
|
if options["resistive_heaters"]:
|
||||||
key = f"{heat_system.system_type} resistive heater"
|
key = f"{heat_system.central_or_decentral} resistive heater"
|
||||||
|
|
||||||
n.madd(
|
n.madd(
|
||||||
"Link",
|
"Link",
|
||||||
nodes + f" {heat_system} resistive heater",
|
nodes + f" {heat_system} resistive heater",
|
||||||
bus0=nodes,
|
bus0=nodes,
|
||||||
bus1=nodes + f" {heat_system} heat",
|
bus1=nodes + f" {heat_system} heat",
|
||||||
carrier=heat_system.value + " resistive heater",
|
carrier=f"{heat_system} resistive heater",
|
||||||
efficiency=costs.at[key, "efficiency"],
|
efficiency=costs.at[key, "efficiency"],
|
||||||
capital_cost=costs.at[key, "efficiency"]
|
capital_cost=costs.at[key, "efficiency"]
|
||||||
* costs.at[key, "fixed"]
|
* costs.at[key, "fixed"]
|
||||||
@ -1979,7 +1978,7 @@ def add_heat(n, costs):
|
|||||||
)
|
)
|
||||||
|
|
||||||
if options["boilers"]:
|
if options["boilers"]:
|
||||||
key = f"{heat_system.system_type} gas boiler"
|
key = f"{heat_system.central_or_decentral} gas boiler"
|
||||||
|
|
||||||
n.madd(
|
n.madd(
|
||||||
"Link",
|
"Link",
|
||||||
@ -1988,7 +1987,7 @@ def add_heat(n, costs):
|
|||||||
bus0=spatial.gas.df.loc[nodes, "nodes"].values,
|
bus0=spatial.gas.df.loc[nodes, "nodes"].values,
|
||||||
bus1=nodes + f" {heat_system} heat",
|
bus1=nodes + f" {heat_system} heat",
|
||||||
bus2="co2 atmosphere",
|
bus2="co2 atmosphere",
|
||||||
carrier=heat_system.value + " gas boiler",
|
carrier=f"{heat_system} gas boiler",
|
||||||
efficiency=costs.at[key, "efficiency"],
|
efficiency=costs.at[key, "efficiency"],
|
||||||
efficiency2=costs.at["gas", "CO2 intensity"],
|
efficiency2=costs.at["gas", "CO2 intensity"],
|
||||||
capital_cost=costs.at[key, "efficiency"]
|
capital_cost=costs.at[key, "efficiency"]
|
||||||
@ -1998,19 +1997,19 @@ def add_heat(n, costs):
|
|||||||
)
|
)
|
||||||
|
|
||||||
if options["solar_thermal"]:
|
if options["solar_thermal"]:
|
||||||
n.add("Carrier", heat_system.value + " solar thermal")
|
n.add("Carrier", f"{heat_system} solar thermal")
|
||||||
|
|
||||||
n.madd(
|
n.madd(
|
||||||
"Generator",
|
"Generator",
|
||||||
nodes,
|
nodes,
|
||||||
suffix=f" {heat_system} solar thermal collector",
|
suffix=f" {heat_system} solar thermal collector",
|
||||||
bus=nodes + f" {heat_system} heat",
|
bus=nodes + f" {heat_system} heat",
|
||||||
carrier=heat_system.value + " solar thermal",
|
carrier=f"{heat_system} solar thermal",
|
||||||
p_nom_extendable=True,
|
p_nom_extendable=True,
|
||||||
capital_cost=costs.at[heat_system.system_type + " solar thermal", "fixed"]
|
capital_cost=costs.at[heat_system.central_or_decentral + " solar thermal", "fixed"]
|
||||||
* overdim_factor,
|
* overdim_factor,
|
||||||
p_max_pu=solar_thermal[nodes],
|
p_max_pu=solar_thermal[nodes],
|
||||||
lifetime=costs.at[heat_system.system_type + " solar thermal", "lifetime"],
|
lifetime=costs.at[heat_system.central_or_decentral + " solar thermal", "lifetime"],
|
||||||
)
|
)
|
||||||
|
|
||||||
if options["chp"] and heat_system == HeatSystem.URBAN_CENTRAL:
|
if options["chp"] and heat_system == HeatSystem.URBAN_CENTRAL:
|
||||||
@ -2115,7 +2114,7 @@ def add_heat(n, costs):
|
|||||||
) / heat_demand.T.groupby(level=[1]).sum().T
|
) / heat_demand.T.groupby(level=[1]).sum().T
|
||||||
|
|
||||||
for name in n.loads[
|
for name in n.loads[
|
||||||
n.loads.carrier.isin([x + " heat" for x in heat_systems])
|
n.loads.carrier.isin([x + " heat" for x in HeatSystem])
|
||||||
].index:
|
].index:
|
||||||
node = n.buses.loc[name, "location"]
|
node = n.buses.loc[name, "location"]
|
||||||
ct = pop_layout.loc[node, "ct"]
|
ct = pop_layout.loc[node, "ct"]
|
||||||
|
Loading…
Reference in New Issue
Block a user