final_energy_system_model #60
|
@ -34,7 +34,7 @@ class EnergyStorageSystem:
|
||||||
self._maximum_operating_temperature = maximum_operating_temperature
|
self._maximum_operating_temperature = maximum_operating_temperature
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def stroage_id(self):
|
def id(self):
|
||||||
"""
|
"""
|
||||||
Get storage id
|
Get storage id
|
||||||
:return: string
|
:return: string
|
||||||
|
@ -151,7 +151,7 @@ class EnergyStorageSystem:
|
||||||
for _layer in self.layers:
|
for _layer in self.layers:
|
||||||
_layers.append(_layer.to_dictionary())
|
_layers.append(_layer.to_dictionary())
|
||||||
content = {'Storage component': {
|
content = {'Storage component': {
|
||||||
'storage id': self.stroage_id,
|
'storage id': self.id,
|
||||||
'name': self.name,
|
'name': self.name,
|
||||||
'model name': self.model_name,
|
'model name': self.model_name,
|
||||||
'manufacturer': self.manufacturer,
|
'manufacturer': self.manufacturer,
|
||||||
|
|
|
@ -115,7 +115,7 @@ class System:
|
||||||
_storage_system = [_storage.to_dictionary() for _storage in
|
_storage_system = [_storage.to_dictionary() for _storage in
|
||||||
self.energy_storage_system] if self.energy_storage_system is not None else None
|
self.energy_storage_system] if self.energy_storage_system is not None else None
|
||||||
|
|
||||||
content = {'Layer': {'id': self.id,
|
content = {'system': {'id': self.id,
|
||||||
'name': self.name,
|
'name': self.name,
|
||||||
'level of detail': self.lod,
|
'level of detail': self.lod,
|
||||||
'demand types': self.demand_types,
|
'demand types': self.demand_types,
|
||||||
|
|
|
@ -40,7 +40,8 @@ class MontrealCustomCatalog(Catalog):
|
||||||
self._catalog_systems,
|
self._catalog_systems,
|
||||||
self._catalog_generation_equipments,
|
self._catalog_generation_equipments,
|
||||||
self._catalog_distribution_equipments,
|
self._catalog_distribution_equipments,
|
||||||
self._catalog_emission_equipments)
|
self._catalog_emission_equipments,
|
||||||
|
storages=None)
|
||||||
|
|
||||||
def _load_generation_equipments(self):
|
def _load_generation_equipments(self):
|
||||||
_equipments = []
|
_equipments = []
|
||||||
|
@ -62,14 +63,34 @@ class MontrealCustomCatalog(Catalog):
|
||||||
storage = literal_eval(equipment['storage'].capitalize())
|
storage = literal_eval(equipment['storage'].capitalize())
|
||||||
generation_system = GenerationSystem(equipment_id,
|
generation_system = GenerationSystem(equipment_id,
|
||||||
name,
|
name,
|
||||||
|
None,
|
||||||
|
None,
|
||||||
equipment_type,
|
equipment_type,
|
||||||
fuel_type,
|
fuel_type,
|
||||||
None,
|
None,
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
None,
|
||||||
heating_efficiency,
|
heating_efficiency,
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
None,
|
||||||
cooling_efficiency,
|
cooling_efficiency,
|
||||||
electricity_efficiency,
|
electricity_efficiency,
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
None,
|
||||||
storage,
|
storage,
|
||||||
None)
|
None)
|
||||||
|
|
||||||
|
@ -153,7 +174,8 @@ class MontrealCustomCatalog(Catalog):
|
||||||
demands,
|
demands,
|
||||||
_generation_equipment,
|
_generation_equipment,
|
||||||
_distribution_equipment,
|
_distribution_equipment,
|
||||||
_emission_equipment))
|
_emission_equipment,
|
||||||
|
energy_storage_systems=None))
|
||||||
return _catalog_systems
|
return _catalog_systems
|
||||||
|
|
||||||
def _load_archetypes(self):
|
def _load_archetypes(self):
|
||||||
|
|
|
@ -6,21 +6,18 @@ Project Coder Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
|
||||||
Code contributors: Saeed Ranjbar saeed.ranjbar@concordia.ca
|
Code contributors: Saeed Ranjbar saeed.ranjbar@concordia.ca
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from ast import literal_eval
|
|
||||||
import xmltodict
|
import xmltodict
|
||||||
from hub.catalog_factories.catalog import Catalog
|
from hub.catalog_factories.catalog import Catalog
|
||||||
from hub.catalog_factories.data_models.energy_systems.system import System
|
from hub.catalog_factories.data_models.energy_systems.system import System
|
||||||
from hub.catalog_factories.data_models.energy_systems.content import Content
|
from hub.catalog_factories.data_models.energy_systems.content import Content
|
||||||
from hub.catalog_factories.data_models.energy_systems.generation_system import GenerationSystem
|
from hub.catalog_factories.data_models.energy_systems.generation_system import GenerationSystem
|
||||||
from hub.catalog_factories.data_models.energy_systems.pv_generation_system import PvGenerationSystem
|
from hub.catalog_factories.data_models.energy_systems.pv_generation_system import PvGenerationSystem
|
||||||
from hub.catalog_factories.data_models.energy_systems.distribution_system import DistributionSystem
|
|
||||||
from hub.catalog_factories.data_models.energy_systems.emission_system import EmissionSystem
|
|
||||||
from hub.catalog_factories.data_models.energy_systems.energy_storage_system import EnergyStorageSystem
|
from hub.catalog_factories.data_models.energy_systems.energy_storage_system import EnergyStorageSystem
|
||||||
from hub.catalog_factories.data_models.energy_systems.performance_curves import PerformanceCurves
|
from hub.catalog_factories.data_models.energy_systems.performance_curves import PerformanceCurves
|
||||||
from hub.catalog_factories.data_models.energy_systems.archetype import Archetype
|
from hub.catalog_factories.data_models.energy_systems.archetype import Archetype
|
||||||
from hub.catalog_factories.data_models.construction.material import Material
|
from hub.catalog_factories.data_models.construction.material import Material
|
||||||
from hub.catalog_factories.data_models.construction.layer import Layer
|
from hub.catalog_factories.data_models.construction.layer import Layer
|
||||||
import hub.helpers.constants as cte
|
|
||||||
|
|
||||||
|
|
||||||
class NorthAmericaEnergySystemCatalog(Catalog):
|
class NorthAmericaEnergySystemCatalog(Catalog):
|
||||||
|
@ -33,12 +30,16 @@ class NorthAmericaEnergySystemCatalog(Catalog):
|
||||||
with open(path, 'r', encoding='utf-8') as xml:
|
with open(path, 'r', encoding='utf-8') as xml:
|
||||||
self._archetypes = xmltodict.parse(xml.read(), force_list=['photovoltaicModules', 'templateStorages'])
|
self._archetypes = xmltodict.parse(xml.read(), force_list=['photovoltaicModules', 'templateStorages'])
|
||||||
self._generation_components = self._load_generation_components()
|
self._generation_components = self._load_generation_components()
|
||||||
print(self._generation_components)
|
|
||||||
print(len(self._generation_components))
|
|
||||||
self._storage_components = self._load_storage_components()
|
self._storage_components = self._load_storage_components()
|
||||||
print(self._storage_components)
|
self._systems = self._load_systems()
|
||||||
# self._systems = self._load_systems()
|
self._system_archetypes = self._load_archetypes()
|
||||||
# print(self._load_systems())
|
print(self._system_archetypes)
|
||||||
|
self._content = Content(self._system_archetypes,
|
||||||
|
self._systems,
|
||||||
|
self._generation_components,
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
self._storage_components)
|
||||||
|
|
||||||
def _load_generation_components(self):
|
def _load_generation_components(self):
|
||||||
generation_components = []
|
generation_components = []
|
||||||
|
@ -349,24 +350,44 @@ class NorthAmericaEnergySystemCatalog(Catalog):
|
||||||
storage_components.append(storage_component)
|
storage_components.append(storage_component)
|
||||||
return storage_components
|
return storage_components
|
||||||
|
|
||||||
# def _load_systems(self):
|
def _load_systems(self):
|
||||||
# _catalog_systems = []
|
_catalog_systems = []
|
||||||
# systems = self._archetypes['EnergySystemCatalog']['systems']['system']
|
systems = self._archetypes['EnergySystemCatalog']['systems']['system']
|
||||||
# for system in systems:
|
for system in systems:
|
||||||
# system_id = system['@id']
|
system_id = system['@id']
|
||||||
# name = system['@name']
|
name = system['name']
|
||||||
# generation_components =
|
demands = system['demands']['demand']
|
||||||
#
|
generation_components = system['components']['generation_id']
|
||||||
# energy_system = System(None,
|
generation_systems = self._search_generation_equipment(self._load_generation_components(), generation_components)
|
||||||
# system_id,
|
if 'storage_id' in system['components'].keys():
|
||||||
# None,
|
storage_components = system['components']['storage_id']
|
||||||
# None,
|
storage_systems = self._search_storage_equipment(self._load_storage_components(), storage_components)
|
||||||
# None,
|
else:
|
||||||
# None,
|
storage_systems = None
|
||||||
# None,
|
energy_system = System(None,
|
||||||
# None)
|
system_id,
|
||||||
# _catalog_systems.append(energy_system)
|
name,
|
||||||
# return _catalog_systems
|
demands,
|
||||||
|
generation_systems,
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
storage_systems)
|
||||||
|
_catalog_systems.append(energy_system)
|
||||||
|
return _catalog_systems
|
||||||
|
|
||||||
|
def _load_archetypes(self):
|
||||||
|
_system_archetypes = []
|
||||||
|
system_clusters = self._archetypes['EnergySystemCatalog']['system_archetypes']['system_archetype']
|
||||||
|
for system_cluster in system_clusters:
|
||||||
|
name = system_cluster['name']
|
||||||
|
systems = system_cluster['systems']['system_id']
|
||||||
|
_systems = []
|
||||||
|
for system in systems:
|
||||||
|
for system_archetype in self._systems:
|
||||||
|
if int(system_archetype.id) == int(system):
|
||||||
|
_systems.append(system_archetype)
|
||||||
|
_system_archetypes.append(Archetype(None, name, _systems))
|
||||||
|
return _system_archetypes
|
||||||
|
|
||||||
def _load_materials(self):
|
def _load_materials(self):
|
||||||
materials = []
|
materials = []
|
||||||
|
@ -398,12 +419,93 @@ class NorthAmericaEnergySystemCatalog(Catalog):
|
||||||
if _material is None:
|
if _material is None:
|
||||||
raise ValueError(f'Material not found in catalog [{material_name}]')
|
raise ValueError(f'Material not found in catalog [{material_name}]')
|
||||||
|
|
||||||
def _load_demands(self):
|
@staticmethod
|
||||||
demands = []
|
def _search_generation_equipment(generation_systems, generation_id):
|
||||||
_demands = self._archetypes['encomp:EnergySystemCatalog']['energydemand']
|
_generation_systems = []
|
||||||
for _demand in _demands:
|
for generation in generation_systems:
|
||||||
demand_type = _demand['@name']
|
if generation.id in generation_id:
|
||||||
demands.append(demand_type)
|
_generation_systems.append(generation)
|
||||||
return demands
|
if len(_generation_systems) == 0:
|
||||||
|
_generation_systems = None
|
||||||
|
raise ValueError(f'The system with the following id is not found in catalog [{generation_id}]')
|
||||||
|
return _generation_systems
|
||||||
|
|
||||||
# def _search_demands(self, config_name):
|
@staticmethod
|
||||||
|
def _search_storage_equipment(storage_systems, storage_id):
|
||||||
|
_storage_systems = []
|
||||||
|
for storage in storage_systems:
|
||||||
|
if storage.id in storage_id:
|
||||||
|
_storage_systems.append(storage)
|
||||||
|
if len(_storage_systems) == 0:
|
||||||
|
_storage_systems_systems = None
|
||||||
|
raise ValueError(f'The system with the following id is not found in catalog [{storage_id}]')
|
||||||
|
return _storage_systems
|
||||||
|
|
||||||
|
def names(self, category=None):
|
||||||
|
"""
|
||||||
|
Get the catalog elements names
|
||||||
|
:parm: optional category filter
|
||||||
|
"""
|
||||||
|
if category is None:
|
||||||
|
_names = {'archetypes': [], 'systems': [], 'generation_equipments': [], 'storage_equipments': []}
|
||||||
|
for archetype in self._content.archetypes:
|
||||||
|
_names['archetypes'].append(archetype.name)
|
||||||
|
for system in self._content.systems:
|
||||||
|
_names['systems'].append(system.name)
|
||||||
|
for equipment in self._content.generation_equipments:
|
||||||
|
_names['generation_equipments'].append(equipment.name)
|
||||||
|
for equipment in self._content.storage_equipments:
|
||||||
|
_names['storage_equipments'].append(equipment.name)
|
||||||
|
else:
|
||||||
|
_names = {category: []}
|
||||||
|
if category.lower() == 'archetypes':
|
||||||
|
for archetype in self._content.archetypes:
|
||||||
|
_names[category].append(archetype.name)
|
||||||
|
elif category.lower() == 'systems':
|
||||||
|
for system in self._content.systems:
|
||||||
|
_names[category].append(system.name)
|
||||||
|
elif category.lower() == 'generation_equipments':
|
||||||
|
for system in self._content.generation_equipments:
|
||||||
|
_names[category].append(system.name)
|
||||||
|
elif category.lower() == 'storage_equipments':
|
||||||
|
for system in self._content.storage_equipments:
|
||||||
|
_names[category].append(system.name)
|
||||||
|
else:
|
||||||
|
raise ValueError(f'Unknown category [{category}]')
|
||||||
|
return _names
|
||||||
|
|
||||||
|
def entries(self, category=None):
|
||||||
|
"""
|
||||||
|
Get the catalog elements
|
||||||
|
:parm: optional category filter
|
||||||
|
"""
|
||||||
|
if category is None:
|
||||||
|
return self._content
|
||||||
|
if category.lower() == 'archetypes':
|
||||||
|
return self._content.archetypes
|
||||||
|
if category.lower() == 'systems':
|
||||||
|
return self._content.systems
|
||||||
|
if category.lower() == 'generation_equipments':
|
||||||
|
return self._content.generation_equipments
|
||||||
|
if category.lower() == 'storage_equipments':
|
||||||
|
return self._content.storage_equipments
|
||||||
|
raise ValueError(f'Unknown category [{category}]')
|
||||||
|
|
||||||
|
def get_entry(self, name):
|
||||||
|
"""
|
||||||
|
Get one catalog element by names
|
||||||
|
:parm: entry name
|
||||||
|
"""
|
||||||
|
for entry in self._content.archetypes:
|
||||||
|
if entry.name.lower() == name.lower():
|
||||||
|
return entry
|
||||||
|
for entry in self._content.systems:
|
||||||
|
if entry.name.lower() == name.lower():
|
||||||
|
return entry
|
||||||
|
for entry in self._content.generation_equipments:
|
||||||
|
if entry.name.lower() == name.lower():
|
||||||
|
return entry
|
||||||
|
for entry in self._content.storage_equipments:
|
||||||
|
if entry.name.lower() == name.lower():
|
||||||
|
return entry
|
||||||
|
raise IndexError(f"{name} doesn't exists in the catalog")
|
||||||
|
|
|
@ -71,8 +71,8 @@
|
||||||
<system id="1">
|
<system id="1">
|
||||||
<name>Air Source Heat Pump with Natural Gas Boiler and thermal storage</name>
|
<name>Air Source Heat Pump with Natural Gas Boiler and thermal storage</name>
|
||||||
<demands>
|
<demands>
|
||||||
<demand_id>1</demand_id>
|
<demand>heating</demand>
|
||||||
<demand_id>2</demand_id>
|
<demand>domestic_hot_water</demand>
|
||||||
</demands>
|
</demands>
|
||||||
<components>
|
<components>
|
||||||
<generation_id>16</generation_id>
|
<generation_id>16</generation_id>
|
||||||
|
@ -83,8 +83,8 @@
|
||||||
<system id="2">
|
<system id="2">
|
||||||
<name>Air Source Heat Pump with Electrical Boiler and thermal storage</name>
|
<name>Air Source Heat Pump with Electrical Boiler and thermal storage</name>
|
||||||
<demands>
|
<demands>
|
||||||
<demand_id>1</demand_id>
|
<demand>heating</demand>
|
||||||
<demand_id>2</demand_id>
|
<demand>domestic_hot_water</demand>
|
||||||
</demands>
|
</demands>
|
||||||
<components>
|
<components>
|
||||||
<generation_id>17</generation_id>
|
<generation_id>17</generation_id>
|
||||||
|
@ -95,8 +95,8 @@
|
||||||
<system id="3">
|
<system id="3">
|
||||||
<name>Ground Source Heat Pump with Natural Gas Boiler and thermal storage</name>
|
<name>Ground Source Heat Pump with Natural Gas Boiler and thermal storage</name>
|
||||||
<demands>
|
<demands>
|
||||||
<demand_id>1</demand_id>
|
<demand>heating</demand>
|
||||||
<demand_id>2</demand_id>
|
<demand>domestic_hot_water</demand>
|
||||||
</demands>
|
</demands>
|
||||||
<components>
|
<components>
|
||||||
<generation_id>16</generation_id>
|
<generation_id>16</generation_id>
|
||||||
|
@ -107,8 +107,8 @@
|
||||||
<system id="4">
|
<system id="4">
|
||||||
<name>Ground Source Heat Pump with Electrical Boiler and thermal storage</name>
|
<name>Ground Source Heat Pump with Electrical Boiler and thermal storage</name>
|
||||||
<demands>
|
<demands>
|
||||||
<demand_id>1</demand_id>
|
<demand>heating</demand>
|
||||||
<demand_id>2</demand_id>
|
<demand>domestic_hot_water</demand>
|
||||||
</demands>
|
</demands>
|
||||||
<components>
|
<components>
|
||||||
<generation_id>17</generation_id>
|
<generation_id>17</generation_id>
|
||||||
|
@ -119,8 +119,8 @@
|
||||||
<system id="5">
|
<system id="5">
|
||||||
<name>Water Source Heat Pump with Natural Gas Boiler and thermal storage</name>
|
<name>Water Source Heat Pump with Natural Gas Boiler and thermal storage</name>
|
||||||
<demands>
|
<demands>
|
||||||
<demand_id>1</demand_id>
|
<demand>heating</demand>
|
||||||
<demand_id>2</demand_id>
|
<demand>domestic_hot_water</demand>
|
||||||
</demands>
|
</demands>
|
||||||
<components>
|
<components>
|
||||||
<generation_id>16</generation_id>
|
<generation_id>16</generation_id>
|
||||||
|
@ -131,8 +131,8 @@
|
||||||
<system id="6">
|
<system id="6">
|
||||||
<name>Water Source Heat Pump with Electrical Boiler and thermal storage</name>
|
<name>Water Source Heat Pump with Electrical Boiler and thermal storage</name>
|
||||||
<demands>
|
<demands>
|
||||||
<demand_id>1</demand_id>
|
<demand>heating</demand>
|
||||||
<demand_id>2</demand_id>
|
<demand>domestic_hot_water</demand>
|
||||||
</demands>
|
</demands>
|
||||||
<components>
|
<components>
|
||||||
<generation_id>17</generation_id>
|
<generation_id>17</generation_id>
|
||||||
|
@ -143,7 +143,7 @@
|
||||||
<system id="7">
|
<system id="7">
|
||||||
<name>Photovoltaic System</name>
|
<name>Photovoltaic System</name>
|
||||||
<demands>
|
<demands>
|
||||||
<demand_id>3</demand_id>
|
<demand>electricity</demand>
|
||||||
</demands>
|
</demands>
|
||||||
<components>
|
<components>
|
||||||
<generation_id>21</generation_id>
|
<generation_id>21</generation_id>
|
||||||
|
|
|
@ -37,3 +37,6 @@ class TestSystemsCatalog(TestCase):
|
||||||
|
|
||||||
def test_north_america_systems_catalog(self):
|
def test_north_america_systems_catalog(self):
|
||||||
catalog = EnergySystemsCatalogFactory('north_america').catalog
|
catalog = EnergySystemsCatalogFactory('north_america').catalog
|
||||||
|
|
||||||
|
def test_montreal_catalog(self):
|
||||||
|
catalog = EnergySystemsCatalogFactory('montreal_custom').catalog
|
||||||
|
|
Loading…
Reference in New Issue
Block a user