system_assignation/unittests/test_construction_factory.py

91 lines
4.6 KiB
Python
Raw Normal View History

2020-06-09 14:07:47 -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
Copyright © 2020 Project Author Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
2020-06-09 14:07:47 -04:00
"""
from pathlib import Path
from unittest import TestCase
from imports.geometry_factory import GeometryFactory
from imports.construction_factory import ConstructionFactory
from imports.geometry.helpers.geometry_helper import GeometryHelper
2020-05-29 07:25:33 -04:00
class TestConstructionFactory(TestCase):
"""
TestConstructionFactory TestCase
"""
def setUp(self) -> None:
"""
Configure test environment
:return:
"""
self._city = None
self._example_path = (Path(__file__).parent / 'tests_data').resolve()
2020-05-29 07:25:33 -04:00
2021-09-23 09:17:23 -04:00
def _get_citygml(self, file=None):
if file is None:
file = 'pluto_building.gml'
file_path = (self._example_path / file).resolve()
self._city = GeometryFactory('citygml', file_path).city
self.assertIsNotNone(self._city, 'city is none')
return self._city
def test_city_with_construction_extended_library(self):
"""
2020-11-06 05:40:17 -05:00
Enrich the city with the physic information and verify it
:return: None
"""
2021-08-27 13:28:49 -04:00
city = self._get_citygml()
for building in city.buildings:
building.function = GeometryHelper.pluto_to_function[building.function]
2021-08-27 13:28:49 -04:00
self.assertIsNotNone(building.surfaces, 'Building has no surfaces')
# case 1: NREL
ConstructionFactory('nrel', city).enrich()
2020-06-26 10:06:43 -04:00
for building in city.buildings:
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')
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:
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.thermal_boundaries, 'thermal_boundaries is none')
for thermal_boundary in thermal_zone.thermal_boundaries:
2021-08-27 12:51:30 -04:00
if thermal_boundary.surface.type != 'Ground':
self.assertIsNotNone(thermal_boundary.outside_solar_absorptance, 'outside_solar_absorptance is none')
self.assertIsNotNone(thermal_boundary.window_ratio, 'window_ratio is none')
print(thermal_boundary.layers)
2021-01-05 15:01:36 -05:00
def test_city_with_construction_reduced_library(self):
2021-08-27 12:51:30 -04:00
"""
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.hft_to_function[building.function]
# case 2: NRCAN
ConstructionFactory('nrcan', city).enrich()
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')
self.assertIsNot(len(building.thermal_zones), 0, 'no building thermal_zones defined')
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.thermal_boundaries, 'thermal_boundaries is none')
self.assertIsNot(len(thermal_zone.thermal_boundaries), 0, 'no boundaries of thermal_zone defined')
for thermal_boundary in thermal_zone.thermal_boundaries:
self.assertIsNotNone(thermal_boundary.outside_solar_absorptance, 'outside_solar_absorptance is none')
self.assertIsNotNone(thermal_boundary.window_ratio, 'window_ratio is none')