Compare commits

..

No commits in common. "44e6820ce688a582158c54a2048162e6bdaa84eb" and "e0d1f1f8fb0475b2982ec5c8a8a7e933a70a3f72" have entirely different histories.

4 changed files with 41 additions and 23 deletions

View File

@ -262,8 +262,8 @@ class Building(CityObject):
@property
def usages(self) -> Union[None, list]:
"""
Get building usages, if none, assume useage is function
:return: None or list of functions
Get building function
:return: None or str
"""
if self._usages is None and self._function is not None:
self._usages = [{'usage': self._function, 'ratio': 1 }]
@ -604,6 +604,19 @@ class Building(CityObject):
"""
self._city = value
@property
def usages_percentage(self):
"""
Get the usages and percentages for the building
"""
_usage = ''
for internal_zone in self.internal_zones:
if internal_zone.usages is None:
continue
for usage in internal_zone.usages:
_usage = f'{_usage}{usage.name}_{usage.percentage} '
return _usage.rstrip()
@property
def energy_systems(self) -> Union[None, List[EnergySystem]]:
"""

View File

@ -34,7 +34,7 @@ class ThermalZone:
volume,
footprint_area,
number_of_storeys,
usages=None):
usage_name=None):
self._id = None
self._parent_internal_zone = parent_internal_zone
self._footprint_area = footprint_area
@ -51,6 +51,10 @@ class ThermalZone:
self._view_factors_matrix = None
self._total_floor_area = None
self._number_of_storeys = number_of_storeys
self._usage_name = usage_name
self._usage_from_parent = False
if usage_name is None:
self._usage_from_parent = True
self._hours_day = None
self._days_year = None
self._mechanical_air_change = None
@ -60,8 +64,7 @@ class ThermalZone:
self._internal_gains = None
self._thermal_control = None
self._domestic_hot_water = None
self._usage_name = None
self._usages = usages
self._usages = None
@property
def parent_internal_zone(self) -> InternalZone:
@ -78,8 +81,20 @@ class ThermalZone:
Eg: 70-office_30-residential
:return: str
"""
if self._usages is not None:
if self._usage_from_parent:
self._usages = copy.deepcopy(self._parent_internal_zone.usages)
else:
values = self._usage_name.split('_')
usages = []
for value in values:
usages.append(value.split('-'))
self._usages = []
for parent_usage in self._parent_internal_zone.usages:
for value in usages:
if parent_usage.name == value[1]:
new_usage = copy.deepcopy(parent_usage)
new_usage.percentage = float(value[0]) / 100
self._usages.append(new_usage)
return self._usages
@property

View File

@ -78,12 +78,7 @@ class ComnetUsageParameters:
logging.error('Building %s no number of storeys assigned, ACH cannot be calculated for usage %s. '
'NRCAN construction data for the year %s is used to calculated number of storeys above '
'ground', building.name, usages, building.year_of_construction)
try:
storeys_above_ground = self.average_storey_height_calculator(self._city, building)
except ValueError as e:
logging.error(e)
continue
storeys_above_ground = self.average_storey_height_calculator(self._city, building)
volume_per_area = building.volume / building.floor_area / storeys_above_ground
for j, usage_type in enumerate(usages):
usage = Usage()
@ -95,7 +90,6 @@ class ComnetUsageParameters:
internal_zone_usages.append(usage)
internal_zone.usages = internal_zone_usages
@staticmethod
def _search_archetypes(comnet_catalog, usage_name):
comnet_archetypes = comnet_catalog.entries('archetypes').usages
@ -274,7 +268,7 @@ class ComnetUsageParameters:
nrcan_catalog = ConstructionCatalogFactory('nrcan').catalog
if building.function not in Dictionaries().hub_function_to_nrcan_construction_function:
raise ValueError('Building %s has an unknown building function %s', building.name, building.function)
logging.error('Building %s has an unknown building function %s', building.name, building.function)
function = Dictionaries().hub_function_to_nrcan_construction_function[building.function]
construction_archetype = None
@ -287,7 +281,7 @@ class ComnetUsageParameters:
construction_archetype = building_archetype
average_storey_height = building_archetype.average_storey_height
if construction_archetype is None:
raise ValueError('Building %s has unknown construction archetype for building function: %s '
logging.error('Building %s has unknown construction archetype for building function: %s '
'[%s], building year of construction: %s and climate zone %s', building.name, function,
building.function, building.year_of_construction, climate_zone)

View File

@ -86,12 +86,8 @@ class NrcanUsageParameters:
logging.error('Building %s no number of storeys assigned, ACH cannot be calculated for function %s. '
'NRCAN construction data for the year %s is used to calculated number of storeys above '
'ground', building.name, building.function, building.year_of_construction)
try:
storeys_above_ground = self.average_storey_height_calculator(self._city, building)
except ValueError as e:
logging.error(e)
continue
storeys_above_ground = self.average_storey_height_calculator(self._city, building)
continue
volume_per_area = building.volume / building.floor_area / storeys_above_ground
for j, usage_type in enumerate(usages):
usage = Usage()
@ -228,7 +224,7 @@ class NrcanUsageParameters:
nrcan_catalog = ConstructionCatalogFactory('nrcan').catalog
if building.function not in Dictionaries().hub_function_to_nrcan_construction_function:
raise ValueError('Building %s has an unknown building function %s', building.name, building.function)
logging.error('Building %s has an unknown building function %s', building.name, building.function)
function = Dictionaries().hub_function_to_nrcan_construction_function[building.function]
construction_archetype = None
@ -241,7 +237,7 @@ class NrcanUsageParameters:
construction_archetype = building_archetype
average_storey_height = building_archetype.average_storey_height
if construction_archetype is None:
raise ValueError('Building %s has unknown construction archetype for building function: %s '
logging.error('Building %s has unknown construction archetype for building function: %s '
'[%s], building year of construction: %s and climate zone %s', building.name, function,
building.function, building.year_of_construction, climate_zone)