diff --git a/hub/exports/building_energy/idf.py b/hub/exports/building_energy/idf.py index a6d06d76..43c7b7f3 100644 --- a/hub/exports/building_energy/idf.py +++ b/hub/exports/building_energy/idf.py @@ -445,7 +445,7 @@ class Idf: subcategory = f'ELECTRIC EQUIPMENT#{zone_name}#InteriorEquipment' self._idf.newidfobject(self._APPLIANCES, Fuel_Type=fuel_type, - Name=f'{zone_name}_appliance', + Name=zone_name, Zone_or_ZoneList_or_Space_or_SpaceList_Name=zone_name, Schedule_Name=f'Appliance schedules {thermal_zone.usage_name}', Design_Level_Calculation_Method=method, diff --git a/hub/exports/building_energy/idf_helper/idf_appliance.py b/hub/exports/building_energy/idf_helper/idf_appliance.py index 9e435abb..754d9a1f 100644 --- a/hub/exports/building_energy/idf_helper/idf_appliance.py +++ b/hub/exports/building_energy/idf_helper/idf_appliance.py @@ -11,7 +11,7 @@ class IdfAppliance(IdfBase): subcategory = f'ELECTRIC EQUIPMENT#{zone_name}#InteriorEquipment' file = self._files['appliances'] self._write_to_idf_format(file, idf_cte.APPLIANCES) - self._write_to_idf_format(file, f'{zone_name}_appliance', 'Name') + self._write_to_idf_format(file, zone_name, 'Name') self._write_to_idf_format(file, 'Electricity', 'Fuel Type') self._write_to_idf_format(file, zone_name, 'Zone or ZoneList or Space or SpaceList Name') self._write_to_idf_format(file, schedule_name, 'Schedule Name') diff --git a/hub/exports/building_energy/idf_helper/idf_dhw.py b/hub/exports/building_energy/idf_helper/idf_dhw.py index 0161116f..73898798 100644 --- a/hub/exports/building_energy/idf_helper/idf_dhw.py +++ b/hub/exports/building_energy/idf_helper/idf_dhw.py @@ -5,15 +5,14 @@ from hub.exports.building_energy.idf_helper.idf_base import IdfBase class IdfDhw(IdfBase): @staticmethod def add(self, thermal_zone, zone_name): - name = f'DHW {zone_name}' peak_flow_rate = thermal_zone.domestic_hot_water.peak_flow * thermal_zone.total_floor_area flow_rate_schedule = f'DHW_prof schedules {thermal_zone.usage_name}' dhw_schedule = f'DHW_temp schedules {thermal_zone.usage_name}' cold_temp_schedule = f'cold_temp schedules {thermal_zone.usage_name}' file = self._files['dhw'] self._write_to_idf_format(file, idf_cte.DHW) - self._write_to_idf_format(file, name, 'Name') - self._write_to_idf_format(file, name, 'EndUse Subcategory') + self._write_to_idf_format(file, zone_name, 'Name') + self._write_to_idf_format(file, zone_name, 'EndUse Subcategory') self._write_to_idf_format(file, peak_flow_rate, 'Peak Flow Rate') self._write_to_idf_format(file, flow_rate_schedule, 'Flow Rate Fraction Schedule Name') self._write_to_idf_format(file, dhw_schedule, 'Target Temperature Schedule Name') diff --git a/hub/imports/results/energy_plus.py b/hub/imports/results/energy_plus.py index 773aca46..92649723 100644 --- a/hub/imports/results/energy_plus.py +++ b/hub/imports/results/energy_plus.py @@ -1,30 +1,26 @@ """ -Insel monthly energy balance +Cerc Idf result import SPDX - License - Identifier: LGPL - 3.0 - or -later Copyright © 2022 Concordia CERC group -Project Coder Saeed Ranjbar saeed.ranjbar@concordia.ca -Project collaborator Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca +Project Coder Guille Guillermo.GutierrezMorote@concordia.ca +Code contributors: Saeed Ranjbar saeed.ranjbar@concordia.ca """ from pathlib import Path import csv -from hub.helpers.monthly_values import MonthlyValues -import hub.helpers.constants as cte - class EnergyPlus: """ Energy plus class """ - def __init__(self, city, base_path): + def __init__(self, city, file_path): self._city = city - self._base_path = base_path - - @staticmethod - def _building_energy_demands(energy_plus_output_file_path): - with open(Path(energy_plus_output_file_path).resolve(), 'r', encoding='utf8') as csv_file: + with open(file_path, 'r', encoding='utf8') as csv_file: csv_output = csv.reader(csv_file) headers = next(csv_output) + print('headers:', headers) + + """ building_energy_demands = { 'Heating (J)': [], 'Cooling (J)': [], @@ -72,12 +68,15 @@ class EnergyPlus: building_energy_demands['Lighting (J)'].append(total_lighting_demand) return building_energy_demands + """ def enrich(self): """ Enrich the city by using the energy plus workflow output files (J) :return: None """ + return + """ for building in self._city.buildings: file_name = f'{building.name}_out.csv' energy_plus_output_file_path = Path(self._base_path / file_name).resolve() @@ -103,3 +102,4 @@ class EnergyPlus: building.domestic_hot_water_heat_demand[cte.YEAR] = [sum(building.domestic_hot_water_heat_demand[cte.MONTH])] building.appliances_electrical_demand[cte.YEAR] = [sum(building.appliances_electrical_demand[cte.MONTH])] building.lighting_electrical_demand[cte.YEAR] = [sum(building.lighting_electrical_demand[cte.MONTH])] + """ \ No newline at end of file diff --git a/hub/imports/results/ep_multiple_buildings.py b/hub/imports/results/ep_multiple_buildings.py index 71d62763..dd748120 100644 --- a/hub/imports/results/ep_multiple_buildings.py +++ b/hub/imports/results/ep_multiple_buildings.py @@ -22,9 +22,11 @@ class EnergyPlusMultipleBuildings: with open(Path(energy_plus_output_file_path).resolve(), 'r', encoding='utf8') as csv_file: csv_output = list(csv.DictReader(csv_file)) - + print(csv_output) + return for building in self._city.buildings: building_name = building.name.upper() + buildings_energy_demands[f'Building {building_name} Heating Demand (J)'] = [ float( row[f"{building_name} IDEAL LOADS AIR SYSTEM:Zone Ideal Loads Supply Air Total Heating Energy [J](Hourly)"]) diff --git a/hub/imports/results_factory.py b/hub/imports/results_factory.py index 66311f60..bd1d8660 100644 --- a/hub/imports/results_factory.py +++ b/hub/imports/results_factory.py @@ -8,6 +8,7 @@ Code contributors: Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concord from pathlib import Path from hub.helpers.utils import validate_import_export_type +from hub.imports.results.energy_plus import EnergyPlus from hub.imports.results.insel_monthly_energry_balance import InselMonthlyEnergyBalance from hub.imports.results.simplified_radiosity_algorithm import SimplifiedRadiosityAlgorithm @@ -60,6 +61,9 @@ class ResultFactory: """ EnergyPlusMultipleBuildings(self._city, self._base_path).enrich() + def _cerc_idf(self): + EnergyPlus(self._city, self._base_path).enrich() + def enrich(self): """ Enrich the city given to the class using the usage factory given handler diff --git a/tests/test_exports.py b/tests/test_exports.py index 96f82400..a12672f0 100644 --- a/tests/test_exports.py +++ b/tests/test_exports.py @@ -17,6 +17,7 @@ from hub.exports.exports_factory import ExportsFactory from hub.helpers.dictionaries import Dictionaries from hub.imports.construction_factory import ConstructionFactory from hub.imports.geometry_factory import GeometryFactory +from hub.imports.results_factory import ResultFactory from hub.imports.usage_factory import UsageFactory from hub.imports.weather_factory import WeatherFactory @@ -137,19 +138,6 @@ class TestExports(TestCase): year_of_construction_field='ANNEE_CONS', function_field='CODE_UTILI', function_to_hub=Dictionaries().montreal_function_to_hub_function).city - """=-043 - "name": "01043081", - "address": "avenue de l' H\u00f4tel-de-Ville (MTL) 3751", - "function": "6911", - "height": 21, - "year_of_construction": 1964, - city = GeometryFactory('geojson', - path=file_path, - height_field='height', - year_of_construction_field='year_of_construction', - function_field='function', - function_to_hub=Dictionaries().montreal_function_to_hub_function).city - """ self.assertIsNotNone(city, 'city is none') #EnergyBuildingsExportsFactory('idf', city, self._output_path).export() ConstructionFactory('nrcan', city).enrich() @@ -159,6 +147,20 @@ class TestExports(TestCase): try: idf = EnergyBuildingsExportsFactory('cerc_idf', city, self._output_path).export() idf.run() - + csv_output_path = (self._output_path / f'{city.name}_out.csv').resolve() + ResultFactory('cerc_idf', city, csv_output_path).enrich() + self.assertTrue(csv_output_path.is_file()) + """ + for building in self._city.buildings: + self.assertIsNotNone(building.heating_demand) + self.assertIsNotNone(building.cooling_demand) + self.assertIsNotNone(building.domestic_hot_water_heat_demand) + self.assertIsNotNone(building.lighting_electrical_demand) + self.assertIsNotNone(building.appliances_electrical_demand) + total_demand = sum(building.heating_demand[cte.HOUR]) + self.assertAlmostEqual(total_demand, building.heating_demand[cte.YEAR][0], 2) + total_demand = sum(building.heating_demand[cte.MONTH]) + self.assertEqual(total_demand, building.heating_demand[cte.YEAR][0], 2) + """ except Exception: self.fail("Idf ExportsFactory raised ExceptionType unexpectedly!") diff --git a/tests/test_results_import.py b/tests/test_results_import.py index a5f9a750..8c19627c 100644 --- a/tests/test_results_import.py +++ b/tests/test_results_import.py @@ -94,6 +94,7 @@ class TestResultsImport(TestCase): self.assertIsNotNone(building.cooling_peak_load) def test_energy_plus_results_import(self): + # todo: this tests aren't actually testing the functionality ResultFactory('energy_plus_single_building', self._city, self._example_path).enrich() for building in self._city.buildings: csv_output_name = f'{building.name}_out.csv' @@ -117,6 +118,7 @@ class TestResultsImport(TestCase): self.assertDictEqual(building.appliances_electrical_demand, {}) def test_energy_plus_multiple_buildings_results_import(self): + # todo: this tests aren't actually testing the functionality ResultFactory('energy_plus_multiple_buildings', self._city, self._example_path).enrich() csv_output_name = f'{self._city.name}_out.csv' csv_output_path = (self._example_path / csv_output_name).resolve() @@ -131,3 +133,7 @@ class TestResultsImport(TestCase): self.assertAlmostEqual(total_demand, building.heating_demand[cte.YEAR][0], 2) total_demand = sum(building.heating_demand[cte.MONTH]) self.assertEqual(total_demand, building.heating_demand[cte.YEAR][0], 2) + + def test_cerc_idf_results(self): + csv_output_path = (self._output_path / f'Montreal_out.csv').resolve() + ResultFactory('cerc_idf', self._city, csv_output_path).enrich()