Compare commits

...

5 Commits

13 changed files with 121 additions and 79 deletions

View File

@ -15,10 +15,11 @@ class Archetype:
""" """
Archetype class Archetype class
""" """
def __init__(self, lod, name, systems): def __init__(self, lod, name, schema, systems):
self._lod = lod self._lod = lod
self._name = name self._name = name
self._schema = schema
self._systems = systems self._systems = systems
@property @property
@ -37,6 +38,14 @@ class Archetype:
""" """
return self._name return self._name
@property
def schema(self):
"""
Get schema path
:return: string
"""
return self._schema
@property @property
def systems(self) -> List[System]: def systems(self) -> List[System]:
""" """
@ -53,6 +62,7 @@ class Archetype:
content = { content = {
'Archetype': { 'Archetype': {
'name': self.name, 'name': self.name,
'schema': self.schema,
'level of detail': self.lod, 'level of detail': self.lod,
'systems': _systems 'systems': _systems
} }

View File

@ -6,6 +6,7 @@ Project Coder Saeed Ranjbar saeed.ranjbar@concordia.ca
Code contributors: Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca Code contributors: Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
""" """
from pathlib import Path
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
@ -366,17 +367,19 @@ class NorthAmericaEnergySystemCatalog(Catalog):
return _catalog_systems return _catalog_systems
def _load_archetypes(self): def _load_archetypes(self):
base_path = Path(Path(__file__).parent.parent.parent / 'data/energy_systems')
_system_archetypes = [] _system_archetypes = []
system_clusters = self._archetypes['EnergySystemCatalog']['system_archetypes']['system_archetype'] system_clusters = self._archetypes['EnergySystemCatalog']['system_archetypes']['system_archetype']
for system_cluster in system_clusters: for system_cluster in system_clusters:
name = system_cluster['name'] name = system_cluster['name']
schema_path = Path(base_path / system_cluster['schema'])
systems = system_cluster['systems']['system_id'] systems = system_cluster['systems']['system_id']
integer_system_ids = [int(item) for item in systems] integer_system_ids = [int(item) for item in systems]
_systems = [] _systems = []
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(None, name, schema_path, _systems))
return _system_archetypes return _system_archetypes
def _load_materials(self): def _load_materials(self):

View File

@ -27,6 +27,7 @@ class Building(CityObject):
""" """
Building(CityObject) class Building(CityObject) class
""" """
def __init__(self, name, surfaces, year_of_construction, function, terrains=None, city=None): def __init__(self, name, surfaces, year_of_construction, function, terrains=None, city=None):
super().__init__(name, surfaces) super().__init__(name, surfaces)
self._city = city self._city = city
@ -715,31 +716,35 @@ class Building(CityObject):
if self.energy_systems is None: if self.energy_systems is None:
return self._distribution_systems_electrical_consumption return self._distribution_systems_electrical_consumption
for energy_system in self.energy_systems: for energy_system in self.energy_systems:
emission_system = energy_system.emission_systems.generic_emission_system energy_emission_systems = energy_system.emission_systems
parasitic_energy_consumption = 0 energy_distribution_systems = energy_system.distribution_systems
if emission_system is not None: for energy_emission_system in energy_distribution_systems:
parasitic_energy_consumption = emission_system.parasitic_energy_consumption emission_system = energy_emission_system.generic_emission_system
distribution_system = energy_system.distribution_systems.generic_distribution_system parasitic_energy_consumption = 0
consumption_variable_flow = distribution_system.distribution_consumption_variable_flow if emission_system is not None:
for demand_type in energy_system.demand_types: parasitic_energy_consumption = emission_system.parasitic_energy_consumption
if demand_type.lower() == cte.HEATING.lower(): for energy_distribution_system in energy_emission_systems:
if _peak_load_type == cte.HEATING.lower(): distribution_system = energy_distribution_system.generic_distribution_system
_consumption_fix_flow = distribution_system.distribution_consumption_fix_flow consumption_variable_flow = distribution_system.distribution_consumption_variable_flow
for heating_demand_key in self.heating_demand: for demand_type in energy_system.demand_types:
_consumption = [0]*len(self.heating_demand[heating_demand_key]) if demand_type.lower() == cte.HEATING.lower():
_demand = self.heating_demand[heating_demand_key] if _peak_load_type == cte.HEATING.lower():
for i, _ in enumerate(_consumption): _consumption_fix_flow = distribution_system.distribution_consumption_fix_flow
_consumption[i] += (parasitic_energy_consumption + consumption_variable_flow) * _demand[i] for heating_demand_key in self.heating_demand:
self._distribution_systems_electrical_consumption[heating_demand_key] = _consumption _consumption = [0] * len(self.heating_demand[heating_demand_key])
if demand_type.lower() == cte.COOLING.lower(): _demand = self.heating_demand[heating_demand_key]
if _peak_load_type == cte.COOLING.lower(): for i, _ in enumerate(_consumption):
_consumption_fix_flow = distribution_system.distribution_consumption_fix_flow _consumption[i] += (parasitic_energy_consumption + consumption_variable_flow) * _demand[i]
for demand_key in self.cooling_demand: self._distribution_systems_electrical_consumption[heating_demand_key] = _consumption
_consumption = self._distribution_systems_electrical_consumption[demand_key] if demand_type.lower() == cte.COOLING.lower():
_demand = self.cooling_demand[demand_key] if _peak_load_type == cte.COOLING.lower():
for i, _ in enumerate(_consumption): _consumption_fix_flow = distribution_system.distribution_consumption_fix_flow
_consumption[i] += (parasitic_energy_consumption + consumption_variable_flow) * _demand[i] for demand_key in self.cooling_demand:
self._distribution_systems_electrical_consumption[demand_key] = _consumption _consumption = self._distribution_systems_electrical_consumption[demand_key]
_demand = self.cooling_demand[demand_key]
for i, _ in enumerate(_consumption):
_consumption[i] += (parasitic_energy_consumption + consumption_variable_flow) * _demand[i]
self._distribution_systems_electrical_consumption[demand_key] = _consumption
for key, item in self._distribution_systems_electrical_consumption.items(): for key, item in self._distribution_systems_electrical_consumption.items():
for i in range(0, len(item)): for i in range(0, len(item)):
@ -753,27 +758,26 @@ class Building(CityObject):
if self.energy_systems is None: if self.energy_systems is None:
return None return None
for energy_system in self.energy_systems: for energy_system in self.energy_systems:
generation_systems = energy_system.generation_systems energy_system_generation_systems = energy_system.generation_systems
print(generation_systems)
print(type(generation_systems))
for demand_type in energy_system.demand_types: for demand_type in energy_system.demand_types:
if demand_type.lower() == consumption_type.lower(): if demand_type.lower() == consumption_type.lower():
if consumption_type in (cte.HEATING, cte.DOMESTIC_HOT_WATER): if consumption_type in (cte.HEATING, cte.DOMESTIC_HOT_WATER):
for generation_system in generation_systems: for generation_system in energy_system_generation_systems:
coefficient_of_performance = generation_system.generic_generation_system.heat_efficiency coefficient_of_performance = generation_system.generic_generation_system.heat_efficiency
elif consumption_type == cte.COOLING: elif consumption_type == cte.COOLING:
for generation_system in generation_systems: for generation_system in energy_system_generation_systems:
coefficient_of_performance = generation_system.generic_generation_system.cooling_efficiency coefficient_of_performance = generation_system.generic_generation_system.cooling_efficiency
elif consumption_type == cte.ELECTRICITY: elif consumption_type == cte.ELECTRICITY:
for generation_system in generation_systems: for generation_system in energy_system_generation_systems:
coefficient_of_performance = generation_system.generic_generation_system.electricity_efficiency coefficient_of_performance = \
generation_system.generic_generation_system.electricity_efficiency
if coefficient_of_performance == 0: if coefficient_of_performance == 0:
values = [0]*len(demand) values = [0] * len(demand)
final_energy_consumed = values final_energy_consumed = values
else: else:
final_energy_consumed = [] final_energy_consumed = []
for demand_value in demand: for demand_value in demand:
final_energy_consumed.append(demand_value / coefficient_of_performance) final_energy_consumed.append(demand_value / float(coefficient_of_performance))
return final_energy_consumed return final_energy_consumed
@property @property
@ -797,16 +801,18 @@ class Building(CityObject):
if self.energy_systems is None: if self.energy_systems is None:
return self._onsite_electrical_production return self._onsite_electrical_production
for energy_system in self.energy_systems: for energy_system in self.energy_systems:
if energy_system.generation_systems.generic_generation_system.type == cte.PHOTOVOLTAIC: energy_system_generation_systems = energy_system.generation_systems
_efficiency = energy_system.generation_systems.generic_generation_system.electricity_efficiency for generation_system in energy_system_generation_systems:
self._onsite_electrical_production = {} if generation_system.generic_generation_system.type == cte.PHOTOVOLTAIC:
for _key in self.roofs[0].global_irradiance.keys(): _efficiency = generation_system.generic_generation_system.electricity_efficiency
_results = [0 for _ in range(0, len(self.roofs[0].global_irradiance[_key]))] self._onsite_electrical_production = {}
for surface in self.roofs: for _key in self.roofs[0].global_irradiance.keys():
if _key in orientation_losses_factor: _results = [0 for _ in range(0, len(self.roofs[0].global_irradiance[_key]))]
_results = [x + y * _efficiency * surface.perimeter_area for surface in self.roofs:
* surface.solar_collectors_area_reduction_factor * z if _key in orientation_losses_factor:
for x, y, z in zip(_results, surface.global_irradiance[_key], _results = [x + y * _efficiency * surface.perimeter_area
orientation_losses_factor[_key]['south'])] * surface.solar_collectors_area_reduction_factor * z
self._onsite_electrical_production[_key] = _results for x, y, z in zip(_results, surface.global_irradiance[_key],
orientation_losses_factor[_key]['south'])]
self._onsite_electrical_production[_key] = _results
return self._onsite_electrical_production return self._onsite_electrical_production

View File

@ -1,6 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<EnergySystemCatalog> <EnergySystemCatalog>
<schemas_path>./schemas/</schemas_path>
<medias> <medias>
<media media_id="1" media_name="Water" density="981.0" heatCapacity="4180.0" evaporationTemperature="100.0"/> <media media_id="1" media_name="Water" density="981.0" heatCapacity="4180.0" evaporationTemperature="100.0"/>
</medias> </medias>
@ -177,6 +176,7 @@
<system_archetypes> <system_archetypes>
<system_archetype id="1"> <system_archetype id="1">
<name>PV+ASHP+GasBoiler+TES</name> <name>PV+ASHP+GasBoiler+TES</name>
<schema>schemas/PV+ASHP+GasBoiler+TES.jpg</schema>
<systems> <systems>
<system_id>7</system_id> <system_id>7</system_id>
<system_id>1</system_id> <system_id>1</system_id>
@ -184,6 +184,7 @@
</system_archetype> </system_archetype>
<system_archetype id="2"> <system_archetype id="2">
<name>PV+ASHP+ElectricBoiler+TES</name> <name>PV+ASHP+ElectricBoiler+TES</name>
<schema>schemas/PV+ASHP+ElectricBoiler+TES.jpg</schema>
<systems> <systems>
<system_id>7</system_id> <system_id>7</system_id>
<system_id>2</system_id> <system_id>2</system_id>
@ -191,6 +192,7 @@
</system_archetype> </system_archetype>
<system_archetype id="3"> <system_archetype id="3">
<name>PV+GSHP+GasBoiler+TES</name> <name>PV+GSHP+GasBoiler+TES</name>
<schema>schemas/PV+GSHP+GasBoiler+TES.jpg</schema>
<systems> <systems>
<system_id>7</system_id> <system_id>7</system_id>
<system_id>3</system_id> <system_id>3</system_id>
@ -198,6 +200,7 @@
</system_archetype> </system_archetype>
<system_archetype id="4"> <system_archetype id="4">
<name>PV+GSHP+ElectricBoiler+TES</name> <name>PV+GSHP+ElectricBoiler+TES</name>
<schema>schemas/PV+GSHP+ElectricBoiler+TES.jpg</schema>
<systems> <systems>
<system_id>7</system_id> <system_id>7</system_id>
<system_id>4</system_id> <system_id>4</system_id>
@ -205,6 +208,7 @@
</system_archetype> </system_archetype>
<system_archetype id="5"> <system_archetype id="5">
<name>PV+WSHP+GasBoiler+TES</name> <name>PV+WSHP+GasBoiler+TES</name>
<schema>schemas/PV+WSHP+GasBoiler+TES.jpg</schema>
<systems> <systems>
<system_id>7</system_id> <system_id>7</system_id>
<system_id>5</system_id> <system_id>5</system_id>
@ -212,6 +216,7 @@
</system_archetype> </system_archetype>
<system_archetype id="6"> <system_archetype id="6">
<name>PV+WSHP+ElectricBoiler+TES</name> <name>PV+WSHP+ElectricBoiler+TES</name>
<schema>schemas/PV+WSHP+ElectricBoiler+TES.jpg</schema>
<systems> <systems>
<system_id>7</system_id> <system_id>7</system_id>
<system_id>6</system_id> <system_id>6</system_id>

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

View File

@ -158,12 +158,12 @@ class NorthAmericaCustomEnergySystemParameters:
copy.deepcopy(_generic_building_generation_system) copy.deepcopy(_generic_building_generation_system)
_generation_systems.append(_building_generation_system) _generation_systems.append(_building_generation_system)
_building_energy_equipment.generation_systems = _generation_systems _building_energy_equipment.generation_systems = _generation_systems
_building_storage_system = ThermalStorageSystem() # _building_storage_system = ThermalStorageSystem()
_building_storage_system.generic_storage_system = \ # _building_storage_system.generic_storage_system = \
copy.deepcopy(_generic_building_energy_system.energy_storage_systems) # copy.deepcopy(_generic_building_energy_system.energy_storage_systems)
#
#
_building_energy_equipment.energy_storage_systems = _building_storage_system # _building_energy_equipment.energy_storage_systems = _building_storage_system
_building_energy_systems.append(_building_energy_equipment) _building_energy_systems.append(_building_energy_equipment)
building.energy_systems = _building_energy_systems building.energy_systems = _building_energy_systems

View File

@ -40,4 +40,24 @@ 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
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(21, len(generation_equipments['generation_equipments']))
storage_equipments = catalog.names('storage_equipments')
self.assertEqual(6, len(storage_equipments['storage_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)
print(catalog.entries()) print(catalog.entries())
with self.assertRaises(IndexError):
catalog.get_entry('unknown')

View File

@ -26,10 +26,12 @@ from hub.city_model_structure.energy_systems.distribution_system import Distribu
from hub.city_model_structure.energy_systems.emission_system import EmissionSystem from hub.city_model_structure.energy_systems.emission_system import EmissionSystem
from hub.city_model_structure.energy_systems.thermal_storage_system import ThermalStorageSystem from hub.city_model_structure.energy_systems.thermal_storage_system import ThermalStorageSystem
class TestSystemsFactory(TestCase): class TestSystemsFactory(TestCase):
""" """
TestSystemsFactory TestCase TestSystemsFactory TestCase
""" """
def setUp(self) -> None: def setUp(self) -> None:
""" """
Test setup Test setup
@ -160,36 +162,32 @@ class TestSystemsFactory(TestCase):
for _generic_building_energy_system in _generic_building_energy_systems: for _generic_building_energy_system in _generic_building_energy_systems:
_building_energy_equipment = EnergySystem() _building_energy_equipment = EnergySystem()
_building_energy_equipment.demand_types = _generic_building_energy_system.demand_types _building_energy_equipment.demand_types = _generic_building_energy_system.demand_types
_building_generation_systems = _generic_building_energy_system.generation_systems
_building_distribution_system = DistributionSystem() _generic_system_generation_systems = []
_building_distribution_system.generic_distribution_system = ( for _building_generation_system in _building_generation_systems:
copy.deepcopy(_generic_building_energy_system.distribution_systems) _generation_system = GenerationSystem()
) _generation_system.generic_generation_system = (
_building_emission_system = EmissionSystem() copy.deepcopy(_building_generation_system)
_building_emission_system.generic_emission_system = ( )
copy.deepcopy(_generic_building_energy_system.emission_systems) if cte.HEATING in _building_energy_equipment.demand_types:
) _generation_system.heat_power = building.heating_peak_load[cte.YEAR][0]
_building_generation_system = GenerationSystem() if cte.COOLING in _building_energy_equipment.demand_types:
_building_generation_system.generic_generation_system = ( _generation_system.cooling_power = building.cooling_peak_load[cte.YEAR][0]
copy.deepcopy(_generic_building_energy_system.generation_systems) _generic_system_generation_systems.append(_generation_system)
) print(_generic_system_generation_systems)
_building_energy_equipment.generation_systems = _generic_system_generation_systems
_building_storage_system = ThermalStorageSystem() _building_storage_system = ThermalStorageSystem()
_building_storage_system.generic_storage_system = \ _building_storage_system.generic_storage_system = \
copy.deepcopy(_generic_building_energy_system.energy_storage_systems) copy.deepcopy(_generic_building_energy_system.energy_storage_systems)
if cte.HEATING in _building_energy_equipment.demand_types:
_building_generation_system.heat_power = building.heating_peak_load[cte.YEAR][0]
if cte.COOLING in _building_energy_equipment.demand_types:
_building_generation_system.cooling_power = building.cooling_peak_load[cte.YEAR][0]
_building_energy_equipment.generation_systems = _building_generation_system
_building_energy_equipment.distribution_systems = _building_distribution_system
_building_energy_equipment.emission_systems = _building_emission_system
_building_energy_systems.append(_building_energy_equipment) _building_energy_systems.append(_building_energy_equipment)
building.energy_systems = _building_energy_systems building.energy_systems = _building_energy_systems
for building in self._city.buildings: for building in self._city.buildings:
print(building.heating_consumption[cte.YEAR][0])
print(building.cooling_consumption[cte.YEAR][0])
print(building.domestic_hot_water_consumption[cte.YEAR][0])
print(building.onsite_electrical_production[cte.YEAR][0])
self.assertLess(0, building.heating_consumption[cte.YEAR][0]) self.assertLess(0, building.heating_consumption[cte.YEAR][0])
self.assertLess(0, building.cooling_consumption[cte.YEAR][0]) self.assertEqual(0, building.cooling_consumption[cte.YEAR][0])
self.assertLess(0, building.domestic_hot_water_consumption[cte.YEAR][0]) self.assertLess(0, building.domestic_hot_water_consumption[cte.YEAR][0])
self.assertLess(0, building.onsite_electrical_production[cte.YEAR][0]) self.assertLess(0, building.onsite_electrical_production[cte.YEAR][0])