2021-01-06 16:42:38 -05:00
|
|
|
"""
|
2021-06-03 15:56:59 -04:00
|
|
|
HftUsageParameters model the usage properties
|
2021-01-06 16:42:38 -05:00
|
|
|
SPDX - License - Identifier: LGPL - 3.0 - or -later
|
2021-05-27 17:20:06 -04:00
|
|
|
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
|
|
|
|
|
2021-06-01 18:31:50 -04:00
|
|
|
from imports.geometry.helpers.geometry_helper import GeometryHelper as gh
|
2021-06-03 15:56:59 -04:00
|
|
|
from imports.usage.hft_usage_interface import HftUsageInterface
|
2021-08-06 12:28:20 -04:00
|
|
|
from city_model_structure.building_demand.usage_zone import UsageZone
|
|
|
|
from city_model_structure.building_demand.internal_gains import InternalGains
|
2022-03-17 18:49:44 -04:00
|
|
|
from city_model_structure.building_demand.occupancy import Occupancy
|
|
|
|
from city_model_structure.building_demand.appliances import Appliances
|
|
|
|
from city_model_structure.building_demand.thermal_control import ThermalControl
|
2021-01-07 16:14:19 -05:00
|
|
|
|
2021-05-26 18:17:23 -04:00
|
|
|
|
2021-05-27 17:20:06 -04:00
|
|
|
class HftUsageParameters(HftUsageInterface):
|
2021-01-06 16:42:38 -05:00
|
|
|
"""
|
2021-05-27 17:20:06 -04:00
|
|
|
HftUsageParameters class
|
2021-01-06 16:42:38 -05:00
|
|
|
"""
|
|
|
|
def __init__(self, city, base_path):
|
2021-08-11 11:14:06 -04:00
|
|
|
super().__init__(base_path, 'de_library.xml')
|
2021-01-06 16:42:38 -05:00
|
|
|
self._city = city
|
|
|
|
|
2021-01-07 18:12:13 -05:00
|
|
|
def enrich_buildings(self):
|
2021-01-06 16:42:38 -05:00
|
|
|
"""
|
2021-06-03 15:56:59 -04: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:
|
2022-03-17 18:49:44 -04:00
|
|
|
usage = gh.usage_from_function(building.function)
|
|
|
|
try:
|
|
|
|
archetype = self._search_archetype(usage)
|
|
|
|
except KeyError:
|
2021-05-27 17:20:06 -04:00
|
|
|
sys.stderr.write(f'Building {building.name} has unknown archetype for building function:'
|
2021-06-03 15:56:59 -04:00
|
|
|
f' {building.function}, that assigns building usage as '
|
2021-05-27 18:23:39 -04:00
|
|
|
f'{gh.usage_from_function(building.function)}\n')
|
2022-03-17 18:49:44 -04:00
|
|
|
return
|
2022-03-08 20:08:03 -05:00
|
|
|
|
|
|
|
for internal_zone in building.internal_zones:
|
2021-08-10 17:09:42 -04:00
|
|
|
usage_zone = UsageZone()
|
2022-03-17 18:49:44 -04:00
|
|
|
usage_zone.usage = building.function
|
2021-08-10 17:09:42 -04:00
|
|
|
self._assign_values(usage_zone, archetype)
|
2022-03-17 18:49:44 -04:00
|
|
|
usage_zone.percentage = 1
|
|
|
|
internal_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
|
|
|
|
|
2021-01-07 18:12:13 -05:00
|
|
|
@staticmethod
|
|
|
|
def _assign_values(usage_zone, archetype):
|
2021-04-15 11:20:11 -04:00
|
|
|
# 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.
|
2022-03-17 18:49:44 -04:00
|
|
|
# Due to the fact that python is not a typed language, the wrong object type is assigned to
|
|
|
|
# usage_zone.occupancy when writing usage_zone.occupancy = archetype.occupancy.
|
|
|
|
# Same happens for lighting and appliances. Therefore, this walk around has been done.
|
2021-01-06 16:42:38 -05:00
|
|
|
usage_zone.mechanical_air_change = archetype.mechanical_air_change
|
2022-03-17 18:49:44 -04:00
|
|
|
_occupancy = Occupancy()
|
|
|
|
_occupancy.occupancy_density = archetype.occupancy.occupancy_density
|
|
|
|
usage_zone.occupancy = _occupancy
|
|
|
|
_appliances = Appliances()
|
|
|
|
_appliances.appliances_density = archetype.appliances.appliances_density
|
|
|
|
usage_zone.appliances = _appliances
|
|
|
|
_control = ThermalControl()
|
|
|
|
_control.mean_heating_set_point = archetype.thermal_control.mean_heating_set_point
|
|
|
|
_control.heating_set_back = archetype.thermal_control.heating_set_back
|
|
|
|
_control.mean_cooling_set_point = archetype.thermal_control.mean_cooling_set_point
|
|
|
|
_control.cooling_set_point_schedules = archetype.thermal_control.cooling_set_point_schedules
|
|
|
|
_control.heating_set_point_schedules = archetype.thermal_control.heating_set_point_schedules
|
|
|
|
usage_zone.thermal_control = _control
|
|
|
|
_internal_gains = []
|
|
|
|
for archetype_internal_gain in archetype.not_detailed_source_mean_annual_internal_gains:
|
|
|
|
_internal_gain = InternalGains()
|
|
|
|
_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_gain.schedules = archetype_internal_gain.schedules
|
|
|
|
_internal_gains.append(_internal_gain)
|
|
|
|
usage_zone.not_detailed_source_mean_annual_internal_gains = _internal_gains
|