made some changes to the test_systems_factory.py to take into account the fact that generation systems are a list

This commit is contained in:
Saeed Ranjbar 2023-10-09 20:36:43 -04:00
parent d29161b05e
commit 0c7371787b
3 changed files with 46 additions and 50 deletions

View File

@ -27,6 +27,7 @@ class Building(CityObject):
"""
Building(CityObject) class
"""
def __init__(self, name, surfaces, year_of_construction, function, terrains=None, city=None):
super().__init__(name, surfaces)
self._city = city
@ -726,7 +727,7 @@ class Building(CityObject):
if _peak_load_type == cte.HEATING.lower():
_consumption_fix_flow = distribution_system.distribution_consumption_fix_flow
for heating_demand_key in self.heating_demand:
_consumption = [0]*len(self.heating_demand[heating_demand_key])
_consumption = [0] * len(self.heating_demand[heating_demand_key])
_demand = self.heating_demand[heating_demand_key]
for i, _ in enumerate(_consumption):
_consumption[i] += (parasitic_energy_consumption + consumption_variable_flow) * _demand[i]
@ -753,22 +754,21 @@ class Building(CityObject):
if self.energy_systems is None:
return None
for energy_system in self.energy_systems:
generation_systems = energy_system.generation_systems
print(generation_systems)
print(type(generation_systems))
energy_system_generation_systems = energy_system.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):
for generation_system in generation_systems:
for generation_system in energy_system_generation_systems:
coefficient_of_performance = generation_system.generic_generation_system.heat_efficiency
elif consumption_type == cte.COOLING:
for generation_system in generation_systems:
for generation_system in energy_system_generation_systems:
coefficient_of_performance = generation_system.generic_generation_system.cooling_efficiency
elif consumption_type == cte.ELECTRICITY:
for generation_system in generation_systems:
coefficient_of_performance = generation_system.generic_generation_system.electricity_efficiency
for generation_system in energy_system_generation_systems:
coefficient_of_performance = \
generation_system.generic_generation_system.electricity_efficiency
if coefficient_of_performance == 0:
values = [0]*len(demand)
values = [0] * len(demand)
final_energy_consumed = values
else:
final_energy_consumed = []
@ -797,16 +797,18 @@ 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_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]))]
for surface in self.roofs:
if _key in orientation_losses_factor:
_results = [x + y * _efficiency * surface.perimeter_area
* surface.solar_collectors_area_reduction_factor * z
for x, y, z in zip(_results, surface.global_irradiance[_key],
orientation_losses_factor[_key]['south'])]
self._onsite_electrical_production[_key] = _results
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
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]))]
for surface in self.roofs:
if _key in orientation_losses_factor:
_results = [x + y * _efficiency * surface.perimeter_area
* surface.solar_collectors_area_reduction_factor * z
for x, y, z in zip(_results, surface.global_irradiance[_key],
orientation_losses_factor[_key]['south'])]
self._onsite_electrical_production[_key] = _results
return self._onsite_electrical_production

View File

@ -158,12 +158,12 @@ class NorthAmericaCustomEnergySystemParameters:
copy.deepcopy(_generic_building_generation_system)
_generation_systems.append(_building_generation_system)
_building_energy_equipment.generation_systems = _generation_systems
_building_storage_system = ThermalStorageSystem()
_building_storage_system.generic_storage_system = \
copy.deepcopy(_generic_building_energy_system.energy_storage_systems)
_building_energy_equipment.energy_storage_systems = _building_storage_system
# _building_storage_system = ThermalStorageSystem()
# _building_storage_system.generic_storage_system = \
# copy.deepcopy(_generic_building_energy_system.energy_storage_systems)
#
#
# _building_energy_equipment.energy_storage_systems = _building_storage_system
_building_energy_systems.append(_building_energy_equipment)
building.energy_systems = _building_energy_systems

View File

@ -160,30 +160,24 @@ class TestSystemsFactory(TestCase):
for _generic_building_energy_system in _generic_building_energy_systems:
_building_energy_equipment = EnergySystem()
_building_energy_equipment.demand_types = _generic_building_energy_system.demand_types
_building_generation_systems = _generic_building_energy_system.generation_systems
_generic_system_generation_systems = []
for _building_generation_system in _building_generation_systems:
_building_generation_system = GenerationSystem()
_building_generation_system.generic_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_systems)
_building_distribution_system = DistributionSystem()
_building_distribution_system.generic_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_systems)
)
_building_generation_system = GenerationSystem()
_building_generation_system.generic_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_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_systems = _building_generation_system
_building_energy_equipment.distribution_systems = _building_distribution_system
_building_energy_equipment.emission_systems = _building_emission_system
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]
_generic_system_generation_systems.append(_building_generation_system)
print(_generic_system_generation_systems)
_building_energy_equipment.generation_systems = _generic_system_generation_systems
_building_energy_systems.append(_building_energy_equipment)
building.energy_systems = _building_energy_systems