system_assignation/imports/usage/hft_usage_parameters.py

79 lines
3.6 KiB
Python
Raw Normal View History

2021-01-06 16:42:38 -05:00
"""
HftUsageParameters model the usage properties
2021-01-06 16:42:38 -05:00
SPDX - License - Identifier: LGPL - 3.0 - or -later
Copyright © 2020 Project Author Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
2021-01-06 16:42:38 -05:00
"""
2021-01-07 17:33:55 -05:00
import sys
from imports.geometry.helpers.geometry_helper import GeometryHelper as gh
from imports.usage.hft_usage_interface import HftUsageInterface
from city_model_structure.building_demand.usage_zone import UsageZone
from city_model_structure.building_demand.internal_gains import InternalGains
2021-01-07 16:14:19 -05:00
class HftUsageParameters(HftUsageInterface):
2021-01-06 16:42:38 -05:00
"""
HftUsageParameters class
2021-01-06 16:42:38 -05:00
"""
def __init__(self, city, base_path):
super().__init__(base_path, 'de_library.xml')
2021-01-06 16:42:38 -05:00
self._city = city
# 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
def enrich_buildings(self):
2021-01-06 16:42:38 -05:00
"""
Returns the city with the usage parameters assigned to the buildings
2021-01-06 16:42:38 -05:00
:return:
"""
city = self._city
for building in city.buildings:
archetype = self._search_archetype(gh.usage_from_function(building.function))
2021-01-06 16:42:38 -05:00
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')
2021-01-06 16:42:38 -05:00
continue
# todo: what to do with mix-usage usage from gml?
2021-01-06 16:42:38 -05:00
mix_usage = False
if not mix_usage:
# just one usage_zone
for thermal_zone in building.thermal_zones:
usage_zone = UsageZone()
self._assign_values(usage_zone, archetype)
usage_zone.volume = thermal_zone.volume
thermal_zone.usage_zones = [usage_zone]
2021-01-06 16:42:38 -05:00
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):
2021-01-06 16:42:38 -05:00
usage_zone.usage = archetype.usage
# Due to the fact that python is not a typed language, the wrong object type is assigned to
# usage_zone.internal_gains when writing usage_zone.internal_gains = archetype.internal_gains.
# Therefore, this walk around has been done.
internal_gains = []
2022-03-08 19:19:52 -05:00
for archetype_internal_gain in archetype.not_detailed_source_mean_annual_internal_gains:
internal_gain = InternalGains()
2021-08-27 12:51:30 -04:00
internal_gain.average_internal_gain = archetype_internal_gain.average_internal_gain
internal_gain.convective_fraction = archetype_internal_gain.convective_fraction
internal_gain.radiative_fraction = archetype_internal_gain.radiative_fraction
internal_gain.latent_fraction = archetype_internal_gain.latent_fraction
internal_gains.append(internal_gain)
2022-03-08 19:19:52 -05:00
usage_zone.not_detailed_source_mean_annual_internal_gains = internal_gains
2021-01-06 16:42:38 -05:00
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