api_v1.4/hub_api/mockup/building.py

232 lines
6.8 KiB
Python
Raw Normal View History

"""
Mockup Building module
SPDX - License - Identifier: LGPL - 3.0 - or -later
Copyright © 2023 Concordia CERC group
Project Coder Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
"""
2023-08-01 16:40:49 -04:00
import hub.helpers.constants as cte
2023-08-02 15:47:09 -04:00
from hub.helpers.dictionaries import Dictionaries
2023-07-31 16:55:39 -04:00
from hub_api.mockup.properties import *
class Building:
"""
Building class
"""
2023-07-31 16:56:37 -04:00
def __init__(self, building_info, results, catalog_archetype):
self._function = building_info.function
self._area = building_info.area
self._volume = building_info.volume
self._total_heating_area = building_info.total_heating_area
self._wall_area = building_info.wall_area
self._windows_area = building_info.windows_area
self._roof_area = building_info.roof_area
2023-07-31 14:51:23 -04:00
self._total_pv_area = building_info.total_pv_area
2023-08-01 16:40:49 -04:00
self._energy_systems_archetype_name = building_info.system_name
self._heating_consumption = {
2023-11-28 01:42:03 -05:00
cte.YEAR: results['insel meb']['yearly_heating_consumption'],
cte.MONTH: results['insel meb']['monthly_heating_consumption']
2023-08-01 16:40:49 -04:00
}
self._cooling_consumption = {
2023-11-28 01:42:03 -05:00
cte.YEAR: results['insel meb']['yearly_cooling_consumption'],
cte.MONTH: results['insel meb']['monthly_cooling_consumption']
2023-08-01 16:40:49 -04:00
}
self._domestic_hot_water_consumption = {
2023-11-28 01:42:03 -05:00
cte.YEAR: results['insel meb']['yearly_domestic_hot_water_consumption'],
cte.MONTH: results['insel meb']['monthly_domestic_hot_water_consumption']
2023-08-01 16:40:49 -04:00
}
self._lighting_electrical_demand = {
2023-11-28 01:42:03 -05:00
cte.YEAR: results['insel meb']['yearly_lighting_electrical_demand'],
cte.MONTH: results['insel meb']['monthly_lighting_electrical_demand']
2023-08-01 16:40:49 -04:00
}
self._appliances_electrical_demand = {
2023-11-28 01:42:03 -05:00
cte.YEAR: results['insel meb']['yearly_appliances_electrical_demand'],
cte.MONTH: results['insel meb']['monthly_appliances_electrical_demand']
2023-08-01 16:40:49 -04:00
}
self._heating_peak_load = {
2023-11-28 01:42:03 -05:00
cte.YEAR: results['insel meb']['yearly_heating_peak_load'],
cte.MONTH: results['insel meb']['monthly_heating_peak_load']
2023-08-01 16:40:49 -04:00
}
self._cooling_peak_load = {
2023-11-28 01:42:03 -05:00
cte.YEAR: results['insel meb']['yearly_cooling_peak_load'],
cte.MONTH: results['insel meb']['monthly_cooling_peak_load']
2023-08-01 16:40:49 -04:00
}
self._lighting_peak_load = {
2023-11-28 01:42:03 -05:00
cte.YEAR: results['insel meb']['yearly_lighting_peak_load'],
cte.MONTH: results['insel meb']['monthly_lighting_peak_load']
2023-08-01 16:40:49 -04:00
}
self._appliances_peak_load = {
2023-11-28 01:42:03 -05:00
cte.YEAR: results['insel meb']['yearly_appliances_peak_load'],
cte.MONTH: results['insel meb']['monthly_appliances_peak_load']
2023-08-01 16:40:49 -04:00
}
self._onsite_electrical_production = {
2023-11-28 01:42:03 -05:00
cte.YEAR: results['insel meb']['yearly_on_site_electrical_production'],
cte.MONTH: results['insel meb']['monthly_on_site_electrical_production']
2023-08-01 16:40:49 -04:00
}
2023-07-31 14:42:13 -04:00
self._catalog_archetype = catalog_archetype
@property
def function(self):
2023-08-08 15:59:06 -04:00
"""
Get building function
:return: str
"""
return self._function
@property
def volume(self):
2023-08-08 15:59:06 -04:00
"""
Get building volume in m3
:return: float
"""
return self._volume
@property
def thermal_zones_from_internal_zones(self) -> [ThermalZone]:
2023-08-08 15:59:06 -04:00
"""
Get building thermal zones
:return: [ThermalZone]
"""
ground = ThermalBoundary()
ground.type = 'Ground'
ground.opaque_area = self._area
roof = ThermalBoundary()
roof.type = 'Roof'
roof.opaque_area = self._roof_area
wall = ThermalBoundary()
wall.type = 'Wall'
wall.opaque_area = self._wall_area
wall.window_ratio = self._windows_area / (self._windows_area + self._wall_area)
thermal_zone = ThermalZone()
thermal_zone.total_floor_area = self._total_heating_area
thermal_zone.thermal_boundaries = [roof, wall, ground]
return [thermal_zone]
@property
2023-08-08 15:59:06 -04:00
def roofs(self) -> [Roof]:
"""
Get building roofs
:return: [Roof]
"""
polygon = Polygon()
polygon.area = self._roof_area
roof = Roof()
roof.solid_polygon = polygon
2023-07-31 14:51:23 -04:00
roof.solar_collectors_area_reduction_factor = self._total_pv_area / self._roof_area
return [roof]
@property
def heating_consumption(self):
2023-08-08 15:59:06 -04:00
"""
Get building heating consumption in J
:return: dict
"""
return self._heating_consumption
@property
def cooling_consumption(self):
2023-08-08 15:59:06 -04:00
"""
Get building cooling consumption in J
:return: dict
"""
return self._cooling_consumption
@property
def domestic_hot_water_consumption(self):
2023-08-08 15:59:06 -04:00
"""
Get building domestic hot water consumption in J
:return: dict
"""
return self._domestic_hot_water_consumption
@property
def lighting_electrical_demand(self):
2023-08-08 15:59:06 -04:00
"""
Get building lighting demand in J
:return: dict
"""
return self._lighting_electrical_demand
@property
def appliances_electrical_demand(self):
2023-08-08 15:59:06 -04:00
"""
Get building appliances electrical demand in J
:return: dict
"""
return self._appliances_electrical_demand
@property
def heating_peak_load(self):
2023-08-08 15:59:06 -04:00
"""
Get building heating peak load in W
:return: dict
"""
return self._heating_peak_load
@property
def cooling_peak_load(self):
2023-08-08 15:59:06 -04:00
"""
Get building cooling peak load in W
:return: dict
"""
return self._cooling_peak_load
2023-08-01 16:40:49 -04:00
@property
def lighting_peak_load(self):
2023-08-08 16:02:13 -04:00
"""
Get building lighting peak load in W
:return: dict
"""
2023-08-01 16:40:49 -04:00
return self._lighting_peak_load
@property
def appliances_peak_load(self):
2023-08-08 16:02:13 -04:00
"""
Get building appliances peak load in W
:return: dict
"""
2023-08-01 16:40:49 -04:00
return self._appliances_peak_load
@property
def onsite_electrical_production(self):
2023-08-08 15:59:06 -04:00
"""
Get building onsite electrical production in J
:return: dict
"""
return self._onsite_electrical_production
2023-08-01 16:40:49 -04:00
@property
def energy_systems_archetype_name(self):
2023-08-08 16:02:13 -04:00
"""
Get energy systems archetype name
:return: dict
"""
2023-08-01 16:40:49 -04:00
return self._energy_systems_archetype_name
@property
2023-08-08 15:59:06 -04:00
def energy_systems(self) -> [EnergySystem]:
"""
Get building energy systems
:return: [EnergySystem]
"""
_energy_systems = []
2023-07-31 14:42:13 -04:00
for system in self._catalog_archetype.systems:
2023-08-02 15:47:09 -04:00
_hub_demand_types = []
for demand_type in system.demand_types:
# todo: generalize this when we have more catalogs
_hub_demand_types.append(Dictionaries().montreal_demand_type_to_hub_energy_demand_type[demand_type])
demands = _hub_demand_types
2024-04-18 01:32:32 -04:00
fuel_type = Dictionaries().montreal_custom_fuel_to_hub_fuel[system.generation_systems[0].fuel_type]
generic_generation_system = GenericGenerationSystem()
generic_generation_system.fuel_type = fuel_type
generation_system = GenerationSystem()
generation_system.generic_generation_system = generic_generation_system
energy_system = EnergySystem()
energy_system.generation_system = generation_system
energy_system.demand_types = demands
_energy_systems.append(energy_system)
return _energy_systems