diff --git a/hub/catalog_factories/data_models/energy_systems/distribution_system.py b/hub/catalog_factories/data_models/energy_systems/distribution_system.py index b6836086..2483ccd2 100644 --- a/hub/catalog_factories/data_models/energy_systems/distribution_system.py +++ b/hub/catalog_factories/data_models/energy_systems/distribution_system.py @@ -9,7 +9,8 @@ Code contributors: Saeed Ranjbar saeed.ranjbar@concordia.ca from typing import Union, List from hub.catalog_factories.data_models.energy_systems.generation_system import GenerationSystem - +from hub.catalog_factories.data_models.energy_systems.energy_storage_system import EnergyStorageSystem +from hub.catalog_factories.data_models.energy_systems.emission_system import EmissionSystem class DistributionSystem: """ @@ -18,7 +19,7 @@ class DistributionSystem: def __init__(self, system_id, model_name=None, system_type=None, supply_temperature=None, distribution_consumption_fix_flow=None, distribution_consumption_variable_flow=None, heat_losses=None, - generation_systems=None): + generation_systems=None, energy_storage_systems=None, emission_systems=None): self._system_id = system_id self._model_name = model_name self._type = system_type @@ -27,6 +28,8 @@ class DistributionSystem: self._distribution_consumption_variable_flow = distribution_consumption_variable_flow self._heat_losses = heat_losses self._generation_systems = generation_systems + self._energy_storage_systems = energy_storage_systems + self._emission_systems = emission_systems @property def id(self): @@ -93,10 +96,30 @@ class DistributionSystem: """ return self._generation_systems + @property + def energy_storage_systems(self) -> Union[None, List[EnergyStorageSystem]]: + """ + Get energy storage systems connected to this distribution system + :return: [EnergyStorageSystem] + """ + return self._energy_storage_systems + + @property + def emission_systems(self) -> Union[None, List[EmissionSystem]]: + """ + Get energy emission systems connected to this distribution system + :return: [EmissionSystem] + """ + return self._emission_systems + def to_dictionary(self): """Class content to dictionary""" _generation_systems = [_generation_system.to_dictionary() for _generation_system in self.generation_systems] if self.generation_systems is not None else None + _energy_storage_systems = [_energy_storage_system.to_dictionary() for _energy_storage_system in + self.energy_storage_systems] if self.energy_storage_systems is not None else None + _emission_systems = [_emission_system.to_dictionary() for _emission_system in + self.emission_systems] if self.emission_systems is not None else None content = { 'Layer': { @@ -107,7 +130,9 @@ class DistributionSystem: 'distribution consumption if fix flow over peak power [W/W]': self.distribution_consumption_fix_flow, 'distribution consumption if variable flow over peak power [J/J]': self.distribution_consumption_variable_flow, 'heat losses per energy produced [J/J]': self.heat_losses, - 'generation systems connected': _generation_systems + 'generation systems connected': _generation_systems, + 'energy storage systems connected': _energy_storage_systems, + 'emission systems connected': _emission_systems } } return content diff --git a/hub/catalog_factories/data_models/energy_systems/generation_system.py b/hub/catalog_factories/data_models/energy_systems/generation_system.py index 3849a039..bb0ba255 100644 --- a/hub/catalog_factories/data_models/energy_systems/generation_system.py +++ b/hub/catalog_factories/data_models/energy_systems/generation_system.py @@ -9,6 +9,8 @@ Code contributors: Saeed Ranjbar saeed.ranjbar@concordia.ca from abc import ABC from typing import List, Union, TypeVar +from hub.catalog_factories.data_models.energy_systems.energy_storage_system import EnergyStorageSystem + DistributionSystem = TypeVar('DistributionSystem') @@ -17,12 +19,14 @@ class GenerationSystem(ABC): Heat Generation system class """ - def __init__(self, system_id, model_name=None, manufacturer=None, fuel_type=None, distribution_systems=None): + def __init__(self, system_id, model_name=None, manufacturer=None, fuel_type=None, + distribution_systems=None, energy_storage_systems=None): self._system_id = system_id self._model_name = model_name self._manufacturer = manufacturer self._fuel_type = fuel_type self._distribution_systems = distribution_systems + self._energy_storage_systems = energy_storage_systems @property def id(self): @@ -68,10 +72,18 @@ class GenerationSystem(ABC): def distribution_systems(self) -> Union[None, List[DistributionSystem]]: """ Get distributions systems connected to this generation system - :return: [DistributionSystems] + :return: [DistributionSystem] """ return self._distribution_systems + @property + def energy_storage_systems(self) -> Union[None, List[EnergyStorageSystem]]: + """ + Get energy storage systems connected to this generation system + :return: [EnergyStorageSystem] + """ + return self._energy_storage_systems + def to_dictionary(self): """Class content to dictionary""" raise NotImplementedError diff --git a/hub/catalog_factories/data_models/energy_systems/non_pv_generation_system.py b/hub/catalog_factories/data_models/energy_systems/non_pv_generation_system.py index b9780df5..87e688d3 100644 --- a/hub/catalog_factories/data_models/energy_systems/non_pv_generation_system.py +++ b/hub/catalog_factories/data_models/energy_systems/non_pv_generation_system.py @@ -24,8 +24,10 @@ class NonPvGenerationSystem(GenerationSystem): maximum_heat_supply_temperature=None, minimum_heat_supply_temperature=None, maximum_cooling_supply_temperature=None, minimum_cooling_supply_temperature=None, heat_output_curve=None, heat_fuel_consumption_curve=None, heat_efficiency_curve=None, cooling_output_curve=None, - cooling_fuel_consumption_curve=None, cooling_efficiency_curve=None): - super().__init__(system_id=system_id, model_name=model_name, manufacturer=manufacturer, fuel_type=fuel_type) + cooling_fuel_consumption_curve=None, cooling_efficiency_curve=None, + distribution_systems=None, energy_storage_systems=None): + super().__init__(system_id=system_id, model_name=model_name, manufacturer=manufacturer, fuel_type=fuel_type, + distribution_systems=distribution_systems, energy_storage_systems=energy_storage_systems) self._system_type = system_type self._nominal_thermal_output = nominal_thermal_output self._maximum_heat_output = maximum_heat_output @@ -256,6 +258,9 @@ class NonPvGenerationSystem(GenerationSystem): """Class content to dictionary""" _distribution_systems = [_distribution_system.to_dictionary() for _distribution_system in self.distribution_systems] if self.distribution_systems is not None else None + _energy_storage_systems = [_energy_storage_system.to_dictionary() for _energy_storage_system in + self.energy_storage_systems] if self.energy_storage_systems is not None else None + content = { 'Energy Generation component': { @@ -288,7 +293,8 @@ class NonPvGenerationSystem(GenerationSystem): 'cooling output curve': self.cooling_output_curve, 'cooling fuel consumption curve': self.cooling_fuel_consumption_curve, 'cooling efficiency curve': self.cooling_efficiency_curve, - 'distribution systems connected': _distribution_systems + 'distribution systems connected': _distribution_systems, + 'storage systems connected': _energy_storage_systems } } return content diff --git a/hub/catalog_factories/data_models/energy_systems/pv_generation_system.py b/hub/catalog_factories/data_models/energy_systems/pv_generation_system.py index ce037239..15965912 100644 --- a/hub/catalog_factories/data_models/energy_systems/pv_generation_system.py +++ b/hub/catalog_factories/data_models/energy_systems/pv_generation_system.py @@ -17,9 +17,11 @@ class PvGenerationSystem(GenerationSystem): def __init__(self, system_id, model_name=None, manufacturer=None, electricity_efficiency=None, nominal_electricity_output=None, nominal_ambient_temperature=None, nominal_cell_temperature=None, nominal_radiation=None, standard_test_condition_cell_temperature=None, - standard_test_condition_maximum_power=None, cell_temperature_coefficient=None, width=None, height=None): + standard_test_condition_maximum_power=None, cell_temperature_coefficient=None, width=None, height=None, + distribution_systems=None, energy_storage_systems=None): super().__init__(system_id=system_id, model_name=model_name, - manufacturer=manufacturer, fuel_type='renewable') + manufacturer=manufacturer, fuel_type='renewable', distribution_systems=distribution_systems, + energy_storage_systems=energy_storage_systems) self._system_type = 'PV' self._electricity_efficiency = electricity_efficiency self._nominal_electricity_output = nominal_electricity_output @@ -124,6 +126,8 @@ class PvGenerationSystem(GenerationSystem): """Class content to dictionary""" _distribution_systems = [_distribution_system.to_dictionary() for _distribution_system in self.distribution_systems] if self.distribution_systems is not None else None + _energy_storage_systems = [_energy_storage_system.to_dictionary() for _energy_storage_system in + self.energy_storage_systems] if self.energy_storage_systems is not None else None content = { 'Energy Generation component': { @@ -142,7 +146,8 @@ class PvGenerationSystem(GenerationSystem): 'cell temperature coefficient': self.cell_temperature_coefficient, 'width': self.width, 'height': self.height, - 'distribution systems connected': _distribution_systems + 'distribution systems connected': _distribution_systems, + 'storage systems connected': _energy_storage_systems } } return content diff --git a/hub/catalog_factories/data_models/energy_systems/system.py b/hub/catalog_factories/data_models/energy_systems/system.py index 3479e0dc..962c03dd 100644 --- a/hub/catalog_factories/data_models/energy_systems/system.py +++ b/hub/catalog_factories/data_models/energy_systems/system.py @@ -24,16 +24,12 @@ class System: name=None, generation_systems=None, distribution_systems=None, - emission_systems=None, - energy_storage_systems=None, configuration_schema=None): self._system_id = system_id self._name = name self._demand_types = demand_types self._distribution_systems = distribution_systems - self._emission_systems = emission_systems self._generation_systems = generation_systems - self._energy_storage_systems = energy_storage_systems self._configuration_schema = configuration_schema @property @@ -96,7 +92,8 @@ class System: 'name': self.name, 'demand types': self.demand_types, 'generation system(s)': _generation_systems, - 'distribution system(s)': _distribution_systems + 'distribution system(s)': _distribution_systems, + 'configuration schema path': self.configuration_schema } } return content diff --git a/hub/catalog_factories/energy_systems/montreal_custom_catalog.py b/hub/catalog_factories/energy_systems/montreal_custom_catalog.py index c8ba7011..3b31cd81 100644 --- a/hub/catalog_factories/energy_systems/montreal_custom_catalog.py +++ b/hub/catalog_factories/energy_systems/montreal_custom_catalog.py @@ -30,7 +30,7 @@ class MontrealCustomCatalog(Catalog): self._archetypes = xmltodict.parse(xml.read(), force_list=('system', 'system_cluster', 'equipment', 'demand', 'system_id')) - self._catalog_generation_equipments, self._catalog_storage_equipments = self._load_generation_and_storage_equipments() + self._catalog_generation_equipments = self._load_generation_equipments() self._catalog_distribution_equipments = self._load_distribution_equipments() self._catalog_emission_equipments = self._load_emission_equipments() self._catalog_systems = self._load_systems() @@ -41,7 +41,7 @@ class MontrealCustomCatalog(Catalog): self._catalog_generation_equipments, self._catalog_distribution_equipments) - def _load_generation_and_storage_equipments(self): + def _load_generation_equipments(self): _equipments = [] _storages = [] equipments = self._archetypes['catalog']['generation_equipments']['equipment'] @@ -73,16 +73,16 @@ class MontrealCustomCatalog(Catalog): cooling_efficiency=cooling_efficiency, electricity_efficiency=electricity_efficiency, ) - _equipments.append(generation_system) storage = literal_eval(equipment['storage'].capitalize()) if storage: if equipment_type == 'electricity generator': storage_system = ElectricalStorageSystem(equipment_id) else: storage_system = ThermalStorageSystem(equipment_id) - _storages.append(storage_system) + generation_system.energy_storage_systems = [storage_system] + _equipments.append(generation_system) - return _equipments, _storages + return _equipments def _load_distribution_equipments(self): _equipments = [] @@ -143,10 +143,6 @@ class MontrealCustomCatalog(Catalog): for equipment_archetype in self._catalog_generation_equipments: if int(equipment_archetype.id) == int(generation_equipment): _generation_equipments = [equipment_archetype] - _storage_equipments = None - for equipment_archetype in self._catalog_storage_equipments: - if int(equipment_archetype.id) == int(generation_equipment): - _storage_equipments = [equipment_archetype] distribution_equipment = system['equipments']['distribution_id'] _distribution_equipments = None for equipment_archetype in self._catalog_distribution_equipments: @@ -158,13 +154,18 @@ class MontrealCustomCatalog(Catalog): if int(equipment_archetype.id) == int(emission_equipment): _emission_equipments = [equipment_archetype] + + + + + + + _catalog_systems.append(System(system_id, demands, name=name, generation_systems=_generation_equipments, - distribution_systems=_distribution_equipments, - emission_systems=_emission_equipments, - energy_storage_systems=_storage_equipments)) + distribution_systems=_distribution_equipments)) return _catalog_systems def _load_archetypes(self): diff --git a/tests/test_systems_catalog.py b/tests/test_systems_catalog.py index 4d37d965..563e1b7d 100644 --- a/tests/test_systems_catalog.py +++ b/tests/test_systems_catalog.py @@ -31,8 +31,6 @@ class TestSystemsCatalog(TestCase): for value in catalog_categories[category]: catalog.get_entry(value) - print(catalog.entries()) - with self.assertRaises(IndexError): catalog.get_entry('unknown')