modified ca_usage_parameters.py to make a walk around for a bug in python

This commit is contained in:
Pilar 2021-04-15 10:04:44 -04:00
parent 3a0eb76834
commit 7b9ce04e16
5 changed files with 31 additions and 10 deletions

View File

@ -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

View File

@ -70,7 +70,6 @@ class Surface:
"""
Set surface short wave reflectance
:param value: float
:return: None
"""
self._swr = value

View File

@ -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):
"""

View File

@ -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)

View File

@ -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