finished the test

This commit is contained in:
Saeed Ranjbar 2023-10-10 11:38:41 -04:00
parent 1801aa6f00
commit f2d78c381e
2 changed files with 21 additions and 19 deletions

View File

@ -759,21 +759,23 @@ 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[0].heat_efficiency generic_gen = generation_system.generic_generation_system
print(generation_system)
coefficient_of_performance = generation_system.generic_generation_system.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[0].cooling_efficiency coefficient_of_performance = generation_system.generic_generation_system.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[0].electricity_efficiency generation_system.generic_generation_system.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
else: else:
final_energy_consumed = [] final_energy_consumed = []
for demand_value in demand: for demand_value in demand:
final_energy_consumed.append(demand_value / coefficient_of_performance) final_energy_consumed.append(demand_value / float(coefficient_of_performance))
return final_energy_consumed return final_energy_consumed
@property @property
@ -799,8 +801,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[0].type == cte.PHOTOVOLTAIC: if generation_system.generic_generation_system.type == cte.PHOTOVOLTAIC:
_efficiency = generation_system.generic_generation_system[0].electricity_efficiency _efficiency = generation_system.generic_generation_system.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

@ -26,10 +26,12 @@ from hub.city_model_structure.energy_systems.distribution_system import Distribu
from hub.city_model_structure.energy_systems.emission_system import EmissionSystem from hub.city_model_structure.energy_systems.emission_system import EmissionSystem
from hub.city_model_structure.energy_systems.thermal_storage_system import ThermalStorageSystem from hub.city_model_structure.energy_systems.thermal_storage_system import ThermalStorageSystem
class TestSystemsFactory(TestCase): class TestSystemsFactory(TestCase):
""" """
TestSystemsFactory TestCase TestSystemsFactory TestCase
""" """
def setUp(self) -> None: def setUp(self) -> None:
""" """
Test setup Test setup
@ -163,22 +165,20 @@ class TestSystemsFactory(TestCase):
_building_generation_systems = _generic_building_energy_system.generation_systems _building_generation_systems = _generic_building_energy_system.generation_systems
_generic_system_generation_systems = [] _generic_system_generation_systems = []
for _building_generation_system in _building_generation_systems: for _building_generation_system in _building_generation_systems:
_building_generation_system = GenerationSystem() _generation_system = GenerationSystem()
_building_generation_system.generic_generation_system = ( _generation_system.generic_generation_system = (
copy.deepcopy(_generic_building_energy_system.generation_systems) copy.deepcopy(_building_generation_system)
) )
if cte.HEATING in _building_energy_equipment.demand_types:
_generation_system.heat_power = building.heating_peak_load[cte.YEAR][0]
if cte.COOLING in _building_energy_equipment.demand_types:
_generation_system.cooling_power = building.cooling_peak_load[cte.YEAR][0]
_generic_system_generation_systems.append(_generation_system)
print(_generic_system_generation_systems)
_building_energy_equipment.generation_systems = _generic_system_generation_systems
_building_storage_system = ThermalStorageSystem() _building_storage_system = ThermalStorageSystem()
_building_storage_system.generic_storage_system = \ _building_storage_system.generic_storage_system = \
copy.deepcopy(_generic_building_energy_system.energy_storage_systems) 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]
_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.append(_building_energy_equipment)
building.energy_systems = _building_energy_systems building.energy_systems = _building_energy_systems
@ -188,6 +188,6 @@ class TestSystemsFactory(TestCase):
print(building.domestic_hot_water_consumption[cte.YEAR][0]) print(building.domestic_hot_water_consumption[cte.YEAR][0])
print(building.onsite_electrical_production[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.assertEqual(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])
self.assertLess(0, building.onsite_electrical_production[cte.YEAR][0]) self.assertLess(0, building.onsite_electrical_production[cte.YEAR][0])