2021-01-06 16:42:38 -05:00
|
|
|
"""
|
|
|
|
CaUsageParameters model the usage properties for a Canadian building
|
|
|
|
SPDX - License - Identifier: LGPL - 3.0 - or -later
|
|
|
|
Copyright © 2020 Project Author Pilar Monsalvete pilar_monsalvete@yahoo.es
|
|
|
|
"""
|
2021-01-07 17:33:55 -05:00
|
|
|
import sys
|
|
|
|
|
2021-01-06 16:42:38 -05:00
|
|
|
from factories.usage_feeders.hft_usage_interface import HftUsageInterface
|
|
|
|
from city_model_structure.attributes.usage_zone import UsageZone
|
|
|
|
|
2021-01-07 16:14:19 -05:00
|
|
|
|
2021-01-06 16:42:38 -05:00
|
|
|
class CaUsageParameters(HftUsageInterface):
|
|
|
|
"""
|
|
|
|
CaUsageParameters class
|
|
|
|
"""
|
|
|
|
def __init__(self, city, base_path):
|
|
|
|
super().__init__(base_path, 'ca_archetypes_reduced.xml')
|
|
|
|
self._city = city
|
2021-01-11 17:11:50 -05:00
|
|
|
# todo: this is a wrong location for self._min_air_change -> re-think where to place this info
|
|
|
|
# and where it comes from
|
|
|
|
self._min_air_change = 0
|
2021-01-06 16:42:38 -05:00
|
|
|
|
2021-01-07 18:12:13 -05:00
|
|
|
def enrich_buildings(self):
|
2021-01-06 16:42:38 -05:00
|
|
|
"""
|
|
|
|
Returns the city with the usage parameters assigned to the buildings
|
|
|
|
:return:
|
|
|
|
"""
|
|
|
|
city = self._city
|
|
|
|
for building in city.buildings:
|
|
|
|
archetype = self._search_archetype(building.function)
|
|
|
|
if archetype is None:
|
2021-01-07 18:12:13 -05:00
|
|
|
sys.stderr.write(f'Building {building.name} has unknown archetype for building usage: {building.function}\n')
|
2021-01-06 16:42:38 -05:00
|
|
|
continue
|
|
|
|
# todo: what to do with mix-usage usages from gml?
|
|
|
|
mix_usage = False
|
|
|
|
if not mix_usage:
|
|
|
|
# just one usage_zone
|
2021-01-11 17:11:50 -05:00
|
|
|
usage_zone = UsageZone(self._min_air_change)
|
2021-01-06 16:42:38 -05:00
|
|
|
self._assign_values(usage_zone, archetype)
|
|
|
|
building.usage_zones = [usage_zone]
|
|
|
|
|
|
|
|
def _search_archetype(self, building_usage):
|
|
|
|
for building_archetype in self._usage_archetypes:
|
|
|
|
if building_archetype.usage == building_usage:
|
|
|
|
return building_archetype
|
|
|
|
return None
|
|
|
|
|
2021-01-07 18:12:13 -05:00
|
|
|
@staticmethod
|
|
|
|
def _assign_values(usage_zone, archetype):
|
2021-01-06 16:42:38 -05:00
|
|
|
usage_zone.usage = archetype.usage
|
|
|
|
usage_zone.internal_gains = archetype.internal_gains
|
|
|
|
usage_zone.heating_setpoint = archetype.heating_setpoint
|
|
|
|
usage_zone.heating_setback = archetype.heating_setback
|
|
|
|
usage_zone.cooling_setpoint = archetype.cooling_setpoint
|
|
|
|
usage_zone.occupancy_density = archetype.occupancy_density
|
|
|
|
usage_zone.hours_day = archetype.hours_day
|
|
|
|
usage_zone.days_year = archetype.days_year
|
|
|
|
usage_zone.dhw_average_volume_pers_day = archetype.dhw_average_volume_pers_day
|
|
|
|
usage_zone.dhw_preparation_temperature = archetype.dhw_preparation_temperature
|
|
|
|
usage_zone.electrical_app_average_consumption_sqm_year = archetype.electrical_app_average_consumption_sqm_year
|
|
|
|
usage_zone.mechanical_air_change = archetype.mechanical_air_change
|