[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
This commit is contained in:
parent
46f9c7b520
commit
5361facbb7
@ -217,19 +217,37 @@ rule build_temperature_profiles:
|
|||||||
|
|
||||||
rule build_cop_profiles:
|
rule build_cop_profiles:
|
||||||
params:
|
params:
|
||||||
heat_pump_sink_T_decentral_heating=config_provider("sector", "heat_pump_sink_T_individual_heating"),
|
heat_pump_sink_T_decentral_heating=config_provider(
|
||||||
forward_temperature_district_heating=config_provider("sector", "district_heating", "forward_temperature"),
|
"sector", "heat_pump_sink_T_individual_heating"
|
||||||
return_temperature_district_heating=config_provider("sector", "district_heating", "return_temperature"),
|
),
|
||||||
heat_source_cooling_district_heating=config_provider("sector", "district_heating", "heat_source_cooling"),
|
forward_temperature_district_heating=config_provider(
|
||||||
heat_pump_cop_approximation_district_heating=config_provider("sector", "district_heating", "heat_pump_cop_approximation"),
|
"sector", "district_heating", "forward_temperature"
|
||||||
|
),
|
||||||
|
return_temperature_district_heating=config_provider(
|
||||||
|
"sector", "district_heating", "return_temperature"
|
||||||
|
),
|
||||||
|
heat_source_cooling_district_heating=config_provider(
|
||||||
|
"sector", "district_heating", "heat_source_cooling"
|
||||||
|
),
|
||||||
|
heat_pump_cop_approximation_district_heating=config_provider(
|
||||||
|
"sector", "district_heating", "heat_pump_cop_approximation"
|
||||||
|
),
|
||||||
input:
|
input:
|
||||||
temp_soil_total=resources("temp_soil_total_elec_s{simpl}_{clusters}.nc"),
|
temp_soil_total=resources("temp_soil_total_elec_s{simpl}_{clusters}.nc"),
|
||||||
temp_air_total=resources("temp_air_total_elec_s{simpl}_{clusters}.nc"),
|
temp_air_total=resources("temp_air_total_elec_s{simpl}_{clusters}.nc"),
|
||||||
output:
|
output:
|
||||||
cop_air_decentral_heating=resources("cop_air_decentral_heating_elec_s{simpl}_{clusters}.nc"),
|
cop_air_decentral_heating=resources(
|
||||||
cop_soil_decentral_heating=resources("cop_soil_decentral_heating_elec_s{simpl}_{clusters}.nc"),
|
"cop_air_decentral_heating_elec_s{simpl}_{clusters}.nc"
|
||||||
cop_air_central_heating=resources("cop_air_central_heating_elec_s{simpl}_{clusters}.nc"),
|
),
|
||||||
cop_soil_central_heating=resources("cop_soil_central_heating_elec_s{simpl}_{clusters}.nc"),
|
cop_soil_decentral_heating=resources(
|
||||||
|
"cop_soil_decentral_heating_elec_s{simpl}_{clusters}.nc"
|
||||||
|
),
|
||||||
|
cop_air_central_heating=resources(
|
||||||
|
"cop_air_central_heating_elec_s{simpl}_{clusters}.nc"
|
||||||
|
),
|
||||||
|
cop_soil_central_heating=resources(
|
||||||
|
"cop_soil_central_heating_elec_s{simpl}_{clusters}.nc"
|
||||||
|
),
|
||||||
resources:
|
resources:
|
||||||
mem_mb=20000,
|
mem_mb=20000,
|
||||||
log:
|
log:
|
||||||
@ -1027,10 +1045,18 @@ rule prepare_sector_network:
|
|||||||
temp_air_total=resources("temp_air_total_elec_s{simpl}_{clusters}.nc"),
|
temp_air_total=resources("temp_air_total_elec_s{simpl}_{clusters}.nc"),
|
||||||
temp_air_rural=resources("temp_air_rural_elec_s{simpl}_{clusters}.nc"),
|
temp_air_rural=resources("temp_air_rural_elec_s{simpl}_{clusters}.nc"),
|
||||||
temp_air_urban=resources("temp_air_urban_elec_s{simpl}_{clusters}.nc"),
|
temp_air_urban=resources("temp_air_urban_elec_s{simpl}_{clusters}.nc"),
|
||||||
cop_soil_decentral_heating=resources("cop_soil_decentral_heating_elec_s{simpl}_{clusters}.nc"),
|
cop_soil_decentral_heating=resources(
|
||||||
cop_air_decentral_heating=resources("cop_air_decentral_heating_elec_s{simpl}_{clusters}.nc"),
|
"cop_soil_decentral_heating_elec_s{simpl}_{clusters}.nc"
|
||||||
cop_air_central_heating=resources("cop_air_central_heating_elec_s{simpl}_{clusters}.nc"),
|
),
|
||||||
cop_soil_central_heating=resources("cop_soil_central_heating_elec_s{simpl}_{clusters}.nc"),
|
cop_air_decentral_heating=resources(
|
||||||
|
"cop_air_decentral_heating_elec_s{simpl}_{clusters}.nc"
|
||||||
|
),
|
||||||
|
cop_air_central_heating=resources(
|
||||||
|
"cop_air_central_heating_elec_s{simpl}_{clusters}.nc"
|
||||||
|
),
|
||||||
|
cop_soil_central_heating=resources(
|
||||||
|
"cop_soil_central_heating_elec_s{simpl}_{clusters}.nc"
|
||||||
|
),
|
||||||
solar_thermal_total=lambda w: (
|
solar_thermal_total=lambda w: (
|
||||||
resources("solar_thermal_total_elec_s{simpl}_{clusters}.nc")
|
resources("solar_thermal_total_elec_s{simpl}_{clusters}.nc")
|
||||||
if config_provider("sector", "solar_thermal")(w)
|
if config_provider("sector", "solar_thermal")(w)
|
||||||
|
@ -38,10 +38,11 @@ References
|
|||||||
[3] Pieper et al., Energy 205 (2020): Comparison of COP estimation methods for large-scale heat pumps used in energy planning, https://doi.org/10.1016/j.energy.2020.117994
|
[3] Pieper et al., Energy 205 (2020): Comparison of COP estimation methods for large-scale heat pumps used in energy planning, https://doi.org/10.1016/j.energy.2020.117994
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from typing import Union
|
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
import xarray as xr
|
from typing import Union
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
import xarray as xr
|
||||||
from _helpers import set_scenario_config
|
from _helpers import set_scenario_config
|
||||||
|
|
||||||
|
|
||||||
@ -54,17 +55,23 @@ def coefficient_of_performance_individual_heating(delta_T, source="air"):
|
|||||||
raise NotImplementedError("'source' must be one of ['air', 'soil']")
|
raise NotImplementedError("'source' must be one of ['air', 'soil']")
|
||||||
|
|
||||||
|
|
||||||
def celsius_to_kelvin(t_celsius: Union[float, xr.DataArray, np.array]) -> Union[float, xr.DataArray, np.array]:
|
def celsius_to_kelvin(
|
||||||
|
t_celsius: Union[float, xr.DataArray, np.array]
|
||||||
|
) -> Union[float, xr.DataArray, np.array]:
|
||||||
if (np.asarray(t_celsius) > 200).any():
|
if (np.asarray(t_celsius) > 200).any():
|
||||||
raise ValueError("t_celsius > 200. Are you sure you are using the right units?")
|
raise ValueError("t_celsius > 200. Are you sure you are using the right units?")
|
||||||
return t_celsius + 273.15
|
return t_celsius + 273.15
|
||||||
|
|
||||||
|
|
||||||
def logarithmic_mean(t_hot: Union[float, xr.DataArray, np.ndarray], t_cold: Union[float, xr.DataArray, np.ndarray]) -> Union[float, xr.DataArray, np.ndarray]:
|
def logarithmic_mean(
|
||||||
|
t_hot: Union[float, xr.DataArray, np.ndarray],
|
||||||
|
t_cold: Union[float, xr.DataArray, np.ndarray],
|
||||||
|
) -> Union[float, xr.DataArray, np.ndarray]:
|
||||||
if (np.asarray(t_hot <= t_cold)).any():
|
if (np.asarray(t_hot <= t_cold)).any():
|
||||||
raise ValueError("t_hot must be greater than t_cold")
|
raise ValueError("t_hot must be greater than t_cold")
|
||||||
return (t_hot - t_cold) / np.log(t_hot / t_cold)
|
return (t_hot - t_cold) / np.log(t_hot / t_cold)
|
||||||
|
|
||||||
|
|
||||||
class CopDistrictHeating:
|
class CopDistrictHeating:
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
@ -142,7 +149,8 @@ class CopDistrictHeating:
|
|||||||
@property
|
@property
|
||||||
def t_sink_mean(self) -> Union[xr.DataArray, np.array]:
|
def t_sink_mean(self) -> Union[xr.DataArray, np.array]:
|
||||||
"""
|
"""
|
||||||
Calculate the logarithmic mean temperature difference between the cold and hot sinks.
|
Calculate the logarithmic mean temperature difference between the cold
|
||||||
|
and hot sinks.
|
||||||
|
|
||||||
Returns
|
Returns
|
||||||
-------
|
-------
|
||||||
@ -166,7 +174,8 @@ class CopDistrictHeating:
|
|||||||
@property
|
@property
|
||||||
def delta_t_lift(self) -> Union[xr.DataArray, np.array]:
|
def delta_t_lift(self) -> Union[xr.DataArray, np.array]:
|
||||||
"""
|
"""
|
||||||
Calculate the temperature lift as the difference between the logarithmic sink and source temperatures.
|
Calculate the temperature lift as the difference between the
|
||||||
|
logarithmic sink and source temperatures.
|
||||||
|
|
||||||
Returns
|
Returns
|
||||||
-------
|
-------
|
||||||
@ -187,14 +196,14 @@ class CopDistrictHeating:
|
|||||||
-------
|
-------
|
||||||
np.array
|
np.array
|
||||||
The ideal Lorenz COP.
|
The ideal Lorenz COP.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
return self.t_sink_mean / self.delta_t_lift
|
return self.t_sink_mean / self.delta_t_lift
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def delta_t_refrigerant_source(self) -> Union[xr.DataArray, np.array]:
|
def delta_t_refrigerant_source(self) -> Union[xr.DataArray, np.array]:
|
||||||
"""
|
"""
|
||||||
Calculate the temperature difference between the refrigerant source inlet and outlet.
|
Calculate the temperature difference between the refrigerant source
|
||||||
|
inlet and outlet.
|
||||||
|
|
||||||
Returns
|
Returns
|
||||||
-------
|
-------
|
||||||
@ -208,7 +217,8 @@ class CopDistrictHeating:
|
|||||||
@property
|
@property
|
||||||
def delta_t_refrigerant_sink(self) -> Union[xr.DataArray, np.array]:
|
def delta_t_refrigerant_sink(self) -> Union[xr.DataArray, np.array]:
|
||||||
"""
|
"""
|
||||||
Temperature difference between the refrigerant and the sink based on approximation.
|
Temperature difference between the refrigerant and the sink based on
|
||||||
|
approximation.
|
||||||
|
|
||||||
Returns
|
Returns
|
||||||
-------
|
-------
|
||||||
@ -220,7 +230,8 @@ class CopDistrictHeating:
|
|||||||
@property
|
@property
|
||||||
def ratio_evaporation_compression_work(self) -> Union[xr.DataArray, np.array]:
|
def ratio_evaporation_compression_work(self) -> Union[xr.DataArray, np.array]:
|
||||||
"""
|
"""
|
||||||
Calculate the ratio of evaporation to compression work based on approximation.
|
Calculate the ratio of evaporation to compression work based on
|
||||||
|
approximation.
|
||||||
|
|
||||||
Returns
|
Returns
|
||||||
-------
|
-------
|
||||||
@ -245,7 +256,8 @@ class CopDistrictHeating:
|
|||||||
self, delta_t_source: Union[xr.DataArray, np.array]
|
self, delta_t_source: Union[xr.DataArray, np.array]
|
||||||
) -> Union[xr.DataArray, np.array]:
|
) -> Union[xr.DataArray, np.array]:
|
||||||
"""
|
"""
|
||||||
Approximates the temperature difference between the refrigerant and the source.
|
Approximates the temperature difference between the refrigerant and the
|
||||||
|
source.
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
----------
|
----------
|
||||||
@ -291,7 +303,6 @@ class CopDistrictHeating:
|
|||||||
|
|
||||||
The approximate temperature difference at the refrigerant sink is calculated using the following formula:
|
The approximate temperature difference at the refrigerant sink is calculated using the following formula:
|
||||||
a * (t_sink_out - t_source_out + 2 * delta_t_pinch) + b * delta_t_sink + c
|
a * (t_sink_out - t_source_out + 2 * delta_t_pinch) + b * delta_t_sink + c
|
||||||
|
|
||||||
"""
|
"""
|
||||||
if refrigerant not in a.keys():
|
if refrigerant not in a.keys():
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
@ -366,16 +377,21 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
delta_T = snakemake.params.heat_pump_sink_T_decentral_heating - source_T
|
delta_T = snakemake.params.heat_pump_sink_T_decentral_heating - source_T
|
||||||
|
|
||||||
cop_individual_heating = coefficient_of_performance_individual_heating(delta_T, source)
|
cop_individual_heating = coefficient_of_performance_individual_heating(
|
||||||
cop_individual_heating.to_netcdf(snakemake.output[f"cop_{source}_decentral_heating"])
|
delta_T, source
|
||||||
|
)
|
||||||
|
cop_individual_heating.to_netcdf(
|
||||||
|
snakemake.output[f"cop_{source}_decentral_heating"]
|
||||||
|
)
|
||||||
|
|
||||||
cop_district_heating = CopDistrictHeating(
|
cop_district_heating = CopDistrictHeating(
|
||||||
forward_temperature_celsius=snakemake.params.forward_temperature_district_heating,
|
forward_temperature_celsius=snakemake.params.forward_temperature_district_heating,
|
||||||
return_temperature_celsius=snakemake.params.return_temperature_district_heating,
|
return_temperature_celsius=snakemake.params.return_temperature_district_heating,
|
||||||
source_inlet_temperature_celsius=source_T,
|
source_inlet_temperature_celsius=source_T,
|
||||||
source_outlet_temperature_celsius=source_T - snakemake.params.heat_source_cooling_district_heating,
|
source_outlet_temperature_celsius=source_T
|
||||||
|
- snakemake.params.heat_source_cooling_district_heating,
|
||||||
).cop()
|
).cop()
|
||||||
|
|
||||||
cop_district_heating.to_netcdf(snakemake.output[f"cop_{source}_central_heating"])
|
cop_district_heating.to_netcdf(
|
||||||
|
snakemake.output[f"cop_{source}_central_heating"]
|
||||||
|
)
|
||||||
|
@ -1827,7 +1827,9 @@ def add_heat(n, costs):
|
|||||||
"air decentral": xr.open_dataarray(snakemake.input.cop_air_decentral_heating)
|
"air decentral": xr.open_dataarray(snakemake.input.cop_air_decentral_heating)
|
||||||
.to_pandas()
|
.to_pandas()
|
||||||
.reindex(index=n.snapshots),
|
.reindex(index=n.snapshots),
|
||||||
"ground decentral": xr.open_dataarray(snakemake.input.cop_soil_decentral_heating)
|
"ground decentral": xr.open_dataarray(
|
||||||
|
snakemake.input.cop_soil_decentral_heating
|
||||||
|
)
|
||||||
.to_pandas()
|
.to_pandas()
|
||||||
.reindex(index=n.snapshots),
|
.reindex(index=n.snapshots),
|
||||||
"air central": xr.open_dataarray(snakemake.input.cop_air_central_heating)
|
"air central": xr.open_dataarray(snakemake.input.cop_air_central_heating)
|
||||||
|
Loading…
Reference in New Issue
Block a user