constants.py moved from MEB and monthly_to_hourly_demand.py created but not finished

This commit is contained in:
pilar 2020-10-19 10:07:03 -04:00
parent c878b13bc5
commit 6f7bde1716
3 changed files with 77 additions and 0 deletions

View File

@ -43,6 +43,7 @@ class Building(CityObject):
self._monthly_cooling = pd.DataFrame() self._monthly_cooling = pd.DataFrame()
self._hourly_heating = pd.DataFrame() self._hourly_heating = pd.DataFrame()
self._hourly_cooling = pd.DataFrame() self._hourly_cooling = pd.DataFrame()
self._hourly_external_temperature = []
# ToDo: Check this for LOD4 # ToDo: Check this for LOD4
self._thermal_zones = [] self._thermal_zones = []
@ -337,3 +338,19 @@ class Building(CityObject):
:param value: DataFrame(cooling demand) :param value: DataFrame(cooling demand)
""" """
self._hourly_cooling.append(value) self._hourly_cooling.append(value)
@property
def hourly_external_temperature(self):
"""
hourly temperature surrounding the building in Celsius
:return: [external_temperature]
"""
return self._hourly_external_temperature
@hourly_external_temperature.setter
def hourly_external_temperature(self, value):
"""
hourly temperature surrounding the building in Celsius
:param value: [external_temperature]
"""
self._hourly_external_temperature = value

View File

@ -0,0 +1,58 @@
"""
monthly_to_hourly_demand module
SPDX - License - Identifier: LGPL - 3.0 - or -later
Copyright © 2020 Project Author Pilar Monsalvete pilar_monsalvete@yahoo.es
"""
import pandas as pd
import helpers.constants as cte
class MonthlyToHourlyDemand:
"""
MonthlyToHourlyDemand class
"""
def __init__(self, building):
self._hourly_heating = pd.DataFrame()
self._hourly_cooling = pd.DataFrame()
self._building = building
@property
def hourly_heating(self):
# todo: this method and the insel model have to be reviewed for more than one thermal zone
external_temp = self._building.hourly_external_temperature
# todo: review index depending on how the schedules are defined, either 8760 or 24 hours
# todo: usage_zone values not implemented
period = 'day'
for usage_zone in self._building.usage_zones:
temp_set = usage_zone.heating_setpoint_schedule(period)
temp_back = usage_zone.heating_setback_schedule(period)
heating_schedule = usage_zone.heating_schedule_month
self._hourly_heating = pd.DataFrame(columns=['monthly to hourly'])
i = 0
for month in range(0, 12):
temp_grad_month = 0
for day in cte.days_of_month[month]:
external_temp_med = 0
for hour in range(0, 24):
external_temp_med += external_temp[i]/24
for hour in range(0, 24):
if external_temp_med < temp_set[i] & heating_schedule[month] == 1:
schedule = usage_zone.heating_schedule_day[day]
if schedule[hour] == 1:
temp_grad_day = temp_set[i] - external_temp[i]
else:
temp_grad_day = temp_back[i] - external_temp[i]
else:
temp_grad_day = 0
temp_grad_month += temp_grad_day
self._hourly_heating.append(self._building.monthly_heating(month)*temp_grad_day/temp_grad_month)
i += 1
return self._hourly_heating
@property
def hourly_cooling(self) -> NotImplementedError:
raise NotImplementedError

2
helpers/constants.py Normal file
View File

@ -0,0 +1,2 @@
celsius_to_kelvin = 273.15
days_of_month = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]