diff --git a/hub/city_model_structure/energy_systems/generic_energy_system.py b/hub/city_model_structure/energy_systems/generic_energy_system.py index 45767ed7..350e3f0d 100644 --- a/hub/city_model_structure/energy_systems/generic_energy_system.py +++ b/hub/city_model_structure/energy_systems/generic_energy_system.py @@ -5,11 +5,12 @@ Copyright © 2023 Concordia CERC group Project Coder Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca """ -from typing import Union +from typing import Union, List from hub.city_model_structure.energy_systems.generic_generation_system import GenericGenerationSystem from hub.city_model_structure.energy_systems.generic_distribution_system import GenericDistributionSystem from hub.city_model_structure.energy_systems.generic_emission_system import GenericEmissionSystem +from hub.city_model_structure.city_object import CityObject class GenericEnergySystem: @@ -21,6 +22,7 @@ class GenericEnergySystem: self._generation_system = None self._distribution_system = None self._emission_system = None + self._connected_city_objects = None @property def demand_types(self): @@ -44,16 +46,9 @@ class GenericEnergySystem: Get generation system :return: GenerationSystem """ + self._generation_system = GenericGenerationSystem(self.connected_city_objects) return self._generation_system - @generation_system.setter - def generation_system(self, value): - """ - Set generation system - :param value: GenerationSystem - """ - self._generation_system = value - @property def distribution_system(self) -> Union[None, GenericDistributionSystem]: """ @@ -85,3 +80,19 @@ class GenericEnergySystem: :param value: EmissionSystem """ self._emission_system = value + + @property + def connected_city_objects(self) -> Union[None, List[CityObject]]: + """ + Get list of city objects that are connected to this energy system + :return: List[CityObject] + """ + return self._connected_city_objects + + @connected_city_objects.setter + def connected_city_objects(self, value): + """ + Set list of city objects that are connected to this energy system + :param value: List[CityObject] + """ + self._connected_city_objects = value diff --git a/hub/city_model_structure/energy_systems/generic_generation_system.py b/hub/city_model_structure/energy_systems/generic_generation_system.py index 64fa35b5..1d19ea5c 100644 --- a/hub/city_model_structure/energy_systems/generic_generation_system.py +++ b/hub/city_model_structure/energy_systems/generic_generation_system.py @@ -8,17 +8,20 @@ Project Coder Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca from __future__ import annotations from typing import Union +import hub.helpers.constants as cte + class GenericGenerationSystem: """ GenericGenerationSystem class """ - def __init__(self): + def __init__(self, city_objects=None, heat_power=None, cooling_power=None, electricity_power=None): + self._city_objects = city_objects self._type = None self._fuel_type = None - self._heat_power = None - self._cooling_power = None - self._electricity_power = None + self._heat_power = heat_power + self._cooling_power = cooling_power + self._electricity_power = electricity_power self._source_types = None self._heat_efficiency = None self._cooling_efficiency = None @@ -84,48 +87,46 @@ class GenericGenerationSystem: Get heat_power in W :return: float """ + if self._heat_power is None: + self._heat_power = 0 + for city_object in self._city_objects: + if city_object.heating_peak_load is not None: + if self.peak_coverages[cte.HEATING] is None: + return None + self._heat_power += city_object.heating_peak_load[cte.YEAR][0] * self.peak_coverages[cte.HEATING] return self._heat_power - @heat_power.setter - def heat_power(self, value): - """ - Set heat_power in W - :param value: float - """ - self._heat_power = value - @property def cooling_power(self): """ Get cooling_power in W :return: float """ + if self._cooling_power is None: + self._cooling_power = 0 + for city_object in self._city_objects: + if city_object.cooling_peak_load is not None: + if self.peak_coverages[cte.COOLING] is None: + return None + self._cooling_power += city_object.cooling_peak_load[cte.YEAR][0] * self.peak_coverages[cte.COOLING] return self._cooling_power - @cooling_power.setter - def cooling_power(self, value): - """ - Set cooling_power in W - :param value: float - """ - self._cooling_power = value - @property def electricity_power(self): """ Get electricity_power in W :return: float """ + if self._electricity_power is None: + self._electricity_power = 0 + for city_object in self._city_objects: + if city_object.electricity_peak_load is not None: + if self.peak_coverages[cte.ELECTRICITY] is None: + return None + self._electricity_power += city_object.electricity_peak_load[cte.YEAR][0]\ + * self.peak_coverages[cte.ELECTRICITY] return self._electricity_power - @electricity_power.setter - def electricity_power(self, value): - """ - Set electricity_power in W - :param value: float - """ - self._electricity_power = value - @property def heat_efficiency(self): """ @@ -214,14 +215,6 @@ class GenericGenerationSystem: """ return self._storage_capacity - @storage_capacity.setter - def storage_capacity(self, value): - """ - Set storage_capacity in J - :param value: float - """ - self._storage_capacity = value - @property def storage(self): """ @@ -246,14 +239,6 @@ class GenericGenerationSystem: """ return self._auxiliary_equipment - @auxiliary_equipment.setter - def auxiliary_equipment(self, value): - """ - Set auxiliary_equipment - :param value: GenerationSystem - """ - self._auxiliary_equipment = value - @property def peak_coverages(self) -> dict: """