From f5987cfbcc14a440d366def8ffc6680096333048 Mon Sep 17 00:00:00 2001 From: p_monsalvete Date: Fri, 24 Mar 2023 13:34:37 -0400 Subject: [PATCH] solved bug in ventilation + infiltration calculation --- .../insel/insel_monthly_energy_balance.py | 24 ++++++++++++++++- hub/helpers/constants.py | 26 +++++++++++++++++-- .../results/insel_monthly_energry_balance.py | 15 +++-------- hub/unittests/test_usage_factory.py | 8 ++---- 4 files changed, 52 insertions(+), 21 deletions(-) diff --git a/hub/exports/building_energy/insel/insel_monthly_energy_balance.py b/hub/exports/building_energy/insel/insel_monthly_energy_balance.py index 966c7586..8254cef0 100644 --- a/hub/exports/building_energy/insel/insel_monthly_energy_balance.py +++ b/hub/exports/building_energy/insel/insel_monthly_energy_balance.py @@ -132,7 +132,29 @@ class InselMonthlyEnergyBalance(Insel): parameters.append(f'{usage.hours_day} % BP(16) #6 Usage hours per day zone {i + 1}') parameters.append(f'{usage.days_year} % BP(17) #7 Usage days per year zone {i + 1}') - ventilation_infiltration = usage.mechanical_air_change + internal_zone.thermal_zones[0].infiltration_rate_system_off + ventilation = 0 + infiltration = 0 + for schedule in usage.thermal_control.hvac_availability_schedules: + ventilation_day = 0 + infiltration_day = 0 + for value in schedule.values: + if value == 0: + infiltration_day += internal_zone.thermal_zones[0].infiltration_rate_system_off / 24 + ventilation_day += 0 + else: + ventilation_value = usage.mechanical_air_change * value + infiltration_value = internal_zone.thermal_zones[0].infiltration_rate_system_off * value + if ventilation_value >= infiltration_value: + ventilation_day += ventilation_value / 24 + infiltration_day += 0 + else: + ventilation_day += 0 + infiltration_day += infiltration_value / 24 + for day_type in schedule.day_types: + infiltration += infiltration_day * cte.DAYS_A_YEAR[day_type] / 365 + ventilation += ventilation_day * cte.DAYS_A_YEAR[day_type] / 365 + + ventilation_infiltration = ventilation + infiltration parameters.append(f'{ventilation_infiltration} % BP(18) #8 Minimum air change rate zone {i + 1} (ACH)') parameters.append(f'{len(thermal_zone.thermal_boundaries)} % Number of surfaces = BP(11+8z) \n' diff --git a/hub/helpers/constants.py b/hub/helpers/constants.py index 2a20c263..b147e26d 100644 --- a/hub/helpers/constants.py +++ b/hub/helpers/constants.py @@ -8,8 +8,12 @@ Project Coder Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca # universal constants KELVIN = 273.15 -WATER_DENSITY = 1000 -WATER_HEAT_CAPACITY = 4182 +WATER_DENSITY = 1000 # kg/m3 +WATER_HEAT_CAPACITY = 4182 # J/kgK + +AIR_DENSITY = 1.293 # kg/m3 +AIR_HEAT_CAPACITY = 1005.2 # J/kgK + # converters HOUR_TO_MINUTES = 60 @@ -44,6 +48,24 @@ WEEK_DAYS = 'Weekdays' WEEK_ENDS = 'Weekends' ALL_DAYS = 'Alldays' +DAYS_A_MONTH = {'monday': [5, 4, 4, 5, 4, 4, 5, 4, 4, 5, 4, 5], + 'tuesday': [5, 4, 4, 4, 5, 4, 5, 4, 4, 5, 4, 4], + 'wednesday': [5, 4, 4, 4, 5, 4, 4, 5, 4, 5, 4, 4], + 'thursday': [4, 4, 5, 4, 5, 4, 4, 5, 4, 4, 5, 4], + 'friday': [4, 4, 5, 4, 4, 5, 4, 5, 4, 4, 5, 4], + 'saturday': [4, 4, 5, 4, 4, 5, 4, 4, 5, 4, 4, 5], + 'sunday': [4, 4, 4, 5, 4, 4, 5, 4, 5, 4, 4, 5], + 'holiday': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]} + +DAYS_A_YEAR = {'monday': 53, + 'tuesday': 52, + 'wednesday': 52, + 'thursday': 52, + 'friday': 52, + 'saturday': 52, + 'sunday': 52, + 'holiday': 0} + # data types ANY_NUMBER = 'any_number' FRACTION = 'fraction' diff --git a/hub/imports/results/insel_monthly_energry_balance.py b/hub/imports/results/insel_monthly_energry_balance.py index 82594c3f..5e421330 100644 --- a/hub/imports/results/insel_monthly_energry_balance.py +++ b/hub/imports/results/insel_monthly_energry_balance.py @@ -10,15 +10,6 @@ import pandas as pd import csv import hub.helpers.constants as cte -_DAYS_A_MONTH = {cte.MONDAY: [5, 4, 4, 5, 4, 4, 5, 4, 4, 5, 4, 5], - cte.TUESDAY: [5, 4, 4, 4, 5, 4, 5, 4, 4, 5, 4, 4], - cte.WEDNESDAY: [5, 4, 4, 4, 5, 4, 4, 5, 4, 5, 4, 4], - cte.THURSDAY: [4, 4, 5, 4, 5, 4, 4, 5, 4, 4, 5, 4], - cte.FRIDAY: [4, 4, 5, 4, 4, 5, 4, 5, 4, 4, 5, 4], - cte.SATURDAY: [4, 4, 5, 4, 4, 5, 4, 4, 5, 4, 4, 5], - cte.SUNDAY: [4, 4, 4, 5, 4, 4, 5, 4, 5, 4, 4, 5], - cte.HOLIDAY: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]} - class InselMonthlyEnergyBalance: """ @@ -67,7 +58,7 @@ class InselMonthlyEnergyBalance: for day_type in schedule.day_types: demand = thermal_zone.domestic_hot_water.peak_flow * cte.WATER_DENSITY * cte.WATER_HEAT_CAPACITY \ * (thermal_zone.domestic_hot_water.service_temperature - cold_water[month]) - total_dhw_demand += total_day * _DAYS_A_MONTH[day_type][month] * demand + total_dhw_demand += total_day * cte.DAYS_A_MONTH[day_type][month] * demand domestic_hot_water_demand.append(total_dhw_demand * area) building.domestic_hot_water_heat_demand[cte.MONTH] = \ @@ -91,7 +82,7 @@ class InselMonthlyEnergyBalance: for value in schedule.values: total_day += value for day_type in schedule.day_types: - total_lighting += total_day * _DAYS_A_MONTH[day_type][month] * thermal_zone.lighting.density + total_lighting += total_day * cte.DAYS_A_MONTH[day_type][month] * thermal_zone.lighting.density lighting_demand.append(total_lighting * area) total_appliances = 0 @@ -100,7 +91,7 @@ class InselMonthlyEnergyBalance: for value in schedule.values: total_day += value for day_type in schedule.day_types: - total_appliances += total_day * _DAYS_A_MONTH[day_type][month] * thermal_zone.appliances.density + total_appliances += total_day * cte.DAYS_A_MONTH[day_type][month] * thermal_zone.appliances.density appliances_demand.append(total_appliances * area) building.lighting_electrical_demand[cte.MONTH] = pd.DataFrame(lighting_demand, columns=[cte.INSEL_MEB]) diff --git a/hub/unittests/test_usage_factory.py b/hub/unittests/test_usage_factory.py index 2f86776a..ad5fb1b4 100644 --- a/hub/unittests/test_usage_factory.py +++ b/hub/unittests/test_usage_factory.py @@ -51,9 +51,7 @@ class TestUsageFactory(TestCase): self.assertIsNotNone(building.walls, 'building walls is none') self.assertIsNotNone(building.roofs, 'building roofs is none') for internal_zone in building.internal_zones: - if internal_zone.usages is None: - print('non heated') - else: + if internal_zone.usages is not None: self.assertTrue(len(internal_zone.usages) > 0, 'usage zones are not defined') self.assertIsNone(internal_zone.thermal_zones, 'thermal zones are defined') self.assertIsNone(building.basement_heated, 'building basement_heated is not none') @@ -148,9 +146,7 @@ class TestUsageFactory(TestCase): self._check_buildings(city) for building in city.buildings: for internal_zone in building.internal_zones: - if internal_zone.usages is None: - print('non heated') - else: + if internal_zone.usages is not None: self.assertIsNot(len(internal_zone.usages), 0, 'no building usage defined') for usage in internal_zone.usages: self._check_usage(usage)