154 lines
7.6 KiB
Python
154 lines
7.6 KiB
Python
"""
|
|
TestUsageFactory test and validate the city model structure usage parameters
|
|
SPDX - License - Identifier: LGPL - 3.0 - or -later
|
|
Copyright © 2020 Project Author Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
|
|
"""
|
|
from pathlib import Path
|
|
from unittest import TestCase
|
|
|
|
from imports.geometry_factory import GeometryFactory
|
|
from imports.usage_factory import UsageFactory
|
|
from imports.schedules_factory import SchedulesFactory
|
|
from imports.construction_factory import ConstructionFactory
|
|
from imports.geometry.helpers.geometry_helper import GeometryHelper
|
|
from imports.construction_factory import ConstructionFactory
|
|
|
|
|
|
class TestUsageFactory(TestCase):
|
|
"""
|
|
TestUsageFactory TestCase
|
|
"""
|
|
def setUp(self) -> None:
|
|
"""
|
|
Configure test environment
|
|
:return:
|
|
"""
|
|
self._city = None
|
|
self._example_path = (Path(__file__).parent / 'tests_data').resolve()
|
|
|
|
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
|
|
|
|
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')
|
|
self.assertIsNotNone(building.geometrical_zones, 'no geometrical zones created')
|
|
self.assertIsNotNone(building.grounds, 'building grounds is none')
|
|
self.assertIsNotNone(building.walls, 'building walls is none')
|
|
self.assertIsNotNone(building.roofs, 'building roofs is none')
|
|
self.assertTrue(len(building.usage_zones) > 0, 'usage zones are not defined')
|
|
self.assertTrue(len(building.thermal_zones) > 0, 'thermal zones are not defined')
|
|
self.assertIsNotNone(building.basement_heated, 'building basement_heated is none')
|
|
self.assertIsNotNone(building.attic_heated, 'building attic_heated is none')
|
|
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')
|
|
self.assertIsNotNone(building.average_storey_height, 'building average_storey_height is none')
|
|
self.assertIsNotNone(building.storeys_above_ground, 'building storeys_above_ground is none')
|
|
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.storeys, 'building storeys are not defined')
|
|
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')
|
|
|
|
|
|
def _check_hvac(self, thermal_zone):
|
|
self.assertIsNotNone(None, 'hvac')
|
|
|
|
def _check_control(self, thermal_zone):
|
|
self.assertIsNotNone(None, 'control')
|
|
|
|
def test_import_comnet(self):
|
|
"""
|
|
Enrich the city with the usage information from comnet and verify it
|
|
"""
|
|
file = 'pluto_building.gml'
|
|
city = self._get_citygml(file)
|
|
for building in city.buildings:
|
|
building.function = GeometryHelper.pluto_to_function[building.function]
|
|
|
|
UsageFactory('comnet', city).enrich()
|
|
SchedulesFactory('comnet', city).enrich()
|
|
self._check_buildings(city)
|
|
for building in city.buildings:
|
|
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:
|
|
self._check_extended_usage(usage_zone)
|
|
|
|
def test_import_hft(self):
|
|
"""
|
|
Enrich the city with the usage information from hft and verify it
|
|
"""
|
|
# todo: read schedules!!
|
|
file = 'pluto_building.gml'
|
|
city = self._get_citygml(file)
|
|
for building in city.buildings:
|
|
building.function = GeometryHelper.pluto_to_function[building.function]
|
|
|
|
UsageFactory('hft', city).enrich()
|
|
for building in city.buildings:
|
|
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:
|
|
self._check_extended_usage(usage_zone)
|
|
|
|
def test_import_ca(self):
|
|
"""
|
|
Enrich the city with the usage information from canada and verify it
|
|
"""
|
|
file = 'one_building_in_kelowna.gml'
|
|
city = self._get_citygml(file)
|
|
UsageFactory('ca', city).enrich()
|
|
for building in city.buildings:
|
|
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:
|
|
self._check_reduced_usage(usage_zone)
|
|
|
|
def _check_extended_usage(self, usage_zone):
|
|
self.assertIsNotNone(usage_zone.usage, 'usage is none')
|
|
self.assertIsNotNone(usage_zone.not_detailed_source_mean_annual_internal_gains, 'usage is none')
|
|
self.assertIsNotNone(usage_zone.cooling_setpoint, 'usage is none')
|
|
self.assertIsNotNone(usage_zone.heating_setback, 'usage is none')
|
|
self.assertIsNotNone(usage_zone.heating_setpoint, 'usage is none')
|
|
self.assertIsNotNone(usage_zone.occupancy_density, 'usage is none')
|
|
self.assertIsNotNone(usage_zone.hours_day, 'usage is none')
|
|
self.assertIsNotNone(usage_zone.days_year, 'usage is none')
|
|
self.assertIsNotNone(usage_zone.dhw_average_volume_pers_day, 'usage is none')
|
|
self.assertIsNotNone(usage_zone.dhw_preparation_temperature, 'usage is none')
|
|
self.assertIsNotNone(usage_zone.electrical_app_average_consumption_sqm_year, 'usage is none')
|
|
self.assertIsNotNone(usage_zone.is_heated, 'thermal_zone heated is none')
|
|
self.assertIsNotNone(usage_zone.is_cooled, 'thermal_zone cooled is none')
|
|
|
|
|
|
def _check_reduced_usage(self, usage_zone):
|
|
self.assertIsNotNone(usage_zone.usage, 'usage is none')
|
|
self.assertIsNotNone(usage_zone.internal_gains, 'usage is none')
|
|
self.assertIsNotNone(usage_zone.cooling_setpoint, 'usage is none')
|
|
self.assertIsNotNone(usage_zone.heating_setback, 'usage is none')
|
|
self.assertIsNotNone(usage_zone.heating_setpoint, 'usage is none')
|
|
self.assertIsNotNone(usage_zone.occupancy_density, 'usage is none')
|
|
self.assertIsNotNone(usage_zone.hours_day, 'usage is none')
|
|
self.assertIsNotNone(usage_zone.days_year, 'usage is none')
|