hub/city_model_structure/building_demand/usage_zone.py

235 lines
7.1 KiB
Python
Raw Normal View History

2020-10-28 13:42:58 -04:00
"""
UsageZone module
SPDX - License - Identifier: LGPL - 3.0 - or -later
Copyright © 2020 Project Author Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
2020-11-26 09:26:55 -05:00
Contributors Guille Gutierrez guillermo.gutierrezmorote@concordia.ca
2020-10-28 13:42:58 -04:00
"""
import uuid
2022-03-08 19:19:52 -05:00
from typing import List, Union
import helpers.constants as cte
from city_model_structure.building_demand.internal_gains import InternalGains
from city_model_structure.building_demand.occupancy import Occupancy
from city_model_structure.building_demand.lighting import Lighting
from city_model_structure.building_demand.appliances import Appliances
2020-10-28 13:42:58 -04:00
class UsageZone:
"""
UsageZone class
"""
def __init__(self):
self._id = None
2020-10-28 13:42:58 -04:00
self._usage = None
2022-03-08 19:19:52 -05:00
self._not_detailed_source_mean_annual_internal_gains = None
2020-10-28 13:42:58 -04:00
self._hours_day = None
self._days_year = None
2022-03-08 19:19:52 -05:00
# self._electrical_app_average_consumption_sqm_year = None
self._mechanical_air_change = None
2022-03-08 19:19:52 -05:00
self._occupancy = None
self._lighting = None
self._appliances = None
self._internal_gains = None
2020-12-15 11:05:02 -05:00
@property
def id(self):
"""
Get usage zone id, an universally unique identifier randomly generated
:return: str
"""
if self._id is None:
self._id = uuid.uuid4()
return self._id
2020-10-28 13:42:58 -04:00
@property
2022-03-08 19:19:52 -05:00
def not_detailed_source_mean_annual_internal_gains(self) -> List[InternalGains]:
2020-10-28 13:42:58 -04:00
"""
2022-03-08 19:19:52 -05:00
Get usage zone internal gains with unknown energy source
2020-10-28 13:42:58 -04:00
:return: [InternalGains]
"""
2022-03-08 19:19:52 -05:00
return self._not_detailed_source_mean_annual_internal_gains
2020-10-28 13:42:58 -04:00
2022-03-08 19:19:52 -05:00
@not_detailed_source_mean_annual_internal_gains.setter
def not_detailed_source_mean_annual_internal_gains(self, value):
2020-10-28 13:42:58 -04:00
"""
2022-03-08 19:19:52 -05:00
Set usage zone internal gains with unknown energy source
2020-10-28 13:42:58 -04:00
:param value: [InternalGains]
"""
2022-03-08 19:19:52 -05:00
self._not_detailed_source_mean_annual_internal_gains = value
2020-10-28 13:42:58 -04:00
@property
2021-09-14 13:46:48 -04:00
def hours_day(self) -> Union[None, float]:
2020-10-28 13:42:58 -04:00
"""
Get usage zone usage hours per day
2021-09-14 13:46:48 -04:00
:return: None or float
2020-10-28 13:42:58 -04:00
"""
return self._hours_day
@hours_day.setter
def hours_day(self, value):
"""
Set usage zone usage hours per day
2020-10-28 13:42:58 -04:00
:param value: float
"""
2021-09-14 13:46:48 -04:00
if value is not None:
self._hours_day = float(value)
2020-10-28 13:42:58 -04:00
@property
2021-09-14 13:46:48 -04:00
def days_year(self) -> Union[None, float]:
2020-10-28 13:42:58 -04:00
"""
Get usage zone usage days per year
2021-09-14 13:46:48 -04:00
:return: None or float
2020-10-28 13:42:58 -04:00
"""
return self._days_year
@days_year.setter
def days_year(self, value):
"""
Set usage zone usage days per year
2020-10-28 13:42:58 -04:00
:param value: float
"""
2021-09-14 13:46:48 -04:00
if value is not None:
self._days_year = float(value)
2020-10-28 13:42:58 -04:00
@property
2021-09-14 13:46:48 -04:00
def mechanical_air_change(self) -> Union[None, float]:
2020-10-28 13:42:58 -04:00
"""
Get usage zone mechanical air change in air change per hour (ACH)
2021-09-14 13:46:48 -04:00
:return: None or float
2020-10-28 13:42:58 -04:00
"""
return self._mechanical_air_change
@mechanical_air_change.setter
def mechanical_air_change(self, value):
"""
Set usage zone mechanical air change in air change per hour (ACH)
2020-10-28 13:42:58 -04:00
:param value: float
"""
2021-09-14 13:46:48 -04:00
if value is not None:
self._mechanical_air_change = float(value)
2020-10-28 13:42:58 -04:00
@property
2021-09-14 13:46:48 -04:00
def usage(self) -> Union[None, str]:
2020-10-28 13:42:58 -04:00
"""
Get usage zone usage
2021-09-14 13:46:48 -04:00
:return: None or str
2020-10-28 13:42:58 -04:00
"""
return self._usage
@usage.setter
def usage(self, value):
"""
Set usage zone usage
2020-10-28 13:42:58 -04:00
:param value: str
"""
2021-09-14 13:46:48 -04:00
if value is not None:
self._usage = str(value)
2020-10-28 13:42:58 -04:00
@property
2021-09-14 13:46:48 -04:00
def electrical_app_average_consumption_sqm_year(self) -> Union[None, float]:
"""
Get average consumption of electrical appliances in Joules hour per square meter and year (J/m2yr)
2021-09-14 13:46:48 -04:00
:return: None or float
"""
return self._electrical_app_average_consumption_sqm_year
@electrical_app_average_consumption_sqm_year.setter
2021-09-13 15:14:54 -04:00
def electrical_app_average_consumption_sqm_year(self, value):
"""
Set average consumption of electrical appliances in Joules per square meter and year (J/m2yr)
2021-09-13 15:14:54 -04:00
:param value: float
"""
2021-09-14 13:46:48 -04:00
if value is not None:
self._electrical_app_average_consumption_sqm_year = float(value)
@property
2022-03-08 19:19:52 -05:00
def occupancy(self) -> Union[None, Occupancy]:
"""
2022-03-08 19:19:52 -05:00
Get occupancy in the usage zone
:return: None or Occupancy
"""
2022-03-08 19:19:52 -05:00
return self._occupancy
2022-03-08 19:19:52 -05:00
@occupancy.setter
def occupancy(self, value):
"""
2022-03-08 19:19:52 -05:00
Set occupancy in the usage zone
:param value: Occupancy
"""
2022-03-08 19:19:52 -05:00
self._occupancy = value
2022-03-08 19:19:52 -05:00
@property
def lighting(self) -> Union[None, Lighting]:
"""
2022-03-08 19:19:52 -05:00
Get lighting information
:return: None or Lighting
"""
2022-03-08 19:19:52 -05:00
return self._lighting
2022-03-08 19:19:52 -05:00
@lighting.setter
def lighting(self, value):
"""
2022-03-08 19:19:52 -05:00
Set lighting information
:param value: Lighting
"""
2022-03-08 19:19:52 -05:00
self._lighting = value
2022-03-08 19:19:52 -05:00
@property
def appliances(self) -> Union[None, Appliances]:
"""
2022-03-08 19:19:52 -05:00
Get appliances information
:return: None or Appliances
"""
2022-03-08 19:19:52 -05:00
return self._appliances
2022-03-08 19:19:52 -05:00
@appliances.setter
def appliances(self, value):
"""
2022-03-08 19:19:52 -05:00
Set appliances information
:param value: Appliances
"""
2022-03-08 19:19:52 -05:00
self._appliances = value
2022-03-08 19:19:52 -05:00
def get_internal_gains(self) -> [InternalGains]:
"""
2022-03-08 19:19:52 -05:00
Calculates and returns the list of all internal gains defined
:return: InternalGains
"""
2022-03-08 19:19:52 -05:00
if self.occupancy is not None:
if self.occupancy.latent_internal_gain is not None:
_internal_gain = InternalGains()
_internal_gain.type = cte.OCCUPANCY
_total_heat_gain = (self.occupancy.sensible_convective_internal_gain
+ self.occupancy.sensible_radiant_internal_gain
+ self.occupancy.latent_internal_gain)
_internal_gain.average_internal_gain = _total_heat_gain
_internal_gain.latent_fraction = self.occupancy.latent_internal_gain / _total_heat_gain
_internal_gain.radiative_fraction = self.occupancy.sensible_radiant_internal_gain / _total_heat_gain
_internal_gain.convective_fraction = self.occupancy.sensible_convective_internal_gain / _total_heat_gain
_internal_gain.schedule = self.occupancy.occupancy_schedule
self._internal_gains = [_internal_gain]
if self.lighting is not None:
_internal_gain = InternalGains()
_internal_gain.type = cte.LIGHTING
_internal_gain.average_internal_gain = self.lighting.lighting_density
_internal_gain.latent_fraction = self.lighting.latent_fraction
_internal_gain.radiative_fraction = self.lighting.radiant_fraction
_internal_gain.convective_fraction = self.lighting.convective_fraction
_internal_gain.schedule = self.lighting.schedule
if self._internal_gains is not None:
self._internal_gains.append(_internal_gain)
else:
self._internal_gains = [_internal_gain]
if self.appliances is not None:
_internal_gain = InternalGains()
_internal_gain.type = cte.APPLIANCES
_internal_gain.average_internal_gain = self.appliances.lighting_density
_internal_gain.latent_fraction = self.appliances.latent_fraction
_internal_gain.radiative_fraction = self.appliances.radiant_fraction
_internal_gain.convective_fraction = self.appliances.convective_fraction
_internal_gain.schedule = self.appliances.schedule
if self._internal_gains is not None:
self._internal_gains.append(_internal_gain)
else:
self._internal_gains = [_internal_gain]
return self._internal_gains