2020-06-09 14:07:47 -04:00
|
|
|
"""
|
|
|
|
TestPhysicsFactory test and validate the city model structure physics parameters
|
|
|
|
SPDX - License - Identifier: LGPL - 3.0 - or -later
|
|
|
|
Copyright © 2020 Project Author Guille Gutierrez guillermo.gutierrezmorote@concordia.ca
|
|
|
|
"""
|
2020-06-04 12:47:48 -04:00
|
|
|
from pathlib import Path
|
2020-06-16 10:34:17 -04:00
|
|
|
from unittest import TestCase
|
|
|
|
|
2020-10-29 08:16:48 -04:00
|
|
|
from factories.geometry_factory import GeometryFactory
|
|
|
|
from factories.physics_factory import PhysicsFactory
|
2020-05-29 07:25:33 -04:00
|
|
|
|
|
|
|
|
|
|
|
class TestPhysicsFactory(TestCase):
|
2020-06-11 15:45:11 -04:00
|
|
|
"""
|
|
|
|
TestPhysicsFactory TestCase
|
|
|
|
"""
|
2020-06-11 16:55:52 -04:00
|
|
|
def setUp(self) -> None:
|
|
|
|
"""
|
|
|
|
Configure test environment
|
|
|
|
:return:
|
|
|
|
"""
|
2020-06-04 12:47:48 -04:00
|
|
|
self._city_gml = None
|
|
|
|
self._nyc_with_physics = None
|
|
|
|
self._example_path = (Path(__file__).parent.parent / 'tests_data').resolve()
|
2020-05-29 07:25:33 -04:00
|
|
|
|
2020-06-11 16:55:52 -04:00
|
|
|
def _get_citygml(self):
|
2020-06-04 12:47:48 -04:00
|
|
|
if self._city_gml is None:
|
2021-01-06 16:42:38 -05:00
|
|
|
file_path = (self._example_path / 'lod2_buildings.gml').resolve()
|
2020-06-04 12:47:48 -04:00
|
|
|
self._city_gml = GeometryFactory('citygml', file_path).city
|
|
|
|
self.assertIsNotNone(self._city_gml, 'city is none')
|
|
|
|
return self._city_gml
|
|
|
|
|
2020-06-11 16:55:52 -04:00
|
|
|
def _get_city_with_physics(self):
|
2020-06-04 12:47:48 -04:00
|
|
|
if self._nyc_with_physics is None:
|
2020-06-11 16:55:52 -04:00
|
|
|
self._nyc_with_physics = self._get_citygml()
|
2020-11-04 11:56:57 -05:00
|
|
|
PhysicsFactory('us_new_york', self._nyc_with_physics)
|
2020-06-04 12:47:48 -04:00
|
|
|
return self._nyc_with_physics
|
|
|
|
|
|
|
|
def test_city_with_physics(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
|
|
|
|
"""
|
|
|
|
city = self._get_city_with_physics()
|
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')
|
|
|
|
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:
|
|
|
|
self.assertIsNotNone(thermal_boundary.outside_solar_absorptance, 'outside_solar_absorptance is none')
|
|
|
|
self.assertIsNotNone(thermal_boundary.window_ratio, 'window_ratio is none')
|
|
|
|
self.assertIsNotNone(thermal_boundary.layers, 'layers is none')
|
2021-01-05 15:01:36 -05:00
|
|
|
|
|
|
|
def test_nrel_interface(self):
|
|
|
|
city = self._get_citygml()
|
2021-01-06 16:42:38 -05:00
|
|
|
# todo: extended library using the us case
|
|
|
|
#PhysicsFactory('us_new_york', city)
|
|
|
|
print('Extended passed')
|
2021-01-05 15:01:36 -05:00
|
|
|
# reduced library
|
2021-01-06 16:42:38 -05:00
|
|
|
PhysicsFactory('ca', city)
|
|
|
|
print('Reduced passed')
|