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 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[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:
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:
for generation_system in energy_system_generation_systems:
coefficient_of_performance = \
generation_system.generic_generation_system[0].electricity_efficiency
generation_system.generic_generation_system.electricity_efficiency
if coefficient_of_performance == 0:
values = [0] * len(demand)
final_energy_consumed = values
else:
final_energy_consumed = []
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
@property
@ -799,8 +801,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[0].type == cte.PHOTOVOLTAIC:
_efficiency = generation_system.generic_generation_system[0].electricity_efficiency
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]))]

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.thermal_storage_system import ThermalStorageSystem
class TestSystemsFactory(TestCase):
"""
TestSystemsFactory TestCase
"""
def setUp(self) -> None:
"""
Test setup
@ -163,22 +165,20 @@ class TestSystemsFactory(TestCase):
_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)
_generation_system = GenerationSystem()
_generation_system.generic_generation_system = (
copy.deepcopy(_building_generation_system)
)
_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]
_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)
_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.generic_storage_system = \
copy.deepcopy(_generic_building_energy_system.energy_storage_systems)
_building_energy_systems.append(_building_energy_equipment)
building.energy_systems = _building_energy_systems
@ -188,6 +188,6 @@ class TestSystemsFactory(TestCase):
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.assertEqual(0, building.cooling_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])