diff --git a/helpers/constants.py b/helpers/constants.py index 49ec5aef..31597435 100644 --- a/helpers/constants.py +++ b/helpers/constants.py @@ -1,8 +1,51 @@ +# universal constants KELVIN = 273.15 + +# time MINUTE = 'minute' HOUR = 'hour' DAY = 'day' WEEK = 'week' MONTH = 'month' YEAR = 'year' + +# todo: modify code to use global constants instead of hard-coded values +# surface types +WALL = 'Wall' +GROUND_WALL = 'Ground wall' +GROUND = 'Ground' +ATTIC_FLOOR = 'Attic floor' +ROOF = 'Roof' +INTERIOR_SLAB = 'Interior slab' +INTERIOR_WALL = 'Interior wall' +WINDOW = 'Window' +DOOR = 'Door' +SKYLIGHT = 'Skylight' + +# todo: homogenize function and usage!! +# function +RESIDENTIAL = 'residential' +SFH = 'single family house' +MFH = 'multifamily house' +HOTEL = 'hotel' +HOSPITAL = 'hospital' +OUTPATIENT = 'outpatient' +COMMERCIAL = 'commercial' +STRIP_MALL = 'strip mall' +WAREHOUSE = 'warehouse' +PRIMARY_SCHOOL = 'primary school' +SECONDARY_SCHOOL = 'secondary school' +OFFICE = 'office' +LARGE_OFFICE = 'large office' + +# usage +INDUSTRY = 'industry' +OFFICE_ADMINISTRATION = 'office and administration' +HEALTH_CARE = 'health care' +RETAIL = 'retail' +HALL = 'hall' +RESTAURANT = 'restaurant' +EDUCATION = 'education' + +# general project-related ROUGHNESS = "MediumRough" diff --git a/helpers/enrich_city.py b/helpers/enrich_city.py new file mode 100644 index 00000000..fc4cc337 --- /dev/null +++ b/helpers/enrich_city.py @@ -0,0 +1,71 @@ +""" +Enrich city +SPDX - License - Identifier: LGPL - 3.0 - or -later +Copyright © 2020 Project Author Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca +""" + +from imports.construction_factory import ConstructionFactory +from imports.usage_factory import UsageFactory +from imports.schedules_factory import SchedulesFactory + + +class EnrichCity: + def __init__(self, city): + self._city = city + self._enriched_city = None + self._errors = [] + + @property + def errors(self): + return self._errors + + def enriched_city(self, construction_format=None, usage_format=None, schedules_format=None): + if self._enriched_city is None: + self._errors = [] + + print('original:', len(self._city.buildings)) + if construction_format is not None: + ConstructionFactory(construction_format, self._city).enrich() + for building in self._city.buildings: + # infiltration_rate_system_off is a mandatory parameter. + # If it is not returned, extract the building from the calculation list + if building.thermal_zones[0].infiltration_rate_system_off is None: + self._city.remove_city_object(building) + if self._city.buildings is None: + self._errors.append('no archetype found per construction') + self._enriched_city = self._city + return self._enriched_city + print('enriched with construction:', len(self._city.buildings)) + + if usage_format is not None: + UsageFactory(usage_format, self._city).enrich() + for building in self._city.buildings: + # At least one thermal zone must be created. + # If it is not created, extract the building from the calculation list + if len(building.usage_zones) <= 0: + self._city.remove_city_object(building) + if self._city.buildings is None: + self._errors.append('no archetype found per usage') + self._enriched_city = self._city + return self._enriched_city + print('enriched with usage:', len(self._city.buildings)) + + if schedules_format is not None: + SchedulesFactory(schedules_format, self._city).enrich() + for building in self._city.buildings: + counter_schedules = 0 + for usage_zone in building.usage_zones: + # At least one schedule must be created at each thermal zone. + # If it is not created, extract the building from the calculation list + if len(usage_zone.schedules) > 0: + counter_schedules += 1 + if counter_schedules < len(building.usage_zones): + self._city.remove_city_object(building) + if self._city.buildings is None: + self._errors.append('no archetype found per usage') + self._enriched_city = self._city + return self._enriched_city + print('enriched with occupancy:', len(self._city.buildings)) + + self._enriched_city = self._city + return self._enriched_city diff --git a/imports/construction/helpers/construction_helper.py b/imports/construction/helpers/construction_helper.py index 7257da0d..0a3c1f50 100644 --- a/imports/construction/helpers/construction_helper.py +++ b/imports/construction/helpers/construction_helper.py @@ -4,24 +4,25 @@ SPDX - License - Identifier: LGPL - 3.0 - or -later Copyright © 2020 Project Author Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca """ import sys +from helpers import constants as cte class ConstructionHelper: # NREL function_to_nrel = { - 'residential': 'residential', - 'single family house': 'single family house', - 'multifamily house': 'multifamily house', - 'hotel': 'hotel', - 'hospital': 'hospital', - 'outpatient': 'outpatient', - 'commercial': 'commercial', - 'strip mall': 'strip mall', - 'warehouse': 'warehouse', - 'primary school': 'primary school', - 'secondary school': 'secondary school', - 'office': 'office', - 'large office': 'large office' + cte.RESIDENTIAL: 'residential', + cte.SFH: 'single family house', + cte.MFH: 'multifamily house', + cte.HOTEL: 'hotel', + cte.HOSPITAL: 'hospital', + cte.OUTPATIENT: 'outpatient', + cte.COMMERCIAL: 'commercial', + cte.STRIP_MALL: 'strip mall', + cte.WAREHOUSE: 'warehouse', + cte.PRIMARY_SCHOOL: 'primary school', + cte.SECONDARY_SCHOOL: 'secondary school', + cte.OFFICE: 'office', + cte.LARGE_OFFICE: 'large office' } nrel_function_default_value = 'residential' nrel_standards = { @@ -46,42 +47,42 @@ class ConstructionHelper: 'Duluth': 'ASHRAE_2004:7A', 'Fairbanks': 'ASHRAE_2004:8A' } - nrel_window_types = ['window', 'door', 'skylight'] + nrel_window_types = [cte.WINDOW, cte.DOOR, cte.SKYLIGHT] nrel_construction_types = { - 'Wall': 'exterior wall', - 'Interior wall': 'interior wall', - 'Ground wall': 'ground wall', - 'Ground': 'exterior slab', - 'Attic floor': 'attic floor', - 'Interior slab': 'interior slab', - 'Roof': 'roof' + cte.WALL: 'exterior wall', + cte.INTERIOR_WALL: 'interior wall', + cte.GROUND_WALL: 'ground wall', + cte.GROUND: 'exterior slab', + cte.ATTIC_FLOOR: 'attic floor', + cte.INTERIOR_SLAB: 'interior slab', + cte.ROOF: 'roof' } # NRCAN function_to_nrcan = { - 'residential': 'residential', - 'single family house': 'single family house', - 'multifamily house': 'multifamily house', - 'hotel': 'hotel', - 'hospital': 'hospital', - 'outpatient': 'outpatient', - 'commercial': 'commercial', - 'strip mall': 'strip mall', - 'warehouse': 'warehouse', - 'primary school': 'primary school', - 'secondary school': 'secondary school', - 'office': 'office', - 'large office': 'large office' + cte.RESIDENTIAL: 'residential', + cte.SFH: 'single family house', + cte.MFH: 'multifamily house', + cte.HOTEL: 'hotel', + cte.HOSPITAL: 'hospital', + cte.OUTPATIENT: 'outpatient', + cte.COMMERCIAL: 'commercial', + cte.STRIP_MALL: 'strip mall', + cte.WAREHOUSE: 'warehouse', + cte.PRIMARY_SCHOOL: 'primary school', + cte.SECONDARY_SCHOOL: 'secondary school', + cte.OFFICE: 'office', + cte.LARGE_OFFICE: 'large office' } nrcan_function_default_value = 'residential' - nrcan_window_types = ['window'] + nrcan_window_types = [cte.WINDOW] nrcan_construction_types = { - 'Wall': 'wall', - 'Ground wall': 'basement_wall', - 'Ground': 'floor', - 'Attic floor': 'attic floor', - 'Interior slab': 'interior slab', - 'Roof': 'roof' + cte.WALL: 'exterior wall', + cte.GROUND_WALL: 'ground wall', + cte.GROUND: 'exterior slab', + cte.ATTIC_FLOOR: 'attic floor', + cte.INTERIOR_SLAB: 'interior slab', + cte.ROOF: 'roof' } @staticmethod diff --git a/imports/geometry/helpers/geometry_helper.py b/imports/geometry/helpers/geometry_helper.py index e80f9663..384897d6 100644 --- a/imports/geometry/helpers/geometry_helper.py +++ b/imports/geometry/helpers/geometry_helper.py @@ -4,6 +4,8 @@ SPDX - License - Identifier: LGPL - 3.0 - or -later Copyright © 2020 Project Author Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca """ +import helpers.constants as cte + class GeometryHelper: # function @@ -230,30 +232,30 @@ class GeometryHelper: 'Z9': 'na' } hft_to_function = { - 'residential': 'residential', - 'single family house': 'single family house', - 'multifamily house': 'multifamily house', - 'hotel': 'hotel', - 'hospital': 'hospital', - 'outpatient': 'outpatient', - 'commercial': 'commercial', - 'strip mall': 'strip mall', - 'warehouse': 'warehouse', - 'primary school': 'primary school', - 'secondary school': 'secondary school', - 'office': 'office', - 'large office': 'large office' + 'residential': cte.RESIDENTIAL, + 'single family house': cte.SFH, + 'multifamily house': cte.MFH, + 'hotel': cte.HOTEL, + 'hospital': cte.HOSPITAL, + 'outpatient': cte.OUTPATIENT, + 'commercial': cte.COMMERCIAL, + 'strip mall': cte.STRIP_MALL, + 'warehouse': cte.WAREHOUSE, + 'primary school': cte.PRIMARY_SCHOOL, + 'secondary school': cte.SECONDARY_SCHOOL, + 'office': cte.OFFICE, + 'large office': cte.LARGE_OFFICE } # usage function_to_usage = { 'full service restaurant': 'restaurant', - 'highrise apartment': 'residential', + 'highrise apartment': cte.RESIDENTIAL, 'hospital': 'health care', 'large hotel': 'hotel', 'large office': 'office and administration', 'medium office': 'office and administration', - 'midrise apartment': 'residential', + 'midrise apartment': cte.RESIDENTIAL, 'outpatient healthcare': 'health care', 'primary school': 'education', 'quick service restaurant': 'restaurant', @@ -264,7 +266,7 @@ class GeometryHelper: 'strip mall': 'hall', 'supermarket': 'retail', 'warehouse': 'industry', - 'residential': 'residential' + 'residential': cte.RESIDENTIAL } @staticmethod diff --git a/imports/schedules/helpers/schedules_helper.py b/imports/schedules/helpers/schedules_helper.py index 772ffb54..ed5524de 100644 --- a/imports/schedules/helpers/schedules_helper.py +++ b/imports/schedules/helpers/schedules_helper.py @@ -5,19 +5,20 @@ Copyright © 2020 Project Author Guille Gutierrez guillermo.gutierrezmorote@conc contributors Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca """ import sys +import helpers.constants as cte class SchedulesHelper: usage_to_comnet = { - 'residential': 'C-12 Residential', - 'industry': 'C-10 Warehouse', - 'office and administration': 'C-5 Office', - 'hotel': 'C-3 Hotel', - 'health care': 'C-2 Health', - 'retail': 'C-8 Retail', - 'hall': 'C-8 Retail', - 'restaurant': 'C-7 Restaurant', - 'education': 'C-9 School' + cte.RESIDENTIAL: 'C-12 Residential', + cte.INDUSTRY: 'C-10 Warehouse', + cte.OFFICE_ADMINISTRATION: 'C-5 Office', + cte.HOTEL: 'C-3 Hotel', + cte.HEALTH_CARE: 'C-2 Health', + cte.RETAIL: 'C-8 Retail', + cte.HALL: 'C-8 Retail', + cte.RESTAURANT: 'C-7 Restaurant', + cte.EDUCATION: 'C-9 School' } comnet_default_value = 'C-12 Residential' diff --git a/imports/usage/helpers/usage_helper.py b/imports/usage/helpers/usage_helper.py index e1f27e3a..1657d128 100644 --- a/imports/usage/helpers/usage_helper.py +++ b/imports/usage/helpers/usage_helper.py @@ -4,19 +4,20 @@ SPDX - License - Identifier: LGPL - 3.0 - or -later Copyright © 2020 Project Author Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca """ import sys +import helpers.constants as cte class UsageHelper: usage_to_hft = { - 'residential': 'residential', - 'industry': 'industry', - 'office and administration': 'office and administration', - 'hotel': 'hotel', - 'health care': 'health care', - 'retail': 'retail', - 'hall': 'hall', - 'restaurant': 'restaurant', - 'education': 'education' + cte.RESIDENTIAL: 'residential', + cte.INDUSTRY: 'industry', + cte.OFFICE_ADMINISTRATION: 'office and administration', + cte.HOTEL: 'hotel', + cte.HEALTH_CARE: 'health care', + cte.RETAIL: 'retail', + cte.HALL: 'hall', + cte.RESTAURANT: 'restaurant', + cte.EDUCATION: 'education' } hft_default_value = 'residential' diff --git a/non_functional_tests/test_geometry_factory.py b/non_functional_tests/test_geometry_factory.py index 35f9c1ae..62e30a64 100644 --- a/non_functional_tests/test_geometry_factory.py +++ b/non_functional_tests/test_geometry_factory.py @@ -7,8 +7,6 @@ from pathlib import Path from unittest import TestCase from imports.geometry_factory import GeometryFactory from imports.geometry.helpers.geometry_helper import GeometryHelper -from city_model_structure.city import City -from exports.exports_factory import ExportsFactory class TestGeometryFactory(TestCase):