diff --git a/city_model_structure/attributes/internal_gains.py b/city_model_structure/attributes/internal_gains.py index 1cf6ecd1..0d509cf1 100644 --- a/city_model_structure/attributes/internal_gains.py +++ b/city_model_structure/attributes/internal_gains.py @@ -7,8 +7,9 @@ Copyright © 2020 Project Author Guille Gutierrez guillermo.gutierrezmorote@conc class InternalGains: """ - InternalGains class - """ + InternalGains class + """ + def __init__(self): self._average_internal_gain = None self._convective_fraction = None diff --git a/city_model_structure/attributes/surface.py b/city_model_structure/attributes/surface.py index 65be7837..b364553a 100644 --- a/city_model_structure/attributes/surface.py +++ b/city_model_structure/attributes/surface.py @@ -70,7 +70,6 @@ class Surface: """ Set surface short wave reflectance :param value: float - :return: None """ self._swr = value diff --git a/city_model_structure/city_object.py b/city_model_structure/city_object.py index 10d5181e..6e3c7a11 100644 --- a/city_model_structure/city_object.py +++ b/city_model_structure/city_object.py @@ -105,6 +105,17 @@ class CityObject: return s return None + def surface_by_id(self, identification_number) -> Union[Surface, None]: + """ + Get the city object surface with a given name + :param identification_number: str + :return: None or Surface + """ + for s in self.surfaces: + if str(s.id) == str(identification_number): + return s + return None + @property def centroid(self): """ diff --git a/city_model_structure/monthly_to_hourly_demand.py b/city_model_structure/monthly_to_hourly_demand.py index 6f2412c8..6b8f2e01 100644 --- a/city_model_structure/monthly_to_hourly_demand.py +++ b/city_model_structure/monthly_to_hourly_demand.py @@ -18,10 +18,10 @@ class MonthlyToHourlyDemand: self._building = building self._conditioning_seasons = conditioning_seasons - @property - def hourly_heating(self): + def hourly_heating(self, key): """ hourly distribution of the monthly heating of a building + :param key: string :return: [hourly_heating] """ # todo: this method and the insel model have to be reviewed for more than one thermal zone @@ -43,13 +43,13 @@ class MonthlyToHourlyDemand: for day in range(1, month_range[1]+1): external_temp_med = 0 for hour in range(0, 24): - external_temp_med += external_temp['inseldb'][i]/24 + external_temp_med += external_temp[key][i]/24 for hour in range(0, 24): if external_temp_med < temp_set and heating_schedule[month-1] == 1: if occupancy[hour] > 0: - temp_grad_day.append(temp_set - external_temp['inseldb'][i]) + temp_grad_day.append(temp_set - external_temp[key][i]) else: - temp_grad_day.append(temp_back - external_temp['inseldb'][i]) + temp_grad_day.append(temp_back - external_temp[key][i]) else: temp_grad_day.append(0) diff --git a/imports/usage_feeders/ca_usage_parameters.py b/imports/usage_feeders/ca_usage_parameters.py index 2cb3b6dd..592c2f5d 100644 --- a/imports/usage_feeders/ca_usage_parameters.py +++ b/imports/usage_feeders/ca_usage_parameters.py @@ -7,7 +7,7 @@ import sys from imports.usage_feeders.hft_usage_interface import HftUsageInterface from city_model_structure.attributes.usage_zone import UsageZone - +from city_model_structure.attributes.internal_gains import InternalGains class CaUsageParameters(HftUsageInterface): """ @@ -48,7 +48,17 @@ class CaUsageParameters(HftUsageInterface): @staticmethod def _assign_values(usage_zone, archetype): usage_zone.usage = archetype.usage - usage_zone.internal_gains = archetype.internal_gains + # gue to the low 'tipado' of python, usage_zone.internal_gains = archetype.internal_gains assigns the wrong + # object type to usage_zone.internal_gains. Therefore, this walk around has been done. + internal_gains = [] + for ig in archetype.internal_gains: + internal_gain = InternalGains() + internal_gain.average_internal_gain = ig.average_internal_gain + internal_gain.convective_fraction = ig.convective_fraction + internal_gain.radiative_fraction = ig.radiative_fraction + internal_gain.latent_fraction = ig.latent_fraction + internal_gains.append(internal_gain) + usage_zone.internal_gains = internal_gains usage_zone.heating_setpoint = archetype.heating_setpoint usage_zone.heating_setback = archetype.heating_setback usage_zone.cooling_setpoint = archetype.cooling_setpoint