2020-10-21 15:23:06 -04:00
|
|
|
"""
|
|
|
|
TestOccupancyFactory test and validate the city model structure occupancy parameters
|
|
|
|
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
|
2020-10-29 08:16:48 -04:00
|
|
|
from factories.geometry_factory import GeometryFactory
|
|
|
|
from factories.physics_factory import PhysicsFactory
|
|
|
|
from factories.usage_factory import UsageFactory
|
2020-10-22 07:30:34 -04:00
|
|
|
from helpers.idf_helper import IdfHelper
|
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
|
|
|
|
self._example_path = (Path(__file__).parent.parent / 'tests_data').resolve()
|
2020-11-04 08:54:10 -05:00
|
|
|
self._output_path = (Path(__file__).parent / 'ep_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:
|
2020-11-04 11:56:57 -05:00
|
|
|
file_path = (self._example_path / '20buildings.gml').resolve()
|
2020-10-21 15:23:06 -04:00
|
|
|
self._city_gml = GeometryFactory('citygml', file_path).city
|
2020-11-04 11:56:57 -05:00
|
|
|
PhysicsFactory('us_new_york', self._city_gml)
|
2020-10-27 13:19:50 -04:00
|
|
|
UsageFactory('us_new_york', 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-04 11:56:57 -05:00
|
|
|
|
2020-10-26 13:47:10 -04: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-10-26 10:00:42 -04:00
|
|
|
_idf.add_block(building)
|
2020-11-04 11:56:57 -05:00
|
|
|
test_prefix = 'test_idf_blocks'
|
|
|
|
_idf.run(self._output_path, output_prefix=test_prefix, keep_file=self._output_path, display_render=True)
|
|
|
|
eso_file_path = (self._output_path / f'{test_prefix}out.eso')
|
|
|
|
heating, cooling = _idf.read_eso(str(eso_file_path))
|
|
|
|
self.assertEqual(len(heating), len(cooling), "Cooling and Heating doesn't contains the same amount of values")
|
2020-10-28 12:20:13 -04:00
|
|
|
# todo: clean up the files
|
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-10-27 13:19:50 -04:00
|
|
|
_idf = IdfHelper(idf_file_path, idd_file_path, epw_file_path)
|
|
|
|
city = self._get_city()
|
|
|
|
for building in city.buildings:
|
|
|
|
_idf.add_surfaces(building)
|
2020-11-04 11:56:57 -05:00
|
|
|
test_prefix = 'test_idf_blocks'
|
|
|
|
_idf.run(self._output_path, output_prefix=test_prefix, keep_file=self._output_path)
|
|
|
|
eso_file_path = (self._output_path / f'{test_prefix}out.eso')
|
|
|
|
heating, cooling = _idf.read_eso(str(eso_file_path))
|
|
|
|
self.assertEqual(len(heating), len(cooling), "Cooling and Heating doesn't contains the same amount of values")
|
2020-10-28 12:20:13 -04:00
|
|
|
# todo: clean up the files
|