Compare commits
5 Commits
main
...
energy_sys
Author | SHA1 | Date | |
---|---|---|---|
78795acdcf | |||
3a7f9173c7 | |||
f2d78c381e | |||
1801aa6f00 | |||
0c7371787b |
|
@ -15,10 +15,11 @@ class Archetype:
|
|||
"""
|
||||
Archetype class
|
||||
"""
|
||||
def __init__(self, lod, name, systems):
|
||||
def __init__(self, lod, name, schema, systems):
|
||||
|
||||
self._lod = lod
|
||||
self._name = name
|
||||
self._schema = schema
|
||||
self._systems = systems
|
||||
|
||||
@property
|
||||
|
@ -37,6 +38,14 @@ class Archetype:
|
|||
"""
|
||||
return self._name
|
||||
|
||||
@property
|
||||
def schema(self):
|
||||
"""
|
||||
Get schema path
|
||||
:return: string
|
||||
"""
|
||||
return self._schema
|
||||
|
||||
@property
|
||||
def systems(self) -> List[System]:
|
||||
"""
|
||||
|
@ -53,6 +62,7 @@ class Archetype:
|
|||
content = {
|
||||
'Archetype': {
|
||||
'name': self.name,
|
||||
'schema': self.schema,
|
||||
'level of detail': self.lod,
|
||||
'systems': _systems
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ Project Coder Saeed Ranjbar saeed.ranjbar@concordia.ca
|
|||
Code contributors: Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
|
||||
"""
|
||||
|
||||
from pathlib import Path
|
||||
import xmltodict
|
||||
from hub.catalog_factories.catalog import Catalog
|
||||
from hub.catalog_factories.data_models.energy_systems.system import System
|
||||
|
@ -366,17 +367,19 @@ class NorthAmericaEnergySystemCatalog(Catalog):
|
|||
return _catalog_systems
|
||||
|
||||
def _load_archetypes(self):
|
||||
base_path = Path(Path(__file__).parent.parent.parent / 'data/energy_systems')
|
||||
_system_archetypes = []
|
||||
system_clusters = self._archetypes['EnergySystemCatalog']['system_archetypes']['system_archetype']
|
||||
for system_cluster in system_clusters:
|
||||
name = system_cluster['name']
|
||||
schema_path = Path(base_path / system_cluster['schema'])
|
||||
systems = system_cluster['systems']['system_id']
|
||||
integer_system_ids = [int(item) for item in systems]
|
||||
_systems = []
|
||||
for system_archetype in self._systems:
|
||||
if int(system_archetype.id) in integer_system_ids:
|
||||
_systems.append(system_archetype)
|
||||
_system_archetypes.append(Archetype(None, name, _systems))
|
||||
_system_archetypes.append(Archetype(None, name, schema_path, _systems))
|
||||
return _system_archetypes
|
||||
|
||||
def _load_materials(self):
|
||||
|
|
|
@ -27,6 +27,7 @@ class Building(CityObject):
|
|||
"""
|
||||
Building(CityObject) class
|
||||
"""
|
||||
|
||||
def __init__(self, name, surfaces, year_of_construction, function, terrains=None, city=None):
|
||||
super().__init__(name, surfaces)
|
||||
self._city = city
|
||||
|
@ -715,11 +716,15 @@ class Building(CityObject):
|
|||
if self.energy_systems is None:
|
||||
return self._distribution_systems_electrical_consumption
|
||||
for energy_system in self.energy_systems:
|
||||
emission_system = energy_system.emission_systems.generic_emission_system
|
||||
energy_emission_systems = energy_system.emission_systems
|
||||
energy_distribution_systems = energy_system.distribution_systems
|
||||
for energy_emission_system in energy_distribution_systems:
|
||||
emission_system = energy_emission_system.generic_emission_system
|
||||
parasitic_energy_consumption = 0
|
||||
if emission_system is not None:
|
||||
parasitic_energy_consumption = emission_system.parasitic_energy_consumption
|
||||
distribution_system = energy_system.distribution_systems.generic_distribution_system
|
||||
for energy_distribution_system in energy_emission_systems:
|
||||
distribution_system = energy_distribution_system.generic_distribution_system
|
||||
consumption_variable_flow = distribution_system.distribution_consumption_variable_flow
|
||||
for demand_type in energy_system.demand_types:
|
||||
if demand_type.lower() == cte.HEATING.lower():
|
||||
|
@ -753,27 +758,26 @@ class Building(CityObject):
|
|||
if self.energy_systems is None:
|
||||
return None
|
||||
for energy_system in self.energy_systems:
|
||||
generation_systems = energy_system.generation_systems
|
||||
print(generation_systems)
|
||||
print(type(generation_systems))
|
||||
energy_system_generation_systems = energy_system.generation_systems
|
||||
for demand_type in energy_system.demand_types:
|
||||
if demand_type.lower() == consumption_type.lower():
|
||||
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
|
||||
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
|
||||
elif consumption_type == cte.ELECTRICITY:
|
||||
for generation_system in generation_systems:
|
||||
coefficient_of_performance = generation_system.generic_generation_system.electricity_efficiency
|
||||
for generation_system in energy_system_generation_systems:
|
||||
coefficient_of_performance = \
|
||||
generation_system.generic_generation_system.electricity_efficiency
|
||||
if coefficient_of_performance == 0:
|
||||
values = [0] * len(demand)
|
||||
final_energy_consumed = values
|
||||
else:
|
||||
final_energy_consumed = []
|
||||
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
|
||||
|
||||
@property
|
||||
|
@ -797,8 +801,10 @@ class Building(CityObject):
|
|||
if self.energy_systems is None:
|
||||
return self._onsite_electrical_production
|
||||
for energy_system in self.energy_systems:
|
||||
if energy_system.generation_systems.generic_generation_system.type == cte.PHOTOVOLTAIC:
|
||||
_efficiency = energy_system.generation_systems.generic_generation_system.electricity_efficiency
|
||||
energy_system_generation_systems = energy_system.generation_systems
|
||||
for generation_system in energy_system_generation_systems:
|
||||
if generation_system.generic_generation_system.type == cte.PHOTOVOLTAIC:
|
||||
_efficiency = generation_system.generic_generation_system.electricity_efficiency
|
||||
self._onsite_electrical_production = {}
|
||||
for _key in self.roofs[0].global_irradiance.keys():
|
||||
_results = [0 for _ in range(0, len(self.roofs[0].global_irradiance[_key]))]
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<EnergySystemCatalog>
|
||||
<schemas_path>./schemas/</schemas_path>
|
||||
<medias>
|
||||
<media media_id="1" media_name="Water" density="981.0" heatCapacity="4180.0" evaporationTemperature="100.0"/>
|
||||
</medias>
|
||||
|
@ -177,6 +176,7 @@
|
|||
<system_archetypes>
|
||||
<system_archetype id="1">
|
||||
<name>PV+ASHP+GasBoiler+TES</name>
|
||||
<schema>schemas/PV+ASHP+GasBoiler+TES.jpg</schema>
|
||||
<systems>
|
||||
<system_id>7</system_id>
|
||||
<system_id>1</system_id>
|
||||
|
@ -184,6 +184,7 @@
|
|||
</system_archetype>
|
||||
<system_archetype id="2">
|
||||
<name>PV+ASHP+ElectricBoiler+TES</name>
|
||||
<schema>schemas/PV+ASHP+ElectricBoiler+TES.jpg</schema>
|
||||
<systems>
|
||||
<system_id>7</system_id>
|
||||
<system_id>2</system_id>
|
||||
|
@ -191,6 +192,7 @@
|
|||
</system_archetype>
|
||||
<system_archetype id="3">
|
||||
<name>PV+GSHP+GasBoiler+TES</name>
|
||||
<schema>schemas/PV+GSHP+GasBoiler+TES.jpg</schema>
|
||||
<systems>
|
||||
<system_id>7</system_id>
|
||||
<system_id>3</system_id>
|
||||
|
@ -198,6 +200,7 @@
|
|||
</system_archetype>
|
||||
<system_archetype id="4">
|
||||
<name>PV+GSHP+ElectricBoiler+TES</name>
|
||||
<schema>schemas/PV+GSHP+ElectricBoiler+TES.jpg</schema>
|
||||
<systems>
|
||||
<system_id>7</system_id>
|
||||
<system_id>4</system_id>
|
||||
|
@ -205,6 +208,7 @@
|
|||
</system_archetype>
|
||||
<system_archetype id="5">
|
||||
<name>PV+WSHP+GasBoiler+TES</name>
|
||||
<schema>schemas/PV+WSHP+GasBoiler+TES.jpg</schema>
|
||||
<systems>
|
||||
<system_id>7</system_id>
|
||||
<system_id>5</system_id>
|
||||
|
@ -212,6 +216,7 @@
|
|||
</system_archetype>
|
||||
<system_archetype id="6">
|
||||
<name>PV+WSHP+ElectricBoiler+TES</name>
|
||||
<schema>schemas/PV+WSHP+ElectricBoiler+TES.jpg</schema>
|
||||
<systems>
|
||||
<system_id>7</system_id>
|
||||
<system_id>6</system_id>
|
||||
|
|
BIN
hub/data/energy_systems/schemas/PV+ASHP+ElectricBoiler+TES.jpg
Normal file
BIN
hub/data/energy_systems/schemas/PV+ASHP+ElectricBoiler+TES.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 64 KiB |
BIN
hub/data/energy_systems/schemas/PV+ASHP+GasBoiler+TES.jpg
Normal file
BIN
hub/data/energy_systems/schemas/PV+ASHP+GasBoiler+TES.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 64 KiB |
BIN
hub/data/energy_systems/schemas/PV+GSHP+ElectricBoiler+TES.jpg
Normal file
BIN
hub/data/energy_systems/schemas/PV+GSHP+ElectricBoiler+TES.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 64 KiB |
BIN
hub/data/energy_systems/schemas/PV+GSHP+GasBoiler+TES.jpg
Normal file
BIN
hub/data/energy_systems/schemas/PV+GSHP+GasBoiler+TES.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 64 KiB |
BIN
hub/data/energy_systems/schemas/PV+WSHP+ElectricBoiler+TES.jpg
Normal file
BIN
hub/data/energy_systems/schemas/PV+WSHP+ElectricBoiler+TES.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 64 KiB |
BIN
hub/data/energy_systems/schemas/PV+WSHP+GasBoiler+TES.jpg
Normal file
BIN
hub/data/energy_systems/schemas/PV+WSHP+GasBoiler+TES.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 64 KiB |
|
@ -158,12 +158,12 @@ class NorthAmericaCustomEnergySystemParameters:
|
|||
copy.deepcopy(_generic_building_generation_system)
|
||||
_generation_systems.append(_building_generation_system)
|
||||
_building_energy_equipment.generation_systems = _generation_systems
|
||||
_building_storage_system = ThermalStorageSystem()
|
||||
_building_storage_system.generic_storage_system = \
|
||||
copy.deepcopy(_generic_building_energy_system.energy_storage_systems)
|
||||
|
||||
|
||||
_building_energy_equipment.energy_storage_systems = _building_storage_system
|
||||
# _building_storage_system = ThermalStorageSystem()
|
||||
# _building_storage_system.generic_storage_system = \
|
||||
# copy.deepcopy(_generic_building_energy_system.energy_storage_systems)
|
||||
#
|
||||
#
|
||||
# _building_energy_equipment.energy_storage_systems = _building_storage_system
|
||||
|
||||
_building_energy_systems.append(_building_energy_equipment)
|
||||
building.energy_systems = _building_energy_systems
|
||||
|
|
|
@ -40,4 +40,24 @@ class TestSystemsCatalog(TestCase):
|
|||
|
||||
def test_north_america_systems_catalog(self):
|
||||
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())
|
||||
|
||||
with self.assertRaises(IndexError):
|
||||
catalog.get_entry('unknown')
|
||||
|
|
|
@ -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.thermal_storage_system import ThermalStorageSystem
|
||||
|
||||
|
||||
class TestSystemsFactory(TestCase):
|
||||
"""
|
||||
TestSystemsFactory TestCase
|
||||
"""
|
||||
|
||||
def setUp(self) -> None:
|
||||
"""
|
||||
Test setup
|
||||
|
@ -160,36 +162,32 @@ class TestSystemsFactory(TestCase):
|
|||
for _generic_building_energy_system in _generic_building_energy_systems:
|
||||
_building_energy_equipment = EnergySystem()
|
||||
_building_energy_equipment.demand_types = _generic_building_energy_system.demand_types
|
||||
|
||||
_building_distribution_system = DistributionSystem()
|
||||
_building_distribution_system.generic_distribution_system = (
|
||||
copy.deepcopy(_generic_building_energy_system.distribution_systems)
|
||||
)
|
||||
_building_emission_system = EmissionSystem()
|
||||
_building_emission_system.generic_emission_system = (
|
||||
copy.deepcopy(_generic_building_energy_system.emission_systems)
|
||||
)
|
||||
_building_generation_system = GenerationSystem()
|
||||
_building_generation_system.generic_generation_system = (
|
||||
copy.deepcopy(_generic_building_energy_system.generation_systems)
|
||||
_building_generation_systems = _generic_building_energy_system.generation_systems
|
||||
_generic_system_generation_systems = []
|
||||
for _building_generation_system in _building_generation_systems:
|
||||
_generation_system = GenerationSystem()
|
||||
_generation_system.generic_generation_system = (
|
||||
copy.deepcopy(_building_generation_system)
|
||||
)
|
||||
if cte.HEATING in _building_energy_equipment.demand_types:
|
||||
_generation_system.heat_power = building.heating_peak_load[cte.YEAR][0]
|
||||
if cte.COOLING in _building_energy_equipment.demand_types:
|
||||
_generation_system.cooling_power = building.cooling_peak_load[cte.YEAR][0]
|
||||
_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.generic_storage_system = \
|
||||
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 = _building_energy_systems
|
||||
|
||||
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.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.onsite_electrical_production[cte.YEAR][0])
|
Loading…
Reference in New Issue
Block a user