checking a problem with lists assignation where a single value should be assigned

This commit is contained in:
Pilar Monsalvete 2023-10-10 05:31:57 -04:00
parent 0c7371787b
commit 1801aa6f00
2 changed files with 9 additions and 5 deletions

View File

@ -759,14 +759,14 @@ class Building(CityObject):
if demand_type.lower() == consumption_type.lower(): if demand_type.lower() == consumption_type.lower():
if consumption_type in (cte.HEATING, cte.DOMESTIC_HOT_WATER): if consumption_type in (cte.HEATING, cte.DOMESTIC_HOT_WATER):
for generation_system in energy_system_generation_systems: 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: elif consumption_type == cte.COOLING:
for generation_system in energy_system_generation_systems: 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: elif consumption_type == cte.ELECTRICITY:
for generation_system in energy_system_generation_systems: for generation_system in energy_system_generation_systems:
coefficient_of_performance = \ coefficient_of_performance = \
generation_system.generic_generation_system.electricity_efficiency generation_system.generic_generation_system[0].electricity_efficiency
if coefficient_of_performance == 0: if coefficient_of_performance == 0:
values = [0] * len(demand) values = [0] * len(demand)
final_energy_consumed = values final_energy_consumed = values
@ -799,8 +799,8 @@ class Building(CityObject):
for energy_system in self.energy_systems: for energy_system in self.energy_systems:
energy_system_generation_systems = energy_system.generation_systems energy_system_generation_systems = energy_system.generation_systems
for generation_system in energy_system_generation_systems: for generation_system in energy_system_generation_systems:
if generation_system.generic_generation_system.type == cte.PHOTOVOLTAIC: if generation_system.generic_generation_system[0].type == cte.PHOTOVOLTAIC:
_efficiency = generation_system.generic_generation_system.electricity_efficiency _efficiency = generation_system.generic_generation_system[0].electricity_efficiency
self._onsite_electrical_production = {} self._onsite_electrical_production = {}
for _key in self.roofs[0].global_irradiance.keys(): for _key in self.roofs[0].global_irradiance.keys():
_results = [0 for _ in range(0, len(self.roofs[0].global_irradiance[_key]))] _results = [0 for _ in range(0, len(self.roofs[0].global_irradiance[_key]))]

View File

@ -183,6 +183,10 @@ class TestSystemsFactory(TestCase):
building.energy_systems = _building_energy_systems building.energy_systems = _building_energy_systems
for building in self._city.buildings: 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.heating_consumption[cte.YEAR][0])
self.assertLess(0, building.cooling_consumption[cte.YEAR][0]) self.assertLess(0, building.cooling_consumption[cte.YEAR][0])
self.assertLess(0, building.domestic_hot_water_consumption[cte.YEAR][0]) self.assertLess(0, building.domestic_hot_water_consumption[cte.YEAR][0])