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 9c54b4c1..6c5382d7 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 @@ -87,16 +87,14 @@ class ThermalStorageSystem(EnergyStorageSystem): def to_dictionary(self): """Class content to dictionary""" _layers = None - # _medias = 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()) + if self.storage_medium is not None: + _medias = self.storage_medium.to_dictionary() content = { 'Storage component': 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 41573149..6ba78dfb 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 @@ -29,7 +29,7 @@ class NorthAmericaEnergySystemCatalog(Catalog): 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', 'medias']) + force_list=['photovoltaicModules', 'templateStorages', 'demand']) self._storage_components = self._load_storage_components() self._generation_components = self._load_generation_components() @@ -209,9 +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) + media = self._load_media() + media_id = tes['medium']['@medium_id'] + medium = self._search_media(media, media_id) # the convention is from outside to inside layers = [insulation_layer, tank_layer] storage_component = ThermalStorageSystem(storage_id, @@ -243,9 +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) + media = self._load_media() + media_id = template['medium']['@medium_id'] + medium = self._search_media(media, media_id) storage_component = ThermalStorageSystem(storage_id, None, None, @@ -325,38 +325,38 @@ 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 + def _load_media(self): + media = [] + _media = [self._archetypes['EnergySystemCatalog']['media']['medium']] + for _medium in _media: + medium_id = _medium['@medium_id'] + name = _medium['@medium_name'] + density = _medium['@density'] + thermal_conductivity = _medium['@thermalConductivity'] + specific_heat = _medium['@heatCapacity'] + medium = Material(medium_id, + name, + None, + None, + None, + False, + None, + thermal_conductivity, + density, + specific_heat) + media.append(medium) + return media @staticmethod - def _search_medias(medias, media_id): - _media = None - for media in medias: - if int(media.id) == int(media_id): - _media = media + def _search_media(media, medium_id): + _medium = None + for medium in media: + if int(medium.id) == int(medium_id): + _medium = medium break - if _media is None: - raise ValueError(f'media with the id = [{media_id}] not found in catalog ') - return _media + if _medium is None: + raise ValueError(f'media with the id = [{medium_id}] not found in catalog ') + return _medium @staticmethod def _search_generation_equipment(generation_systems, generation_id): diff --git a/hub/data/energy_systems/north_america_systems.xml b/hub/data/energy_systems/north_america_systems.xml index eaa4c29a..f7c9eb3a 100644 --- a/hub/data/energy_systems/north_america_systems.xml +++ b/hub/data/energy_systems/north_america_systems.xml @@ -1,9 +1,9 @@ ./schemas/ - - - + + + @@ -73,32 +73,32 @@ - + - + - + - + - + - +