diff --git a/city_model_structure/building.py b/city_model_structure/building.py index dc75bb10..af09f207 100644 --- a/city_model_structure/building.py +++ b/city_model_structure/building.py @@ -2,6 +2,7 @@ Building module SPDX - License - Identifier: LGPL - 3.0 - or -later Copyright © 2020 Project Author Guille Gutierrez guillermo.gutierrezmorote@concordia.ca +contributors: Pilar Monsalvete pilar_monsalvete@yahoo.es """ from typing import List diff --git a/city_model_structure/monthly_to_hourly_demand.py b/city_model_structure/monthly_to_hourly_demand.py index 5eb9f9a3..13160b50 100644 --- a/city_model_structure/monthly_to_hourly_demand.py +++ b/city_model_structure/monthly_to_hourly_demand.py @@ -18,16 +18,20 @@ class MonthlyToHourlyDemand: @property def hourly_heating(self): + """ + hourly distribution of the monthly heating of a building + :return: [hourly_heating] + """ # 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 temp_back = usage_zone.heating_setback - occupancy = usage_zone.occupancy(period) + occupancy = usage_zone.occupancy.occupant_schedule(period) + # todo: heating_schedule is still missing heating_schedule = usage_zone.heating_schedule_month self._hourly_heating = pd.DataFrame(columns=['monthly to hourly']) @@ -40,8 +44,7 @@ class MonthlyToHourlyDemand: 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: + if occupancy[hour] == 1: temp_grad_day = temp_set[i] - external_temp[i] else: temp_grad_day = temp_back[i] - external_temp[i] diff --git a/city_model_structure/occupancy.py b/city_model_structure/occupancy.py index 7f7e0cb1..6560e302 100644 --- a/city_model_structure/occupancy.py +++ b/city_model_structure/occupancy.py @@ -11,7 +11,8 @@ class Occupancy: """ def __init__(self, internal_heat_gain, heat_dissipation, occupant_rate, occupant_type, occupant_zone, - number_of_occupants, arrival_time, departure_time, break_time, day_of_week, pd_of_meetings_duration): + number_of_occupants, arrival_time=None, departure_time=None, break_time=None, day_of_week=None, + pd_of_meetings_duration=None, occupant_schedule=None): """ Constructor """ @@ -21,12 +22,13 @@ class Occupancy: self._occupant_rate = occupant_rate self._occupant_type = occupant_type self._occupant_zone = occupant_zone + self._occupant_schedule = occupant_schedule self._number_of_occupants = number_of_occupants - self._arrival_time = arrival_time = None - self._departure_time = departure_time = None - self._break_time = break_time = None - self._day_of_week = day_of_week = None - self._pd_of_meetings_duration = pd_of_meetings_duration = None + self._arrival_time = arrival_time + self._departure_time = departure_time + self._break_time = break_time + self._day_of_week = day_of_week + self._pd_of_meetings_duration = pd_of_meetings_duration @property def internal_heat_gain(self): @@ -68,6 +70,14 @@ class Occupancy: """ return self._occupant_zone + @property + def occupant_schedule(self): + """ + Get the schedule when an occupant is in a zone + :return: occupant schedule + """ + return self._occupant_schedule + @property def number_of_occupants(self): """ @@ -101,7 +111,7 @@ class Occupancy: return self._break_time @property - def day_of_week (self): + def day_of_week(self): """ Get the day of the week :return: day of the week @@ -114,4 +124,4 @@ class Occupancy: Get the probability distribution of the meeting duration :return: probability distribution of the meeting duration """ - return self._pd_of_meetings_duration \ No newline at end of file + return self._pd_of_meetings_duration diff --git a/city_model_structure/usage_zone.py b/city_model_structure/usage_zone.py index c1429bf4..c2a00097 100644 --- a/city_model_structure/usage_zone.py +++ b/city_model_structure/usage_zone.py @@ -7,6 +7,7 @@ from typing import List from city_model_structure.internal_gains import InternalGains from helpers.configuration_helper import ConfigurationHelper +from city_model_structure.occupancy import Occupancy class UsageZone: @@ -24,6 +25,8 @@ class UsageZone: # todo: this must come from library, talk to Rabeeh self._mechanical_air_change = ConfigurationHelper().min_air_change + self._occupancy = None + @property def internal_gains(self) -> List[InternalGains]: """ @@ -159,3 +162,19 @@ class UsageZone: :return: None """ self._usage = value + + @property + def occupancy(self) -> List[Occupancy]: + """ + Get occupancy data + :return: [Occupancy] + """ + return self._occupancy + + @occupancy.setter + def occupancy(self, values): + """ + Set occupancy + :param values: [Occupancy] + """ + self._occupancy = values diff --git a/occupancy/occupancy_feeders/demo_occupancy_parameters.py b/occupancy/occupancy_feeders/demo_occupancy_parameters.py index cecc0e8e..7f97d250 100644 --- a/occupancy/occupancy_feeders/demo_occupancy_parameters.py +++ b/occupancy/occupancy_feeders/demo_occupancy_parameters.py @@ -28,7 +28,7 @@ class DemoOccupancyParameters: row['7pm'], row['8pm'], row['9pm'], row['10pm'], row['11pm'], row['12pm']] row = occupancy.iloc[index + 2] building.sunday_schedule = [row['1am'], row['2am'], row['3am'], row['4am'], row['5am'], row['6am'], - row['7am'], row['8am'], row['9am'], row['10am'], row['11am'], row['12am'], - row['1pm'], row['2pm'], row['3pm'], row['4pm'], row['5pm'], row['6pm'], - row['7pm'], row['8pm'], row['9pm'], row['10pm'], row['11pm'], row['12pm']] + row['7am'], row['8am'], row['9am'], row['10am'], row['11am'], row['12am'], + row['1pm'], row['2pm'], row['3pm'], row['4pm'], row['5pm'], row['6pm'], + row['7pm'], row['8pm'], row['9pm'], row['10pm'], row['11pm'], row['12pm']] break