system_assignation/imports/usage/ashrae_usage_parameters.py

56 lines
2.0 KiB
Python
Raw Normal View History

"""
AshraeUsageParameters model the usage properties
SPDX - License - Identifier: LGPL - 3.0 - or -later
Copyright © 2020 Project Author Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
"""
import sys
from imports.geometry.helpers.geometry_helper import GeometryHelper as gh
from city_model_structure.building_demand.usage_zone import UsageZone
class AshraeUsageParameters:
"""
AshraeUsageParameters class
"""
def __init__(self, city, base_path):
super().__init__(base_path, 'ashrae_archetypes.xml')
self._city = city
self._usage_archetypes = None
def enrich_buildings(self):
"""
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:
sys.stderr.write(f'Building {building.name} has unknown archetype for building function:'
f' {building.function}, that assigns building usage as '
f'{gh.usage_from_function(building.function)}\n')
continue
# todo: what to do with mix-usage usage from gml?
mix_usage = False
if not mix_usage:
# just one usage_zone
for thermal_zone in building.thermal_zones:
usage_zone = UsageZone()
usage_zone.volume = thermal_zone.volume
self._assign_values(usage_zone, archetype)
thermal_zone.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
@staticmethod
def _assign_values(usage_zone, archetype):
usage_zone.usage = archetype.usage
usage_zone.occupancy_density = archetype.occupancy_density
# todo: should I use this value: self._min_air_change??
usage_zone.minimum_ventilation_rate = archetype.minimum_ventilation_rate