Merge pull request 'solved bug in ventilation + infiltration calculation' (#17) from debugging_meb into main
Reviewed-on: https://nextgenerations-cities.encs.concordia.ca/gitea/CERC/hub/pulls/17
This commit is contained in:
commit
1a5db44488
|
@ -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.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}')
|
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'{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'
|
parameters.append(f'{len(thermal_zone.thermal_boundaries)} % Number of surfaces = BP(11+8z) \n'
|
||||||
|
|
|
@ -8,8 +8,12 @@ Project Coder Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
|
||||||
# universal constants
|
# universal constants
|
||||||
|
|
||||||
KELVIN = 273.15
|
KELVIN = 273.15
|
||||||
WATER_DENSITY = 1000
|
WATER_DENSITY = 1000 # kg/m3
|
||||||
WATER_HEAT_CAPACITY = 4182
|
WATER_HEAT_CAPACITY = 4182 # J/kgK
|
||||||
|
|
||||||
|
AIR_DENSITY = 1.293 # kg/m3
|
||||||
|
AIR_HEAT_CAPACITY = 1005.2 # J/kgK
|
||||||
|
|
||||||
|
|
||||||
# converters
|
# converters
|
||||||
HOUR_TO_MINUTES = 60
|
HOUR_TO_MINUTES = 60
|
||||||
|
@ -44,6 +48,24 @@ WEEK_DAYS = 'Weekdays'
|
||||||
WEEK_ENDS = 'Weekends'
|
WEEK_ENDS = 'Weekends'
|
||||||
ALL_DAYS = 'Alldays'
|
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
|
# data types
|
||||||
ANY_NUMBER = 'any_number'
|
ANY_NUMBER = 'any_number'
|
||||||
FRACTION = 'fraction'
|
FRACTION = 'fraction'
|
||||||
|
|
|
@ -10,15 +10,6 @@ import pandas as pd
|
||||||
import csv
|
import csv
|
||||||
import hub.helpers.constants as cte
|
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:
|
class InselMonthlyEnergyBalance:
|
||||||
"""
|
"""
|
||||||
|
@ -67,7 +58,7 @@ class InselMonthlyEnergyBalance:
|
||||||
for day_type in schedule.day_types:
|
for day_type in schedule.day_types:
|
||||||
demand = thermal_zone.domestic_hot_water.peak_flow * cte.WATER_DENSITY * cte.WATER_HEAT_CAPACITY \
|
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])
|
* (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)
|
domestic_hot_water_demand.append(total_dhw_demand * area)
|
||||||
|
|
||||||
building.domestic_hot_water_heat_demand[cte.MONTH] = \
|
building.domestic_hot_water_heat_demand[cte.MONTH] = \
|
||||||
|
@ -91,7 +82,7 @@ class InselMonthlyEnergyBalance:
|
||||||
for value in schedule.values:
|
for value in schedule.values:
|
||||||
total_day += value
|
total_day += value
|
||||||
for day_type in schedule.day_types:
|
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)
|
lighting_demand.append(total_lighting * area)
|
||||||
|
|
||||||
total_appliances = 0
|
total_appliances = 0
|
||||||
|
@ -100,7 +91,7 @@ class InselMonthlyEnergyBalance:
|
||||||
for value in schedule.values:
|
for value in schedule.values:
|
||||||
total_day += value
|
total_day += value
|
||||||
for day_type in schedule.day_types:
|
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)
|
appliances_demand.append(total_appliances * area)
|
||||||
|
|
||||||
building.lighting_electrical_demand[cte.MONTH] = pd.DataFrame(lighting_demand, columns=[cte.INSEL_MEB])
|
building.lighting_electrical_demand[cte.MONTH] = pd.DataFrame(lighting_demand, columns=[cte.INSEL_MEB])
|
||||||
|
|
|
@ -51,9 +51,7 @@ class TestUsageFactory(TestCase):
|
||||||
self.assertIsNotNone(building.walls, 'building walls is none')
|
self.assertIsNotNone(building.walls, 'building walls is none')
|
||||||
self.assertIsNotNone(building.roofs, 'building roofs is none')
|
self.assertIsNotNone(building.roofs, 'building roofs is none')
|
||||||
for internal_zone in building.internal_zones:
|
for internal_zone in building.internal_zones:
|
||||||
if internal_zone.usages is None:
|
if internal_zone.usages is not None:
|
||||||
print('non heated')
|
|
||||||
else:
|
|
||||||
self.assertTrue(len(internal_zone.usages) > 0, 'usage zones are not defined')
|
self.assertTrue(len(internal_zone.usages) > 0, 'usage zones are not defined')
|
||||||
self.assertIsNone(internal_zone.thermal_zones, 'thermal zones are defined')
|
self.assertIsNone(internal_zone.thermal_zones, 'thermal zones are defined')
|
||||||
self.assertIsNone(building.basement_heated, 'building basement_heated is not none')
|
self.assertIsNone(building.basement_heated, 'building basement_heated is not none')
|
||||||
|
@ -148,9 +146,7 @@ class TestUsageFactory(TestCase):
|
||||||
self._check_buildings(city)
|
self._check_buildings(city)
|
||||||
for building in city.buildings:
|
for building in city.buildings:
|
||||||
for internal_zone in building.internal_zones:
|
for internal_zone in building.internal_zones:
|
||||||
if internal_zone.usages is None:
|
if internal_zone.usages is not None:
|
||||||
print('non heated')
|
|
||||||
else:
|
|
||||||
self.assertIsNot(len(internal_zone.usages), 0, 'no building usage defined')
|
self.assertIsNot(len(internal_zone.usages), 0, 'no building usage defined')
|
||||||
for usage in internal_zone.usages:
|
for usage in internal_zone.usages:
|
||||||
self._check_usage(usage)
|
self._check_usage(usage)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user