solved problems when systems not exist

This commit is contained in:
Pilar Monsalvete 2023-05-29 15:26:21 -04:00
parent 8c3e9a2f95
commit 3cdad733b3

View File

@ -566,6 +566,8 @@ class Building(CityObject):
demand = self.heating[heating_demand_key][cte.INSEL_MEB]
consumption_type = cte.HEATING
final_energy_consumed = self._calculate_consumption(consumption_type, demand)
if final_energy_consumed is None:
continue
self._heating_consumption[heating_demand_key] = final_energy_consumed
return self._heating_consumption
@ -580,6 +582,8 @@ class Building(CityObject):
demand = self.cooling[cooling_demand_key][cte.INSEL_MEB]
consumption_type = cte.COOLING
final_energy_consumed = self._calculate_consumption(consumption_type, demand)
if final_energy_consumed is None:
continue
self._cooling_consumption[cooling_demand_key] = final_energy_consumed
return self._cooling_consumption
@ -594,6 +598,8 @@ class Building(CityObject):
demand = self.domestic_hot_water_heat_demand[domestic_hot_water_demand_key][cte.INSEL_MEB]
consumption_type = cte.DOMESTIC_HOT_WATER
final_energy_consumed = self._calculate_consumption(consumption_type, demand)
if final_energy_consumed is None:
continue
self._domestic_hot_water_consumption[domestic_hot_water_demand_key] = final_energy_consumed
return self._domestic_hot_water_consumption
@ -636,6 +642,8 @@ class Building(CityObject):
_peak_load_type = cte.COOLING
_consumption_fix_flow = 0
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
parasitic_energy_consumption = 0
@ -672,6 +680,8 @@ class Building(CityObject):
def _calculate_consumption(self, consumption_type, demand):
# todo: modify when COP depends on the hour
coefficient_of_performance = 0
if self.energy_systems is None:
return None
for energy_system in self.energy_systems:
for demand_type in energy_system.demand_types:
if demand_type.lower() == consumption_type.lower():
@ -709,6 +719,8 @@ class Building(CityObject):
'south': [1.212544],
'west': [0]}
}
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