From 8b66e20e9ae23d6e67bf630f0dd23e550d9ec249 Mon Sep 17 00:00:00 2001 From: p_monsalvete Date: Wed, 27 Sep 2023 05:35:28 -0400 Subject: [PATCH] some refactoring --- hub/exports/building_energy/idf.py | 1 + ...ergy_plus_workflow.py => energy_plus_single_building.py} | 6 ++---- hub/imports/results_factory.py | 6 +++--- tests/test_results_import.py | 2 +- 4 files changed, 7 insertions(+), 8 deletions(-) rename hub/imports/results/{energy_plus_workflow.py => energy_plus_single_building.py} (94%) diff --git a/hub/exports/building_energy/idf.py b/hub/exports/building_energy/idf.py index 50f97849..63ea0b19 100644 --- a/hub/exports/building_energy/idf.py +++ b/hub/exports/building_energy/idf.py @@ -558,6 +558,7 @@ class Idf: self._add_lighting(thermal_zone, building.name) self._add_appliances(thermal_zone, building.name) self._add_dhw(thermal_zone, building.name) + # todo: @Guille: if export_type is not surfaces, we don't differentiate between shadows and buildings? if self._export_type == "Surfaces": if building.name in self._target_buildings or building.name in self._adjacent_buildings: if building.thermal_zones_from_internal_zones is not None: diff --git a/hub/imports/results/energy_plus_workflow.py b/hub/imports/results/energy_plus_single_building.py similarity index 94% rename from hub/imports/results/energy_plus_workflow.py rename to hub/imports/results/energy_plus_single_building.py index 627b3fd7..a5e0fd08 100644 --- a/hub/imports/results/energy_plus_workflow.py +++ b/hub/imports/results/energy_plus_single_building.py @@ -12,7 +12,7 @@ import csv import hub.helpers.constants as cte -class EnergyPlusWorkflow: +class EnergyPlusSingleBuilding: def __init__(self, city, base_path): self._city = city self._base_path = base_path @@ -59,7 +59,7 @@ class EnergyPlusWorkflow: total_cooling_demand += float(line[cooling_index]) building_energy_demands['Cooling (J)'].append(total_cooling_demand) for dhw_index in dhw_column_index: - total_dhw_demand += float(line[dhw_index]) * 3600 + total_dhw_demand += float(line[dhw_index]) * cte.WATTS_HOUR_TO_JULES building_energy_demands['DHW (J)'].append(total_dhw_demand) for appliance_index in appliance_column_index: total_appliance_demand += float(line[appliance_index]) @@ -85,8 +85,6 @@ class EnergyPlusWorkflow: building.domestic_hot_water_heat_demand[cte.HOUR] = building_energy_demands['DHW (J)'] building.appliances_electrical_demand[cte.HOUR] = building_energy_demands['Appliances (J)'] building.lighting_electrical_demand[cte.HOUR] = building_energy_demands['Lighting (J)'] - # todo: @Saeed, this a list of ONE value with the total energy of the year, exactly the same as cte.YEAR. - # You have to use the method to add hourly values from helpers/monthly_values building.heating_demand[cte.MONTH] = MonthlyValues.get_total_month(building.heating_demand[cte.HOUR]) building.cooling_demand[cte.MONTH] = MonthlyValues.get_total_month(building.cooling_demand[cte.HOUR]) building.domestic_hot_water_heat_demand[cte.MONTH] = ( diff --git a/hub/imports/results_factory.py b/hub/imports/results_factory.py index fac60de3..480b5c64 100644 --- a/hub/imports/results_factory.py +++ b/hub/imports/results_factory.py @@ -10,7 +10,7 @@ from pathlib import Path from hub.helpers.utils import validate_import_export_type from hub.imports.results.insel_monthly_energry_balance import InselMonthlyEnergyBalance from hub.imports.results.simplified_radiosity_algorithm import SimplifiedRadiosityAlgorithm -from hub.imports.results.energy_plus_workflow import EnergyPlusWorkflow +from hub.imports.results.energy_plus_single_building import EnergyPlusSingleBuilding class ResultFactory: """ @@ -46,11 +46,11 @@ class ResultFactory: """ InselMonthlyEnergyBalance(self._city, self._base_path).enrich() - def _energy_plus_workflow(self): + def _energy_plus_single_building(self): """ Enrich the city with energy plus results """ - EnergyPlusWorkflow(self._city, self._base_path).enrich() + EnergyPlusSingleBuilding(self._city, self._base_path).enrich() def enrich(self): """ diff --git a/tests/test_results_import.py b/tests/test_results_import.py index 8f4e0aed..b83418e6 100644 --- a/tests/test_results_import.py +++ b/tests/test_results_import.py @@ -94,7 +94,7 @@ class TestResultsImport(TestCase): self.assertIsNotNone(building.cooling_peak_load) def test_energy_plus_results_import(self): - ResultFactory('energy_plus_workflow', self._city, self._example_path).enrich() + 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' csv_output_path = (self._example_path / csv_output_name).resolve()