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
|
|
|
|
|
2023-01-24 10:51:50 -05:00
|
|
|
from hub.imports.geometry_factory import GeometryFactory
|
|
|
|
from hub.imports.usage_factory import UsageFactory
|
2023-01-26 05:21:34 -05:00
|
|
|
from hub.helpers.dictionaries import Dictionaries
|
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-11-21 13:53:58 -05:00
|
|
|
self._city = GeometryFactory('citygml', path=file_path).city
|
2022-03-08 19:19:52 -05:00
|
|
|
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.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:
|
2023-03-24 13:34:37 -04:00
|
|
|
if internal_zone.usages is not None:
|
2023-03-23 16:55:09 -04:00
|
|
|
self.assertTrue(len(internal_zone.usages) > 0, 'usage zones are not defined')
|
|
|
|
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')
|
|
|
|
|
2023-01-26 08:53:00 -05:00
|
|
|
def _check_usage(self, usage):
|
|
|
|
self.assertIsNotNone(usage.name, 'usage is none')
|
|
|
|
self.assertIsNotNone(usage.percentage, 'usage percentage is none')
|
|
|
|
self.assertIsNotNone(usage.hours_day, 'hours per day is none')
|
|
|
|
self.assertIsNotNone(usage.days_year, 'days per year is none')
|
|
|
|
self.assertIsNotNone(usage.thermal_control, 'thermal control is none')
|
|
|
|
self.assertIsNotNone(usage.thermal_control.mean_heating_set_point, 'control heating set point is none')
|
|
|
|
self.assertIsNotNone(usage.thermal_control.heating_set_back, 'control heating set back is none')
|
|
|
|
self.assertIsNotNone(usage.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-12-16 07:21:33 -05:00
|
|
|
building.function = Dictionaries().pluto_function_to_hub_function[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:
|
2023-01-26 08:53:00 -05:00
|
|
|
self.assertIsNot(len(internal_zone.usages), 0, 'no building usage defined')
|
|
|
|
for usage in internal_zone.usages:
|
|
|
|
self._check_usage(usage)
|
|
|
|
self.assertIsNotNone(usage.mechanical_air_change, 'mechanical air change is none')
|
|
|
|
self.assertIsNotNone(usage.thermal_control.heating_set_point_schedules,
|
2022-03-17 18:49:44 -04:00
|
|
|
'control heating set point schedule is none')
|
2023-01-26 08:53:00 -05:00
|
|
|
self.assertIsNotNone(usage.thermal_control.cooling_set_point_schedules,
|
2022-03-17 18:49:44 -04:00
|
|
|
'control cooling set point schedule is none')
|
2023-01-26 08:53:00 -05:00
|
|
|
self.assertIsNotNone(usage.occupancy, 'occupancy is none')
|
|
|
|
occupancy = usage.occupancy
|
2022-03-17 18:49:44 -04:00
|
|
|
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')
|
2023-01-26 08:53:00 -05:00
|
|
|
self.assertIsNotNone(usage.lighting, 'lighting is none')
|
|
|
|
lighting = usage.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')
|
2023-01-26 08:53:00 -05:00
|
|
|
self.assertIsNotNone(usage.appliances, 'appliances is none')
|
|
|
|
appliances = usage.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')
|
2023-01-26 08:53:00 -05:00
|
|
|
self.assertIsNotNone(usage.thermal_control.hvac_availability_schedules,
|
2022-03-17 18:49:44 -04:00
|
|
|
'control hvac availability is none')
|
2023-03-13 14:40:07 -04:00
|
|
|
self.assertIsNotNone(usage.domestic_hot_water.density, 'domestic hot water density is none')
|
|
|
|
self.assertIsNotNone(usage.domestic_hot_water.service_temperature,
|
|
|
|
'domestic hot water service temperature is none')
|
|
|
|
self.assertIsNotNone(usage.domestic_hot_water.schedules, 'domestic hot water schedules is none')
|
2023-03-23 16:55:09 -04:00
|
|
|
|
|
|
|
def test_import_nrcan(self):
|
|
|
|
"""
|
|
|
|
Enrich the city with the usage information from nrcan and verify it
|
|
|
|
"""
|
2023-05-04 13:45:34 -04:00
|
|
|
file = 'concordia.geojson'
|
2023-03-23 16:55:09 -04:00
|
|
|
file_path = (self._example_path / file).resolve()
|
|
|
|
city = GeometryFactory('geojson',
|
|
|
|
path=file_path,
|
2023-05-04 13:45:34 -04:00
|
|
|
height_field='citygml_me',
|
2023-03-23 16:55:09 -04:00
|
|
|
year_of_construction_field='ANNEE_CONS',
|
|
|
|
function_field='CODE_UTILI',
|
|
|
|
function_to_hub=Dictionaries().montreal_function_to_hub_function).city
|
|
|
|
|
|
|
|
UsageFactory('nrcan', city).enrich()
|
|
|
|
self._check_buildings(city)
|
|
|
|
for building in city.buildings:
|
|
|
|
for internal_zone in building.internal_zones:
|
2023-03-24 13:34:37 -04:00
|
|
|
if internal_zone.usages is not None:
|
2023-03-23 16:55:09 -04:00
|
|
|
self.assertIsNot(len(internal_zone.usages), 0, 'no building usage defined')
|
|
|
|
for usage in internal_zone.usages:
|
|
|
|
self._check_usage(usage)
|
|
|
|
self.assertIsNotNone(usage.mechanical_air_change, 'mechanical air change is none')
|
|
|
|
self.assertIsNotNone(usage.thermal_control.heating_set_point_schedules,
|
|
|
|
'control heating set point schedule is none')
|
|
|
|
self.assertIsNotNone(usage.thermal_control.cooling_set_point_schedules,
|
|
|
|
'control cooling set point schedule is none')
|
|
|
|
self.assertIsNotNone(usage.occupancy, 'occupancy is none')
|
|
|
|
occupancy = usage.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.assertIsNotNone(usage.lighting, 'lighting is none')
|
|
|
|
lighting = usage.lighting
|
|
|
|
self.assertIsNotNone(lighting.density, 'lighting density is none')
|
|
|
|
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.appliances, 'appliances is none')
|
|
|
|
appliances = usage.appliances
|
|
|
|
self.assertIsNotNone(appliances.density, 'appliances density is none')
|
|
|
|
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.thermal_control.hvac_availability_schedules,
|
|
|
|
'control hvac availability is none')
|
|
|
|
self.assertIsNotNone(usage.domestic_hot_water.peak_flow, 'domestic hot water peak flow is none')
|
|
|
|
self.assertIsNotNone(usage.domestic_hot_water.service_temperature,
|
|
|
|
'domestic hot water service temperature is none')
|
|
|
|
self.assertIsNotNone(usage.domestic_hot_water.schedules, 'domestic hot water schedules is none')
|