diff --git a/hub/catalog_factories/data_models/energy_systems/thermal_storage_system.py b/hub/catalog_factories/data_models/energy_systems/thermal_storage_system.py index db10840b..9c54b4c1 100644 --- a/hub/catalog_factories/data_models/energy_systems/thermal_storage_system.py +++ b/hub/catalog_factories/data_models/energy_systems/thermal_storage_system.py @@ -8,7 +8,7 @@ Code contributors: Saeed Ranjbar saeed.ranjbar@concordia.ca from hub.catalog_factories.data_models.energy_systems.energy_storage_system import EnergyStorageSystem from hub.catalog_factories.data_models.construction.layer import Layer - +from hub.catalog_factories.data_models.construction.material import Material class ThermalStorageSystem(EnergyStorageSystem): """" @@ -17,7 +17,7 @@ class ThermalStorageSystem(EnergyStorageSystem): def __init__(self, storage_id, model_name=None, manufacturer=None, storage_type=None, nominal_capacity=None, losses_ratio=None, volume=None, height=None, layers=None, - maximum_operating_temperature=None): + maximum_operating_temperature=None, storage_medium=None): super().__init__(storage_id, model_name, manufacturer, nominal_capacity, losses_ratio) self._type_energy_stored = 'thermal' @@ -26,6 +26,7 @@ class ThermalStorageSystem(EnergyStorageSystem): self._height = height self._layers = layers self._maximum_operating_temperature = maximum_operating_temperature + self._storage_medium = storage_medium @property def type_energy_stored(self): @@ -75,13 +76,28 @@ class ThermalStorageSystem(EnergyStorageSystem): """ return self._maximum_operating_temperature + @property + def storage_medium(self) -> Material: + """ + Get thermodynamic characteristics of the storage medium + :return: [material + """ + return self._storage_medium + def to_dictionary(self): """Class content to dictionary""" _layers = None + # _medias = None if self.layers is not None: _layers = [] for _layer in self.layers: _layers.append(_layer.to_dictionary()) + + # if self.storage_medium is not None: + # _medias = [] + # for _media in self.storage_medium: + # _medias.append(_media.to_dictionary()) + content = { 'Storage component': { @@ -95,7 +111,8 @@ class ThermalStorageSystem(EnergyStorageSystem): 'volume [m3]': self.volume, 'height [m]': self.height, 'layers': _layers, - 'maximum operating temperature [Celsius]': self.maximum_operating_temperature + 'maximum operating temperature [Celsius]': self.maximum_operating_temperature, + 'storage_medium': self.storage_medium.to_dictionary() } } return content diff --git a/hub/catalog_factories/energy_systems/north_america_energy_system_catalog.py b/hub/catalog_factories/energy_systems/north_america_energy_system_catalog.py index 3e6c649a..41573149 100644 --- a/hub/catalog_factories/energy_systems/north_america_energy_system_catalog.py +++ b/hub/catalog_factories/energy_systems/north_america_energy_system_catalog.py @@ -28,7 +28,8 @@ class NorthAmericaEnergySystemCatalog(Catalog): def __init__(self, path): path = str(path / 'north_america_systems.xml') with open(path, 'r', encoding='utf-8') as xml: - self._archetypes = xmltodict.parse(xml.read(), force_list=['photovoltaicModules', 'templateStorages', 'demand']) + self._archetypes = xmltodict.parse(xml.read(), + force_list=['photovoltaicModules', 'templateStorages', 'demand', 'medias']) self._storage_components = self._load_storage_components() self._generation_components = self._load_generation_components() @@ -208,6 +209,9 @@ class NorthAmericaEnergySystemCatalog(Catalog): insulation_layer = Layer(None, 'insulation', insulation_material, thickness) thickness = float(tes['physical_characteristics']['@tankThickness']) / 100 # from cm to m tank_layer = Layer(None, 'tank', tank_material, thickness) + medias = self._load_medias() + media_id = tes['medium']['@media_id'] + medium = self._search_medias(medias, media_id) # the convention is from outside to inside layers = [insulation_layer, tank_layer] storage_component = ThermalStorageSystem(storage_id, @@ -219,7 +223,8 @@ class NorthAmericaEnergySystemCatalog(Catalog): volume, height, layers, - maximum_operating_temperature) + maximum_operating_temperature, + medium) storage_components.append(storage_component) for template in template_storages: @@ -238,6 +243,9 @@ class NorthAmericaEnergySystemCatalog(Catalog): tank_layer = Layer(None, 'tank', tank_material, thickness) # the convention is from outside to inside layers = [insulation_layer, tank_layer] + medias = self._load_medias() + media_id = template['medium']['@media_id'] + medium = self._search_medias(medias, media_id) storage_component = ThermalStorageSystem(storage_id, None, None, @@ -247,7 +255,8 @@ class NorthAmericaEnergySystemCatalog(Catalog): None, height, layers, - maximum_temperature) + maximum_temperature, + medium) storage_components.append(storage_component) return storage_components @@ -316,6 +325,39 @@ class NorthAmericaEnergySystemCatalog(Catalog): raise ValueError(f'Material with the id = [{material_id}] not found in catalog ') return _material + def _load_medias(self): + medias = [] + _medias = self._archetypes['EnergySystemCatalog']['medias'] + for _media in _medias: + media_id = _media['media']['@media_id'] + name = _media['media']['@media_name'] + density = _media['media']['@density'] + thermal_conductivity = _media['media']['@thermalConductivity'] + specific_heat = _media['media']['@heatCapacity'] + media = Material(media_id, + name, + None, + None, + None, + False, + None, + thermal_conductivity, + density, + specific_heat) + medias.append(media) + return medias + + @staticmethod + def _search_medias(medias, media_id): + _media = None + for media in medias: + if int(media.id) == int(media_id): + _media = media + break + if _media is None: + raise ValueError(f'media with the id = [{media_id}] not found in catalog ') + return _media + @staticmethod def _search_generation_equipment(generation_systems, generation_id): _generation_systems = [] diff --git a/hub/data/energy_systems/north_america_systems.xml b/hub/data/energy_systems/north_america_systems.xml index ce575841..eaa4c29a 100644 --- a/hub/data/energy_systems/north_america_systems.xml +++ b/hub/data/energy_systems/north_america_systems.xml @@ -2,7 +2,7 @@ ./schemas/ - +