2021-05-27 17:20:06 -04:00
|
|
|
"""
|
|
|
|
TestSchedulesFactory test and validate the city model structure schedules
|
|
|
|
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
|
2021-05-27 17:20:06 -04:00
|
|
|
"""
|
|
|
|
from pathlib import Path
|
|
|
|
from unittest import TestCase
|
|
|
|
|
|
|
|
from imports.geometry_factory import GeometryFactory
|
|
|
|
from imports.usage_factory import UsageFactory
|
2021-08-25 11:05:22 -04:00
|
|
|
from imports.construction_factory import ConstructionFactory
|
2021-05-27 17:20:06 -04:00
|
|
|
from imports.schedules_factory import SchedulesFactory
|
2021-06-01 18:31:50 -04:00
|
|
|
from imports.geometry.helpers.geometry_helper import GeometryHelper
|
2021-05-27 17:20:06 -04:00
|
|
|
|
|
|
|
|
|
|
|
class TestSchedulesFactory(TestCase):
|
|
|
|
"""
|
|
|
|
TestSchedulesFactory TestCase
|
|
|
|
"""
|
|
|
|
|
|
|
|
def setUp(self) -> None:
|
|
|
|
"""
|
|
|
|
Configure test environment
|
|
|
|
:return:
|
|
|
|
"""
|
|
|
|
self._example_path = (Path(__file__).parent / 'tests_data').resolve()
|
|
|
|
|
|
|
|
def _get_citygml(self, file):
|
|
|
|
file_path = (self._example_path / file).resolve()
|
2021-08-27 12:51:30 -04:00
|
|
|
_city = GeometryFactory('citygml', file_path).city
|
2022-04-26 19:14:12 -04:00
|
|
|
for building in _city.buildings:
|
|
|
|
building.year_of_construction = 2006
|
2021-08-27 12:51:30 -04:00
|
|
|
ConstructionFactory('nrel', _city).enrich()
|
|
|
|
self.assertIsNotNone(_city, 'city is none')
|
|
|
|
for building in _city.buildings:
|
2022-03-24 16:51:01 -04:00
|
|
|
building.function = GeometryHelper.libs_function_from_hft(building.function)
|
2022-04-26 19:41:00 -04:00
|
|
|
building.year_of_construction = 2005
|
2021-08-27 12:51:30 -04:00
|
|
|
UsageFactory('hft', _city).enrich()
|
|
|
|
return _city
|
2021-05-27 17:20:06 -04:00
|
|
|
|
2021-08-25 14:29:30 -04:00
|
|
|
def test_doe_idf_archetypes(self):
|
2021-08-27 12:51:30 -04:00
|
|
|
"""
|
|
|
|
Enrich the city with doe_idf schedule archetypes and verify it
|
|
|
|
"""
|
2021-08-25 11:05:22 -04:00
|
|
|
file = (self._example_path / 'C40_Final.gml').resolve()
|
|
|
|
city = self._get_citygml(file)
|
|
|
|
occupancy_handler = 'doe_idf'
|
|
|
|
SchedulesFactory(occupancy_handler, city).enrich()
|
2021-08-26 13:27:43 -04:00
|
|
|
for building in city.buildings:
|
2022-03-24 16:51:01 -04:00
|
|
|
for internal_zone in building.internal_zones:
|
|
|
|
self.assertTrue(len(internal_zone.usage_zones) > 0)
|
|
|
|
for usage_zone in internal_zone.usage_zones:
|
|
|
|
self.assertIsNot(len(usage_zone.occupancy.occupancy_schedules), 0, 'no occupancy schedules defined')
|
|
|
|
for schedule in usage_zone.occupancy.occupancy_schedules:
|
|
|
|
self.assertIsNotNone(schedule.type)
|
|
|
|
self.assertIsNotNone(schedule.values)
|
|
|
|
self.assertIsNotNone(schedule.data_type)
|
|
|
|
self.assertIsNotNone(schedule.time_step)
|
|
|
|
self.assertIsNotNone(schedule.time_range)
|
|
|
|
self.assertIsNotNone(schedule.day_types)
|
|
|
|
self.assertIsNot(len(usage_zone.lighting.schedules), 0, 'no lighting schedules defined')
|
|
|
|
for schedule in usage_zone.lighting.schedules:
|
|
|
|
self.assertIsNotNone(schedule.type)
|
|
|
|
self.assertIsNotNone(schedule.values)
|
|
|
|
self.assertIsNotNone(schedule.data_type)
|
|
|
|
self.assertIsNotNone(schedule.time_step)
|
|
|
|
self.assertIsNotNone(schedule.time_range)
|
|
|
|
self.assertIsNotNone(schedule.day_types)
|