2020-06-09 14:07:47 -04:00
|
|
|
"""
|
2021-05-26 18:17:23 -04:00
|
|
|
TestConstructionFactory test and validate the city model structure construction parameters
|
2020-06-09 14:07:47 -04:00
|
|
|
SPDX - License - Identifier: LGPL - 3.0 - or -later
|
2021-05-27 17:20:06 -04:00
|
|
|
Copyright © 2020 Project Author Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
|
2020-06-09 14:07:47 -04:00
|
|
|
"""
|
2020-06-04 12:47:48 -04:00
|
|
|
from pathlib import Path
|
2020-06-16 10:34:17 -04:00
|
|
|
from unittest import TestCase
|
|
|
|
|
2021-03-02 18:57:09 -05:00
|
|
|
from imports.geometry_factory import GeometryFactory
|
2021-05-26 18:17:23 -04:00
|
|
|
from imports.construction_factory import ConstructionFactory
|
2021-06-01 18:31:50 -04:00
|
|
|
from imports.geometry.helpers.geometry_helper import GeometryHelper
|
2020-05-29 07:25:33 -04:00
|
|
|
|
|
|
|
|
2021-05-26 18:17:23 -04:00
|
|
|
class TestConstructionFactory(TestCase):
|
2020-06-11 15:45:11 -04:00
|
|
|
"""
|
2021-05-26 18:17:23 -04:00
|
|
|
TestConstructionFactory TestCase
|
2020-06-11 15:45:11 -04:00
|
|
|
"""
|
2020-06-11 16:55:52 -04:00
|
|
|
def setUp(self) -> None:
|
|
|
|
"""
|
|
|
|
Configure test environment
|
|
|
|
:return:
|
|
|
|
"""
|
2021-05-27 17:20:06 -04:00
|
|
|
self._city = None
|
2021-03-16 12:33:22 -04:00
|
|
|
self._example_path = (Path(__file__).parent / 'tests_data').resolve()
|
2020-05-29 07:25:33 -04:00
|
|
|
|
2021-05-27 17:20:06 -04:00
|
|
|
def _get_citygml(self, file):
|
|
|
|
file_path = (self._example_path / file).resolve()
|
|
|
|
self._city = GeometryFactory('citygml', file_path).city
|
|
|
|
self.assertIsNotNone(self._city, 'city is none')
|
|
|
|
return self._city
|
2020-06-04 12:47:48 -04:00
|
|
|
|
2021-05-27 17:20:06 -04:00
|
|
|
def test_city_with_construction_extended_library(self):
|
2020-06-11 16:55:52 -04:00
|
|
|
"""
|
2020-11-06 05:40:17 -05:00
|
|
|
Enrich the city with the physic information and verify it
|
2020-06-11 16:55:52 -04:00
|
|
|
:return: None
|
|
|
|
"""
|
2021-05-27 17:20:06 -04:00
|
|
|
|
2021-08-10 17:09:42 -04:00
|
|
|
# todo: file = 'pluto_building.gml' -> it has 0 surfaces!!
|
2021-05-27 17:20:06 -04:00
|
|
|
file = 'pluto_building.gml'
|
|
|
|
city = self._get_citygml(file)
|
|
|
|
for building in city.buildings:
|
|
|
|
building.function = GeometryHelper.pluto_to_function[building.function]
|
|
|
|
for tz in building.thermal_zones:
|
|
|
|
for tb in tz.bounded:
|
|
|
|
tb.hi = 10
|
|
|
|
tb.he = 25
|
|
|
|
for opening in tb.thermal_openings:
|
|
|
|
opening.hi = 10
|
|
|
|
opening.he = 25
|
|
|
|
# case 1: NREL
|
|
|
|
ConstructionFactory('nrel', city).enrich()
|
2020-06-26 10:06:43 -04:00
|
|
|
for building in city.buildings:
|
2020-06-29 17:41:22 -04:00
|
|
|
self.assertIsNotNone(building.average_storey_height, 'average_storey_height is none')
|
2020-06-26 10:06:43 -04:00
|
|
|
self.assertIsNotNone(building.storeys_above_ground, 'storeys_above_ground is none')
|
2021-06-23 09:53:33 -04:00
|
|
|
self.assertIsNot(len(building.thermal_zones), 0, 'no building thermal_zones defined')
|
2020-06-26 10:06:43 -04:00
|
|
|
for thermal_zone in building.thermal_zones:
|
2020-06-05 12:24:03 -04:00
|
|
|
self.assertIsNotNone(thermal_zone.effective_thermal_capacity, 'effective_thermal_capacity is none')
|
|
|
|
self.assertIsNotNone(thermal_zone.additional_thermal_bridge_u_value,
|
|
|
|
'additional_thermal_bridge_u_value is none')
|
|
|
|
self.assertIsNotNone(thermal_zone.indirectly_heated_area_ratio, 'indirectly_heated_area_ratio is none')
|
|
|
|
self.assertIsNotNone(thermal_zone.infiltration_rate_system_on, 'infiltration_rate_system_on is none')
|
|
|
|
self.assertIsNotNone(thermal_zone.infiltration_rate_system_off, 'infiltration_rate_system_off is none')
|
|
|
|
self.assertIsNotNone(thermal_zone.bounded, 'bounded is none')
|
|
|
|
for thermal_boundary in thermal_zone.bounded:
|
2021-04-08 11:47:58 -04:00
|
|
|
if thermal_boundary.surface.type is not 'Ground':
|
|
|
|
self.assertIsNotNone(thermal_boundary.outside_solar_absorptance, 'outside_solar_absorptance is none')
|
|
|
|
self.assertIsNotNone(thermal_boundary.window_ratio, 'window_ratio is none')
|
2021-01-05 15:01:36 -05:00
|
|
|
|
2021-05-27 17:20:06 -04:00
|
|
|
def test_city_with_construction_reduced_library(self):
|
|
|
|
file = 'one_building_in_kelowna.gml'
|
|
|
|
city = self._get_citygml(file)
|
|
|
|
for building in city.buildings:
|
|
|
|
building.function = GeometryHelper.hft_to_function[building.function]
|
|
|
|
# case 2: NRCAN
|
|
|
|
ConstructionFactory('nrcan', city).enrich()
|
2021-01-07 19:46:52 -05:00
|
|
|
for building in city.buildings:
|
|
|
|
self.assertIsNotNone(building.average_storey_height, 'average_storey_height is none')
|
|
|
|
self.assertIsNotNone(building.storeys_above_ground, 'storeys_above_ground is none')
|
2021-06-23 09:53:33 -04:00
|
|
|
self.assertIsNot(len(building.thermal_zones), 0, 'no building thermal_zones defined')
|
2021-01-07 19:46:52 -05:00
|
|
|
for thermal_zone in building.thermal_zones:
|
|
|
|
self.assertIsNotNone(thermal_zone.effective_thermal_capacity, 'effective_thermal_capacity is none')
|
|
|
|
self.assertIsNotNone(thermal_zone.additional_thermal_bridge_u_value,
|
|
|
|
'additional_thermal_bridge_u_value is none')
|
|
|
|
self.assertIsNotNone(thermal_zone.indirectly_heated_area_ratio, 'indirectly_heated_area_ratio is none')
|
|
|
|
self.assertIsNotNone(thermal_zone.infiltration_rate_system_on, 'infiltration_rate_system_on is none')
|
|
|
|
self.assertIsNotNone(thermal_zone.infiltration_rate_system_off, 'infiltration_rate_system_off is none')
|
|
|
|
self.assertIsNotNone(thermal_zone.bounded, 'bounded is none')
|
2021-08-12 11:08:29 -04:00
|
|
|
self.assertIsNot(len(thermal_zone.bounded), 0, 'no boundaries of thermal_zone defined')
|
2021-01-07 19:46:52 -05:00
|
|
|
for thermal_boundary in thermal_zone.bounded:
|
|
|
|
self.assertIsNotNone(thermal_boundary.outside_solar_absorptance, 'outside_solar_absorptance is none')
|
|
|
|
self.assertIsNotNone(thermal_boundary.window_ratio, 'window_ratio is none')
|