From bb76d05f178b3bad8f155d3f8d0c1bc8c4b8ff70 Mon Sep 17 00:00:00 2001 From: Guille Gutierrez Date: Tue, 8 Aug 2023 13:06:34 -0400 Subject: [PATCH 1/4] Update hub/version.py --- hub/version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hub/version.py b/hub/version.py index 21ec607b..b04fde01 100644 --- a/hub/version.py +++ b/hub/version.py @@ -1,4 +1,4 @@ """ Hub version number """ -__version__ = '0.1.8.3' +__version__ = '0.1.8.4' From deb04cbe2d7f0076f7b1529d8cfefaffdfabf20c Mon Sep 17 00:00:00 2001 From: Guille Date: Wed, 9 Aug 2023 13:52:55 -0400 Subject: [PATCH 2/4] Add retrieve result test and correct lock in sqlalchemy --- hub/helpers/constants.py | 1 + .../data/montreal_function_to_hub_function.py | 43 ++++++++++++++++++- .../helpers/construction_helper.py | 17 +++++++- 3 files changed, 59 insertions(+), 2 deletions(-) diff --git a/hub/helpers/constants.py b/hub/helpers/constants.py index 31f89eff..7cd6151e 100644 --- a/hub/helpers/constants.py +++ b/hub/helpers/constants.py @@ -166,6 +166,7 @@ PARKING_GARAGE = 'parking garage' RELIGIOUS = 'religious' NON_HEATED = 'non-heated' DATACENTER = 'datacenter' +FARM = 'farm' LIGHTING = 'Lights' OCCUPANCY = 'Occupancy' diff --git a/hub/helpers/data/montreal_function_to_hub_function.py b/hub/helpers/data/montreal_function_to_hub_function.py index cf557044..e03020af 100644 --- a/hub/helpers/data/montreal_function_to_hub_function.py +++ b/hub/helpers/data/montreal_function_to_hub_function.py @@ -583,7 +583,48 @@ class MontrealFunctionToHubFunction: '6353': cte.WAREHOUSE, '3392': cte.INDUSTRY, '5114': cte.STRIP_MALL, - '5131': cte.STRIP_MALL} + '5131': cte.STRIP_MALL, + '3641': cte.INDUSTRY, + '2614': cte.INDUSTRY, + '3661': cte.INDUSTRY, + '2081': cte.INDUSTRY, + '3340': cte.INDUSTRY, + '4928': cte.WORKSHOP, + '3712': cte.INDUSTRY, + '3253': cte.INDUSTRY, + '3860': cte.INDUSTRY, + '3892': cte.INDUSTRY, + '2992': cte.INDUSTRY, + '5598': cte.RETAIL_SHOP_WITHOUT_REFRIGERATED_FOOD, + '4825': cte.NON_HEATED, + '2071': cte.INDUSTRY, + '6495': cte.INDUSTRY, + '2914': cte.INDUSTRY, + '3182': cte.INDUSTRY, + '3791': cte.INDUSTRY, + '3992': cte.INDUSTRY, + '3114': cte.INDUSTRY, + '7920': cte.OFFICE_AND_ADMINISTRATION, + '5891': cte.RESTAURANT, + '5835': cte.SMALL_HOTEL, + '6565': cte.HEALTH_CARE, + '3391': cte.INDUSTRY, + '6615': cte.INDUSTRY, + '3883': cte.INDUSTRY, + '2032': cte.INDUSTRY, + '2994': cte.INDUSTRY, + '4871': cte.INDUSTRY, + '5113': cte.WORKSHOP, + '3571': cte.INDUSTRY, + '2342': cte.INDUSTRY, + '3911': cte.INDUSTRY, + '7444': cte.EDUCATION, + '2221': cte.INDUSTRY, + '8192': cte.FARM, + '2439': cte.INDUSTRY, + '3891': cte.INDUSTRY, + '6354': cte.WORKSHOP + } @property def dictionary(self) -> dict: diff --git a/hub/imports/construction/helpers/construction_helper.py b/hub/imports/construction/helpers/construction_helper.py index cece5716..eddabd33 100644 --- a/hub/imports/construction/helpers/construction_helper.py +++ b/hub/imports/construction/helpers/construction_helper.py @@ -42,7 +42,22 @@ class ConstructionHelper: 'Varennes': '6', 'Laval': '6', 'Longueuil': '6', - 'Saint-Leonard': '6' + 'Saint-Leonard': '6', + 'Mont-Royal': '6', + 'Deux-Montagnes': '6', + 'Dorval': '6', + 'Dollard-Des Ormeaux': '6', + 'Notre-Dame-de-Grace': '6', + 'Westmount': '6', + 'Cote-Saint-Luc': '6', + 'Kirkland': '6', + 'Beaconsfield': '6', + 'Sainte-Catherine': '6', + 'Vaudreuil-Dorion': '6', + 'Saint-Laurent': '6', + 'Pointe-Claire': '6', + 'Boucherville': '6', + 'Mascouche': '6', } _reference_city_to_israel_climate_zone = { From 30908eda6d20c7d29e1293b657ee28d8a31c0e26 Mon Sep 17 00:00:00 2001 From: Guille Date: Wed, 9 Aug 2023 16:12:10 -0400 Subject: [PATCH 3/4] Add retrieve result test and correct lock in sqlalchemy --- hub/city_model_structure/building.py | 3 +- .../building_demand/thermal_control.py | 4 +- .../peak_calculation/loads_calculation.py | 72 +++++++++---------- hub/helpers/peak_loads.py | 9 +-- 4 files changed, 37 insertions(+), 51 deletions(-) diff --git a/hub/city_model_structure/building.py b/hub/city_model_structure/building.py index 9f907325..8d8b5ea3 100644 --- a/hub/city_model_structure/building.py +++ b/hub/city_model_structure/building.py @@ -440,8 +440,7 @@ class Building(CityObject): """ results = {} if cte.HOUR in self.heating_demand: - monthly_values = PeakLoads().\ - peak_loads_from_hourly(self.heating_demand[cte.HOUR]) + monthly_values = PeakLoads().peak_loads_from_hourly(self.heating_demand[cte.HOUR]) else: monthly_values = PeakLoads(self).heating_peak_loads_from_methodology if monthly_values is None: diff --git a/hub/city_model_structure/building_demand/thermal_control.py b/hub/city_model_structure/building_demand/thermal_control.py index d939c4eb..ee3de07c 100644 --- a/hub/city_model_structure/building_demand/thermal_control.py +++ b/hub/city_model_structure/building_demand/thermal_control.py @@ -33,9 +33,7 @@ class ThermalControl: def _minimum_value(schedules): minimum = 1000 for schedule in schedules: - for value in schedule.values: - if value < minimum: - minimum = value + minimum = min(minimum, min(schedule.values)) return minimum @property diff --git a/hub/helpers/peak_calculation/loads_calculation.py b/hub/helpers/peak_calculation/loads_calculation.py index 41a693ba..d10b9715 100644 --- a/hub/helpers/peak_calculation/loads_calculation.py +++ b/hub/helpers/peak_calculation/loads_calculation.py @@ -63,11 +63,10 @@ class LoadsCalculation: :return: int """ heating_load_transmitted = 0 - for internal_zone in self._building.internal_zones: - for thermal_zone in internal_zone.thermal_zones_from_internal_zones: - internal_temperature = thermal_zone.thermal_control.mean_heating_set_point - heating_load_transmitted += self._get_load_transmitted(thermal_zone, internal_temperature, ambient_temperature, - ground_temperature) + for thermal_zone in self._building.thermal_zones_from_internal_zones: + internal_temperature = thermal_zone.thermal_control.mean_heating_set_point + heating_load_transmitted += self._get_load_transmitted(thermal_zone, internal_temperature, ambient_temperature, + ground_temperature) return heating_load_transmitted def get_cooling_transmitted_load(self, ambient_temperature, ground_temperature): @@ -76,11 +75,10 @@ class LoadsCalculation: :return: int """ cooling_load_transmitted = 0 - for internal_zone in self._building.internal_zones: - for thermal_zone in internal_zone.thermal_zones_from_internal_zones: - internal_temperature = thermal_zone.thermal_control.mean_cooling_set_point - cooling_load_transmitted += self._get_load_transmitted(thermal_zone, internal_temperature, ambient_temperature, - ground_temperature) + for thermal_zone in self._building.thermal_zones_from_internal_zones: + internal_temperature = thermal_zone.thermal_control.mean_cooling_set_point + cooling_load_transmitted += self._get_load_transmitted(thermal_zone, internal_temperature, ambient_temperature, + ground_temperature) return cooling_load_transmitted def get_heating_ventilation_load_sensible(self, ambient_temperature): @@ -89,10 +87,9 @@ class LoadsCalculation: :return: int """ heating_ventilation_load = 0 - for internal_zone in self._building.internal_zones: - for thermal_zone in internal_zone.thermal_zones_from_internal_zones: - internal_temperature = thermal_zone.thermal_control.mean_heating_set_point - heating_ventilation_load += self._get_load_ventilation(thermal_zone, internal_temperature, ambient_temperature) + for thermal_zone in self._building.thermal_zones_from_internal_zones: + internal_temperature = thermal_zone.thermal_control.mean_heating_set_point + heating_ventilation_load += self._get_load_ventilation(thermal_zone, internal_temperature, ambient_temperature) return heating_ventilation_load def get_cooling_ventilation_load_sensible(self, ambient_temperature): @@ -101,10 +98,9 @@ class LoadsCalculation: :return: int """ cooling_ventilation_load = 0 - for internal_zone in self._building.internal_zones: - for thermal_zone in internal_zone.thermal_zones_from_internal_zones: - internal_temperature = thermal_zone.thermal_control.mean_cooling_set_point - cooling_ventilation_load += self._get_load_ventilation(thermal_zone, internal_temperature, ambient_temperature) + for thermal_zone in self._building.thermal_zones_from_internal_zones: + internal_temperature = thermal_zone.thermal_control.mean_cooling_set_point + cooling_ventilation_load += self._get_load_ventilation(thermal_zone, internal_temperature, ambient_temperature) return cooling_ventilation_load def get_internal_load_sensible(self): @@ -115,19 +111,18 @@ class LoadsCalculation: cooling_load_occupancy_sensible = 0 cooling_load_lighting = 0 cooling_load_equipment_sensible = 0 - for internal_zone in self._building.internal_zones: - for thermal_zone in internal_zone.thermal_zones_from_internal_zones: - cooling_load_occupancy_sensible += (thermal_zone.occupancy.sensible_convective_internal_gain - + thermal_zone.occupancy.sensible_radiative_internal_gain) \ - * thermal_zone.footprint_area - cooling_load_lighting += ( - thermal_zone.lighting.density * thermal_zone.lighting.convective_fraction + thermal_zone.lighting.density * - thermal_zone.lighting.radiative_fraction - ) * thermal_zone.footprint_area - cooling_load_equipment_sensible += ( - thermal_zone.appliances.density * thermal_zone.appliances.convective_fraction + - thermal_zone.appliances.density * thermal_zone.appliances.radiative_fraction - ) * thermal_zone.footprint_area + for thermal_zone in self._building.thermal_zones_from_internal_zones: + cooling_load_occupancy_sensible += (thermal_zone.occupancy.sensible_convective_internal_gain + + thermal_zone.occupancy.sensible_radiative_internal_gain) \ + * thermal_zone.footprint_area + cooling_load_lighting += ( + thermal_zone.lighting.density * thermal_zone.lighting.convective_fraction + thermal_zone.lighting.density * + thermal_zone.lighting.radiative_fraction + ) * thermal_zone.footprint_area + cooling_load_equipment_sensible += ( + thermal_zone.appliances.density * thermal_zone.appliances.convective_fraction + + thermal_zone.appliances.density * thermal_zone.appliances.radiative_fraction + ) * thermal_zone.footprint_area internal_load = cooling_load_occupancy_sensible + cooling_load_lighting + cooling_load_equipment_sensible return internal_load @@ -137,12 +132,11 @@ class LoadsCalculation: :return: int """ cooling_load_radiation = 0 - for internal_zone in self._building.internal_zones: - for thermal_zone in internal_zone.thermal_zones_from_internal_zones: - for thermal_boundary in thermal_zone.thermal_boundaries: - for thermal_opening in thermal_boundary.thermal_openings: - radiation = thermal_boundary.parent_surface.global_irradiance[cte.HOUR][hour] * cte.WATTS_HOUR_TO_JULES - cooling_load_radiation += ( - thermal_opening.area * (1 - thermal_opening.frame_ratio) * thermal_opening.g_value * radiation - ) + for thermal_zone in self._building.thermal_zones_from_internal_zones: + for thermal_boundary in thermal_zone.thermal_boundaries: + for thermal_opening in thermal_boundary.thermal_openings: + radiation = thermal_boundary.parent_surface.global_irradiance[cte.HOUR][hour] * cte.WATTS_HOUR_TO_JULES + cooling_load_radiation += ( + thermal_opening.area * (1 - thermal_opening.frame_ratio) * thermal_opening.g_value * radiation + ) return cooling_load_radiation diff --git a/hub/helpers/peak_loads.py b/hub/helpers/peak_loads.py index 995e2ada..bd3fd1f5 100644 --- a/hub/helpers/peak_loads.py +++ b/hub/helpers/peak_loads.py @@ -54,13 +54,11 @@ class PeakLoads: """ month = 1 peaks = [0 for _ in range(12)] - print('hv', hourly_values) for i in range(0, len(hourly_values)): if _MONTH_STARTING_HOUR[month] <= i: month += 1 if hourly_values[i] > peaks[month-1]: peaks[month-1] = hourly_values[i] - print('peak', peaks) return peaks @property @@ -75,18 +73,15 @@ class PeakLoads: ambient_temperature = self._building.external_temperature[cte.HOUR] for month in range(0, 12): ground_temperature = self._building.ground_temperature[cte.MONTH]['2'][month] - heating_ambient_temperature = 100 start_hour = _MONTH_STARTING_HOUR[month] end_hour = 8760 if month < 11: end_hour = _MONTH_STARTING_HOUR[month + 1] - for hour in range(start_hour, end_hour): - temperature = ambient_temperature[hour] - if temperature < heating_ambient_temperature: - heating_ambient_temperature = temperature + heating_ambient_temperature = min(ambient_temperature[start_hour:end_hour]) loads = LoadsCalculation(self._building) heating_load_transmitted = loads.get_heating_transmitted_load(heating_ambient_temperature, ground_temperature) heating_load_ventilation_sensible = loads.get_heating_ventilation_load_sensible(heating_ambient_temperature) + # todo: include heating ventilation latent heating_load_ventilation_latent = 0 heating_load = heating_load_transmitted + heating_load_ventilation_sensible + heating_load_ventilation_latent heating_load = max(heating_load, 0) From e2c8ef0c565b0f41f9f08e9bf17d08c128bba8b4 Mon Sep 17 00:00:00 2001 From: Guille Gutierrez Date: Wed, 9 Aug 2023 16:12:41 -0400 Subject: [PATCH 4/4] Update hub/version.py --- hub/version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hub/version.py b/hub/version.py index b04fde01..a8617103 100644 --- a/hub/version.py +++ b/hub/version.py @@ -1,4 +1,4 @@ """ Hub version number """ -__version__ = '0.1.8.4' +__version__ = '0.1.8.5'