Modified the classes and the north amercia catalog importer based on the changes Pilar made in the data model structure

This commit is contained in:
Saeed Ranjbar 2023-10-16 16:44:53 -04:00
parent 3f649fd020
commit c6d4feec89
6 changed files with 110 additions and 134 deletions

View File

@ -19,9 +19,10 @@ class GenerationSystem(ABC):
Heat Generation system class Heat Generation system class
""" """
def __init__(self, system_id, model_name=None, manufacturer=None, fuel_type=None, def __init__(self, system_id, name, model_name=None, manufacturer=None, fuel_type=None,
distribution_systems=None, energy_storage_systems=None): distribution_systems=None, energy_storage_systems=None):
self._system_id = system_id self._system_id = system_id
self._name = name
self._model_name = model_name self._model_name = model_name
self._manufacturer = manufacturer self._manufacturer = manufacturer
self._fuel_type = fuel_type self._fuel_type = fuel_type
@ -36,6 +37,14 @@ class GenerationSystem(ABC):
""" """
return self._system_id return self._system_id
@property
def name(self):
"""
Get system name
:return: string
"""
return self._name
@property @property
def system_type(self): def system_type(self):
""" """

View File

@ -16,7 +16,7 @@ class NonPvGenerationSystem(GenerationSystem):
Non PV Generation system class Non PV Generation system class
""" """
def __init__(self, system_id, system_type, model_name=None, manufacturer=None, fuel_type=None, def __init__(self, system_id, name, system_type, model_name=None, manufacturer=None, fuel_type=None,
nominal_heat_output=None, maximum_heat_output=None, minimum_heat_output=None, source_medium=None, nominal_heat_output=None, maximum_heat_output=None, minimum_heat_output=None, source_medium=None,
supply_medium=None, heat_efficiency=None, nominal_cooling_output=None, maximum_cooling_output=None, supply_medium=None, heat_efficiency=None, nominal_cooling_output=None, maximum_cooling_output=None,
minimum_cooling_output=None, cooling_efficiency=None, electricity_efficiency=None, minimum_cooling_output=None, cooling_efficiency=None, electricity_efficiency=None,
@ -26,7 +26,7 @@ class NonPvGenerationSystem(GenerationSystem):
heat_fuel_consumption_curve=None, heat_efficiency_curve=None, cooling_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, cooling_fuel_consumption_curve=None, cooling_efficiency_curve=None,
distribution_systems=None, energy_storage_systems=None): distribution_systems=None, energy_storage_systems=None):
super().__init__(system_id=system_id, model_name=model_name, manufacturer=manufacturer, fuel_type=fuel_type, super().__init__(system_id=system_id, name=name, model_name=model_name, manufacturer=manufacturer, fuel_type=fuel_type,
distribution_systems=distribution_systems, energy_storage_systems=energy_storage_systems) distribution_systems=distribution_systems, energy_storage_systems=energy_storage_systems)
self._system_type = system_type self._system_type = system_type
self._nominal_heat_output = nominal_heat_output self._nominal_heat_output = nominal_heat_output

View File

@ -14,12 +14,12 @@ class PvGenerationSystem(GenerationSystem):
Electricity Generation system class Electricity Generation system class
""" """
def __init__(self, system_id, model_name=None, manufacturer=None, electricity_efficiency=None, def __init__(self, system_id, name, model_name=None, manufacturer=None, electricity_efficiency=None,
nominal_electricity_output=None, nominal_ambient_temperature=None, nominal_cell_temperature=None, nominal_electricity_output=None, nominal_ambient_temperature=None, nominal_cell_temperature=None,
nominal_radiation=None, standard_test_condition_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): distribution_systems=None, energy_storage_systems=None):
super().__init__(system_id=system_id, model_name=model_name, super().__init__(system_id=system_id, name=name, model_name=model_name,
manufacturer=manufacturer, fuel_type='renewable', distribution_systems=distribution_systems, manufacturer=manufacturer, fuel_type='renewable', distribution_systems=distribution_systems,
energy_storage_systems=energy_storage_systems) energy_storage_systems=energy_storage_systems)
self._system_type = 'PV system' self._system_type = 'PV system'

View File

@ -28,8 +28,9 @@ 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(), force_list=['photovoltaicModules', 'templateStorages']) self._archetypes = xmltodict.parse(xml.read(), force_list=['photovoltaicModules', 'templateStorages'])
self._generation_components = self._load_generation_components()
self._storage_components = self._load_storage_components() self._storage_components = self._load_storage_components()
self._generation_components = self._load_generation_components()
self._systems = self._load_systems() self._systems = self._load_systems()
self._system_archetypes = self._load_archetypes() self._system_archetypes = self._load_archetypes()
self._content = Content(self._system_archetypes, self._content = Content(self._system_archetypes,
@ -39,12 +40,18 @@ class NorthAmericaEnergySystemCatalog(Catalog):
def _load_generation_components(self): def _load_generation_components(self):
generation_components = [] generation_components = []
boilers = self._archetypes['EnergySystemCatalog']['energy_generation_components']['boilers'] boilers = self._archetypes['EnergySystemCatalog']['energy_generation_components']['boilers']
print(len(boilers))
heat_pumps = self._archetypes['EnergySystemCatalog']['energy_generation_components']['heatPumps'] heat_pumps = self._archetypes['EnergySystemCatalog']['energy_generation_components']['heatPumps']
print(len(heat_pumps))
photovoltaics = self._archetypes['EnergySystemCatalog']['energy_generation_components']['photovoltaicModules'] photovoltaics = self._archetypes['EnergySystemCatalog']['energy_generation_components']['photovoltaicModules']
print(len(photovoltaics))
templates = self._archetypes['EnergySystemCatalog']['energy_generation_components']['templateGenerationEquipments'] templates = self._archetypes['EnergySystemCatalog']['energy_generation_components']['templateGenerationEquipments']
print(len(templates))
for boiler in boilers: for boiler in boilers:
print(boiler)
boiler_id = boiler['@generation_id'] boiler_id = boiler['@generation_id']
system_type = boiler['@name'] name = boiler['@name']
system_type = 'Boiler'
boiler_model_name = boiler['@modelName'] boiler_model_name = boiler['@modelName']
boiler_manufacturer = boiler['@manufacturer'] boiler_manufacturer = boiler['@manufacturer']
boiler_fuel_type = boiler['@fuel'] boiler_fuel_type = boiler['@fuel']
@ -53,7 +60,8 @@ class NorthAmericaEnergySystemCatalog(Catalog):
boiler_minimum_heat_output = float(boiler['@minimumHeatOutput']) boiler_minimum_heat_output = float(boiler['@minimumHeatOutput'])
boiler_heat_efficiency = float(boiler['@nominalEfficiency']) boiler_heat_efficiency = float(boiler['@nominalEfficiency'])
boiler_component = NonPvGenerationSystem(boiler_id, boiler_component = NonPvGenerationSystem(boiler_id,
system_type, name=name,
system_type=system_type,
model_name=boiler_model_name, model_name=boiler_model_name,
manufacturer=boiler_manufacturer, manufacturer=boiler_manufacturer,
fuel_type=boiler_fuel_type, fuel_type=boiler_fuel_type,
@ -64,7 +72,8 @@ class NorthAmericaEnergySystemCatalog(Catalog):
generation_components.append(boiler_component) generation_components.append(boiler_component)
for heat_pump in heat_pumps: for heat_pump in heat_pumps:
heat_pump_id = heat_pump['@generation_id'] heat_pump_id = heat_pump['@generation_id']
system_type = heat_pump['@name'] name = heat_pump['@name']
system_type = 'Heat Pump'
heat_pump_model_name = heat_pump['@modelName'] heat_pump_model_name = heat_pump['@modelName']
heat_pump_manufacturer = heat_pump['@manufacturer'] heat_pump_manufacturer = heat_pump['@manufacturer']
heat_pump_fuel_type = heat_pump['@fuel'] heat_pump_fuel_type = heat_pump['@fuel']
@ -85,7 +94,8 @@ class NorthAmericaEnergySystemCatalog(Catalog):
cop_curve = PerformanceCurves(cop_curve_type, dependant_variable, parameters, coefficients) cop_curve = PerformanceCurves(cop_curve_type, dependant_variable, parameters, coefficients)
heat_pump_component = NonPvGenerationSystem(heat_pump_id, heat_pump_component = NonPvGenerationSystem(heat_pump_id,
system_type, name=name,
system_type=system_type,
model_name=heat_pump_model_name, model_name=heat_pump_model_name,
manufacturer=heat_pump_manufacturer, manufacturer=heat_pump_manufacturer,
fuel_type=heat_pump_fuel_type, fuel_type=heat_pump_fuel_type,
@ -103,6 +113,7 @@ class NorthAmericaEnergySystemCatalog(Catalog):
generation_components.append(heat_pump_component) generation_components.append(heat_pump_component)
for pv in photovoltaics: for pv in photovoltaics:
pv_id = pv['@generation_id'] pv_id = pv['@generation_id']
name = pv['@name']
pv_model_name = pv['@modelName'] pv_model_name = pv['@modelName']
pv_manufacturer = pv['@manufacturer'] pv_manufacturer = pv['@manufacturer']
pv_electricity_efficiency = pv['@nominalEfficiency'] pv_electricity_efficiency = pv['@nominalEfficiency']
@ -117,6 +128,7 @@ class NorthAmericaEnergySystemCatalog(Catalog):
height = float(pv['@height']) height = float(pv['@height'])
pv_component = PvGenerationSystem(pv_id, pv_component = PvGenerationSystem(pv_id,
name=name,
model_name=pv_model_name, model_name=pv_model_name,
manufacturer=pv_manufacturer, manufacturer=pv_manufacturer,
electricity_efficiency=pv_electricity_efficiency, electricity_efficiency=pv_electricity_efficiency,
@ -130,45 +142,26 @@ class NorthAmericaEnergySystemCatalog(Catalog):
width=width, width=width,
height=height) height=height)
generation_components.append(pv_component) generation_components.append(pv_component)
for template in templates: for template in templates:
system_id = template['@generation_id'] system_id = template['@generation_id']
system_name = template['@name'] system_name = template['@name']
if 'storage_id' in template.keys():
storage_component = template['storage_id']
storage_systems = self._search_storage_equipment(self._load_storage_components(), storage_component)
energy_storage_system = storage_systems
else:
energy_storage_system = None
if "Boiler" in system_name: if "Boiler" in system_name:
system_type = 'boiler' system_type = 'boiler'
fuel_type = template['@fuel'] fuel_type = template['@fuel']
heat_efficiency = float(template['@nominalEfficiency']) heat_efficiency = float(template['@nominalEfficiency'])
source_medium = None boiler_template = NonPvGenerationSystem(system_id=system_id,
supply_medium = None name=system_name,
boiler_template = GenerationSystem(system_id, system_type=system_type,
system_name, fuel_type=fuel_type,
None, heat_efficiency=heat_efficiency,
None, energy_storage_systems=energy_storage_system)
system_type,
fuel_type,
None,
None,
None,
source_medium,
supply_medium,
heat_efficiency,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None)
generation_components.append(boiler_template) generation_components.append(boiler_template)
elif "Heat Pump" in system_name: elif "Heat Pump" in system_name:
system_type = 'heat pump' system_type = 'heat pump'
@ -176,55 +169,23 @@ class NorthAmericaEnergySystemCatalog(Catalog):
heat_efficiency = template['@nominalCOP'] heat_efficiency = template['@nominalCOP']
source_medium = template['@heatSource'] source_medium = template['@heatSource']
supply_medium = template['@supply_medium'] supply_medium = template['@supply_medium']
heat_pump_template = GenerationSystem(system_id, heat_pump_template = NonPvGenerationSystem(system_id=system_id,
system_name, name=system_name,
None, system_type=system_type,
None, source_medium=source_medium,
system_type, supply_medium=supply_medium,
fuel_type, fuel_type=fuel_type,
None, heat_efficiency=heat_efficiency)
None,
None,
source_medium,
supply_medium,
heat_efficiency,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None)
generation_components.append(heat_pump_template) generation_components.append(heat_pump_template)
else: else:
electricity_efficiency = float(template['@nominalEfficiency']) electricity_efficiency = float(template['@nominalEfficiency'])
height = float(template['@height']) height = float(template['@height'])
width = float(template['@width']) width = float(template['@width'])
pv_template = PvGenerationSystem(system_id, pv_template = PvGenerationSystem(system_id=system_id,
system_name, name=system_name,
None, electricity_efficiency=electricity_efficiency,
None, width=width,
electricity_efficiency, height=height)
None,
None,
None,
None,
None,
None,
None,
width,
height)
generation_components.append(pv_template) generation_components.append(pv_template)
return generation_components return generation_components
@ -235,7 +196,6 @@ class NorthAmericaEnergySystemCatalog(Catalog):
template_storages = self._archetypes['EnergySystemCatalog']['energy_storage_components']['templateStorages'] template_storages = self._archetypes['EnergySystemCatalog']['energy_storage_components']['templateStorages']
for tes in thermal_storages: for tes in thermal_storages:
storage_id = tes['@storage_id'] storage_id = tes['@storage_id']
name = tes['@name']
model_name = tes['@modelName'] model_name = tes['@modelName']
manufacturer = tes['@manufacturer'] manufacturer = tes['@manufacturer']
storage_type = 'sensible' storage_type = 'sensible'
@ -254,7 +214,6 @@ class NorthAmericaEnergySystemCatalog(Catalog):
# 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,
name,
model_name, model_name,
manufacturer, manufacturer,
storage_type, storage_type,
@ -268,7 +227,6 @@ class NorthAmericaEnergySystemCatalog(Catalog):
for template in template_storages: for template in template_storages:
storage_id = template['@storage_id'] storage_id = template['@storage_id']
name = template['@name']
storage_type = 'sensible' storage_type = 'sensible'
maximum_temperature = template['@maxTemp'] maximum_temperature = template['@maxTemp']
height = template['physical_characteristics']['@height'] height = template['physical_characteristics']['@height']
@ -284,7 +242,6 @@ class NorthAmericaEnergySystemCatalog(Catalog):
# 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,
name,
None, None,
None, None,
storage_type, storage_type,
@ -306,19 +263,12 @@ class NorthAmericaEnergySystemCatalog(Catalog):
demands = system['demands']['demand'] demands = system['demands']['demand']
generation_components = system['components']['generation_id'] generation_components = system['components']['generation_id']
generation_systems = self._search_generation_equipment(self._load_generation_components(), generation_components) generation_systems = self._search_generation_equipment(self._load_generation_components(), generation_components)
if 'storage_id' in system['components'].keys(): energy_system = System(system_id=system_id,
storage_components = system['components']['storage_id'] name=name,
storage_systems = self._search_storage_equipment(self._load_storage_components(), storage_components) demand_types=demands,
else: generation_systems=generation_systems,
storage_systems = None distribution_systems=None,
energy_system = System(None, configuration_schema=None)
system_id,
name,
demands,
generation_systems,
None,
None,
storage_systems)
_catalog_systems.append(energy_system) _catalog_systems.append(energy_system)
return _catalog_systems return _catalog_systems
@ -333,7 +283,7 @@ class NorthAmericaEnergySystemCatalog(Catalog):
for system_archetype in self._systems: for system_archetype in self._systems:
if int(system_archetype.id) in integer_system_ids: if int(system_archetype.id) in integer_system_ids:
_systems.append(system_archetype) _systems.append(system_archetype)
_system_archetypes.append(Archetype(None, name, _systems)) _system_archetypes.append(Archetype(name=name, systems=_systems))
return _system_archetypes return _system_archetypes
def _load_materials(self): def _load_materials(self):
@ -411,8 +361,6 @@ class NorthAmericaEnergySystemCatalog(Catalog):
_names['systems'].append(system.name) _names['systems'].append(system.name)
for equipment in self._content.generation_equipments: for equipment in self._content.generation_equipments:
_names['generation_equipments'].append(equipment.name) _names['generation_equipments'].append(equipment.name)
for equipment in self._content.storage_equipments:
_names['storage_equipments'].append(equipment.name)
else: else:
_names = {category: []} _names = {category: []}
if category.lower() == 'archetypes': if category.lower() == 'archetypes':
@ -424,9 +372,6 @@ class NorthAmericaEnergySystemCatalog(Catalog):
elif category.lower() == 'generation_equipments': elif category.lower() == 'generation_equipments':
for system in self._content.generation_equipments: for system in self._content.generation_equipments:
_names[category].append(system.name) _names[category].append(system.name)
elif category.lower() == 'storage_equipments':
for system in self._content.storage_equipments:
_names[category].append(system.name)
else: else:
raise ValueError(f'Unknown category [{category}]') raise ValueError(f'Unknown category [{category}]')
return _names return _names
@ -444,8 +389,6 @@ class NorthAmericaEnergySystemCatalog(Catalog):
return self._content.systems return self._content.systems
if category.lower() == 'generation_equipments': if category.lower() == 'generation_equipments':
return self._content.generation_equipments return self._content.generation_equipments
if category.lower() == 'storage_equipments':
return self._content.storage_equipments
raise ValueError(f'Unknown category [{category}]') raise ValueError(f'Unknown category [{category}]')
def get_entry(self, name): def get_entry(self, name):
@ -462,7 +405,4 @@ class NorthAmericaEnergySystemCatalog(Catalog):
for entry in self._content.generation_equipments: for entry in self._content.generation_equipments:
if entry.name.lower() == name.lower(): if entry.name.lower() == name.lower():
return entry 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") raise IndexError(f"{name} doesn't exists in the catalog")

View File

@ -41,12 +41,27 @@
<coefficients a="0.00109" b="0.209" c="-0.00291" d="-0.172" e="0.00102" f="8.95"/> <coefficients a="0.00109" b="0.209" c="-0.00291" d="-0.172" e="0.00102" f="8.95"/>
</performance_curve> </performance_curve>
</heatPumps> </heatPumps>
<templateGenerationEquipments generation_id="16" name="template Natural-Gas Boiler" nominalEfficiency="0.90" fuel="natural gas"/> <templateGenerationEquipments generation_id="16" name="template Natural-Gas Boiler" nominalEfficiency="0.90" fuel="natural gas">
<templateGenerationEquipments generation_id="17" name="template Electric Boiler" nominalEfficiency="0.95" fuel="electricity"/> <storage_id>6</storage_id>
<templateGenerationEquipments generation_id="18" name="template Air-to-Water Heat Pump" fuel="electricity" heatSource="Air" nominalCOP="3" supply_medium="water"/> </templateGenerationEquipments>
<templateGenerationEquipments generation_id="19" name="template Groundwater-to-Water Heat Pump" fuel="electricity" heatSource="Ground" nominalCOP="3.5" supply_medium="water"/> <templateGenerationEquipments generation_id="17" name="template Electric Boiler" nominalEfficiency="0.95" fuel="electricity">
<templateGenerationEquipments generation_id="20" name="template Water-to-Water Heat Pump" fuel="electricity" heatSource="Water" nominalCOP="3.5" supply_medium="water"/> <storage_id>6</storage_id>
<templateGenerationEquipments generation_id="21" name="template Photovoltaic Module" nominalEfficiency="0.2" width="1.0" height="1.0"/> </templateGenerationEquipments>
<templateGenerationEquipments generation_id="18" name="template Air-to-Water Heat Pump" fuel="electricity" heatSource="Air" nominalCOP="3" supply_medium="water">
<storage_id>6</storage_id>
</templateGenerationEquipments>
<templateGenerationEquipments generation_id="19" name="template Groundwater-to-Water Heat Pump" fuel="electricity" heatSource="Ground" nominalCOP="3.5" supply_medium="water">
<storage_id>6</storage_id>
</templateGenerationEquipments>
<templateGenerationEquipments generation_id="20" name="template Water-to-Water Heat Pump" fuel="electricity" heatSource="Water" nominalCOP="3.5" supply_medium="water">
<storage_id>6</storage_id>
</templateGenerationEquipments>
<templateGenerationEquipments generation_id="21" name="template Natural-Gas Boiler" nominalEfficiency="0.90" fuel="natural gas"/>
<templateGenerationEquipments generation_id="22" name="template Electric Boiler" nominalEfficiency="0.95" fuel="electricity"/>
<templateGenerationEquipments generation_id="23" name="template Air-to-Water Heat Pump" fuel="electricity" heatSource="Air" nominalCOP="3" supply_medium="water"/>
<templateGenerationEquipments generation_id="24" name="template Groundwater-to-Water Heat Pump" fuel="electricity" heatSource="Ground" nominalCOP="3.5" supply_medium="water"/>
<templateGenerationEquipments generation_id="25" name="template Water-to-Water Heat Pump" fuel="electricity" heatSource="Water" nominalCOP="3.5" supply_medium="water"/>
<templateGenerationEquipments generation_id="26" name="template Photovoltaic Module" nominalEfficiency="0.2" width="1.0" height="1.0"/>
<manufacturers manufacturer_id="1" name="Alpine" country="USA" product="Natural Gas Boiler"/> <manufacturers manufacturer_id="1" name="Alpine" country="USA" product="Natural Gas Boiler"/>
<manufacturers manufacturer_id="2" name="Alta" country="USA" product="Natural Gas Boiler"/> <manufacturers manufacturer_id="2" name="Alta" country="USA" product="Natural Gas Boiler"/>
<manufacturers manufacturer_id="3" name="Aspen" country="USA" product="Natural Gas Boiler"/> <manufacturers manufacturer_id="3" name="Aspen" country="USA" product="Natural Gas Boiler"/>
@ -99,9 +114,8 @@
<demand>domestic_hot_water</demand> <demand>domestic_hot_water</demand>
</demands> </demands>
<components> <components>
<generation_id>16</generation_id> <generation_id>21</generation_id>
<generation_id>18</generation_id> <generation_id>18</generation_id>
<storage_id>6</storage_id>
</components> </components>
</system> </system>
<system id="2"> <system id="2">
@ -111,9 +125,8 @@
<demand>domestic_hot_water</demand> <demand>domestic_hot_water</demand>
</demands> </demands>
<components> <components>
<generation_id>17</generation_id> <generation_id>22</generation_id>
<generation_id>18</generation_id> <generation_id>18</generation_id>
<storage_id>6</storage_id>
</components> </components>
</system> </system>
<system id="3"> <system id="3">
@ -123,9 +136,8 @@
<demand>domestic_hot_water</demand> <demand>domestic_hot_water</demand>
</demands> </demands>
<components> <components>
<generation_id>16</generation_id> <generation_id>21</generation_id>
<generation_id>19</generation_id> <generation_id>19</generation_id>
<storage_id>6</storage_id>
</components> </components>
</system> </system>
<system id="4"> <system id="4">
@ -135,9 +147,8 @@
<demand>domestic_hot_water</demand> <demand>domestic_hot_water</demand>
</demands> </demands>
<components> <components>
<generation_id>17</generation_id> <generation_id>22</generation_id>
<generation_id>19</generation_id> <generation_id>19</generation_id>
<storage_id>6</storage_id>
</components> </components>
</system> </system>
<system id="5"> <system id="5">
@ -147,9 +158,8 @@
<demand>domestic_hot_water</demand> <demand>domestic_hot_water</demand>
</demands> </demands>
<components> <components>
<generation_id>16</generation_id> <generation_id>21</generation_id>
<generation_id>20</generation_id> <generation_id>20</generation_id>
<storage_id>6</storage_id>
</components> </components>
</system> </system>
<system id="6"> <system id="6">
@ -159,9 +169,8 @@
<demand>domestic_hot_water</demand> <demand>domestic_hot_water</demand>
</demands> </demands>
<components> <components>
<generation_id>17</generation_id> <generation_id>22</generation_id>
<generation_id>20</generation_id> <generation_id>20</generation_id>
<storage_id>6</storage_id>
</components> </components>
</system> </system>
<system id="7"> <system id="7">
@ -170,7 +179,7 @@
<demand>electricity</demand> <demand>electricity</demand>
</demands> </demands>
<components> <components>
<generation_id>21</generation_id> <generation_id>26</generation_id>
</components> </components>
</system> </system>
</systems> </systems>

View File

@ -36,4 +36,22 @@ 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
print(catalog.entries())
catalog_categories = catalog.names()
archetypes = catalog.names('archetypes')
self.assertEqual(6, len(archetypes['archetypes']))
systems = catalog.names('systems')
self.assertEqual(7, len(systems['systems']))
generation_equipments = catalog.names('generation_equipments')
self.assertEqual(26, len(generation_equipments['generation_equipments']))
with self.assertRaises(ValueError):
catalog.names('unknown')
# retrieving all the entries should not raise any exceptions
for category in catalog_categories:
for value in catalog_categories[category]:
catalog.get_entry(value)
with self.assertRaises(IndexError):
catalog.get_entry('unknown')