From ca48d6448b918fa7873232fb1b53315665b3b62a Mon Sep 17 00:00:00 2001 From: Saeed Ranjbar Date: Thu, 5 Oct 2023 13:18:57 -0400 Subject: [PATCH] changed all the singular names to plural and turned distribution and emission systems into lists --- hub/city_model_structure/building.py | 12 +++-- .../energy_systems/energy_system.py | 48 +++++++++---------- ...ontreal_custom_energy_system_parameters.py | 10 ++-- ...america_custom_energy_system_parameters.py | 16 +++---- tests/test_systems_factory.py | 22 ++++----- 5 files changed, 55 insertions(+), 53 deletions(-) diff --git a/hub/city_model_structure/building.py b/hub/city_model_structure/building.py index 2ef73469..c0595bba 100644 --- a/hub/city_model_structure/building.py +++ b/hub/city_model_structure/building.py @@ -706,11 +706,11 @@ class Building(CityObject): if self.energy_systems is None: return self._distribution_systems_electrical_consumption for energy_system in self.energy_systems: - emission_system = energy_system.emission_system.generic_emission_system + emission_system = energy_system.emission_systems.generic_emission_system parasitic_energy_consumption = 0 if emission_system is not None: parasitic_energy_consumption = emission_system.parasitic_energy_consumption - distribution_system = energy_system.distribution_system.generic_distribution_system + distribution_system = energy_system.distribution_systems.generic_distribution_system consumption_variable_flow = distribution_system.distribution_consumption_variable_flow for demand_type in energy_system.demand_types: if demand_type.lower() == cte.HEATING.lower(): @@ -744,7 +744,9 @@ class Building(CityObject): if self.energy_systems is None: return None for energy_system in self.energy_systems: - generation_systems = energy_system.generation_system + generation_systems = energy_system.generation_systems + print(generation_systems) + print(type(generation_systems)) for demand_type in energy_system.demand_types: if demand_type.lower() == consumption_type.lower(): if consumption_type in (cte.HEATING, cte.DOMESTIC_HOT_WATER): @@ -786,8 +788,8 @@ class Building(CityObject): if self.energy_systems is None: return self._onsite_electrical_production for energy_system in self.energy_systems: - if energy_system.generation_system.generic_generation_system.type == cte.PHOTOVOLTAIC: - _efficiency = energy_system.generation_system.generic_generation_system.electricity_efficiency + if energy_system.generation_systems.generic_generation_system.type == cte.PHOTOVOLTAIC: + _efficiency = energy_system.generation_systems.generic_generation_system.electricity_efficiency self._onsite_electrical_production = {} for _key in self.roofs[0].global_irradiance.keys(): _results = [0 for _ in range(0, len(self.roofs[0].global_irradiance[_key]))] diff --git a/hub/city_model_structure/energy_systems/energy_system.py b/hub/city_model_structure/energy_systems/energy_system.py index f4a9ea96..01d683ba 100644 --- a/hub/city_model_structure/energy_systems/energy_system.py +++ b/hub/city_model_structure/energy_systems/energy_system.py @@ -23,12 +23,12 @@ class EnergySystem: def __init__(self): self._name = None self._demand_types = None - self._generation_system = None - self._distribution_system = None - self._emission_system = None + self._generation_systems = None + self._distribution_systems = None + self._emission_systems = None self._connected_city_objects = None self._control_system = None - self._energy_storage_system = None + self._energy_storage_systems = None @property def name(self): @@ -63,52 +63,52 @@ class EnergySystem: self._demand_types = value @property - def generation_system(self) -> List[GenerationSystem]: + def generation_systems(self) -> List[GenerationSystem]: """ Get generation systems :return: GenerationSystem """ - return self._generation_system + return self._generation_systems - @generation_system.setter - def generation_system(self, value): + @generation_systems.setter + def generation_systems(self, value): """ Set generation system :param value: GenerationSystem """ - self._generation_system = value + self._generation_systems = value @property - def distribution_system(self) -> Union[None, DistributionSystem]: + def distribution_systems(self) -> Union[None, List[DistributionSystem]]: """ Get distribution system :return: DistributionSystem """ - return self._distribution_system + return self._distribution_systems - @distribution_system.setter - def distribution_system(self, value): + @distribution_systems.setter + def distribution_systems(self, value): """ Set distribution system :param value: DistributionSystem """ - self._distribution_system = value + self._distribution_systems = value @property - def emission_system(self) -> Union[None, EmissionSystem]: + def emission_systems(self) -> Union[None, List[EmissionSystem]]: """ Get emission system :return: EmissionSystem """ - return self._emission_system + return self._emission_systems - @emission_system.setter - def emission_system(self, value): + @emission_systems.setter + def emission_systems(self, value): """ Set emission system :param value: EmissionSystem """ - self._emission_system = value + self._emission_systems = value @property def connected_city_objects(self) -> Union[None, List[CityObject]]: @@ -143,17 +143,17 @@ class EnergySystem: self._control_system = value @property - def energy_storage_system(self) -> Union[None, List[ThermalStorageSystem], List[ElectricalStorageSystem]]: + def energy_storage_systems(self) -> Union[None, List[ThermalStorageSystem], List[ElectricalStorageSystem]]: """ Get energy storage systems :return: [EnergyStorageSystem] """ - return self._energy_storage_system + return self._energy_storage_systems - @energy_storage_system.setter - def energy_storage_system(self, value): + @energy_storage_systems.setter + def energy_storage_systems(self, value): """ Set storage system :param value: [EnergyStorageSystem] """ - self._energy_storage_system = value + self._energy_storage_systems = value diff --git a/hub/imports/energy_systems/montreal_custom_energy_system_parameters.py b/hub/imports/energy_systems/montreal_custom_energy_system_parameters.py index 49f7086f..f0c35168 100644 --- a/hub/imports/energy_systems/montreal_custom_energy_system_parameters.py +++ b/hub/imports/energy_systems/montreal_custom_energy_system_parameters.py @@ -86,7 +86,7 @@ class MontrealCustomEnergySystemParameters: energy_system.name = system.name energy_system.demand_types = _hub_demand_types _generation_system = GenericGenerationSystem() - archetype_generation_equipment = system.generation_system + archetype_generation_equipment = system.generation_systems _type = system.name _generation_system.type = Dictionaries().montreal_system_to_hub_energy_generation_system[ _type] @@ -145,11 +145,11 @@ class MontrealCustomEnergySystemParameters: copy.deepcopy(_generic_building_energy_system.emission_systems) _building_generation_system = GenerationSystem() _building_generation_system.generic_generation_system = \ - copy.deepcopy(_generic_building_energy_system.generation_system) + copy.deepcopy(_generic_building_energy_system.generation_systems) - _building_energy_equipment.generation_system = _building_generation_system - _building_energy_equipment.distribution_system = _building_distribution_system - _building_energy_equipment.emission_system = _building_emission_system + _building_energy_equipment.generation_systems = _building_generation_system + _building_energy_equipment.distribution_systems = _building_distribution_system + _building_energy_equipment.emission_systems = _building_emission_system _building_energy_systems.append(_building_energy_equipment) building.energy_systems = _building_energy_systems diff --git a/hub/imports/energy_systems/north_america_custom_energy_system_parameters.py b/hub/imports/energy_systems/north_america_custom_energy_system_parameters.py index f5360568..040658cf 100644 --- a/hub/imports/energy_systems/north_america_custom_energy_system_parameters.py +++ b/hub/imports/energy_systems/north_america_custom_energy_system_parameters.py @@ -154,21 +154,21 @@ class NorthAmericaCustomEnergySystemParameters: _building_distribution_system = DistributionSystem() _building_distribution_system.generic_distribution_system = \ - copy.deepcopy(_generic_building_energy_system.distribution_system) + copy.deepcopy(_generic_building_energy_system.distribution_systems) _building_emission_system = EmissionSystem() _building_emission_system.generic_emission_system = \ - copy.deepcopy(_generic_building_energy_system.emission_system) + copy.deepcopy(_generic_building_energy_system.emission_systems) _building_generation_system = GenerationSystem() _building_generation_system.generic_generation_system = \ - copy.deepcopy(_generic_building_energy_system.generation_system) + copy.deepcopy(_generic_building_energy_system.generation_systems) _building_storage_system = ThermalStorageSystem() _building_storage_system.generic_storage_system = \ - copy.deepcopy(_generic_building_energy_system.energy_storage_system) + copy.deepcopy(_generic_building_energy_system.energy_storage_systems) - _building_energy_equipment.generation_system = _building_generation_system - _building_energy_equipment.distribution_system = _building_distribution_system - _building_energy_equipment.emission_system = _building_emission_system - _building_energy_equipment.energy_storage_system = _building_storage_system + _building_energy_equipment.generation_systems = _building_generation_system + _building_energy_equipment.distribution_systems = _building_distribution_system + _building_energy_equipment.emission_systems = _building_emission_system + _building_energy_equipment.energy_storage_systems = _building_storage_system _building_energy_systems.append(_building_energy_equipment) building.energy_systems = _building_energy_systems diff --git a/tests/test_systems_factory.py b/tests/test_systems_factory.py index 4dd70998..07c9683a 100644 --- a/tests/test_systems_factory.py +++ b/tests/test_systems_factory.py @@ -98,15 +98,15 @@ class TestSystemsFactory(TestCase): ) _building_generation_system = GenerationSystem() _building_generation_system.generic_generation_system = ( - copy.deepcopy(_generic_building_energy_system.generation_system) + copy.deepcopy(_generic_building_energy_system.generation_systems) ) if cte.HEATING in _building_energy_equipment.demand_types: _building_generation_system.heat_power = building.heating_peak_load[cte.YEAR][0] if cte.COOLING in _building_energy_equipment.demand_types: _building_generation_system.cooling_power = building.cooling_peak_load[cte.YEAR][0] - _building_energy_equipment.generation_system = _building_generation_system - _building_energy_equipment.distribution_system = _building_distribution_system - _building_energy_equipment.emission_system = _building_emission_system + _building_energy_equipment.generation_systems = _building_generation_system + _building_energy_equipment.distribution_systems = _building_distribution_system + _building_energy_equipment.emission_systems = _building_emission_system _building_energy_systems.append(_building_energy_equipment) building.energy_systems = _building_energy_systems @@ -161,27 +161,27 @@ class TestSystemsFactory(TestCase): _building_distribution_system = DistributionSystem() _building_distribution_system.generic_distribution_system = ( - copy.deepcopy(_generic_building_energy_system.distribution_system) + copy.deepcopy(_generic_building_energy_system.distribution_systems) ) _building_emission_system = EmissionSystem() _building_emission_system.generic_emission_system = ( - copy.deepcopy(_generic_building_energy_system.emission_system) + copy.deepcopy(_generic_building_energy_system.emission_systems) ) _building_generation_system = GenerationSystem() _building_generation_system.generic_generation_system = ( - copy.deepcopy(_generic_building_energy_system.generation_system) + copy.deepcopy(_generic_building_energy_system.generation_systems) ) _building_storage_system = ThermalStorageSystem() _building_storage_system.generic_storage_system = \ - copy.deepcopy(_generic_building_energy_system.energy_storage_system) + copy.deepcopy(_generic_building_energy_system.energy_storage_systems) if cte.HEATING in _building_energy_equipment.demand_types: _building_generation_system.heat_power = building.heating_peak_load[cte.YEAR][0] if cte.COOLING in _building_energy_equipment.demand_types: _building_generation_system.cooling_power = building.cooling_peak_load[cte.YEAR][0] - _building_energy_equipment.generation_system = _building_generation_system - _building_energy_equipment.distribution_system = _building_distribution_system - _building_energy_equipment.emission_system = _building_emission_system + _building_energy_equipment.generation_systems = _building_generation_system + _building_energy_equipment.distribution_systems = _building_distribution_system + _building_energy_equipment.emission_systems = _building_emission_system _building_energy_systems.append(_building_energy_equipment) building.energy_systems = _building_energy_systems