From fba7effd52d95020731398ed129580a04ba5d250 Mon Sep 17 00:00:00 2001 From: guille Date: Mon, 2 Dec 2024 20:53:45 +0100 Subject: [PATCH] bug fix --- .../idf_helper/idf_infiltration.py | 2 +- hub/imports/results/energy_plus.py | 43 +++++++++++-------- tests/test_exports.py | 5 +-- 3 files changed, 27 insertions(+), 23 deletions(-) diff --git a/hub/exports/building_energy/idf_helper/idf_infiltration.py b/hub/exports/building_energy/idf_helper/idf_infiltration.py index 25557d14..59c97126 100644 --- a/hub/exports/building_energy/idf_helper/idf_infiltration.py +++ b/hub/exports/building_energy/idf_helper/idf_infiltration.py @@ -10,7 +10,7 @@ class IdfInfiltration(IdfBase): @staticmethod def add_surface(self, thermal_zone, zone_name): - IdfInfiltration._add_infiltration(self, thermal_zone, zone_name, 'Flow/ExteriorWallArea', 1) + IdfInfiltration._add_infiltration(self, thermal_zone, zone_name, 'Flow/ExteriorWallArea', cte.INFILTRATION_75PA_TO_4PA) @staticmethod def _add_infiltration(self, thermal_zone, zone_name, calculation_method, multiplier): diff --git a/hub/imports/results/energy_plus.py b/hub/imports/results/energy_plus.py index 382c185b..62ff0934 100644 --- a/hub/imports/results/energy_plus.py +++ b/hub/imports/results/energy_plus.py @@ -61,21 +61,21 @@ class EnergyPlus: continue for line in self._lines: building_energy_demands[header].append(line[position]) + # print(building_energy_demands['Zone Ideal Loads Supply Air Total Heating Energy [J](Hourly)']) EnergyPlus._set_building_demands(building, building_energy_demands) @staticmethod def _set_building_demands(building, building_energy_demands): - print(building.name, building_energy_demands) - building.heating_demand[cte.HOUR] = [float(x) for x in building_energy_demands[ - 'Zone Ideal Loads Supply Air Total Heating Energy [J](Hourly)']] - building.cooling_demand[cte.HOUR] = [float(x) for x in building_energy_demands[ - 'Zone Ideal Loads Supply Air Total Cooling Energy [J](Hourly)']] - building.domestic_hot_water_heat_demand[cte.HOUR] = [float(x) * cte.WATTS_HOUR_TO_JULES for x in building_energy_demands[ - 'Water Use Equipment Heating Rate [W](Hourly)']] - building.appliances_electrical_demand[cte.HOUR] = [float(x) * cte.WATTS_HOUR_TO_JULES for x in building_energy_demands[ - 'Other Equipment Electricity Rate [W](Hourly)']] - building.lighting_electrical_demand[cte.HOUR] = [float(x) * cte.WATTS_HOUR_TO_JULES for x in building_energy_demands[ - 'Zone Lights Electricity Rate [W](Hourly)']] + heating = [float(x) for x in building_energy_demands['Zone Ideal Loads Supply Air Total Heating Energy [J](Hourly)']] + cooling = [float(x) for x in building_energy_demands['Zone Ideal Loads Supply Air Total Cooling Energy [J](Hourly)']] + dhw = [float(x) * cte.WATTS_HOUR_TO_JULES for x in building_energy_demands['Water Use Equipment Heating Rate [W](Hourly)']] + appliances = [float(x) * cte.WATTS_HOUR_TO_JULES for x in building_energy_demands['Other Equipment Electricity Rate [W](Hourly)']] + lighting = [float(x) * cte.WATTS_HOUR_TO_JULES for x in building_energy_demands['Zone Lights Electricity Rate [W](Hourly)']] + building.heating_demand[cte.HOUR] = heating.copy() + building.cooling_demand[cte.HOUR] = cooling.copy() + building.domestic_hot_water_heat_demand[cte.HOUR] = dhw.copy() + building.appliances_electrical_demand[cte.HOUR] = appliances.copy() + building.lighting_electrical_demand[cte.HOUR] = lighting.copy() building.heating_demand[cte.MONTH] = [] building.cooling_demand[cte.MONTH] = [] building.domestic_hot_water_heat_demand[cte.MONTH] = [] @@ -83,20 +83,25 @@ class EnergyPlus: building.lighting_electrical_demand[cte.MONTH] = [] start = 0 + """ for hours in cte.HOURS_A_MONTH.values(): end = hours + start + if end == 8760: + print(building.heating_demand[cte.HOUR][start: end]) building.heating_demand[cte.MONTH].append(sum(building.heating_demand[cte.HOUR][start: end])) building.cooling_demand[cte.MONTH].append(sum(building.cooling_demand[cte.HOUR][start: end])) - building.domestic_hot_water_heat_demand[cte.MONTH].append(sum(building.domestic_hot_water_heat_demand[cte.HOUR][start: end])) - building.appliances_electrical_demand[cte.MONTH].append(sum(building.appliances_electrical_demand[cte.HOUR][start: end])) - building.lighting_electrical_demand[cte.MONTH].append(sum(building.lighting_electrical_demand[cte.HOUR][start: end])) + building.domestic_hot_water_heat_demand[cte.MONTH].append(sum(dhw[start: end])) + building.appliances_electrical_demand[cte.MONTH].append(sum(appliances[start: end])) + building.lighting_electrical_demand[cte.MONTH].append(sum(lighting[start: end])) start = end + """ + building.heating_demand[cte.YEAR] = [sum(building.heating_demand[cte.HOUR])] + building.cooling_demand[cte.YEAR] = [sum(building.cooling_demand[cte.HOUR])] + building.domestic_hot_water_heat_demand[cte.YEAR] = [sum(building.domestic_hot_water_heat_demand[cte.HOUR])] + building.appliances_electrical_demand[cte.YEAR] = [sum(building.appliances_electrical_demand[cte.HOUR])] + building.lighting_electrical_demand[cte.YEAR] = [sum(building.lighting_electrical_demand[cte.HOUR])] - building.heating_demand[cte.YEAR] = [sum(building.heating_demand[cte.MONTH])] - building.cooling_demand[cte.YEAR] = [sum(building.cooling_demand[cte.MONTH])] - 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])] + #print(f'jan: {building.heating_demand[cte.MONTH][0]}, year {building.heating_demand[cte.YEAR]}') diff --git a/tests/test_exports.py b/tests/test_exports.py index ed6d33cb..9fa6a643 100644 --- a/tests/test_exports.py +++ b/tests/test_exports.py @@ -151,6 +151,7 @@ class TestExports(TestCase): ResultFactory('cerc_idf', city, csv_output_path).enrich() self.assertTrue(csv_output_path.is_file()) for building in city.buildings: + print(building.name) self.assertIsNotNone(building.heating_demand) self.assertIsNotNone(building.cooling_demand) self.assertIsNotNone(building.domestic_hot_water_heat_demand) @@ -159,9 +160,7 @@ class TestExports(TestCase): total_demand = sum(building.heating_demand[cte.HOUR]) total_demand_month = sum(building.heating_demand[cte.MONTH]) print(building.heating_demand[cte.YEAR]) - print(building.heating_demand[cte.YEAR][0], total_demand_month, total_demand) + # print(building.heating_demand[cte.YEAR][0], total_demand_month, total_demand) 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!")