2020-10-28 13:42:58 -04:00
|
|
|
"""
|
2022-11-21 11:03:28 -05:00
|
|
|
Usage module
|
2020-10-28 13:42:58 -04:00
|
|
|
SPDX - License - Identifier: LGPL - 3.0 - or -later
|
2022-04-08 09:35:33 -04:00
|
|
|
Copyright © 2022 Concordia CERC group
|
|
|
|
Project Coder Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
|
|
|
|
Code contributors: Guille Gutierrez guillermo.gutierrezmorote@concordia.ca
|
2020-10-28 13:42:58 -04:00
|
|
|
"""
|
2021-03-26 12:53:27 -04:00
|
|
|
import uuid
|
2022-05-18 14:52:41 -04:00
|
|
|
from typing import Union, List
|
2022-11-07 11:49:59 -05:00
|
|
|
import helpers.constants as cte
|
2022-03-08 19:19:52 -05:00
|
|
|
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
|
2022-03-17 18:49:44 -04:00
|
|
|
from city_model_structure.building_demand.thermal_control import ThermalControl
|
2022-05-18 14:52:41 -04:00
|
|
|
from city_model_structure.building_demand.internal_gain import InternalGain
|
2020-10-28 13:42:58 -04:00
|
|
|
|
|
|
|
|
2022-11-21 11:03:28 -05:00
|
|
|
class Usage:
|
2020-10-28 13:42:58 -04:00
|
|
|
"""
|
2022-11-21 11:03:28 -05:00
|
|
|
Usage class
|
2020-10-28 13:42:58 -04:00
|
|
|
"""
|
2022-05-18 14:52:41 -04:00
|
|
|
def __init__(self):
|
2021-03-26 12:53:27 -04:00
|
|
|
self._id = None
|
2022-11-21 11:03:28 -05:00
|
|
|
self._name = None
|
2022-03-17 18:49:44 -04:00
|
|
|
self._percentage = None
|
2022-05-18 14:52:41 -04:00
|
|
|
self._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
|
2021-03-01 16:42:03 -05:00
|
|
|
self._mechanical_air_change = None
|
2022-03-08 19:19:52 -05:00
|
|
|
self._occupancy = None
|
|
|
|
self._lighting = None
|
|
|
|
self._appliances = None
|
2022-03-17 18:49:44 -04:00
|
|
|
self._thermal_control = None
|
2020-12-15 11:05:02 -05:00
|
|
|
|
2021-03-26 12:53:27 -04:00
|
|
|
@property
|
|
|
|
def id(self):
|
2021-06-09 14:23:45 -04:00
|
|
|
"""
|
2022-05-16 10:19:03 -04:00
|
|
|
Get usage zone id, a universally unique identifier randomly generated
|
2021-06-09 14:23:45 -04:00
|
|
|
:return: str
|
|
|
|
"""
|
2021-03-26 12:53:27 -04:00
|
|
|
if self._id is None:
|
|
|
|
self._id = uuid.uuid4()
|
|
|
|
return self._id
|
|
|
|
|
2022-03-17 18:49:44 -04:00
|
|
|
@property
|
2022-11-21 11:03:28 -05:00
|
|
|
def name(self) -> Union[None, str]:
|
2022-03-17 18:49:44 -04:00
|
|
|
"""
|
|
|
|
Get usage zone usage
|
|
|
|
:return: None or str
|
|
|
|
"""
|
2022-11-21 11:03:28 -05:00
|
|
|
return self._name
|
2022-03-17 18:49:44 -04:00
|
|
|
|
2022-11-21 11:03:28 -05:00
|
|
|
@name.setter
|
|
|
|
def name(self, value):
|
2022-03-17 18:49:44 -04:00
|
|
|
"""
|
|
|
|
Set usage zone usage
|
|
|
|
:param value: str
|
|
|
|
"""
|
|
|
|
if value is not None:
|
2022-11-21 11:03:28 -05:00
|
|
|
self._name = str(value)
|
2022-03-17 18:49:44 -04:00
|
|
|
|
|
|
|
@property
|
|
|
|
def percentage(self):
|
|
|
|
"""
|
|
|
|
Get usage zone percentage in range[0,1]
|
|
|
|
:return: float
|
|
|
|
"""
|
|
|
|
return self._percentage
|
|
|
|
|
|
|
|
@percentage.setter
|
|
|
|
def percentage(self, value):
|
|
|
|
"""
|
|
|
|
Set usage zone percentage in range[0,1]
|
|
|
|
:param value: float
|
|
|
|
"""
|
|
|
|
if value is not None:
|
|
|
|
self._percentage = float(value)
|
|
|
|
|
2022-05-18 14:52:41 -04:00
|
|
|
@property
|
|
|
|
def internal_gains(self) -> List[InternalGain]:
|
|
|
|
"""
|
2022-11-07 11:49:59 -05:00
|
|
|
Calculates and returns the list of all internal gains defined
|
|
|
|
:return: InternalGains
|
|
|
|
"""
|
|
|
|
if self._internal_gains is None:
|
|
|
|
if self.occupancy is not None:
|
|
|
|
if self.occupancy.latent_internal_gain is not None:
|
|
|
|
_internal_gain = InternalGain()
|
|
|
|
_internal_gain.type = cte.OCCUPANCY
|
|
|
|
_total_heat_gain = (self.occupancy.sensible_convective_internal_gain
|
|
|
|
+ self.occupancy.sensible_radiative_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_radiative_internal_gain / _total_heat_gain
|
|
|
|
_internal_gain.convective_fraction = self.occupancy.sensible_convective_internal_gain / _total_heat_gain
|
|
|
|
_internal_gain.schedules = self.occupancy.occupancy_schedules
|
|
|
|
self._internal_gains = [_internal_gain]
|
|
|
|
if self.lighting is not None:
|
|
|
|
_internal_gain = InternalGain()
|
|
|
|
_internal_gain.type = cte.LIGHTING
|
|
|
|
_internal_gain.average_internal_gain = self.lighting.density
|
|
|
|
_internal_gain.latent_fraction = self.lighting.latent_fraction
|
|
|
|
_internal_gain.radiative_fraction = self.lighting.radiative_fraction
|
|
|
|
_internal_gain.convective_fraction = self.lighting.convective_fraction
|
|
|
|
_internal_gain.schedules = self.lighting.schedules
|
|
|
|
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 = InternalGain()
|
|
|
|
_internal_gain.type = cte.APPLIANCES
|
|
|
|
_internal_gain.average_internal_gain = self.appliances.density
|
|
|
|
_internal_gain.latent_fraction = self.appliances.latent_fraction
|
|
|
|
_internal_gain.radiative_fraction = self.appliances.radiative_fraction
|
|
|
|
_internal_gain.convective_fraction = self.appliances.convective_fraction
|
|
|
|
_internal_gain.schedules = self.appliances.schedules
|
|
|
|
if self._internal_gains is not None:
|
|
|
|
self._internal_gains.append(_internal_gain)
|
|
|
|
else:
|
|
|
|
self._internal_gains = [_internal_gain]
|
2022-05-18 14:52:41 -04:00
|
|
|
return self._internal_gains
|
|
|
|
|
|
|
|
@internal_gains.setter
|
|
|
|
def internal_gains(self, value):
|
|
|
|
"""
|
|
|
|
Set usage zone internal gains
|
|
|
|
:param value: [InternalGain]
|
|
|
|
"""
|
|
|
|
self._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
|
|
|
"""
|
2021-06-03 15:56:59 -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):
|
|
|
|
"""
|
2021-06-03 15:56:59 -04:00
|
|
|
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
|
|
|
"""
|
2021-06-03 15:56:59 -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):
|
|
|
|
"""
|
2021-06-03 15:56:59 -04:00
|
|
|
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
|
|
|
"""
|
2021-08-30 14:39:24 -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):
|
|
|
|
"""
|
2021-08-30 14:39:24 -04:00
|
|
|
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
|
|
|
|
2021-03-16 13:43:59 -04:00
|
|
|
@property
|
2022-03-08 19:19:52 -05:00
|
|
|
def occupancy(self) -> Union[None, Occupancy]:
|
2021-03-16 13:43:59 -04:00
|
|
|
"""
|
2022-03-08 19:19:52 -05:00
|
|
|
Get occupancy in the usage zone
|
|
|
|
:return: None or Occupancy
|
2021-03-16 13:43:59 -04:00
|
|
|
"""
|
2022-03-08 19:19:52 -05:00
|
|
|
return self._occupancy
|
2021-08-12 11:08:29 -04:00
|
|
|
|
2022-03-08 19:19:52 -05:00
|
|
|
@occupancy.setter
|
|
|
|
def occupancy(self, value):
|
2021-08-12 11:08:29 -04:00
|
|
|
"""
|
2022-03-08 19:19:52 -05:00
|
|
|
Set occupancy in the usage zone
|
|
|
|
:param value: Occupancy
|
2021-08-12 11:08:29 -04:00
|
|
|
"""
|
2022-03-08 19:19:52 -05:00
|
|
|
self._occupancy = value
|
2021-08-12 11:08:29 -04:00
|
|
|
|
2022-03-08 19:19:52 -05:00
|
|
|
@property
|
|
|
|
def lighting(self) -> Union[None, Lighting]:
|
2021-08-12 11:08:29 -04:00
|
|
|
"""
|
2022-03-08 19:19:52 -05:00
|
|
|
Get lighting information
|
|
|
|
:return: None or Lighting
|
2021-08-12 11:08:29 -04:00
|
|
|
"""
|
2022-03-08 19:19:52 -05:00
|
|
|
return self._lighting
|
2021-08-12 11:42:47 -04:00
|
|
|
|
2022-03-08 19:19:52 -05:00
|
|
|
@lighting.setter
|
|
|
|
def lighting(self, value):
|
2021-08-12 11:42:47 -04:00
|
|
|
"""
|
2022-03-08 19:19:52 -05:00
|
|
|
Set lighting information
|
|
|
|
:param value: Lighting
|
2021-08-12 11:42:47 -04:00
|
|
|
"""
|
2022-03-08 19:19:52 -05:00
|
|
|
self._lighting = value
|
2021-08-12 11:42:47 -04:00
|
|
|
|
2022-03-08 19:19:52 -05:00
|
|
|
@property
|
|
|
|
def appliances(self) -> Union[None, Appliances]:
|
2021-08-12 11:42:47 -04:00
|
|
|
"""
|
2022-03-08 19:19:52 -05:00
|
|
|
Get appliances information
|
|
|
|
:return: None or Appliances
|
2021-08-12 11:42:47 -04:00
|
|
|
"""
|
2022-03-08 19:19:52 -05:00
|
|
|
return self._appliances
|
2021-08-12 11:42:47 -04:00
|
|
|
|
2022-03-08 19:19:52 -05:00
|
|
|
@appliances.setter
|
|
|
|
def appliances(self, value):
|
2021-08-12 11:42:47 -04:00
|
|
|
"""
|
2022-03-08 19:19:52 -05:00
|
|
|
Set appliances information
|
|
|
|
:param value: Appliances
|
2021-08-12 11:42:47 -04:00
|
|
|
"""
|
2022-03-08 19:19:52 -05:00
|
|
|
self._appliances = value
|
2021-08-12 11:42:47 -04:00
|
|
|
|
2022-03-17 18:49:44 -04:00
|
|
|
@property
|
|
|
|
def thermal_control(self) -> Union[None, ThermalControl]:
|
|
|
|
"""
|
|
|
|
Get thermal control of this thermal zone
|
|
|
|
:return: None or ThermalControl
|
|
|
|
"""
|
|
|
|
return self._thermal_control
|
|
|
|
|
|
|
|
@thermal_control.setter
|
|
|
|
def thermal_control(self, value):
|
|
|
|
"""
|
|
|
|
Set thermal control for this thermal zone
|
|
|
|
:param value: ThermalControl
|
|
|
|
"""
|
|
|
|
self._thermal_control = value
|