2020-11-06 05:40:17 -05:00
|
|
|
"""
|
2021-06-03 15:56:59 -04:00
|
|
|
TestUsageFactory test and validate the city model structure usage parameters
|
2020-11-06 05:40:17 -05:00
|
|
|
SPDX - License - Identifier: LGPL - 3.0 - or -later
|
2022-04-08 09:35:33 -04:00
|
|
|
Copyright © 2022 Concordia CERC group
|
|
|
|
Project Coder Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
|
2020-11-06 05:40:17 -05:00
|
|
|
"""
|
|
|
|
from pathlib import Path
|
|
|
|
from unittest import TestCase
|
|
|
|
|
2021-03-02 18:57:09 -05:00
|
|
|
from imports.geometry_factory import GeometryFactory
|
|
|
|
from imports.usage_factory import UsageFactory
|
2021-06-01 18:31:50 -04:00
|
|
|
from imports.geometry.helpers.geometry_helper import GeometryHelper
|
2020-11-06 05:40:17 -05:00
|
|
|
|
|
|
|
|
|
|
|
class TestUsageFactory(TestCase):
|
|
|
|
"""
|
|
|
|
TestUsageFactory TestCase
|
|
|
|
"""
|
|
|
|
def setUp(self) -> None:
|
|
|
|
"""
|
|
|
|
Configure test environment
|
|
|
|
:return:
|
|
|
|
"""
|
2022-03-08 19:19:52 -05:00
|
|
|
self._city = None
|
2021-03-16 12:33:22 -04:00
|
|
|
self._example_path = (Path(__file__).parent / 'tests_data').resolve()
|
2020-11-06 05:40:17 -05:00
|
|
|
|
2021-05-27 17:20:06 -04:00
|
|
|
def _get_citygml(self, file):
|
|
|
|
file_path = (self._example_path / file).resolve()
|
2022-03-08 19:19:52 -05:00
|
|
|
self._city = GeometryFactory('citygml', file_path).city
|
|
|
|
self.assertIsNotNone(self._city, 'city is none')
|
|
|
|
return self._city
|
|
|
|
|
|
|
|
def _check_buildings(self, city):
|
|
|
|
for building in city.buildings:
|
|
|
|
self.assertIsNotNone(building.name, 'building name is none')
|
|
|
|
self.assertIsNotNone(building.lod, 'building lod is none')
|
|
|
|
self.assertIsNotNone(building.type, 'building type is none')
|
|
|
|
self.assertIsNotNone(building.volume, 'building volume is none')
|
|
|
|
self.assertIsNotNone(building.detailed_polyhedron, 'building detailed polyhedron is none')
|
|
|
|
self.assertIsNotNone(building.simplified_polyhedron, 'building simplified polyhedron is none')
|
|
|
|
self.assertIsNotNone(building.surfaces, 'building surfaces is none')
|
|
|
|
self.assertIsNotNone(building.centroid, 'building centroid is none')
|
|
|
|
self.assertIsNotNone(building.max_height, 'building max_height is none')
|
|
|
|
self.assertEqual(len(building.external_temperature), 0, 'building external temperature is calculated')
|
|
|
|
self.assertEqual(len(building.global_horizontal), 0, 'building global horizontal is calculated')
|
|
|
|
self.assertEqual(len(building.diffuse), 0, 'building diffuse is calculated')
|
|
|
|
self.assertEqual(len(building.beam), 0, 'building beam is calculated')
|
|
|
|
self.assertIsNotNone(building.lower_corner, 'building lower corner is none')
|
|
|
|
self.assertEqual(len(building.sensors), 0, 'building sensors are assigned')
|
2022-03-17 18:49:44 -04:00
|
|
|
self.assertIsNotNone(building.internal_zones, 'no internal zones created')
|
2022-03-08 19:19:52 -05:00
|
|
|
self.assertIsNotNone(building.grounds, 'building grounds is none')
|
|
|
|
self.assertIsNotNone(building.walls, 'building walls is none')
|
|
|
|
self.assertIsNotNone(building.roofs, 'building roofs is none')
|
2022-03-17 18:49:44 -04:00
|
|
|
for internal_zone in building.internal_zones:
|
|
|
|
self.assertTrue(len(internal_zone.usage_zones) > 0, 'usage zones are not defined')
|
2022-03-24 16:51:01 -04:00
|
|
|
self.assertIsNone(internal_zone.thermal_zones, 'thermal zones are defined')
|
2022-03-17 18:49:44 -04:00
|
|
|
self.assertIsNone(building.basement_heated, 'building basement_heated is not none')
|
|
|
|
self.assertIsNone(building.attic_heated, 'building attic_heated is not none')
|
2022-03-08 19:19:52 -05:00
|
|
|
self.assertIsNone(building.terrains, 'building terrains is not none')
|
|
|
|
self.assertIsNotNone(building.year_of_construction, 'building year_of_construction is none')
|
|
|
|
self.assertIsNotNone(building.function, 'building function is none')
|
2022-03-17 18:49:44 -04:00
|
|
|
self.assertIsNone(building.average_storey_height, 'building average_storey_height is not none')
|
|
|
|
self.assertIsNone(building.storeys_above_ground, 'building storeys_above_ground is not none')
|
2022-03-08 19:19:52 -05:00
|
|
|
self.assertEqual(len(building.heating), 0, 'building heating is not none')
|
|
|
|
self.assertEqual(len(building.cooling), 0, 'building cooling is not none')
|
|
|
|
self.assertIsNotNone(building.eave_height, 'building eave height is none')
|
|
|
|
self.assertIsNotNone(building.roof_type, 'building roof type is none')
|
|
|
|
self.assertIsNotNone(building.floor_area, 'building floor_area is none')
|
|
|
|
self.assertIsNone(building.households, 'building households is not none')
|
|
|
|
self.assertTrue(building.is_conditioned, 'building is not conditioned')
|
|
|
|
|
2022-03-17 18:49:44 -04:00
|
|
|
def _check_usage_zone(self, usage_zone):
|
|
|
|
self.assertIsNotNone(usage_zone.usage, 'usage is none')
|
|
|
|
self.assertIsNotNone(usage_zone.percentage, 'usage percentage is none')
|
|
|
|
self.assertIsNotNone(usage_zone.hours_day, 'hours per day is none')
|
|
|
|
self.assertIsNotNone(usage_zone.days_year, 'days per year is none')
|
|
|
|
self.assertIsNotNone(usage_zone.thermal_control, 'thermal control is none')
|
|
|
|
self.assertIsNotNone(usage_zone.thermal_control.mean_heating_set_point, 'control heating set point is none')
|
|
|
|
self.assertIsNotNone(usage_zone.thermal_control.heating_set_back, 'control heating set back is none')
|
|
|
|
self.assertIsNotNone(usage_zone.thermal_control.mean_cooling_set_point, 'control cooling set point is none')
|
2022-03-08 19:19:52 -05:00
|
|
|
|
|
|
|
def test_import_comnet(self):
|
|
|
|
"""
|
|
|
|
Enrich the city with the usage information from comnet and verify it
|
|
|
|
"""
|
2021-11-18 13:07:49 -05:00
|
|
|
file = 'pluto_building.gml'
|
|
|
|
city = self._get_citygml(file)
|
|
|
|
for building in city.buildings:
|
2022-03-24 16:51:01 -04:00
|
|
|
building.function = GeometryHelper.libs_function_from_pluto(building.function)
|
2022-03-08 19:19:52 -05:00
|
|
|
|
2021-11-18 13:07:49 -05:00
|
|
|
UsageFactory('comnet', city).enrich()
|
2022-03-08 19:19:52 -05:00
|
|
|
self._check_buildings(city)
|
|
|
|
for building in city.buildings:
|
2022-03-08 20:08:03 -05:00
|
|
|
for internal_zone in building.internal_zones:
|
|
|
|
self.assertIsNot(len(internal_zone.usage_zones), 0, 'no building usage_zones defined')
|
|
|
|
for usage_zone in internal_zone.usage_zones:
|
2022-03-17 18:49:44 -04:00
|
|
|
self._check_usage_zone(usage_zone)
|
2022-03-24 16:51:01 -04:00
|
|
|
self.assertIsNotNone(usage_zone.mechanical_air_change, 'mechanical air change is none')
|
2022-03-17 18:49:44 -04:00
|
|
|
self.assertIsNotNone(usage_zone.thermal_control.heating_set_point_schedules,
|
|
|
|
'control heating set point schedule is none')
|
|
|
|
self.assertIsNotNone(usage_zone.thermal_control.cooling_set_point_schedules,
|
|
|
|
'control cooling set point schedule is none')
|
|
|
|
self.assertIsNotNone(usage_zone.occupancy, 'occupancy is none')
|
|
|
|
occupancy = usage_zone.occupancy
|
|
|
|
self.assertIsNotNone(occupancy.occupancy_density, 'occupancy density is none')
|
|
|
|
self.assertIsNotNone(occupancy.latent_internal_gain, 'occupancy latent internal gain is none')
|
|
|
|
self.assertIsNotNone(occupancy.sensible_convective_internal_gain,
|
|
|
|
'occupancy sensible convective internal gain is none')
|
|
|
|
self.assertIsNotNone(occupancy.sensible_radiative_internal_gain,
|
|
|
|
'occupancy sensible radiant internal gain is none')
|
|
|
|
self.assertIsNotNone(occupancy.occupancy_schedules, 'occupancy schedule is none')
|
|
|
|
self.assertIsNone(occupancy.occupants, 'occupancy density is not none')
|
|
|
|
self.assertIsNotNone(usage_zone.lighting, 'lighting is none')
|
|
|
|
lighting = usage_zone.lighting
|
2022-04-06 16:06:55 -04:00
|
|
|
self.assertIsNotNone(lighting.density, 'lighting density is none')
|
2022-03-17 18:49:44 -04:00
|
|
|
self.assertIsNotNone(lighting.latent_fraction, 'lighting latent fraction is none')
|
|
|
|
self.assertIsNotNone(lighting.convective_fraction, 'lighting convective fraction is none')
|
|
|
|
self.assertIsNotNone(lighting.radiative_fraction, 'lighting radiant fraction is none')
|
|
|
|
self.assertIsNotNone(lighting.schedules, 'lighting schedule is none')
|
|
|
|
self.assertIsNotNone(usage_zone.appliances, 'appliances is none')
|
|
|
|
appliances = usage_zone.appliances
|
2022-04-06 16:06:55 -04:00
|
|
|
self.assertIsNotNone(appliances.density, 'appliances density is none')
|
2022-03-17 18:49:44 -04:00
|
|
|
self.assertIsNotNone(appliances.latent_fraction, 'appliances latent fraction is none')
|
|
|
|
self.assertIsNotNone(appliances.convective_fraction, 'appliances convective fraction is none')
|
|
|
|
self.assertIsNotNone(appliances.radiative_fraction, 'appliances radiant fraction is none')
|
|
|
|
self.assertIsNotNone(appliances.schedules, 'appliances schedule is none')
|
|
|
|
self.assertIsNotNone(usage_zone.thermal_control.hvac_availability_schedules,
|
|
|
|
'control hvac availability is none')
|
2021-11-18 13:07:49 -05:00
|
|
|
|
2022-03-17 18:49:44 -04:00
|
|
|
def test_import_hft(self):
|
2022-03-08 19:19:52 -05:00
|
|
|
"""
|
2022-03-17 18:49:44 -04:00
|
|
|
Enrich the city with the usage information from hft and verify it
|
2022-03-08 19:19:52 -05:00
|
|
|
"""
|
2022-03-17 18:49:44 -04:00
|
|
|
file = 'pluto_building.gml'
|
2021-08-11 11:14:06 -04:00
|
|
|
city = self._get_citygml(file)
|
2022-03-17 18:49:44 -04:00
|
|
|
for building in city.buildings:
|
2022-03-24 16:51:01 -04:00
|
|
|
building.function = GeometryHelper.libs_function_from_pluto(building.function)
|
2022-03-17 18:49:44 -04:00
|
|
|
|
|
|
|
UsageFactory('hft', city).enrich()
|
|
|
|
self._check_buildings(city)
|
2021-08-11 11:14:06 -04:00
|
|
|
for building in city.buildings:
|
2022-03-08 20:08:03 -05:00
|
|
|
for internal_zone in building.internal_zones:
|
|
|
|
self.assertIsNot(len(internal_zone.usage_zones), 0, 'no building usage_zones defined')
|
|
|
|
for usage_zone in internal_zone.usage_zones:
|
2022-03-17 18:49:44 -04:00
|
|
|
self._check_usage_zone(usage_zone)
|
2022-03-24 16:51:01 -04:00
|
|
|
self.assertIsNone(usage_zone.mechanical_air_change, 'mechanical air change is not none')
|
2022-03-17 18:49:44 -04:00
|
|
|
self.assertIsNotNone(usage_zone.thermal_control.heating_set_point_schedules,
|
|
|
|
'control heating set point schedule is none')
|
|
|
|
self.assertIsNotNone(usage_zone.thermal_control.cooling_set_point_schedules,
|
|
|
|
'control cooling set point schedule is none')
|
|
|
|
self.assertIsNotNone(usage_zone.occupancy, 'occupancy is none')
|
|
|
|
occupancy = usage_zone.occupancy
|
|
|
|
self.assertIsNotNone(occupancy.occupancy_density, 'occupancy density is none')
|
2022-03-24 16:51:01 -04:00
|
|
|
self.assertIsNone(occupancy.latent_internal_gain, 'occupancy latent internal gain is none')
|
|
|
|
self.assertIsNone(occupancy.sensible_convective_internal_gain,
|
|
|
|
'occupancy sensible convective internal gain is not none')
|
|
|
|
self.assertIsNone(occupancy.sensible_radiative_internal_gain,
|
|
|
|
'occupancy sensible radiant internal gain is not none')
|
|
|
|
self.assertIsNone(occupancy.occupancy_schedules, 'occupancy schedule is not none')
|
2022-03-17 18:49:44 -04:00
|
|
|
self.assertIsNone(occupancy.occupants, 'occupancy density is not none')
|
2022-03-24 16:51:01 -04:00
|
|
|
self.assertIsNone(usage_zone.lighting, 'lighting is not none')
|
|
|
|
self.assertIsNone(usage_zone.appliances, 'appliances is not none')
|