added storage_medium attribute to thermal_storage_system.py to enable us use water thermodynamic characteristics in the modelling

This commit is contained in:
Saeed Ranjbar 2024-01-17 13:05:10 -05:00
parent 11f78ccb89
commit 673cbac77a
3 changed files with 48 additions and 50 deletions

View File

@ -87,16 +87,14 @@ class ThermalStorageSystem(EnergyStorageSystem):
def to_dictionary(self): def to_dictionary(self):
"""Class content to dictionary""" """Class content to dictionary"""
_layers = None _layers = None
# _medias = None _medias = None
if self.layers is not None: if self.layers is not None:
_layers = [] _layers = []
for _layer in self.layers: for _layer in self.layers:
_layers.append(_layer.to_dictionary()) _layers.append(_layer.to_dictionary())
# if self.storage_medium is not None: if self.storage_medium is not None:
# _medias = [] _medias = self.storage_medium.to_dictionary()
# for _media in self.storage_medium:
# _medias.append(_media.to_dictionary())
content = { content = {
'Storage component': 'Storage component':

View File

@ -29,7 +29,7 @@ class NorthAmericaEnergySystemCatalog(Catalog):
path = str(path / 'north_america_systems.xml') path = str(path / 'north_america_systems.xml')
with open(path, 'r', encoding='utf-8') as xml: with open(path, 'r', encoding='utf-8') as xml:
self._archetypes = xmltodict.parse(xml.read(), 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._storage_components = self._load_storage_components()
self._generation_components = self._load_generation_components() self._generation_components = self._load_generation_components()
@ -209,9 +209,9 @@ class NorthAmericaEnergySystemCatalog(Catalog):
insulation_layer = Layer(None, 'insulation', insulation_material, thickness) insulation_layer = Layer(None, 'insulation', insulation_material, thickness)
thickness = float(tes['physical_characteristics']['@tankThickness']) / 100 # from cm to m thickness = float(tes['physical_characteristics']['@tankThickness']) / 100 # from cm to m
tank_layer = Layer(None, 'tank', tank_material, thickness) tank_layer = Layer(None, 'tank', tank_material, thickness)
medias = self._load_medias() media = self._load_media()
media_id = tes['medium']['@media_id'] media_id = tes['medium']['@medium_id']
medium = self._search_medias(medias, media_id) medium = self._search_media(media, media_id)
# the convention is from outside to inside # the convention is from outside to inside
layers = [insulation_layer, tank_layer] layers = [insulation_layer, tank_layer]
storage_component = ThermalStorageSystem(storage_id, storage_component = ThermalStorageSystem(storage_id,
@ -243,9 +243,9 @@ class NorthAmericaEnergySystemCatalog(Catalog):
tank_layer = Layer(None, 'tank', tank_material, thickness) tank_layer = Layer(None, 'tank', tank_material, thickness)
# the convention is from outside to inside # the convention is from outside to inside
layers = [insulation_layer, tank_layer] layers = [insulation_layer, tank_layer]
medias = self._load_medias() media = self._load_media()
media_id = template['medium']['@media_id'] media_id = template['medium']['@medium_id']
medium = self._search_medias(medias, media_id) medium = self._search_media(media, media_id)
storage_component = ThermalStorageSystem(storage_id, storage_component = ThermalStorageSystem(storage_id,
None, None,
None, None,
@ -325,38 +325,38 @@ class NorthAmericaEnergySystemCatalog(Catalog):
raise ValueError(f'Material with the id = [{material_id}] not found in catalog ') raise ValueError(f'Material with the id = [{material_id}] not found in catalog ')
return _material return _material
def _load_medias(self): def _load_media(self):
medias = [] media = []
_medias = self._archetypes['EnergySystemCatalog']['medias'] _media = [self._archetypes['EnergySystemCatalog']['media']['medium']]
for _media in _medias: for _medium in _media:
media_id = _media['media']['@media_id'] medium_id = _medium['@medium_id']
name = _media['media']['@media_name'] name = _medium['@medium_name']
density = _media['media']['@density'] density = _medium['@density']
thermal_conductivity = _media['media']['@thermalConductivity'] thermal_conductivity = _medium['@thermalConductivity']
specific_heat = _media['media']['@heatCapacity'] specific_heat = _medium['@heatCapacity']
media = Material(media_id, medium = Material(medium_id,
name, name,
None, None,
None, None,
None, None,
False, False,
None, None,
thermal_conductivity, thermal_conductivity,
density, density,
specific_heat) specific_heat)
medias.append(media) media.append(medium)
return medias return media
@staticmethod @staticmethod
def _search_medias(medias, media_id): def _search_media(media, medium_id):
_media = None _medium = None
for media in medias: for medium in media:
if int(media.id) == int(media_id): if int(medium.id) == int(medium_id):
_media = media _medium = medium
break break
if _media is None: if _medium is None:
raise ValueError(f'media with the id = [{media_id}] not found in catalog ') raise ValueError(f'media with the id = [{medium_id}] not found in catalog ')
return _media return _medium
@staticmethod @staticmethod
def _search_generation_equipment(generation_systems, generation_id): def _search_generation_equipment(generation_systems, generation_id):

View File

@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<EnergySystemCatalog> <EnergySystemCatalog>
<schemas_path>./schemas/</schemas_path> <schemas_path>./schemas/</schemas_path>
<medias> <media>
<media media_id="1" media_name="Water" density="981.0" heatCapacity="4180.0" thermalConductivity="0.6" evaporationTemperature="100.0"/> <medium medium_id="1" medium_name="Water" density="981.0" heatCapacity="4180.0" thermalConductivity="0.6" evaporationTemperature="100.0"/>
</medias> </media>
<energy_generation_components> <energy_generation_components>
<boilers generation_id="1" name="Natural-Gas Boiler" modelName="ALP080B" manufacturer="Alpine" installedThermalPower="21.0" minimumHeatOutput="4.7" maximumHeatOutput="23.5" modulationRange="0.88" nominalEfficiency="0.95" combi="true" fuel="natural gas"/> <boilers generation_id="1" name="Natural-Gas Boiler" modelName="ALP080B" manufacturer="Alpine" installedThermalPower="21.0" minimumHeatOutput="4.7" maximumHeatOutput="23.5" modulationRange="0.88" nominalEfficiency="0.95" combi="true" fuel="natural gas"/>
<boilers generation_id="2" name="Natural-Gas Boiler" modelName="ALP105B" manufacturer="Alpine" installedThermalPower="28.0" minimumHeatOutput="6.15" maximumHeatOutput="30.8" modulationRange="0.88" nominalEfficiency="0.95" combi="true" fuel="natural gas"/> <boilers generation_id="2" name="Natural-Gas Boiler" modelName="ALP105B" manufacturer="Alpine" installedThermalPower="28.0" minimumHeatOutput="6.15" maximumHeatOutput="30.8" modulationRange="0.88" nominalEfficiency="0.95" combi="true" fuel="natural gas"/>
@ -73,32 +73,32 @@
<thermalStorages storage_id="1" name="Hot Water Storage Tank" modelName="HF 200" manufacturer="reflex" maxTemp="95.0"> <thermalStorages storage_id="1" name="Hot Water Storage Tank" modelName="HF 200" manufacturer="reflex" maxTemp="95.0">
<insulation material_id="1" insulationMaterial="Polyurethane" insulationThickness="90.0"/> <insulation material_id="1" insulationMaterial="Polyurethane" insulationThickness="90.0"/>
<physical_characteristics material_id="2" tankThickness="0" height="1.5" tankMaterial="Steel" volume="0.5"/> <physical_characteristics material_id="2" tankThickness="0" height="1.5" tankMaterial="Steel" volume="0.5"/>
<medium media_id="1" usesMedium="Water"/> <medium medium_id="1" usesMedium="Water"/>
</thermalStorages> </thermalStorages>
<thermalStorages storage_id="2" name="Hot Water Storage Tank" modelName="HF 300" manufacturer="reflex" maxTemp="95.0"> <thermalStorages storage_id="2" name="Hot Water Storage Tank" modelName="HF 300" manufacturer="reflex" maxTemp="95.0">
<insulation material_id="1" insulationMaterial="Polyurethane" insulationThickness="90.0"/> <insulation material_id="1" insulationMaterial="Polyurethane" insulationThickness="90.0"/>
<physical_characteristics material_id="2" tankThickness="0" height="1.5" tankMaterial="Steel" volume="0.6"/> <physical_characteristics material_id="2" tankThickness="0" height="1.5" tankMaterial="Steel" volume="0.6"/>
<medium media_id="1" usesMedium="Water"/> <medium medium_id="1" usesMedium="Water"/>
</thermalStorages> </thermalStorages>
<thermalStorages storage_id="3" name="Hot Water Storage Tank" modelName="HF 500" manufacturer="reflex" maxTemp="95.0"> <thermalStorages storage_id="3" name="Hot Water Storage Tank" modelName="HF 500" manufacturer="reflex" maxTemp="95.0">
<insulation material_id="1" insulationMaterial="Polyurethane" insulationThickness="90.0"/> <insulation material_id="1" insulationMaterial="Polyurethane" insulationThickness="90.0"/>
<physical_characteristics material_id="2" tankThickness="0" height="1.5" tankMaterial="Steel" volume="0.5"/> <physical_characteristics material_id="2" tankThickness="0" height="1.5" tankMaterial="Steel" volume="0.5"/>
<medium media_id="1" usesMedium="Water"/> <medium medium_id="1" usesMedium="Water"/>
</thermalStorages> </thermalStorages>
<thermalStorages storage_id="4" name="Hot Water Storage Tank" modelName="HF 200" manufacturer="reflex" maxTemp="95.0"> <thermalStorages storage_id="4" name="Hot Water Storage Tank" modelName="HF 200" manufacturer="reflex" maxTemp="95.0">
<insulation material_id="1" insulationMaterial="Polyurethane" insulationThickness="90.0"/> <insulation material_id="1" insulationMaterial="Polyurethane" insulationThickness="90.0"/>
<physical_characteristics material_id="2" tankThickness="0" height="1.5" tankMaterial="Steel" volume="0.5"/> <physical_characteristics material_id="2" tankThickness="0" height="1.5" tankMaterial="Steel" volume="0.5"/>
<medium media_id="1" usesMedium="Water"/> <medium medium_id="1" usesMedium="Water"/>
</thermalStorages> </thermalStorages>
<thermalStorages storage_id="5" name="Hot Water Storage Tank" modelName="HF 200" manufacturer="reflex" maxTemp="95.0"> <thermalStorages storage_id="5" name="Hot Water Storage Tank" modelName="HF 200" manufacturer="reflex" maxTemp="95.0">
<insulation material_id="1" insulationMaterial="Polyurethane" insulationThickness="90.0"/> <insulation material_id="1" insulationMaterial="Polyurethane" insulationThickness="90.0"/>
<physical_characteristics material_id="2" tankThickness="0" height="1.5" tankMaterial="Steel" volume="0.5"/> <physical_characteristics material_id="2" tankThickness="0" height="1.5" tankMaterial="Steel" volume="0.5"/>
<medium media_id="1" usesMedium="Water"/> <medium medium_id="1" usesMedium="Water"/>
</thermalStorages> </thermalStorages>
<templateStorages storage_id="6" name="template Hot Water Storage Tank" maxTemp="95.0"> <templateStorages storage_id="6" name="template Hot Water Storage Tank" maxTemp="95.0">
<insulation material_id="1" insulationMaterial="Polyurethane" insulationThickness="90.0"/> <insulation material_id="1" insulationMaterial="Polyurethane" insulationThickness="90.0"/>
<physical_characteristics material_id="2" tankThickness="0" height="1.5" tankMaterial="Steel"/> <physical_characteristics material_id="2" tankThickness="0" height="1.5" tankMaterial="Steel"/>
<medium media_id="1" usesMedium="Water"/> <medium medium_id="1" usesMedium="Water"/>
</templateStorages> </templateStorages>
<manufacturers manufacturer_id="1" name="reflex" product="Storage Tank"/> <manufacturers manufacturer_id="1" name="reflex" product="Storage Tank"/>
</energy_storage_components> </energy_storage_components>