From c04a5c5925570b364c747b8e605c7c2d66401bf2 Mon Sep 17 00:00:00 2001 From: Peter Yefi Date: Fri, 8 Apr 2022 13:39:27 -0400 Subject: [PATCH 1/9] Changed return type --- exports/energy_systems/air_source_hp_export.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exports/energy_systems/air_source_hp_export.py b/exports/energy_systems/air_source_hp_export.py index 9ea7f7d7..d9bc1a5b 100644 --- a/exports/energy_systems/air_source_hp_export.py +++ b/exports/energy_systems/air_source_hp_export.py @@ -26,7 +26,7 @@ class AirSourceHPExport(HeatPumpExport): template_path = (base_path / tmp_file) super().__init__(base_path, city, output_path, template_path) - def _extract_model_coff(self, hp_model: str, data_type='heat') -> Union[Tuple[List, List], None]: + def _extract_model_coff(self, hp_model: str, data_type='heat') -> Union[List, None]: """ Extracts heat pump coefficient data for a specific model. e.g 012, 140 From 1c7165610f4c0ea8d4f9c888e8f7ae029d7ed7ee Mon Sep 17 00:00:00 2001 From: Peter Yefi Date: Fri, 8 Apr 2022 14:01:28 -0400 Subject: [PATCH 2/9] Updated file --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 10a17b31..c1c7f0df 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,4 @@ /development_tests/ /data/energy_systems/heat_pumps/*.csv /data/energy_systems/heat_pumps/*.insel -.DS_Store \ No newline at end of file +.DS_Store From 5e69e0f28ae066c1662ee6a524ab2d1d45f1905d Mon Sep 17 00:00:00 2001 From: Peter Yefi Date: Fri, 8 Apr 2022 14:01:46 -0400 Subject: [PATCH 3/9] Deleted cached files --- .../__pycache__/__init__.cpython-38.pyc | Bin 163 -> 0 bytes .../__pycache__/heat_pump_export.cpython-38.pyc | Bin 8925 -> 0 bytes 2 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 exports/energy_systems/__pycache__/__init__.cpython-38.pyc delete mode 100644 exports/energy_systems/__pycache__/heat_pump_export.cpython-38.pyc diff --git a/exports/energy_systems/__pycache__/__init__.cpython-38.pyc b/exports/energy_systems/__pycache__/__init__.cpython-38.pyc deleted file mode 100644 index 2c72bf79a0ddfec56d36678103fa2610d83ed71b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 163 zcmWIL<>g`kf`3iF5<&E15P=LBfgA@QE@lA|DGb33nv8xc8Hzx{2;!HAerR!OQL%nO zYDsEQWolZczDsIxc1eDLeoB6BL1Iz1eokgmv3_brL4HvQkj_gjO0SGBt}HG|%`MiC fkI&4@EQycTE2zB1VUwGmQks)$2eRQa5HkP({PQYb diff --git a/exports/energy_systems/__pycache__/heat_pump_export.cpython-38.pyc b/exports/energy_systems/__pycache__/heat_pump_export.cpython-38.pyc deleted file mode 100644 index f72a477ebe7ebf26c9941029c35997cf0293427f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 8925 zcma)BOK=-UdY%^s4?aYZ6h*G&^;niI!IJnAC3_XckwQwAToTDh@=8X$nHr)8;E(_Y z>KTaQEVwzyxvjJ3R5n#))n2wLhn!NmCZ`;dTTWA{Tylx3a>yyE+Kco3-2-3%kXi#Z zJ>C8P{dZ6I|L(8G#tI64#s9Ik{{51o{3kWiKOK!bc!DP=m{L-h%CwqVQt{SnT3s*c zb)#g|Go?)3ESai=XG>YYjasgrFXfZILTTg+g=Luet-{PVT4|JNPnBY}_4goLc;GtW zW~<)3_qyrx&~n8qu(r|NM7LG;-ActPdu}7Nyhi9-f&0qkPR*+LyzYcS;pyhu3+tNo z$Sb>zz(wsL1Fl!`Tz<=X^u^{QbX}icMCo(uTFnVvURd>;``oK;ht@y+)>>X%Ua~g1 zzvGre>uxLD2HvI%H0x`(;#p0q?xS|6T6etKeA%xT-eTp-deMlDM_v%dnP;tL&5bi( zH9Wr&8*5%UEUIztnOkqtd}YE;|4cOQ;0gW`g{xpom6FEPlFl@yf2))XH{+VF$qbhH zwZTl5{no&?=2#xE94oL9yz^|7jp1EjUsj9*}(U9epJ`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^l(~x>U)HD zL3b!Ti-InkM5Kc|lT5BKeI@r{ZYnpP8_SJMOkbD~IK?skOTw4FJ#L1f2jp~O5;2`v u;Dgu))7Yl From d7f1b46cf5e79438dc3fa7be46f568134a99d041 Mon Sep 17 00:00:00 2001 From: guille Date: Mon, 11 Apr 2022 12:37:46 -0400 Subject: [PATCH 4/9] complete test and correct errors in construction catalog --- catalogs/catalog.py | 1 - catalogs/construction/nrel_catalog.py | 115 +++++++++++--------- catalogs/construction_catalog_factory.py | 14 ++- catalogs/data_models/construction/window.py | 22 ++-- unittests/test_construction_catalog.py | 33 ++++++ unittests/test_greenery_catalog.py | 3 +- 6 files changed, 120 insertions(+), 68 deletions(-) create mode 100644 unittests/test_construction_catalog.py diff --git a/catalogs/catalog.py b/catalogs/catalog.py index 2525177b..06317050 100644 --- a/catalogs/catalog.py +++ b/catalogs/catalog.py @@ -10,7 +10,6 @@ class Catalog: Catalogs base class not implemented instance of the Catalog base class, catalogs will inherit from this class. """ - @property def names(self, category=None): """ Base property to return the catalog entries names diff --git a/catalogs/construction/nrel_catalog.py b/catalogs/construction/nrel_catalog.py index 4b33cbd6..74774241 100644 --- a/catalogs/construction/nrel_catalog.py +++ b/catalogs/construction/nrel_catalog.py @@ -22,41 +22,52 @@ class NrelCatalog(Catalog): archetypes_path = str(Path(path / 'us_archetypes.xml').resolve()) constructions_path = str(Path(path / 'us_constructions.xml').resolve()) with open(constructions_path) as xml: - self._constructions = xmltodict.parse(xml.read(), force_list=('material', 'window', 'construction')) + self._constructions = xmltodict.parse(xml.read(), force_list=('material', 'window', 'construction', 'layer')) with open(archetypes_path) as xml: self._archetypes = xmltodict.parse(xml.read(), force_list=('archetype', 'construction')) - self._catalog_windows = [] - self._catalog_materials = [] - self._catalog_constructions = [] - self._catalog_archetypes = [] + self._catalog_windows = self._load_windows() + self._catalog_materials = self._load_materials() + self._catalog_constructions = self._load_constructions() + self._catalog_archetypes = self._load_archetypes() + # store the full catalog data model in self._content + self._content = Content(self._catalog_archetypes, + self._catalog_constructions, + self._catalog_materials, + self._catalog_windows) + + def _load_windows(self): + _catalog_windows = [] windows = self._constructions['library']['windows']['window'] for window in windows: - frame_ratio = window['frame_ratio'] + frame_ratio = window['frame_ratio']['#text'] g_value = window['shgc'] - overall_u_value = float(window['conductivity']) / float(window['thickness']) - construction_name = window['@name'] - self._catalog_windows.append(Window(frame_ratio, g_value, overall_u_value, construction_name)) + overall_u_value = float(window['conductivity']['#text']) / float(window['thickness']['#text']) + name = window['@name'] + _catalog_windows.append(Window(frame_ratio, g_value, overall_u_value, name)) + return _catalog_windows + def _load_materials(self): + _catalog_materials = [] materials = self._constructions['library']['materials']['material'] for material in materials: material_id = material['@id'] name = material['@name'] - solar_absorptance = material['solar_absorptance'] - thermal_absorptance = material['thermal_absorptance'] - visible_absorptance = material['visible_absorptance'] + solar_absorptance = material['solar_absorptance']['#text'] + thermal_absorptance = material['thermal_absorptance']['#text'] + visible_absorptance = material['visible_absorptance']['#text'] no_mass = True thermal_resistance = None, conductivity = None, density = None, specific_heat = None - if material['no_mass'] == 'true': + if 'no_mass' in material and material['no_mass'] == 'true': no_mass = True - thermal_resistance = material['thermal_resistance'] + thermal_resistance = material['thermal_resistance']['#text'] else: - conductivity = material['conductivity'] - density = material['density'] - specific_heat = material['specific_heat'] + conductivity = material['conductivity']['#text'] + density = material['density']['#text'] + specific_heat = material['specific_heat']['#text'] _material = Material(material_id, name, solar_absorptance, @@ -67,8 +78,11 @@ class NrelCatalog(Catalog): conductivity, density, specific_heat) - self._catalog_materials.append(_material) + _catalog_materials.append(_material) + return _catalog_materials + def _load_constructions(self): + _catalog_constructions = [] constructions = self._constructions['library']['constructions']['construction'] for construction in constructions: construction_id = construction['@id'] @@ -77,32 +91,37 @@ class NrelCatalog(Catalog): layers = [] for layer in construction['layers']['layer']: layer_id = layer['@id'] - name = layer['@name'] + layer_name = layer['@name'] material_id = layer['material'] - thickness = layer['thickness'] - for material in self._materials: + thickness = 0 + if 'thickness' in layer: + thickness = layer['thickness']['#text'] + for material in self._catalog_materials: if material_id == material.id: - layers.append(Layer(layer_id, name, material, thickness)) + layers.append(Layer(layer_id, layer_name, material, thickness)) break - self._catalog_constructions.append(Construction(construction_id, construction_type, name, layers)) + _catalog_constructions.append(Construction(construction_id, construction_type, name, layers)) + return _catalog_constructions + def _load_archetypes(self): + _catalog_archetypes = [] archetypes = self._archetypes['archetypes']['archetype'] for archetype in archetypes: archetype_id = archetype['@id'] function = nrel_to_function[archetype['@building_type']] - construction_period = reference_standard_to_construction_period[archetype['reference_standard']] - average_storey_height = archetype['average_storey_height'] - number_of_storeys = archetype['number_of_storeys'] - thermal_capacity = archetype['thermal_capacity'] - extra_loses_due_to_thermal_bridges = archetype['extra_loses_due_to_thermal_bridges'] - indirect_heated_ratio = archetype['indirect_heated_ratio'] - infiltration_rate_for_ventilation_system_off = archetype['infiltration_rate_for_ventilation_system_off'] - infiltration_rate_for_ventilation_system_on = archetype['infiltration_rate_for_ventilation_system_on'] + construction_period = reference_standard_to_construction_period[archetype['@reference_standard']] + average_storey_height = archetype['average_storey_height']['#text'] + number_of_storeys = archetype['number_of_storeys']['#text'] + thermal_capacity = archetype['thermal_capacity']['#text'] + extra_loses_due_to_thermal_bridges = archetype['extra_loses_due_to_thermal_bridges']['#text'] + indirect_heated_ratio = archetype['indirect_heated_ratio']['#text'] + infiltration_rate_for_ventilation_system_off = archetype['infiltration_rate_for_ventilation_system_off']['#text'] + infiltration_rate_for_ventilation_system_on = archetype['infiltration_rate_for_ventilation_system_on']['#text'] archetype_constructions = [] for archetype_construction in archetype['constructions']['construction']: - for construction in self._constructions: + for construction in self._catalog_constructions: if construction.id == archetype_construction['@id']: - window_ratio = archetype_construction['window_ratio'] + window_ratio = archetype_construction['window_ratio']['#text'] window = archetype_construction['window'] _construction = Construction(construction.id, construction.type, @@ -111,25 +130,19 @@ class NrelCatalog(Catalog): window_ratio, window) archetype_constructions.append(_construction) - self._catalog_archetypes.append(Archetype(archetype_id, - function, - archetype_constructions, - construction_period, - average_storey_height, - number_of_storeys, - thermal_capacity, - extra_loses_due_to_thermal_bridges, - indirect_heated_ratio, - infiltration_rate_for_ventilation_system_off, - infiltration_rate_for_ventilation_system_on)) + _catalog_archetypes.append(Archetype(archetype_id, + function, + archetype_constructions, + construction_period, + average_storey_height, + number_of_storeys, + thermal_capacity, + extra_loses_due_to_thermal_bridges, + indirect_heated_ratio, + infiltration_rate_for_ventilation_system_off, + infiltration_rate_for_ventilation_system_on)) + return _catalog_archetypes - # store the full catalog data model in self._content - self._content = Content(self._catalog_archetypes, - self._catalog_constructions, - self._catalog_materials, - self._catalog_windows) - - @property def names(self, category=None): """ Get the catalog elements names diff --git a/catalogs/construction_catalog_factory.py b/catalogs/construction_catalog_factory.py index 96d20858..14c0dbc6 100644 --- a/catalogs/construction_catalog_factory.py +++ b/catalogs/construction_catalog_factory.py @@ -8,7 +8,7 @@ Project Coder Guille Gutierrez guillermo.gutierrezmorote@concordia.ca from pathlib import Path from typing import TypeVar from catalogs.construction.nrel_catalog import NrelCatalog -from catalogs.construction.nrcan_catalog import NrcanCatalog +# from catalogs.construction.nrcan_catalog import NrcanCatalog Catalog = TypeVar('Catalog') class ConstructionCatalogFactory: @@ -28,7 +28,7 @@ class ConstructionCatalogFactory: """ Retrieve NRCAN catalog """ - return NrcanCatalog(self._city, self._base_path) + # return NrcanCatalog(self._city, self._base_path) @property def catalog(self) -> Catalog: @@ -36,4 +36,12 @@ class ConstructionCatalogFactory: Enrich the city given to the class using the class given handler :return: Catalog """ - return getattr(self, self._catalog_type, lambda: None) \ No newline at end of file + return getattr(self, self._catalog_type, lambda: None) + + @property + def catalog_debug(self) -> Catalog: + """ + Enrich the city given to the class using the class given handler + :return: Catalog + """ + return NrelCatalog(self._path) \ No newline at end of file diff --git a/catalogs/data_models/construction/window.py b/catalogs/data_models/construction/window.py index 1f57f112..9c3a8b04 100644 --- a/catalogs/data_models/construction/window.py +++ b/catalogs/data_models/construction/window.py @@ -6,11 +6,19 @@ Project Coder Guille Gutierrez guillermo.gutierrezmorote@concordia.ca """ class Window: - def __init__(self, frame_ratio, g_value, overall_u_value, construction_name): + def __init__(self, frame_ratio, g_value, overall_u_value, name): self._frame_ratio = frame_ratio self._g_value = g_value self._overall_u_value = overall_u_value - self._construction_name = construction_name + self._name = name + + @property + def name(self): + """ + Get window name + :return: str + """ + return self._name @property def frame_ratio(self): @@ -34,12 +42,4 @@ class Window: Get thermal opening overall U-value in W/m2K :return: float """ - return self._overall_u_value - - @property - def construction_name(self): - """ - Get thermal opening construction name - :return: str - """ - return self._construction_name + return self._overall_u_value \ No newline at end of file diff --git a/unittests/test_construction_catalog.py b/unittests/test_construction_catalog.py new file mode 100644 index 00000000..ed6867cd --- /dev/null +++ b/unittests/test_construction_catalog.py @@ -0,0 +1,33 @@ +""" +TestConstructionCatalog +SPDX - License - Identifier: LGPL - 3.0 - or -later +Copyright © 2022 Concordia CERC group +Project Coder Guille Gutierrez guillermo.gutierrezmorote@concordia.ca +""" + +from unittest import TestCase +from catalogs.construction_catalog_factory import ConstructionCatalogFactory + + +class TestConstructionCatalog(TestCase): + + def test_nrel_catalog(self): + catalog = ConstructionCatalogFactory('nrel').catalog_debug + catalog_categories = catalog.names() + constructions = catalog.names('constructions') + windows = catalog.names('windows') + materials = catalog.names('materials') + self.assertTrue(len(constructions['constructions']), 24) + self.assertTrue(len(windows['windows']), 4) + self.assertTrue(len(materials['materials']), 19) + with self.assertRaises(ValueError): + catalog.names('unknown') + + # retrieving all the entries should not raise any exceptions + for category in catalog_categories: + for value in catalog_categories[category]: + catalog.get_entry(value) + + with self.assertRaises(IndexError): + catalog.get_entry('unknown') + diff --git a/unittests/test_greenery_catalog.py b/unittests/test_greenery_catalog.py index 9cf75a3d..65f3085a 100644 --- a/unittests/test_greenery_catalog.py +++ b/unittests/test_greenery_catalog.py @@ -6,13 +6,12 @@ Project Coder Guille Gutierrez guillermo.gutierrezmorote@concordia.ca """ from unittest import TestCase - from catalogs.greenery_catalog_factory import GreeneryCatalogFactory class TestGreeneryCatalog(TestCase): def test_catalog(self): - catalog = GreeneryCatalogFactory('nrel').catalog_debug + catalog = GreeneryCatalogFactory('nrel').catalog catalog_categories = catalog.names() vegetations = catalog.names('vegetations') plants = catalog.names('plants') From 9287da7a66e42a059844db1d3f85c744e2ec2bab Mon Sep 17 00:00:00 2001 From: guille Date: Mon, 11 Apr 2022 12:44:23 -0400 Subject: [PATCH 5/9] correct merge errors --- catalog_factories/construction_catalog_factory.py | 12 +++++++++++- unittests/test_construction_catalog.py | 4 ++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/catalog_factories/construction_catalog_factory.py b/catalog_factories/construction_catalog_factory.py index 6787bac2..c9794029 100644 --- a/catalog_factories/construction_catalog_factory.py +++ b/catalog_factories/construction_catalog_factory.py @@ -18,12 +18,14 @@ class ConstructionCatalogFactory: self._catalog_type = '_' + file_type.lower() self._path = base_path + @property def _nrel(self): """ Retrieve NREL catalog """ return NrelCatalog(self._path) + @property def _nrcan(self): """ Retrieve NRCAN catalog @@ -36,4 +38,12 @@ class ConstructionCatalogFactory: Enrich the city given to the class using the class given handler :return: Catalog """ - return getattr(self, self._catalog_type, lambda: None) \ No newline at end of file + return getattr(self, self._catalog_type, lambda: None) + + @property + def catalog_debug(self) -> Catalog: + """ + Enrich the city given to the class using the class given handler + :return: Catalog + """ + return self._nrel() \ No newline at end of file diff --git a/unittests/test_construction_catalog.py b/unittests/test_construction_catalog.py index ed6867cd..8ee48cae 100644 --- a/unittests/test_construction_catalog.py +++ b/unittests/test_construction_catalog.py @@ -6,13 +6,13 @@ Project Coder Guille Gutierrez guillermo.gutierrezmorote@concordia.ca """ from unittest import TestCase -from catalogs.construction_catalog_factory import ConstructionCatalogFactory +from catalog_factories.construction_catalog_factory import ConstructionCatalogFactory class TestConstructionCatalog(TestCase): def test_nrel_catalog(self): - catalog = ConstructionCatalogFactory('nrel').catalog_debug + catalog = ConstructionCatalogFactory('nrel').catalog catalog_categories = catalog.names() constructions = catalog.names('constructions') windows = catalog.names('windows') From 3e03ca6f08d38b15f279078024b2169f3b208359 Mon Sep 17 00:00:00 2001 From: guille Date: Mon, 11 Apr 2022 12:45:00 -0400 Subject: [PATCH 6/9] remove debug function --- catalog_factories/construction_catalog_factory.py | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/catalog_factories/construction_catalog_factory.py b/catalog_factories/construction_catalog_factory.py index c9794029..b77fbec9 100644 --- a/catalog_factories/construction_catalog_factory.py +++ b/catalog_factories/construction_catalog_factory.py @@ -38,12 +38,4 @@ class ConstructionCatalogFactory: Enrich the city given to the class using the class given handler :return: Catalog """ - return getattr(self, self._catalog_type, lambda: None) - - @property - def catalog_debug(self) -> Catalog: - """ - Enrich the city given to the class using the class given handler - :return: Catalog - """ - return self._nrel() \ No newline at end of file + return getattr(self, self._catalog_type, lambda: None) \ No newline at end of file From a273c38a4507515ac33b1c3deb19654ccaae1bdb Mon Sep 17 00:00:00 2001 From: guille Date: Mon, 11 Apr 2022 14:32:44 -0400 Subject: [PATCH 7/9] remove nrcan construction library and fix some unit tests --- .../construction/construction_helpers.py | 4 + .../construction/nrcan_catalog.py | 0 .../construction/nrel_catalog.py | 6 +- .../construction_catalog_factory.py | 8 - .../data_models/construction/construction.py | 15 -- data/construction/ca_archetypes_reduced.xml | 165 ------------------ .../construction/ca_constructions_reduced.xml | 156 ----------------- imports/construction/ca_physics_parameters.py | 83 --------- .../helpers/construction_helper.py | 50 +----- imports/construction_factory.py | 13 +- .../air_source_hp_parameters.py | 2 +- unittests/test_construction_factory.py | 30 ---- unittests/test_enrichement.py | 2 +- .../test_life_cycle_assessment_factory.py | 4 +- 14 files changed, 13 insertions(+), 525 deletions(-) delete mode 100644 catalog_factories/construction/nrcan_catalog.py delete mode 100644 data/construction/ca_archetypes_reduced.xml delete mode 100644 data/construction/ca_constructions_reduced.xml delete mode 100644 imports/construction/ca_physics_parameters.py diff --git a/catalog_factories/construction/construction_helpers.py b/catalog_factories/construction/construction_helpers.py index 7ad3fd39..1d9e4bf4 100644 --- a/catalog_factories/construction/construction_helpers.py +++ b/catalog_factories/construction/construction_helpers.py @@ -21,6 +21,10 @@ nrel_to_function = { 'large hotel': cte.LARGE_HOTEL } +nrcan_to_function = { + 'residential': cte.RESIDENTIAL, +} + reference_standard_to_construction_period = { 'ASHRAE 90.1_2004': '2004 - 2009', 'ASHRAE 189.1_2009': '2009 - PRESENT' diff --git a/catalog_factories/construction/nrcan_catalog.py b/catalog_factories/construction/nrcan_catalog.py deleted file mode 100644 index e69de29b..00000000 diff --git a/catalog_factories/construction/nrel_catalog.py b/catalog_factories/construction/nrel_catalog.py index ea7e9dc9..3fc6a0d2 100644 --- a/catalog_factories/construction/nrel_catalog.py +++ b/catalog_factories/construction/nrel_catalog.py @@ -1,5 +1,5 @@ """ -Greenery catalog +Nrel construction catalog SPDX - License - Identifier: LGPL - 3.0 - or -later Copyright © 2022 Concordia CERC group Project Coder Guille Gutierrez guillermo.gutierrezmorote@concordia.ca @@ -14,7 +14,8 @@ from catalog_factories.data_models.construction.layer import Layer from catalog_factories.data_models.construction.construction import Construction from catalog_factories.data_models.construction.content import Content from catalog_factories.data_models.construction.archetype import Archetype -from catalog_factories.construction.construction_helpers import nrel_to_function, reference_standard_to_construction_period +from catalog_factories.construction.construction_helpers import nrel_to_function +from catalog_factories.construction.construction_helpers import reference_standard_to_construction_period class NrelCatalog(Catalog): @@ -213,4 +214,3 @@ class NrelCatalog(Catalog): if entry.name.lower() == name.lower(): return entry raise IndexError(f"{name} doesn't exists in the catalog") - pass diff --git a/catalog_factories/construction_catalog_factory.py b/catalog_factories/construction_catalog_factory.py index b77fbec9..410103a8 100644 --- a/catalog_factories/construction_catalog_factory.py +++ b/catalog_factories/construction_catalog_factory.py @@ -8,7 +8,6 @@ Project Coder Guille Gutierrez guillermo.gutierrezmorote@concordia.ca from pathlib import Path from typing import TypeVar from catalog_factories.construction.nrel_catalog import NrelCatalog -# from catalog_factories.construction.nrcan_catalog import NrcanCatalog Catalog = TypeVar('Catalog') class ConstructionCatalogFactory: @@ -25,13 +24,6 @@ class ConstructionCatalogFactory: """ return NrelCatalog(self._path) - @property - def _nrcan(self): - """ - Retrieve NRCAN catalog - """ - # return NrcanCatalog(self._city, self._base_path) - @property def catalog(self) -> Catalog: """ diff --git a/catalog_factories/data_models/construction/construction.py b/catalog_factories/data_models/construction/construction.py index fc76371b..03eac115 100644 --- a/catalog_factories/data_models/construction/construction.py +++ b/catalog_factories/data_models/construction/construction.py @@ -46,18 +46,3 @@ class Construction: """ return self._layers - @property - def window_ratio(self): - """ - Get construction window ratio (only when used as archetype construction) - :return: (0..1) or None - """ - return self._window_ratio - - @property - def window(self): - """ - Get construction window (only when used as archetype construction) - :return: window or None - """ - return self._window diff --git a/data/construction/ca_archetypes_reduced.xml b/data/construction/ca_archetypes_reduced.xml deleted file mode 100644 index cc7758a3..00000000 --- a/data/construction/ca_archetypes_reduced.xml +++ /dev/null @@ -1,165 +0,0 @@ - - - - - - - 0.2 - 33 - - - - - 3 - 1 - 90 - 0.1 - 0.15 - 0.5 - 0 - - - - - - 0.2 - 34 - - - - - 3 - 1 - 90 - 0.1 - 0.15 - 0.5 - 0 - - - - - - 0.2 - 34 - - - - - 3 - 1 - 90 - 0.1 - 0.15 - 0.5 - 0 - - - - - - 0.2 - 34 - - - - - 3 - 1 - 90 - 0.1 - 0.15 - 0.5 - 0 - - - - - - 0.13 - 34 - - - - - 3 - 1 - 90 - 0.1 - 0.15 - 0.3 - 0 - - - - - - 0.13 - 34 - - - - - 3 - 1 - 90 - 0.05 - 0.15 - 0.3 - 0 - - - - - - 0.13 - 34 - - - - - 3 - 1 - 90 - 0.05 - 0.15 - 0.3 - 0 - - - - - - 0.13 - 34 - - - - - 3 - 1 - 90 - 0.05 - 0.15 - 0.3 - 0 - - - - - - 0.13 - 34 - - - - - 3 - 1 - 90 - 0.05 - 0.15 - 0.3 - 0 - - diff --git a/data/construction/ca_constructions_reduced.xml b/data/construction/ca_constructions_reduced.xml deleted file mode 100644 index 42bf460e..00000000 --- a/data/construction/ca_constructions_reduced.xml +++ /dev/null @@ -1,156 +0,0 @@ - - - - - 0.46 - 0.46 - 0.3 - 1.8 - - - 0.52 - 0.52 - 0.3 - 2.7 - - - 0.52 - 0.52 - 0.3 - 0.8 - - - - - 0.18 - 0.8 - 0.2 - - - 0.17 - 0.8 - 0.2 - - - 0.17 - 0.8 - 0.2 - - - 0.253 - 0.8 - 0.2 - - - 0.253 - 0.8 - 0.2 - - - 0.253 - 0.8 - 0.2 - - - 0.253 - 0.8 - 0.2 - - - 0.26 - 0.8 - 0.2 - - #wall above grade - - 0.3 - 0.7 - 0.3 - - - 0.30 - 0.7 - 0.3 - - - 0.32 - 0.7 - 0.3 - - - 0.327 - 0.7 - 0.3 - - - 0.327 - 0.7 - 0.3 - - - 0.364 - 0.7 - 0.3 - - - 0.411 - 0.7 - 0.3 - - - 0.411 - 0.7 - 0.3 - - #wall below grade - - 0.512 - - - 0.512 - - - 0.67 - - - 0.848 - - - 1.048 - - - 1.154 - - - 1.243 - - - 1.425 - - #slab on grade - - 0.512 - - - 0.67 - - - 0.67 - - - 0.848 - - - 0.848 - - - 1.05 - - - 1.154 - - - 1.154 - - - diff --git a/imports/construction/ca_physics_parameters.py b/imports/construction/ca_physics_parameters.py deleted file mode 100644 index 445bb378..00000000 --- a/imports/construction/ca_physics_parameters.py +++ /dev/null @@ -1,83 +0,0 @@ -""" -CaPhysicsParameters import the construction and material information for Canada -SPDX - License - Identifier: LGPL - 3.0 - or -later -Copyright © 2022 Concordia CERC group -Project Coder Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca -""" -import sys -from imports.construction.helpers.construction_helper import ConstructionHelper -from imports.construction.nrel_physics_interface import NrelPhysicsInterface - - -class CaPhysicsParameters(NrelPhysicsInterface): - """ - CaPhysicsParameters class - """ - def __init__(self, city, base_path): - super().__init__(base_path, 'ca_constructions_reduced.xml', 'ca_archetypes_reduced.xml') - self._city = city - - def enrich_buildings(self): - """ - Returns the city with the construction parameters assigned to the buildings - :return: None - """ - city = self._city - # it is assumed that all buildings have the same archetypes' keys - for building in city.buildings: - try: - archetype = self._search_archetype(ConstructionHelper.nrcan_from_libs_function(building.function), - building.year_of_construction) - except KeyError: - sys.stderr.write(f'Building {building.name} has unknown archetype for building function: ' - f'{ConstructionHelper.nrcan_from_libs_function(building.function)} ' - f'and building year of construction: {building.year_of_construction}\n') - return - - # if building has no thermal zones defined from geometry, one thermal zone per storey is assigned - if len(building.internal_zones) == 1: - if building.internal_zones[0].thermal_zones is None: - self._create_storeys(building, archetype) - - self._assign_values(building.internal_zones, archetype) - for internal_zone in building.internal_zones: - for thermal_zone in internal_zone.thermal_zones: - self._calculate_view_factors(thermal_zone) - - def _search_archetype(self, function, year_of_construction): - for building_archetype in self._building_archetypes: - a_ft = str(building_archetype.archetype_keys['@function']) - a_pc = str(building_archetype.archetype_keys['@periodOfConstruction']) - a_yc1 = int(a_pc.split(sep='-')[0]) - a_yc2 = int(a_pc.split(sep='-')[1]) - if a_ft == str(function): - if a_yc1 <= int(year_of_construction) <= a_yc2: - return building_archetype - return None - - def _assign_values(self, internal_zones, archetype): - for internal_zone in internal_zones: - for thermal_zone in internal_zone.thermal_zones: - thermal_zone.additional_thermal_bridge_u_value = archetype.additional_thermal_bridge_u_value - thermal_zone.effective_thermal_capacity = archetype.effective_thermal_capacity - thermal_zone.indirectly_heated_area_ratio = archetype.indirectly_heated_area_ratio - thermal_zone.infiltration_rate_system_on = archetype.infiltration_rate_system_on - thermal_zone.infiltration_rate_system_off = archetype.infiltration_rate_system_off - for thermal_boundary in thermal_zone.thermal_boundaries: - construction_type = ConstructionHelper.nrcan_construction_types[thermal_boundary.type] - thermal_boundary_archetype = self._search_construction_in_archetype(archetype, construction_type) - thermal_boundary.u_value = thermal_boundary_archetype.overall_u_value - thermal_boundary.outside_solar_absorptance = thermal_boundary_archetype.outside_solar_absorptance - thermal_boundary.construction_name = thermal_boundary_archetype.construction_name - try: - thermal_boundary.window_ratio = thermal_boundary_archetype.window_ratio - except ValueError: - # This is the normal operation way when the windows are defined in the geometry - continue - if thermal_boundary.thermal_openings is not None: - for thermal_opening in thermal_boundary.thermal_openings: - if thermal_boundary_archetype.thermal_opening_archetype is not None: - thermal_opening_archetype = thermal_boundary_archetype.thermal_opening_archetype - thermal_opening.frame_ratio = thermal_opening_archetype.frame_ratio - thermal_opening.g_value = thermal_opening_archetype.g_value - thermal_opening.overall_u_value = thermal_opening_archetype.overall_u_value diff --git a/imports/construction/helpers/construction_helper.py b/imports/construction/helpers/construction_helper.py index c81180ed..04c45b6c 100644 --- a/imports/construction/helpers/construction_helper.py +++ b/imports/construction/helpers/construction_helper.py @@ -71,42 +71,6 @@ class ConstructionHelper: cte.ROOF: 'roof' } - # NRCAN - _function_to_nrcan = { - cte.RESIDENTIAL: 'residential', - cte.SINGLE_FAMILY_HOUSE: 'residential', - cte.MULTI_FAMILY_HOUSE: 'residential', - cte.ROW_HOSE: 'residential', - cte.MID_RISE_APARTMENT: 'residential', - cte.HIGH_RISE_APARTMENT: 'residential', - cte.SMALL_OFFICE: cte.SMALL_OFFICE, - cte.MEDIUM_OFFICE: cte.MEDIUM_OFFICE, - cte.LARGE_OFFICE: cte.LARGE_OFFICE, - cte.PRIMARY_SCHOOL: cte.PRIMARY_SCHOOL, - cte.SECONDARY_SCHOOL: cte.SECONDARY_SCHOOL, - cte.STAND_ALONE_RETAIL: cte.STAND_ALONE_RETAIL, - cte.HOSPITAL: cte.HOSPITAL, - cte.OUT_PATIENT_HEALTH_CARE: cte.OUT_PATIENT_HEALTH_CARE, - cte.STRIP_MALL: cte.STRIP_MALL, - cte.SUPERMARKET: cte.SUPERMARKET, - cte.WAREHOUSE: cte.WAREHOUSE, - cte.QUICK_SERVICE_RESTAURANT: cte.QUICK_SERVICE_RESTAURANT, - cte.FULL_SERVICE_RESTAURANT: cte.FULL_SERVICE_RESTAURANT, - cte.SMALL_HOTEL: cte.SMALL_HOTEL, - cte.LARGE_HOTEL: cte.LARGE_HOTEL - } - - nrcan_window_types = [cte.WINDOW] - - nrcan_construction_types = { - cte.WALL: 'wall', - cte.GROUND_WALL: 'basement_wall', - cte.GROUND: 'floor', - cte.ATTIC_FLOOR: 'attic floor', - cte.INTERIOR_SLAB: 'floor', - cte.ROOF: 'roof' - } - @staticmethod def nrel_from_libs_function(function): """ @@ -153,16 +117,4 @@ class ConstructionHelper: :return: str """ reference_city = ConstructionHelper.city_to_reference_city(city) - return ConstructionHelper._reference_city_to_nrel_climate_zone[reference_city] - - @staticmethod - def nrcan_from_libs_function(function): - """ - Get NREL function from the given internal function key - :param function: str - :return: str - """ - try: - return ConstructionHelper._function_to_nrcan[function] - except KeyError: - sys.stderr.write('Error: keyword not found.\n') + return ConstructionHelper._reference_city_to_nrel_climate_zone[reference_city] \ No newline at end of file diff --git a/imports/construction_factory.py b/imports/construction_factory.py index 3298bf51..b201555b 100644 --- a/imports/construction_factory.py +++ b/imports/construction_factory.py @@ -6,7 +6,6 @@ Project Coder Guille Gutierrez guillermo.gutierrezmorote@concordia.ca """ from pathlib import Path from imports.construction.us_physics_parameters import UsPhysicsParameters -from imports.construction.ca_physics_parameters import CaPhysicsParameters class ConstructionFactory: @@ -26,19 +25,9 @@ class ConstructionFactory: """ UsPhysicsParameters(self._city, self._base_path).enrich_buildings() - def _nrcan(self): - """ - Enrich the city by using NRCAN information - :alert: NRCAN handler only contains simplified construction information (residential) - """ - CaPhysicsParameters(self._city, self._base_path).enrich_buildings() - def enrich(self): """ Enrich the city given to the class using the class given handler :return: None """ - getattr(self, self._handler, lambda: None)() - - def _enrich_debug(self): - self._nrel() + getattr(self, self._handler, lambda: None)() \ No newline at end of file diff --git a/imports/energy_systems/air_source_hp_parameters.py b/imports/energy_systems/air_source_hp_parameters.py index decb6617..72cf41e8 100644 --- a/imports/energy_systems/air_source_hp_parameters.py +++ b/imports/energy_systems/air_source_hp_parameters.py @@ -22,7 +22,7 @@ class AirSourceHeatPumpParameters: def __init__(self, city, base_path): self._city = city - self._base_path = (base_path / 'heat_pumps/Air source.xlsx') + self._base_path = (base_path / 'heat_pumps/air_source.xlsx') def _read_file(self) -> Dict: """ diff --git a/unittests/test_construction_factory.py b/unittests/test_construction_factory.py index 8eeb16ab..b04cc901 100644 --- a/unittests/test_construction_factory.py +++ b/unittests/test_construction_factory.py @@ -168,36 +168,6 @@ class TestConstructionFactory(TestCase): for building in city.buildings: self.assertRaises(Exception, lambda: self._internal_function(function_format, building.function)) - def test_city_with_construction_reduced_library(self): - """ - Enrich the city with the construction reduced library and verify it - """ - file = 'one_building_in_kelowna.gml' - city = self._get_citygml(file) - for building in city.buildings: - building.function = GeometryHelper.libs_function_from_hft(building.function) - ConstructionFactory('nrcan', city).enrich() - - self._check_buildings(city) - for building in city.buildings: - for internal_zone in building.internal_zones: - self._check_thermal_zones(internal_zone) - for thermal_zone in internal_zone.thermal_zones: - self._check_thermal_boundaries(thermal_zone) - for thermal_boundary in thermal_zone.thermal_boundaries: - self.assertIsNone(thermal_boundary.outside_thermal_absorptance, 'outside_thermal_absorptance is not none') - self.assertIsNone(thermal_boundary.outside_visible_absorptance, 'outside_visible_absorptance is not none') - self.assertIsNone(thermal_boundary.layers, 'layers is not none') - - self._check_thermal_openings(thermal_boundary) - for thermal_opening in thermal_boundary.thermal_openings: - self.assertIsNone(thermal_opening.conductivity, 'thermal_opening conductivity is not none') - self.assertIsNone(thermal_opening.thickness, 'thermal opening thickness is not none') - self.assertIsNone(thermal_opening.front_side_solar_transmittance_at_normal_incidence, - 'thermal opening front_side_solar_transmittance_at_normal_incidence is not none') - self.assertIsNone(thermal_opening.back_side_solar_transmittance_at_normal_incidence, - 'thermal opening back_side_solar_transmittance_at_normal_incidence is not none') - def test_city_with_construction_extended_library(self): """ Enrich the city with the construction information and verify it diff --git a/unittests/test_enrichement.py b/unittests/test_enrichement.py index bf0af703..3507e3d6 100644 --- a/unittests/test_enrichement.py +++ b/unittests/test_enrichement.py @@ -90,7 +90,7 @@ class TestGeometryFactory(TestCase): UsageFactory(usage_key, city).enrich() def _test_hft(self, file): - _construction_keys = ['nrel', 'nrcan'] + _construction_keys = ['nrel'] _usage_keys = ['ca', 'comnet', 'hft'] for construction_key in _construction_keys: for usage_key in _usage_keys: diff --git a/unittests/test_life_cycle_assessment_factory.py b/unittests/test_life_cycle_assessment_factory.py index 2c5de645..43ba7feb 100644 --- a/unittests/test_life_cycle_assessment_factory.py +++ b/unittests/test_life_cycle_assessment_factory.py @@ -47,8 +47,8 @@ class TestLifeCycleAssessment(TestCase): city_file = "../unittests/tests_data/C40_Final.gml" city = GeometryFactory('citygml', city_file).city LifeCycleAssessment('material', city).enrich() - for material in city.materials: - self.assertTrue(len(city.materials) > 0) + for material in city.lca_materials: + self.assertTrue(len(city.lca_materials) > 0) From d062c5654e0a23efe5eea0c91dbc65a5f2ea4751 Mon Sep 17 00:00:00 2001 From: guille Date: Mon, 11 Apr 2022 14:53:22 -0400 Subject: [PATCH 8/9] change back city object name as readonly, add new property human_readable_name for building --- city_model_structure/building.py | 9 +++++++++ city_model_structure/city_object.py | 8 -------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/city_model_structure/building.py b/city_model_structure/building.py index f2ac273b..9c00647d 100644 --- a/city_model_structure/building.py +++ b/city_model_structure/building.py @@ -33,6 +33,7 @@ class Building(CityObject): self._roof_type = None self._internal_zones = None self._shell = None + self._human_readable_name = None self._type = 'building' self._heating = dict() self._cooling = dict() @@ -322,3 +323,11 @@ class Building(CityObject): if usage_zone.thermal_control is not None: return True return False + + @property + def human_readable_name(self): + return self._human_readable_name + + @human_readable_name.setter + def human_readable_name(self, value): + self._human_readable_name = value \ No newline at end of file diff --git a/city_model_structure/city_object.py b/city_model_structure/city_object.py index bea861da..16447583 100644 --- a/city_model_structure/city_object.py +++ b/city_model_structure/city_object.py @@ -45,14 +45,6 @@ class CityObject: """ return self._name - @name.setter - def name(self, value): - """ - Set city object name - :return: str - """ - self._name = value - @property def lod(self) -> int: """ From a0bae83ff5150fa2892d76a53870227a3f661078 Mon Sep 17 00:00:00 2001 From: guille Date: Tue, 12 Apr 2022 07:04:53 -0400 Subject: [PATCH 9/9] commit --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 10a17b31..64fa325d 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,5 @@ /development_tests/ /data/energy_systems/heat_pumps/*.csv /data/energy_systems/heat_pumps/*.insel -.DS_Store \ No newline at end of file +.DS_Store +__pycache__/