diff --git a/scripts/add_existing_baseyear.py b/scripts/add_existing_baseyear.py index ff1a3e46..f67c38d9 100644 --- a/scripts/add_existing_baseyear.py +++ b/scripts/add_existing_baseyear.py @@ -420,13 +420,13 @@ def add_power_capacities_installed_before_baseyear(n, grouping_years, costs, bas def add_heating_capacities_installed_before_baseyear( - n, - baseyear, - grouping_years, + n: pypsa.Network, + baseyear: int, + grouping_years: list, cop: dict, time_dep_hp_cop: bool, - costs, - default_lifetime, + costs: pd.DataFrame, + default_lifetime: int, existing_heating: pd.DataFrame, ): """ @@ -500,7 +500,7 @@ def add_heating_capacities_installed_before_baseyear( ) .to_pandas() .reindex(index=n.snapshots) - if options["time_dep_hp_cop"] + if time_dep_hp_cop else costs.at[costs_name, "efficiency"] ) diff --git a/scripts/definitions/heat_system.py b/scripts/definitions/heat_system.py index 2f305644..b907b0fe 100644 --- a/scripts/definitions/heat_system.py +++ b/scripts/definitions/heat_system.py @@ -212,6 +212,7 @@ class HeatSystem(Enum): """ Generates the name for the heat pump costs based on the heat source and system. + Used to retrieve data from `technology-data `. Parameters ---------- @@ -230,6 +231,7 @@ class HeatSystem(Enum): """ Generates the name for the resistive heater costs based on the heat system. + Used to retrieve data from `technology-data `. Returns ------- @@ -242,6 +244,7 @@ class HeatSystem(Enum): def gas_boiler_costs_name(self) -> str: """ Generates the name for the gas boiler costs based on the heat system. + Used to retrieve data from `technology-data `. Returns ------- @@ -254,6 +257,7 @@ class HeatSystem(Enum): def oil_boiler_costs_name(self) -> str: """ Generates the name for the oil boiler costs based on the heat system. + Used to retrieve data from `technology-data `. Returns ------- diff --git a/scripts/prepare_sector_network.py b/scripts/prepare_sector_network.py index d9d0f6e3..585b3f25 100644 --- a/scripts/prepare_sector_network.py +++ b/scripts/prepare_sector_network.py @@ -1780,7 +1780,7 @@ def build_heat_demand(n): .unstack(level=1) ) - sectors = ["residential", "services"] + sectors = [sector.value for sector in HeatSector] uses = ["water", "space"] heat_demand = {} @@ -1808,10 +1808,21 @@ def build_heat_demand(n): return heat_demand -def add_heat(n, costs, cop): +def add_heat(n: pypsa.Network, costs: pd.DataFrame, cop: xr.DataArray): + """ + Add heat sector to the network. + + Parameters: + n (pypsa.Network): The PyPSA network object. + costs (pd.DataFrame): DataFrame containing cost information. + cop (xr.DataArray): DataArray containing coefficient of performance (COP) values. + + Returns: + None + """ logger.info("Add heat sector") - sectors = ["residential", "services"] + sectors = [sector.value for sector in HeatSector] heat_demand = build_heat_demand(n) @@ -3113,27 +3124,23 @@ def add_industry(n, costs): if options["oil_boilers"]: nodes = pop_layout.index - for name in [ - "residential rural", - "services rural", - "residential urban decentral", - "services urban decentral", - ]: - n.madd( - "Link", - nodes + f" {name} oil boiler", - p_nom_extendable=True, - bus0=spatial.oil.nodes, - bus1=nodes + f" {name} heat", - bus2="co2 atmosphere", - carrier=f"{name} oil boiler", - efficiency=costs.at["decentral oil boiler", "efficiency"], - efficiency2=costs.at["oil", "CO2 intensity"], - capital_cost=costs.at["decentral oil boiler", "efficiency"] - * costs.at["decentral oil boiler", "fixed"] - * options["overdimension_individual_heating"], - lifetime=costs.at["decentral oil boiler", "lifetime"], - ) + for heat_system in HeatSystem: + if not heat_system == HeatSystem.URBAN_CENTRAL: + n.madd( + "Link", + nodes + f" {heat_system} oil boiler", + p_nom_extendable=True, + bus0=spatial.oil.nodes, + bus1=nodes + f" {heat_system} heat", + bus2="co2 atmosphere", + carrier=f"{heat_system} oil boiler", + efficiency=costs.at["decentral oil boiler", "efficiency"], + efficiency2=costs.at["oil", "CO2 intensity"], + capital_cost=costs.at["decentral oil boiler", "efficiency"] + * costs.at["decentral oil boiler", "fixed"] + * options["overdimension_individual_heating"], + lifetime=costs.at["decentral oil boiler", "lifetime"], + ) n.madd( "Link",