clean up, improve docs

This commit is contained in:
AmosSchledorn 2024-08-05 16:11:18 +02:00
parent 2e35bef480
commit 0e8fb80bc4
3 changed files with 41 additions and 30 deletions

View File

@ -420,13 +420,13 @@ def add_power_capacities_installed_before_baseyear(n, grouping_years, costs, bas
def add_heating_capacities_installed_before_baseyear( def add_heating_capacities_installed_before_baseyear(
n, n: pypsa.Network,
baseyear, baseyear: int,
grouping_years, grouping_years: list,
cop: dict, cop: dict,
time_dep_hp_cop: bool, time_dep_hp_cop: bool,
costs, costs: pd.DataFrame,
default_lifetime, default_lifetime: int,
existing_heating: pd.DataFrame, existing_heating: pd.DataFrame,
): ):
""" """
@ -500,7 +500,7 @@ def add_heating_capacities_installed_before_baseyear(
) )
.to_pandas() .to_pandas()
.reindex(index=n.snapshots) .reindex(index=n.snapshots)
if options["time_dep_hp_cop"] if time_dep_hp_cop
else costs.at[costs_name, "efficiency"] else costs.at[costs_name, "efficiency"]
) )

View File

@ -212,6 +212,7 @@ class HeatSystem(Enum):
""" """
Generates the name for the heat pump costs based on the heat source and Generates the name for the heat pump costs based on the heat source and
system. system.
Used to retrieve data from `technology-data <https://github.com/PyPSA/technology-data>`.
Parameters Parameters
---------- ----------
@ -230,6 +231,7 @@ class HeatSystem(Enum):
""" """
Generates the name for the resistive heater costs based on the heat Generates the name for the resistive heater costs based on the heat
system. system.
Used to retrieve data from `technology-data <https://github.com/PyPSA/technology-data>`.
Returns Returns
------- -------
@ -242,6 +244,7 @@ class HeatSystem(Enum):
def gas_boiler_costs_name(self) -> str: def gas_boiler_costs_name(self) -> str:
""" """
Generates the name for the gas boiler costs based on the heat system. Generates the name for the gas boiler costs based on the heat system.
Used to retrieve data from `technology-data <https://github.com/PyPSA/technology-data>`.
Returns Returns
------- -------
@ -254,6 +257,7 @@ class HeatSystem(Enum):
def oil_boiler_costs_name(self) -> str: def oil_boiler_costs_name(self) -> str:
""" """
Generates the name for the oil boiler costs based on the heat system. Generates the name for the oil boiler costs based on the heat system.
Used to retrieve data from `technology-data <https://github.com/PyPSA/technology-data>`.
Returns Returns
------- -------

View File

@ -1780,7 +1780,7 @@ def build_heat_demand(n):
.unstack(level=1) .unstack(level=1)
) )
sectors = ["residential", "services"] sectors = [sector.value for sector in HeatSector]
uses = ["water", "space"] uses = ["water", "space"]
heat_demand = {} heat_demand = {}
@ -1808,10 +1808,21 @@ def build_heat_demand(n):
return heat_demand 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") logger.info("Add heat sector")
sectors = ["residential", "services"] sectors = [sector.value for sector in HeatSector]
heat_demand = build_heat_demand(n) heat_demand = build_heat_demand(n)
@ -3113,27 +3124,23 @@ def add_industry(n, costs):
if options["oil_boilers"]: if options["oil_boilers"]:
nodes = pop_layout.index nodes = pop_layout.index
for name in [ for heat_system in HeatSystem:
"residential rural", if not heat_system == HeatSystem.URBAN_CENTRAL:
"services rural", n.madd(
"residential urban decentral", "Link",
"services urban decentral", nodes + f" {heat_system} oil boiler",
]: p_nom_extendable=True,
n.madd( bus0=spatial.oil.nodes,
"Link", bus1=nodes + f" {heat_system} heat",
nodes + f" {name} oil boiler", bus2="co2 atmosphere",
p_nom_extendable=True, carrier=f"{heat_system} oil boiler",
bus0=spatial.oil.nodes, efficiency=costs.at["decentral oil boiler", "efficiency"],
bus1=nodes + f" {name} heat", efficiency2=costs.at["oil", "CO2 intensity"],
bus2="co2 atmosphere", capital_cost=costs.at["decentral oil boiler", "efficiency"]
carrier=f"{name} oil boiler", * costs.at["decentral oil boiler", "fixed"]
efficiency=costs.at["decentral oil boiler", "efficiency"], * options["overdimension_individual_heating"],
efficiency2=costs.at["oil", "CO2 intensity"], lifetime=costs.at["decentral oil boiler", "lifetime"],
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( n.madd(
"Link", "Link",