Simple usage
Introduction¶
The present notebook creates a simple district heating load curve for a distrcit heating supplying only space heating requirements (i.e. no industry and no domestic hot water). Additionally, the aggregated monthly data chosen as inputs are considered to already account for heat losses (representative of a case where aggregated monthly data were collected at the production plant boundaries).
import numpy as np
import pandas as pd
import plotly.graph_objects as go
import plotly.io as pio
# Needed for correct layout of the produced html
pio.renderers.default='notebook'
pd.options.plotting.backend = "plotly"
Imports of input data¶
In this Section, input data are loaded.
These input data are composed of a trajectory of external temperature and the dates of heating season.
from heatpro.external_factors import ExternalFactors, EXTERNAL_TEMPERATURE_NAME, HEATING_SEASON_NAME
#loading external temperature
df = pd.read_csv('../data/external_factors.csv',index_col=0,parse_dates=True).iloc[:8760]
#Seating External Factors
external_factors = ExternalFactors(df)
external_factors.data.astype(float).plot()
Calculation of induced factors based on the input data¶
In this Section, induced factors are calculated.
For this example, departure and return temperature are calculated as well as the ground temperature.
from heatpro.external_factors import basic_temperature_departure, basic_temperature_return, kasuda_soil_temperature
induced_factors = pd.concat((
basic_temperature_departure(external_factors,
T_max_HS=90,
T_max_NHS=60,
T_min_HS=50,
T_min_NHS=48,
T_ext_mid=15,
T_ext_min=-15,
),
basic_temperature_return(external_factors,
T_HS=40,
T_NHS=42,
),
kasuda_soil_temperature(external_factors,
d=1,
alpha=2.42*24*3600/(840*3200)
),
)
,axis=1)
go.Figure(
data=[
go.Scatter(
x = induced_factors.index,
y = induced_factors["departure_temperature"],
name="Departure"
),
go.Scatter(
x = induced_factors.index,
y = induced_factors["return_temperature"],
name="Return"
),
go.Scatter(
x = induced_factors.index,
y = induced_factors["soil_temperature"],
name="Soil"
),
]
)
Input data for monthly aggregated loads¶
In this Section, the user enters the monthly load for the residential (space heating) demand.
It is here composed of 12 months of data for the year 2021.
from heatpro.temporal_demand import MonthlyHeatDemand
from heatpro.check import ENERGY_FEATURE_NAME
monthly_building_load = MonthlyHeatDemand(
"residential",
pd.DataFrame(
np.array([4000000,2700000,2200000,1800000,900000,0,0,0,0,750000,2000000,2500000,]),
index = pd.date_range('2021',end='2022',freq='MS',inclusive='left'),
columns=[ENERGY_FEATURE_NAME]
)
)
monthly_building_load.data.plot.bar()
Disaggregation of the monthly data at the hourly time step¶
In this Section, hourly data are reconstructed using the monthly loads and user inputs normalized daily.
The firs part of the cell below sets the normalized heat consumption profile for each week. The second parts uses the obtained weights to distribute the monthly loads at an hourly time step.
from heatpro.demand_profile import apply_weekly_hourly_pattern, basic_building_heating_profile, BUILDING_FELT_TEMPERATURE_NAME
from heatpro.disaggregation import weekly_weighted_disaggregate
hourly_mapping = {(day,hour):1 for day in range(7) for hour in range(24)}
for day in [0,1,2,3,4]:
for hour in [0,1,2,3,4,19,20,21,22,23]:
hourly_mapping[day,hour] = 0.8
for day in [5,6]:
for hour in range(24):
hourly_mapping[day,hour] = 0.8
hourly_mapping = {key:value/sum(hourly_mapping.values()) for key, value in hourly_mapping.items()}
hourly_residential_profile = basic_building_heating_profile(
felt_temperature=pd.DataFrame(external_factors.data[EXTERNAL_TEMPERATURE_NAME].ewm(24).mean().rename(BUILDING_FELT_TEMPERATURE_NAME)),
non_heating_temperature=18,
hourly_weight=apply_weekly_hourly_pattern(
hourly_index=external_factors.data.index,
hourly_mapping=hourly_mapping
)
)
hourly_residential_load = weekly_weighted_disaggregate(
monthly_demand=monthly_building_load,
weights=hourly_residential_profile,
)
hourly_residential_load.data['thermal_energy_kWh'].plot()
Correction of the return temperature¶
In this Section, a variation of the return temperature is imposed. In this example, the user chooses to have a maximum 4K difference compared to the initial return temperature trajectory. The 'fit' method calculates maximal and minimal flow rates to cope with this 4K difference. Then, the flow rate trajectory and consequently the return temperature trajectory is corrected.
from heatpro.district_heating_load import DistrictHeatingLoad
district_heating = DistrictHeatingLoad(
demands = [
hourly_residential_load,
],
external_factors=external_factors,
district_network_temperature=induced_factors,
delta_temperature=4,
cp=4.18,
)
district_heating.fit()
district_heating.data.astype(float).plot()