Correct error in meb (temporary workaround)
This commit is contained in:
parent
30908eda6d
commit
491b976fd9
|
@ -4,7 +4,7 @@ SPDX - License - Identifier: LGPL - 3.0 - or -later
|
|||
Copyright © 2022 Concordia CERC group
|
||||
Project Coder Guillermo.GutierrezMorote@concordia.ca
|
||||
"""
|
||||
|
||||
import logging
|
||||
from pathlib import Path
|
||||
import csv
|
||||
|
||||
|
@ -43,53 +43,61 @@ class InselMonthlyEnergyBalance:
|
|||
domestic_hot_water_demand = []
|
||||
lighting_demand = []
|
||||
appliances_demand = []
|
||||
if building.internal_zones[0].thermal_zones_from_internal_zones is None:
|
||||
|
||||
# todo: REFACTOR after retrofit project, this is a hack for the pickle files
|
||||
try:
|
||||
if building.internal_zones[0].thermal_zones_from_internal_zones is None:
|
||||
domestic_hot_water_demand = [0] * 12
|
||||
lighting_demand = [0] * 12
|
||||
appliances_demand = [0] * 12
|
||||
else:
|
||||
thermal_zone = building.internal_zones[0].thermal_zones_from_internal_zones[0]
|
||||
area = thermal_zone.total_floor_area
|
||||
cold_water = building.cold_water_temperature[cte.MONTH]
|
||||
peak_flow = thermal_zone.domestic_hot_water.peak_flow
|
||||
service_temperature = thermal_zone.domestic_hot_water.service_temperature
|
||||
lighting_density = thermal_zone.lighting.density
|
||||
appliances_density = thermal_zone.appliances.density
|
||||
|
||||
for month in range(0, 12):
|
||||
total_dhw_demand = 0
|
||||
total_lighting = 0
|
||||
total_appliances = 0
|
||||
|
||||
for schedule in thermal_zone.lighting.schedules:
|
||||
total_day = 0
|
||||
for value in schedule.values:
|
||||
total_day += value
|
||||
for day_type in schedule.day_types:
|
||||
total_lighting += total_day * cte.WEEK_DAYS_A_MONTH[day_type][month] \
|
||||
* lighting_density / cte.WATTS_HOUR_TO_JULES
|
||||
lighting_demand.append(total_lighting * area)
|
||||
|
||||
for schedule in thermal_zone.appliances.schedules:
|
||||
total_day = 0
|
||||
for value in schedule.values:
|
||||
total_day += value
|
||||
for day_type in schedule.day_types:
|
||||
total_appliances += total_day * cte.WEEK_DAYS_A_MONTH[day_type][month] \
|
||||
* appliances_density / cte.WATTS_HOUR_TO_JULES
|
||||
appliances_demand.append(total_appliances * area)
|
||||
|
||||
for schedule in thermal_zone.domestic_hot_water.schedules:
|
||||
total_day = 0
|
||||
for value in schedule.values:
|
||||
total_day += value
|
||||
for day_type in schedule.day_types:
|
||||
demand = (
|
||||
peak_flow * cte.WATER_DENSITY * cte.WATER_HEAT_CAPACITY
|
||||
* (service_temperature - cold_water[month]) / cte.WATTS_HOUR_TO_JULES
|
||||
)
|
||||
total_dhw_demand += total_day * cte.WEEK_DAYS_A_MONTH[day_type][month] * demand
|
||||
domestic_hot_water_demand.append(total_dhw_demand * area)
|
||||
except AttributeError:
|
||||
domestic_hot_water_demand = [0] * 12
|
||||
lighting_demand = [0] * 12
|
||||
appliances_demand = [0] * 12
|
||||
else:
|
||||
thermal_zone = building.internal_zones[0].thermal_zones_from_internal_zones[0]
|
||||
area = thermal_zone.total_floor_area
|
||||
cold_water = building.cold_water_temperature[cte.MONTH]
|
||||
peak_flow = thermal_zone.domestic_hot_water.peak_flow
|
||||
service_temperature = thermal_zone.domestic_hot_water.service_temperature
|
||||
lighting_density = thermal_zone.lighting.density
|
||||
appliances_density = thermal_zone.appliances.density
|
||||
|
||||
for month in range(0, 12):
|
||||
total_dhw_demand = 0
|
||||
total_lighting = 0
|
||||
total_appliances = 0
|
||||
|
||||
for schedule in thermal_zone.lighting.schedules:
|
||||
total_day = 0
|
||||
for value in schedule.values:
|
||||
total_day += value
|
||||
for day_type in schedule.day_types:
|
||||
total_lighting += total_day * cte.WEEK_DAYS_A_MONTH[day_type][month] \
|
||||
* lighting_density / cte.WATTS_HOUR_TO_JULES
|
||||
lighting_demand.append(total_lighting * area)
|
||||
|
||||
for schedule in thermal_zone.appliances.schedules:
|
||||
total_day = 0
|
||||
for value in schedule.values:
|
||||
total_day += value
|
||||
for day_type in schedule.day_types:
|
||||
total_appliances += total_day * cte.WEEK_DAYS_A_MONTH[day_type][month] \
|
||||
* appliances_density / cte.WATTS_HOUR_TO_JULES
|
||||
appliances_demand.append(total_appliances * area)
|
||||
|
||||
for schedule in thermal_zone.domestic_hot_water.schedules:
|
||||
total_day = 0
|
||||
for value in schedule.values:
|
||||
total_day += value
|
||||
for day_type in schedule.day_types:
|
||||
demand = (
|
||||
peak_flow * cte.WATER_DENSITY * cte.WATER_HEAT_CAPACITY
|
||||
* (service_temperature - cold_water[month]) / cte.WATTS_HOUR_TO_JULES
|
||||
)
|
||||
total_dhw_demand += total_day * cte.WEEK_DAYS_A_MONTH[day_type][month] * demand
|
||||
domestic_hot_water_demand.append(total_dhw_demand * area)
|
||||
logging.warning('Building internal zone raised an error, most likely the building has missing archetypes')
|
||||
|
||||
building.domestic_hot_water_heat_demand[cte.MONTH] = domestic_hot_water_demand
|
||||
building.domestic_hot_water_heat_demand[cte.YEAR] = [sum(domestic_hot_water_demand)]
|
||||
|
|
Loading…
Reference in New Issue
Block a user