2020-10-21 15:23:06 -04:00
|
|
|
"""
|
2021-05-26 18:17:23 -04:00
|
|
|
TestOccupancyFactory test and validate the city model structure schedules parameters
|
2020-10-21 15:23:06 -04:00
|
|
|
SPDX - License - Identifier: LGPL - 3.0 - or -later
|
|
|
|
Copyright © 2020 Project Author Guille Gutierrez guillermo.gutierrezmorote@concordia.ca
|
|
|
|
"""
|
|
|
|
from pathlib import Path
|
|
|
|
from unittest import TestCase
|
2021-03-02 18:57:09 -05:00
|
|
|
from imports.geometry_factory import GeometryFactory
|
2021-05-26 18:17:23 -04:00
|
|
|
from imports.construction_factory import ConstructionFactory
|
2021-03-02 18:57:09 -05:00
|
|
|
from imports.usage_factory import UsageFactory
|
|
|
|
from imports.schedules_factory import SchedulesFactory
|
2020-11-05 11:11:43 -05:00
|
|
|
import os
|
|
|
|
import glob
|
2020-10-21 15:23:06 -04:00
|
|
|
|
|
|
|
|
|
|
|
class TestIdf(TestCase):
|
|
|
|
"""
|
|
|
|
Test IDF Class
|
|
|
|
"""
|
|
|
|
|
|
|
|
def setUp(self) -> None:
|
|
|
|
"""
|
|
|
|
Test setup
|
|
|
|
:return: None
|
|
|
|
"""
|
|
|
|
self._city_gml = None
|
2021-03-16 12:33:22 -04:00
|
|
|
self._example_path = (Path(__file__).parent / 'tests_data').resolve()
|
|
|
|
self._output_path = (Path(__file__).parent / 'tests_outputs').resolve()
|
2020-10-21 15:23:06 -04:00
|
|
|
|
2020-10-27 13:19:50 -04:00
|
|
|
def _get_city(self):
|
2020-10-21 15:23:06 -04:00
|
|
|
if self._city_gml is None:
|
2021-05-27 17:20:06 -04:00
|
|
|
file_path = (self._example_path / 'pluto_building.gml').resolve()
|
2020-10-21 15:23:06 -04:00
|
|
|
self._city_gml = GeometryFactory('citygml', file_path).city
|
2021-05-26 18:17:23 -04:00
|
|
|
ConstructionFactory('us_new_york', self._city_gml)
|
2020-10-27 13:19:50 -04:00
|
|
|
UsageFactory('us_new_york', self._city_gml)
|
2020-11-18 08:58:37 -05:00
|
|
|
UsageFactory('us_new_york', self._city_gml)
|
2020-12-15 14:57:46 -05:00
|
|
|
SchedulesFactory('demo', self._city_gml)
|
2020-10-21 15:23:06 -04:00
|
|
|
return self._city_gml
|
|
|
|
|
2020-10-27 13:19:50 -04:00
|
|
|
def test_idf_blocks(self):
|
2020-10-21 15:23:06 -04:00
|
|
|
idd_file_path = (self._example_path / 'energy+.idd').resolve()
|
|
|
|
idf_file_path = (self._example_path / 'minimal.idf').resolve()
|
|
|
|
epw_file_path = (self._example_path / 'montreal.epw').resolve()
|
2020-11-12 13:50:43 -05:00
|
|
|
idf = IdfHelper(idf_file_path, idd_file_path, epw_file_path)
|
2020-10-27 13:19:50 -04:00
|
|
|
city = self._get_city()
|
2020-10-21 15:23:06 -04:00
|
|
|
for building in city.buildings:
|
2020-11-12 13:50:43 -05:00
|
|
|
idf.add_block(building)
|
2020-11-04 11:56:57 -05:00
|
|
|
test_prefix = 'test_idf_blocks'
|
2020-11-12 13:50:43 -05:00
|
|
|
idf.run(self._output_path, output_prefix=test_prefix, keep_file=self._output_path)
|
2020-11-04 11:56:57 -05:00
|
|
|
eso_file_path = (self._output_path / f'{test_prefix}out.eso')
|
2020-11-12 13:50:43 -05:00
|
|
|
heating, cooling = idf.read_eso(str(eso_file_path))
|
2020-11-04 11:56:57 -05:00
|
|
|
self.assertEqual(len(heating), len(cooling), "Cooling and Heating doesn't contains the same amount of values")
|
2020-11-05 11:11:43 -05:00
|
|
|
self.assertNotEqual(len(heating), 0, "Cooling and Heating series are empty")
|
2020-11-12 13:50:43 -05:00
|
|
|
file_list = glob.glob(str(Path(self._output_path / '*').resolve()))
|
2020-11-05 11:11:43 -05:00
|
|
|
for file_path in file_list:
|
|
|
|
os.remove(file_path)
|
2020-10-26 13:33:03 -04:00
|
|
|
|
2020-10-27 13:19:50 -04:00
|
|
|
def test_idf_surfaces(self):
|
|
|
|
idd_file_path = (self._example_path / 'energy+.idd').resolve()
|
|
|
|
idf_file_path = (self._example_path / 'minimal.idf').resolve()
|
|
|
|
epw_file_path = (self._example_path / 'montreal.epw').resolve()
|
2020-10-28 12:20:13 -04:00
|
|
|
|
2020-11-12 13:50:43 -05:00
|
|
|
idf = IdfHelper(idf_file_path, idd_file_path, epw_file_path)
|
2020-10-27 13:19:50 -04:00
|
|
|
city = self._get_city()
|
|
|
|
for building in city.buildings:
|
2020-11-12 13:50:43 -05:00
|
|
|
idf.add_surfaces(building)
|
2020-11-18 02:28:29 -05:00
|
|
|
idf.add_schedule(building)
|
|
|
|
idf.add_occupancy()
|
2020-11-04 11:56:57 -05:00
|
|
|
test_prefix = 'test_idf_blocks'
|
2020-11-12 13:50:43 -05:00
|
|
|
idf.run(self._output_path, output_prefix=test_prefix, keep_file=self._output_path)
|
2020-11-04 11:56:57 -05:00
|
|
|
eso_file_path = (self._output_path / f'{test_prefix}out.eso')
|
2020-11-12 13:50:43 -05:00
|
|
|
heating, cooling = idf.read_eso(str(eso_file_path))
|
2020-11-04 11:56:57 -05:00
|
|
|
self.assertEqual(len(heating), len(cooling), "Cooling and Heating doesn't contains the same amount of values")
|
2020-11-05 11:11:43 -05:00
|
|
|
self.assertNotEqual(len(heating), 0, "Cooling and Heating series are empty")
|
|
|
|
file_list = glob.glob(str(Path(self._output_path / '*').resolve()))
|
|
|
|
for file_path in file_list:
|
|
|
|
os.remove(file_path)
|