From a273c38a4507515ac33b1c3deb19654ccaae1bdb Mon Sep 17 00:00:00 2001 From: guille Date: Mon, 11 Apr 2022 14:32:44 -0400 Subject: [PATCH] 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)