diff --git a/factories/occupancy_feeders/helpers/occupancy_helper.py b/factories/occupancy_feeders/helpers/occupancy_helper.py index ffadb7ca..baab5423 100644 --- a/factories/occupancy_feeders/helpers/occupancy_helper.py +++ b/factories/occupancy_feeders/helpers/occupancy_helper.py @@ -7,8 +7,14 @@ Copyright © 2020 Project Author Guille Gutierrez guillermo.gutierrezmorote@conc class OccupancyHelper: occupancy_function = { + 'C1': 'C-12 Residential', + 'D3': 'C-12 Residential', + 'D6': 'C-12 Residential', 'I1': 'C-2 Health', - 'C1': 'C-12 Residential' + 'RI': 'C-12 Residential', + 'RM': 'C-12 Residential', + 'U0': 'C-10 Warehouse', + 'W4': 'C-9 School', } @staticmethod diff --git a/helpers/idf_helper.py b/helpers/idf_helper.py index b6685337..16cbe3e9 100644 --- a/helpers/idf_helper.py +++ b/helpers/idf_helper.py @@ -4,6 +4,7 @@ SPDX - License - Identifier: LGPL - 3.0 - or -later Copyright © 2020 Project Author Soroush Samareh Abolhassani - soroush.samarehabolhassani@mail.concordia.ca """ from geomeppy import IDF +import os import esoreader from pathlib import Path @@ -62,9 +63,8 @@ class IdfHelper: _points = IdfHelper._matrix_to_2d_list(building.foot_print.points) self._idf.add_block(name=building.name, coordinates=_points, height=building.max_height, num_stories=int(building.storeys_above_ground)) - # self._idf.intersect_match() - # self._idf.set_default_constructions() self.add_heating_system(building) + self._idf.intersect_match() def add_surfaces(self, building): self.add_block(building) @@ -78,35 +78,38 @@ class IdfHelper: print(surface.area) wall.setcoords(coordinates) - def run(self, window_ratio=0.35, display_render=False, output_prefix=None, output_directory='tests', keep_file=None): - self._idf.intersect_match() + + def run(self, output_directory, window_ratio=0.35, display_render=False, output_prefix=None, keep_file=None): + self._idf.set_default_constructions() self._idf.set_wwr(window_ratio, construction="Project External Window") self._idf.translate_to_origin() if display_render: self._idf.view_model() - - # self._idf.to_obj('ep_outputs/city.obj') - # Run - #self._idf.newidfobject("OUTPUT:METER", Key_Name="Heating:DistrictHeating", Reporting_Frequency="hourly") - #self._idf.newidfobject("OUTPUT:METER", Key_Name="Cooling:DistrictCooling", Reporting_Frequency="hourly") + self._idf.newidfobject("OUTPUT:METER", Key_Name="Heating:DistrictHeating", Reporting_Frequency="hourly") + self._idf.newidfobject("OUTPUT:METER", Key_Name="Cooling:DistrictCooling", Reporting_Frequency="hourly") + idf_path = None if keep_file is not None: idf_path = (keep_file / 'in.idf').resolve() - print(str(idf_path)) self._idf.saveas(str(idf_path)) - self._idf.run(output_prefix=output_prefix, output_directory=output_directory, expandobjects=True) + if idf_path is None: + idf_path = (Path(__file__).parent / 'in.idf').resolve() + + # There is a bug in the IDF class, when called, it return an error, as a work around we call call energy+ directly + run_command = f"energyplus --weather {self._epw_file_path} --output-directory {output_directory} --idd " \ + f"{self._idd_file_path} --expandobjects --output-prefix {output_prefix} {idf_path}" + os.system(run_command) + + if keep_file is None: + os.remove(idf_path) return @staticmethod - def read_eso(eso_path): - print("read_eso") - return [], [] - """ - eso = esoreader.read(str(eso_path)) - list_values = [v for v in df.values()] + def read_eso(eso_file_path): + dd, data = esoreader.read(eso_file_path) + list_values = [v for v in data.values()] heating = [(float(x)) / 3600000.0 for x in list_values[0]] cooling = [(float(x)) / 3600000.0 for x in list_values[1]] - return heating, cooling - """ + diff --git a/tests/test_geometry_factory.py b/tests/test_geometry_factory.py index 4ce0a163..d293b5e7 100644 --- a/tests/test_geometry_factory.py +++ b/tests/test_geometry_factory.py @@ -24,7 +24,7 @@ class TestGeometryFactory(TestCase): def _get_citygml(self): if self._city_gml is None: - file_path = (self._example_path / 'buildings.gml').resolve() + file_path = (self._example_path / '20buildings.gml').resolve() self._city_gml = GeometryFactory('citygml', file_path).city self.assertIsNotNone(self._city_gml, 'city is none') return self._city_gml @@ -102,8 +102,7 @@ class TestGeometryFactory(TestCase): self.assertIsNotNone(surface.points_list, 'surface points_list is none') self.assertIsNotNone(surface.polygon, 'surface polygon is none') self.assertIsNotNone(surface.shapely, 'surface shapely is none') - self.assertIsNotNone(surface.global_irradiance_hour, 'surface global_irradiance_hour is none') - self.assertIsNotNone(surface.global_irradiance_month, 'surface global_irradiance_month is none') + self.assertIsNotNone(surface.global_irradiance, 'monthly irradiance is none') self.assertIsNotNone(surface.normal, 'surface normal is none') self.assertIsNotNone(surface.projection, 'surface projection is none') self.assertIsNotNone(surface.swr, 'surface swr is none') diff --git a/tests/test_idf.py b/tests/test_idf.py index 15ae93f8..8b064d71 100644 --- a/tests/test_idf.py +++ b/tests/test_idf.py @@ -27,9 +27,9 @@ class TestIdf(TestCase): def _get_city(self): if self._city_gml is None: - file_path = (self._example_path / 'buildings.gml').resolve() + file_path = (self._example_path / '20buildings.gml').resolve() self._city_gml = GeometryFactory('citygml', file_path).city - PhysicsFactory('us_new_york', self._city_gml, base_path=self._example_path) + PhysicsFactory('us_new_york', self._city_gml) UsageFactory('us_new_york', self._city_gml) return self._city_gml @@ -37,14 +37,16 @@ class TestIdf(TestCase): 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() + _idf = IdfHelper(idf_file_path, idd_file_path, epw_file_path) city = self._get_city() for building in city.buildings: _idf.add_block(building) - break - _idf.run(output_prefix='test_idf_blocks', output_directory="ep_outputs", keep_file=self._output_path) - _idf.read_eso(str(self._example_path)) - self.assertEqual(1, 2, "arent equal") + 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") # todo: clean up the files def test_idf_surfaces(self): @@ -56,6 +58,9 @@ class TestIdf(TestCase): city = self._get_city() for building in city.buildings: _idf.add_surfaces(building) - _idf.run(output_prefix='test_idf_surfaces', output_directory="ep_outputs", keep_file=self._output_path) - self.assertEqual(1, 2, "arent equal") + 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") # todo: clean up the files diff --git a/tests/test_occupancy_factory.py b/tests/test_occupancy_factory.py index 66939e3d..5c313b8e 100644 --- a/tests/test_occupancy_factory.py +++ b/tests/test_occupancy_factory.py @@ -34,7 +34,7 @@ class TestOccupancyFactory(TestCase): def _get_citygml_with_usage(self): if self._city_gml_with_usage is None: - file_path = (self._example_path / 'buildings.gml').resolve() + file_path = (self._example_path / '20buildings.gml').resolve() self._city_gml_with_usage = GeometryFactory('citygml', file_path).city self.assertIsNotNone(self._city_gml_with_usage, 'city is none') UsageFactory(self._handler, self._city_gml_with_usage) @@ -47,4 +47,3 @@ class TestOccupancyFactory(TestCase): for building in city.buildings: for usage_zone in building.usage_zones: self.assertTrue(usage_zone.schedules) - print(len(Occupancy().get_complete_year_schedule(usage_zone.schedules['Occupancy']))) diff --git a/tests/test_physics_factory.py b/tests/test_physics_factory.py index d22b3126..5654c957 100644 --- a/tests/test_physics_factory.py +++ b/tests/test_physics_factory.py @@ -25,7 +25,7 @@ class TestPhysicsFactory(TestCase): def _get_citygml(self): if self._city_gml is None: - file_path = (self._example_path / 'buildings.gml').resolve() + file_path = (self._example_path / '20buildings.gml').resolve() self._city_gml = GeometryFactory('citygml', file_path).city self.assertIsNotNone(self._city_gml, 'city is none') return self._city_gml @@ -33,7 +33,7 @@ class TestPhysicsFactory(TestCase): def _get_city_with_physics(self): if self._nyc_with_physics is None: self._nyc_with_physics = self._get_citygml() - PhysicsFactory('us_new_york', self._nyc_with_physics, base_path=self._example_path) + PhysicsFactory('us_new_york', self._nyc_with_physics) return self._nyc_with_physics def test_city_with_physics(self): diff --git a/tests/test_weather_factory.py b/tests/test_weather_factory.py index 84f7c554..c07f8179 100644 --- a/tests/test_weather_factory.py +++ b/tests/test_weather_factory.py @@ -26,7 +26,7 @@ class TestWeatherFactory(TestCase): def _get_citygml(self): if self._city_gml is None: - file_path = (self._example_path / 'buildings.gml').resolve() + file_path = (self._example_path / '20buildings.gml').resolve() self._city_gml = GeometryFactory('citygml', file_path).city self.assertIsNotNone(self._city_gml, 'city is none') return self._city_gml