From 1801aa6f00aa05c578163e75ae7b6f47db4aa831 Mon Sep 17 00:00:00 2001 From: p_monsalvete Date: Tue, 10 Oct 2023 05:31:57 -0400 Subject: [PATCH] checking a problem with lists assignation where a single value should be assigned --- hub/city_model_structure/building.py | 10 +++++----- tests/test_systems_factory.py | 4 ++++ 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/hub/city_model_structure/building.py b/hub/city_model_structure/building.py index e0b18c66..cbbda322 100644 --- a/hub/city_model_structure/building.py +++ b/hub/city_model_structure/building.py @@ -759,14 +759,14 @@ class Building(CityObject): if demand_type.lower() == consumption_type.lower(): if consumption_type in (cte.HEATING, cte.DOMESTIC_HOT_WATER): for generation_system in energy_system_generation_systems: - coefficient_of_performance = generation_system.generic_generation_system.heat_efficiency + coefficient_of_performance = generation_system.generic_generation_system[0].heat_efficiency elif consumption_type == cte.COOLING: for generation_system in energy_system_generation_systems: - coefficient_of_performance = generation_system.generic_generation_system.cooling_efficiency + coefficient_of_performance = generation_system.generic_generation_system[0].cooling_efficiency elif consumption_type == cte.ELECTRICITY: for generation_system in energy_system_generation_systems: coefficient_of_performance = \ - generation_system.generic_generation_system.electricity_efficiency + generation_system.generic_generation_system[0].electricity_efficiency if coefficient_of_performance == 0: values = [0] * len(demand) final_energy_consumed = values @@ -799,8 +799,8 @@ class Building(CityObject): for energy_system in self.energy_systems: energy_system_generation_systems = energy_system.generation_systems for generation_system in energy_system_generation_systems: - if generation_system.generic_generation_system.type == cte.PHOTOVOLTAIC: - _efficiency = generation_system.generic_generation_system.electricity_efficiency + if generation_system.generic_generation_system[0].type == cte.PHOTOVOLTAIC: + _efficiency = generation_system.generic_generation_system[0].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/tests/test_systems_factory.py b/tests/test_systems_factory.py index f502cf8b..f2e3a7b4 100644 --- a/tests/test_systems_factory.py +++ b/tests/test_systems_factory.py @@ -183,6 +183,10 @@ class TestSystemsFactory(TestCase): building.energy_systems = _building_energy_systems for building in self._city.buildings: + print(building.heating_consumption[cte.YEAR][0]) + print(building.cooling_consumption[cte.YEAR][0]) + print(building.domestic_hot_water_consumption[cte.YEAR][0]) + print(building.onsite_electrical_production[cte.YEAR][0]) self.assertLess(0, building.heating_consumption[cte.YEAR][0]) self.assertLess(0, building.cooling_consumption[cte.YEAR][0]) self.assertLess(0, building.domestic_hot_water_consumption[cte.YEAR][0])