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
|
2021-05-27 17:20:06 -04:00
|
|
|
Copyright © 2020 Project Author 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
|
2021-11-18 13:07:49 -05:00
|
|
|
from imports.construction_factory import ConstructionFactory
|
2021-03-02 18:57:09 -05:00
|
|
|
from imports.usage_factory import UsageFactory
|
2021-11-16 12:27:49 -05:00
|
|
|
from imports.construction_factory import ConstructionFactory
|
2021-06-01 18:31:50 -04:00
|
|
|
from imports.geometry.helpers.geometry_helper import GeometryHelper
|
2021-11-16 07:57:47 -05:00
|
|
|
from imports.construction_factory import ConstructionFactory
|
2020-11-06 05:40:17 -05:00
|
|
|
|
|
|
|
|
|
|
|
class TestUsageFactory(TestCase):
|
|
|
|
"""
|
|
|
|
TestUsageFactory TestCase
|
|
|
|
"""
|
|
|
|
def setUp(self) -> None:
|
|
|
|
"""
|
|
|
|
Configure test environment
|
|
|
|
:return:
|
|
|
|
"""
|
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()
|
2021-08-27 12:51:30 -04:00
|
|
|
_city = GeometryFactory('citygml', file_path).city
|
|
|
|
self.assertIsNotNone(_city, 'city is none')
|
|
|
|
return _city
|
2020-11-06 05:40:17 -05:00
|
|
|
|
2021-11-18 13:07:49 -05:00
|
|
|
def test_comnet(self):
|
|
|
|
file = 'pluto_building.gml'
|
|
|
|
city = self._get_citygml(file)
|
|
|
|
for building in city.buildings:
|
|
|
|
building.function = GeometryHelper.pluto_to_function[building.function]
|
|
|
|
|
|
|
|
ConstructionFactory('nrel', city).enrich()
|
|
|
|
UsageFactory('comnet', city).enrich()
|
|
|
|
|
2020-11-06 05:40:17 -05:00
|
|
|
def test_city_with_usage(self):
|
|
|
|
"""
|
2021-06-03 15:56:59 -04:00
|
|
|
Enrich the city with the usage information and verify it
|
2020-11-06 05:40:17 -05:00
|
|
|
:return: None
|
|
|
|
"""
|
2021-08-11 11:14:06 -04:00
|
|
|
# case 1: HFT
|
2021-05-27 17:20:06 -04:00
|
|
|
file = 'pluto_building.gml'
|
|
|
|
city = self._get_citygml(file)
|
|
|
|
for building in city.buildings:
|
|
|
|
building.function = GeometryHelper.pluto_to_function[building.function]
|
2021-11-16 07:57:47 -05:00
|
|
|
ConstructionFactory('nrel', city).enrich()
|
2021-05-27 18:23:39 -04:00
|
|
|
UsageFactory('hft', city).enrich()
|
2020-11-06 05:40:17 -05:00
|
|
|
for building in city.buildings:
|
2021-06-23 09:53:33 -04:00
|
|
|
self.assertIsNot(len(building.usage_zones), 0, 'no building usage_zones defined')
|
2020-11-06 05:40:17 -05:00
|
|
|
for usage_zone in building.usage_zones:
|
2021-06-03 15:56:59 -04:00
|
|
|
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')
|
|
|
|
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')
|
2021-08-12 11:42:47 -04:00
|
|
|
self.assertIsNotNone(usage_zone.is_heated, 'thermal_zone heated is none')
|
|
|
|
self.assertIsNotNone(usage_zone.is_cooled, 'thermal_zone cooled is none')
|
|
|
|
|
2021-08-11 11:14:06 -04:00
|
|
|
|
|
|
|
# case 2: CA
|
|
|
|
file = 'one_building_in_kelowna.gml'
|
|
|
|
city = self._get_citygml(file)
|
2021-11-16 07:57:47 -05:00
|
|
|
ConstructionFactory('nrel', city).enrich()
|
2021-08-11 11:14:06 -04:00
|
|
|
UsageFactory('ca', city).enrich()
|
|
|
|
for building in city.buildings:
|
|
|
|
self.assertIsNot(len(building.usage_zones), 0, 'no building usage_zones defined')
|
|
|
|
for usage_zone in building.usage_zones:
|
|
|
|
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')
|