From 1a7ad201351b814a501f8b41022ce47a78a606b3 Mon Sep 17 00:00:00 2001 From: p_monsalvete Date: Thu, 12 Oct 2023 11:59:52 -0400 Subject: [PATCH] new catalog model and factory finished and test passed --- .../energy_systems/distribution_system.py | 6 +- .../energy_systems/montreal_custom_catalog.py | 43 ++++--- .../montreal_custom_systems.xml | 111 +++++++++++------- tests/test_systems_catalog.py | 2 +- 4 files changed, 94 insertions(+), 68 deletions(-) diff --git a/hub/catalog_factories/data_models/energy_systems/distribution_system.py b/hub/catalog_factories/data_models/energy_systems/distribution_system.py index 8654b533..1b3ad2e2 100644 --- a/hub/catalog_factories/data_models/energy_systems/distribution_system.py +++ b/hub/catalog_factories/data_models/energy_systems/distribution_system.py @@ -6,12 +6,14 @@ Project Coder Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca Code contributors: Saeed Ranjbar saeed.ranjbar@concordia.ca """ -from typing import Union, List +from typing import Union, List, TypeVar -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.energy_storage_system import EnergyStorageSystem from hub.catalog_factories.data_models.energy_systems.emission_system import EmissionSystem +GenerationSystem = TypeVar('GenerationSystem') + class DistributionSystem: """ diff --git a/hub/catalog_factories/energy_systems/montreal_custom_catalog.py b/hub/catalog_factories/energy_systems/montreal_custom_catalog.py index 3b31cd81..9b984fdd 100644 --- a/hub/catalog_factories/energy_systems/montreal_custom_catalog.py +++ b/hub/catalog_factories/energy_systems/montreal_custom_catalog.py @@ -31,8 +31,8 @@ class MontrealCustomCatalog(Catalog): 'demand', 'system_id')) self._catalog_generation_equipments = self._load_generation_equipments() - self._catalog_distribution_equipments = self._load_distribution_equipments() self._catalog_emission_equipments = self._load_emission_equipments() + self._catalog_distribution_equipments = self._load_distribution_equipments() self._catalog_systems = self._load_systems() self._catalog_archetypes = self._load_archetypes() # store the full catalog data model in self._content @@ -59,10 +59,20 @@ class MontrealCustomCatalog(Catalog): electricity_efficiency = None if 'electrical_efficiency' in equipment: electricity_efficiency = float(equipment['electrical_efficiency']) + + storage_systems = None + storage = literal_eval(equipment['storage'].capitalize()) + if storage: + if equipment_type == 'electricity generator': + storage_system = ElectricalStorageSystem(equipment_id) + else: + storage_system = ThermalStorageSystem(equipment_id) + storage_systems = [storage_system] if model_name == 'PV system': generation_system = PvGenerationSystem(equipment_id, model_name=model_name, electricity_efficiency=electricity_efficiency, + energy_storage_systems=storage_systems ) else: generation_system = NonPvGenerationSystem(equipment_id, @@ -72,14 +82,8 @@ class MontrealCustomCatalog(Catalog): heat_efficiency=heating_efficiency, cooling_efficiency=cooling_efficiency, electricity_efficiency=electricity_efficiency, - ) - storage = literal_eval(equipment['storage'].capitalize()) - if storage: - if equipment_type == 'electricity generator': - storage_system = ElectricalStorageSystem(equipment_id) - else: - storage_system = ThermalStorageSystem(equipment_id) - generation_system.energy_storage_systems = [storage_system] + energy_storage_systems=storage_systems + ) _equipments.append(generation_system) return _equipments @@ -102,12 +106,19 @@ class MontrealCustomCatalog(Catalog): distribution_consumption_variable_flow = float( equipment['distribution_consumption_variable_flow']['#text']) / 100 + emission_equipment = equipment['dissipation_id'] + _emission_equipments = None + for equipment_archetype in self._catalog_emission_equipments: + if int(equipment_archetype.id) == int(emission_equipment): + _emission_equipments = [equipment_archetype] + distribution_system = DistributionSystem(equipment_id, model_name=model_name, system_type=equipment_type, distribution_consumption_fix_flow=distribution_consumption_fix_flow, distribution_consumption_variable_flow=distribution_consumption_variable_flow, - heat_losses=distribution_heat_losses) + heat_losses=distribution_heat_losses, + emission_systems=_emission_equipments) _equipments.append(distribution_system) return _equipments @@ -148,18 +159,6 @@ class MontrealCustomCatalog(Catalog): for equipment_archetype in self._catalog_distribution_equipments: if int(equipment_archetype.id) == int(distribution_equipment): _distribution_equipments = [equipment_archetype] - emission_equipment = system['equipments']['dissipation_id'] - _emission_equipments = None - for equipment_archetype in self._catalog_emission_equipments: - if int(equipment_archetype.id) == int(emission_equipment): - _emission_equipments = [equipment_archetype] - - - - - - - _catalog_systems.append(System(system_id, demands, diff --git a/hub/data/energy_systems/montreal_custom_systems.xml b/hub/data/energy_systems/montreal_custom_systems.xml index d3a7591d..f3b0466f 100644 --- a/hub/data/energy_systems/montreal_custom_systems.xml +++ b/hub/data/energy_systems/montreal_custom_systems.xml @@ -38,53 +38,96 @@ - + Water distribution heating 10 2 0 + 1 - + + Water distribution heating + 10 + 2 + 0 + 2 + + + Water distribution heating + 10 + 2 + 0 + 3 + + Water distribution cooling 5 4 0 + 2 - + Central air distribution heating 10 0 13 + 2 - + + Central air distribution heating + 10 + 0 + 13 + 3 + + Central air distribution cooling 5 0 13 + 2 - + Local air distribution heating 5 8 0 + 1 - + + Local air distribution heating + 5 + 8 + 0 + 3 + + Local air distribution cooling 2 8 0 + 3 - + Refrigerant distribution 1 1 0 + 2 - + No distribution 0 0 0 + 1 + + + No distribution + 0 + 0 + 0 + 3 @@ -111,7 +154,6 @@ 1 1 - 1 @@ -122,8 +164,7 @@ 2 - 8 - 1 + 12 @@ -134,8 +175,7 @@ 1 - 1 - 2 + 2 @@ -146,8 +186,7 @@ 2 - 1 - 2 + 2 @@ -158,9 +197,8 @@ 3 - 5 - 1 - + 8 +g Single zone packaged rooftop unit with electrical resistance furnace and baseboards and fuel boiler for acs @@ -170,8 +208,7 @@ 4 - 5 - 1 + 8 @@ -183,7 +220,6 @@ 1 1 - 1 @@ -194,8 +230,7 @@ 2 - 8 - 3 + 13 @@ -206,8 +241,7 @@ 2 - 1 - 3 + 3 @@ -218,8 +252,7 @@ 2 - 8 - 3 + 13 @@ -229,8 +262,7 @@ 5 - 6 - 3 + 10 @@ -240,8 +272,7 @@ 5 - 2 - 2 + 4 @@ -251,8 +282,7 @@ 5 - 6 - 3 + 10 @@ -262,8 +292,7 @@ 5 - 6 - 3 + 10 @@ -273,8 +302,7 @@ 5 - 3 - 3 + 6 @@ -284,8 +312,7 @@ 6 - 5 - 3 + 9 @@ -296,8 +323,7 @@ 7 - 3 - 2 + 5 @@ -307,8 +333,7 @@ 7 - 4 - 2 + 7 diff --git a/tests/test_systems_catalog.py b/tests/test_systems_catalog.py index 563e1b7d..01da9114 100644 --- a/tests/test_systems_catalog.py +++ b/tests/test_systems_catalog.py @@ -22,7 +22,7 @@ class TestSystemsCatalog(TestCase): generation_equipments = catalog.names('generation_equipments') self.assertEqual(7, len(generation_equipments['generation_equipments'])) distribution_equipments = catalog.names('distribution_equipments') - self.assertEqual(8, len(distribution_equipments['distribution_equipments'])) + self.assertEqual(13, len(distribution_equipments['distribution_equipments'])) with self.assertRaises(ValueError): catalog.names('unknown')