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:
parent
d29161b05e
commit
0c7371787b
@ -27,6 +27,7 @@ class Building(CityObject):
|
|||||||
"""
|
"""
|
||||||
Building(CityObject) class
|
Building(CityObject) class
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, name, surfaces, year_of_construction, function, terrains=None, city=None):
|
def __init__(self, name, surfaces, year_of_construction, function, terrains=None, city=None):
|
||||||
super().__init__(name, surfaces)
|
super().__init__(name, surfaces)
|
||||||
self._city = city
|
self._city = city
|
||||||
@ -726,7 +727,7 @@ class Building(CityObject):
|
|||||||
if _peak_load_type == cte.HEATING.lower():
|
if _peak_load_type == cte.HEATING.lower():
|
||||||
_consumption_fix_flow = distribution_system.distribution_consumption_fix_flow
|
_consumption_fix_flow = distribution_system.distribution_consumption_fix_flow
|
||||||
for heating_demand_key in self.heating_demand:
|
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]
|
_demand = self.heating_demand[heating_demand_key]
|
||||||
for i, _ in enumerate(_consumption):
|
for i, _ in enumerate(_consumption):
|
||||||
_consumption[i] += (parasitic_energy_consumption + consumption_variable_flow) * _demand[i]
|
_consumption[i] += (parasitic_energy_consumption + consumption_variable_flow) * _demand[i]
|
||||||
@ -753,22 +754,21 @@ class Building(CityObject):
|
|||||||
if self.energy_systems is None:
|
if self.energy_systems is None:
|
||||||
return None
|
return None
|
||||||
for energy_system in self.energy_systems:
|
for energy_system in self.energy_systems:
|
||||||
generation_systems = energy_system.generation_systems
|
energy_system_generation_systems = energy_system.generation_systems
|
||||||
print(generation_systems)
|
|
||||||
print(type(generation_systems))
|
|
||||||
for demand_type in energy_system.demand_types:
|
for demand_type in energy_system.demand_types:
|
||||||
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 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.heat_efficiency
|
||||||
elif consumption_type == cte.COOLING:
|
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
|
coefficient_of_performance = generation_system.generic_generation_system.cooling_efficiency
|
||||||
elif consumption_type == cte.ELECTRICITY:
|
elif consumption_type == cte.ELECTRICITY:
|
||||||
for generation_system in generation_systems:
|
for generation_system in energy_system_generation_systems:
|
||||||
coefficient_of_performance = generation_system.generic_generation_system.electricity_efficiency
|
coefficient_of_performance = \
|
||||||
|
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 = []
|
||||||
@ -797,16 +797,18 @@ class Building(CityObject):
|
|||||||
if self.energy_systems is None:
|
if self.energy_systems is None:
|
||||||
return self._onsite_electrical_production
|
return self._onsite_electrical_production
|
||||||
for energy_system in self.energy_systems:
|
for energy_system in self.energy_systems:
|
||||||
if energy_system.generation_systems.generic_generation_system.type == cte.PHOTOVOLTAIC:
|
energy_system_generation_systems = energy_system.generation_systems
|
||||||
_efficiency = energy_system.generation_systems.generic_generation_system.electricity_efficiency
|
for generation_system in energy_system_generation_systems:
|
||||||
self._onsite_electrical_production = {}
|
if generation_system.generic_generation_system.type == cte.PHOTOVOLTAIC:
|
||||||
for _key in self.roofs[0].global_irradiance.keys():
|
_efficiency = generation_system.generic_generation_system.electricity_efficiency
|
||||||
_results = [0 for _ in range(0, len(self.roofs[0].global_irradiance[_key]))]
|
self._onsite_electrical_production = {}
|
||||||
for surface in self.roofs:
|
for _key in self.roofs[0].global_irradiance.keys():
|
||||||
if _key in orientation_losses_factor:
|
_results = [0 for _ in range(0, len(self.roofs[0].global_irradiance[_key]))]
|
||||||
_results = [x + y * _efficiency * surface.perimeter_area
|
for surface in self.roofs:
|
||||||
* surface.solar_collectors_area_reduction_factor * z
|
if _key in orientation_losses_factor:
|
||||||
for x, y, z in zip(_results, surface.global_irradiance[_key],
|
_results = [x + y * _efficiency * surface.perimeter_area
|
||||||
orientation_losses_factor[_key]['south'])]
|
* surface.solar_collectors_area_reduction_factor * z
|
||||||
self._onsite_electrical_production[_key] = _results
|
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
|
return self._onsite_electrical_production
|
||||||
|
@ -158,12 +158,12 @@ class NorthAmericaCustomEnergySystemParameters:
|
|||||||
copy.deepcopy(_generic_building_generation_system)
|
copy.deepcopy(_generic_building_generation_system)
|
||||||
_generation_systems.append(_building_generation_system)
|
_generation_systems.append(_building_generation_system)
|
||||||
_building_energy_equipment.generation_systems = _generation_systems
|
_building_energy_equipment.generation_systems = _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)
|
||||||
|
#
|
||||||
|
#
|
||||||
_building_energy_equipment.energy_storage_systems = _building_storage_system
|
# _building_energy_equipment.energy_storage_systems = _building_storage_system
|
||||||
|
|
||||||
_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
|
||||||
|
@ -160,30 +160,24 @@ class TestSystemsFactory(TestCase):
|
|||||||
for _generic_building_energy_system in _generic_building_energy_systems:
|
for _generic_building_energy_system in _generic_building_energy_systems:
|
||||||
_building_energy_equipment = EnergySystem()
|
_building_energy_equipment = EnergySystem()
|
||||||
_building_energy_equipment.demand_types = _generic_building_energy_system.demand_types
|
_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()
|
if cte.HEATING in _building_energy_equipment.demand_types:
|
||||||
_building_distribution_system.generic_distribution_system = (
|
_building_generation_system.heat_power = building.heating_peak_load[cte.YEAR][0]
|
||||||
copy.deepcopy(_generic_building_energy_system.distribution_systems)
|
if cte.COOLING in _building_energy_equipment.demand_types:
|
||||||
)
|
_building_generation_system.cooling_power = building.cooling_peak_load[cte.YEAR][0]
|
||||||
_building_emission_system = EmissionSystem()
|
_generic_system_generation_systems.append(_building_generation_system)
|
||||||
_building_emission_system.generic_emission_system = (
|
print(_generic_system_generation_systems)
|
||||||
copy.deepcopy(_generic_building_energy_system.emission_systems)
|
_building_energy_equipment.generation_systems = _generic_system_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)
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
_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
|
||||||
|
Loading…
Reference in New Issue
Block a user