Merge branch 'systems_catalog' into meb_bugs_fixing

# Conflicts:
#	hub/city_model_structure/building.py
#	hub/imports/energy_systems/montreal_custom_energy_system_parameters.py
This commit is contained in:
Pilar Monsalvete 2023-06-01 13:55:27 -04:00
commit 665bf8159b
6 changed files with 175 additions and 84 deletions

View File

@ -54,7 +54,7 @@ class Income:
Get electricity export incomes in currency per J
:return: None or float
"""
return self._construction_subsidy
return self._electricity_export
@property
def reductions_tax(self) -> Union[None, float]:

View File

@ -86,8 +86,7 @@ class Building(CityObject):
elif surface.type == cte.INTERIOR_SLAB:
self._interior_slabs.append(surface)
else:
error = f'Building {self.name} [{self.aliases}] has an unexpected surface type {surface.type}.\n'
logging.error(error)
logging.error(f'Building {self.name} [{self.aliases}] has an unexpected surface type {surface.type}.\n')
@property
def shell(self) -> Polyhedron:
@ -567,6 +566,8 @@ class Building(CityObject):
demand = self.heating[heating_demand_key][cte.INSEL_MEB]
consumption_type = cte.HEATING
final_energy_consumed = self._calculate_consumption(consumption_type, demand)
if final_energy_consumed is None:
continue
self._heating_consumption[heating_demand_key] = final_energy_consumed
return self._heating_consumption
@ -581,6 +582,8 @@ class Building(CityObject):
demand = self.cooling[cooling_demand_key][cte.INSEL_MEB]
consumption_type = cte.COOLING
final_energy_consumed = self._calculate_consumption(consumption_type, demand)
if final_energy_consumed is None:
continue
self._cooling_consumption[cooling_demand_key] = final_energy_consumed
return self._cooling_consumption
@ -595,6 +598,8 @@ class Building(CityObject):
demand = self.domestic_hot_water_heat_demand[domestic_hot_water_demand_key][cte.INSEL_MEB]
consumption_type = cte.DOMESTIC_HOT_WATER
final_energy_consumed = self._calculate_consumption(consumption_type, demand)
if final_energy_consumed is None:
continue
self._domestic_hot_water_consumption[domestic_hot_water_demand_key] = final_energy_consumed
return self._domestic_hot_water_consumption
@ -620,7 +625,8 @@ class Building(CityObject):
value = 1
_total_hours = 0
for key in _working_hours:
_total_hours += _working_hours[key] * cte.DAYS_A_YEAR[key]
hours = sum(_working_hours[key])
_total_hours += hours * cte.DAYS_A_YEAR[key]
return _total_hours
@property
@ -631,30 +637,35 @@ class Building(CityObject):
"""
if len(self._distribution_systems_electrical_consumption) != 0:
return self._distribution_systems_electrical_consumption
_peak_load = self.heating_peak_load[cte.YEAR]['heating peak loads'][0]
_peak_load = self.heating_peak_load[cte.YEAR][cte.HEATING_PEAK_LOAD][0]
_peak_load_type = cte.HEATING
if _peak_load < self.cooling_peak_load[cte.YEAR]['cooling peak loads'][0]:
_peak_load = self.cooling_peak_load[cte.YEAR]['cooling peak loads'][0]
if _peak_load < self.cooling_peak_load[cte.YEAR][cte.COOLING_PEAK_LOAD][0]:
_peak_load = self.cooling_peak_load[cte.YEAR][cte.COOLING_PEAK_LOAD][0]
_peak_load_type = cte.COOLING
_working_hours = self._calculate_working_hours()
_consumption_fix_flow = 0
if self.energy_systems is None:
return self._distribution_systems_electrical_consumption
for energy_system in self.energy_systems:
emission_system = energy_system.emission_system.generic_emission_system
parasitic_energy_consumption = emission_system.parasitic_energy_consumption
parasitic_energy_consumption = 0
if emission_system is not None:
parasitic_energy_consumption = emission_system.parasitic_energy_consumption
distribution_system = energy_system.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:
if _peak_load_type == cte.HEATING:
if demand_type.lower() == cte.HEATING.lower():
if _peak_load_type == cte.HEATING.lower():
_consumption_fix_flow = distribution_system.distribution_consumption_fix_flow
for heating_demand_key in self.heating:
_consumption = [0]*len(self.heating)
_consumption = [0]*len(self.heating[heating_demand_key][cte.INSEL_MEB])
_demand = self.heating[heating_demand_key][cte.INSEL_MEB]
for i in enumerate(_consumption):
_consumption[i] += (parasitic_energy_consumption + consumption_variable_flow) * _demand[i]
self._distribution_systems_electrical_consumption[heating_demand_key] = _consumption
if demand_type.lower() == cte.COOLING:
if _peak_load_type == cte.COOLING:
if demand_type.lower() == cte.COOLING.lower():
if _peak_load_type == cte.COOLING.lower():
_consumption_fix_flow = distribution_system.distribution_consumption_fix_flow
for demand_key in self.cooling:
_consumption = self._distribution_systems_electrical_consumption[demand_key]
@ -663,15 +674,17 @@ class Building(CityObject):
_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 i in range(0, len(item)):
self._distribution_systems_electrical_consumption[key][i] += _peak_load * _consumption_fix_flow \
* self._calculate_working_hours()
for key, item in self._distribution_systems_electrical_consumption.items():
for i in range(0, len(item)):
self._distribution_systems_electrical_consumption[key][i] += _peak_load * _consumption_fix_flow \
* _working_hours
return self._distribution_systems_electrical_consumption
def _calculate_consumption(self, consumption_type, demand):
# todo: modify when COP depends on the hour
coefficient_of_performance = 0
if self.energy_systems is None:
return None
for energy_system in self.energy_systems:
for demand_type in energy_system.demand_types:
if demand_type.lower() == consumption_type.lower():
@ -709,6 +722,8 @@ class Building(CityObject):
'south': [1.212544],
'west': [0]}
}
if self.energy_systems is None:
return self._onsite_electrical_production
for energy_system in self.energy_systems:
if energy_system.generation_system.generic_generation_system.type == cte.PHOTOVOLTAIC:
_efficiency = energy_system.generation_system.generic_generation_system.electricity_efficiency

View File

@ -7,7 +7,6 @@ Project Coder Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
from typing import Union, List
from hub.city_model_structure.energy_systems.generic_energy_system import GenericEnergySystem
from hub.city_model_structure.energy_systems.generation_system import GenerationSystem
from hub.city_model_structure.energy_systems.distribution_system import DistributionSystem
from hub.city_model_structure.energy_systems.emission_system import EmissionSystem
@ -20,7 +19,8 @@ class EnergySystem:
EnergySystem class
"""
def __init__(self):
self._generic_energy_system = None
self._name = None
self._demand_types = None
self._generation_system = None
self._distribution_system = None
self._emission_system = None
@ -28,20 +28,36 @@ class EnergySystem:
self._control_system = None
@property
def generic_energy_system(self) -> GenericEnergySystem:
def name(self):
"""
Get associated generic_energy_system
:return: GenericEnergySystem
Get energy system name
:return: str
"""
return self._generic_energy_system
return self._name
@generic_energy_system.setter
def generic_energy_system(self, value):
@name.setter
def name(self, value):
"""
Set associated generic_energy_system
:param value: GenericEnergySystem
Set energy system name
:param value:
"""
self._generic_energy_system = value
self._name = value
@property
def demand_types(self):
"""
Get demand able to cover from [Heating, Cooling, Domestic Hot Water, Electricity]
:return: [string]
"""
return self._demand_types
@demand_types.setter
def demand_types(self, value):
"""
Set demand able to cover from [Heating, Cooling, Domestic Hot Water, Electricity]
:param value: [string]
"""
self._demand_types = value
@property
def generation_system(self) -> GenerationSystem:

View File

@ -72,13 +72,13 @@
</fuel>
<fuel fuel_type="gas">
<fixed_monthly cost_unit="currency/month"> 17.71 </fixed_monthly>
<variable cost_unit="currency/kWh"> 0.640 </variable>
<variable cost_unit="currency/kWh"> 0.0640 </variable>
</fuel>
<fuel fuel_type="diesel">
<variable cost_unit="currency/l"> 1.2 </variable>
</fuel>
<fuel fuel_type="biomass">
<variable cost_unit="currency/kg"> 0.09 </variable>
<variable cost_unit="currency/kg"> 0.04 </variable>
</fuel>
</fuels>
<maintenance>
@ -91,12 +91,12 @@
<end_of_life_cost cost_unit="currency/m2"> 6.3 </end_of_life_cost>
<incomes>
<subsidies>
<construction cost_unit="%">2</construction>
<construction cost_unit="%">20</construction>
<hvac cost_unit="%">1.5</hvac>
<photovoltaic cost_unit="%">3.6</photovoltaic>
</subsidies>
<electricity_export cost_unit="currency/kWh">0</electricity_export>
<tax_reduction cost_unit="%">2</tax_reduction>
<electricity_export cost_unit="currency/kWh">0.07</electricity_export>
<tax_reduction cost_unit="%">0.05</tax_reduction>
</incomes>
</archetype>
<archetype function="non-residential" municipality="montreal" country="CA" lod="1">
@ -172,13 +172,13 @@
</fuel>
<fuel fuel_type="gas">
<fixed_monthly cost_unit="currency/month"> 17.71 </fixed_monthly>
<variable cost_unit="currency/m3"> 0.640 </variable>
<variable cost_unit="currency/m3"> 0.0640 </variable>
</fuel>
<fuel fuel_type="diesel">
<variable cost_unit="currency/l"> 1.2 </variable>
</fuel>
<fuel fuel_type="biomass">
<variable cost_unit="currency/kg"> 0.09 </variable>
<variable cost_unit="currency/kg"> 0.04 </variable>
</fuel>
</fuels>
<maintenance>
@ -191,12 +191,12 @@
<end_of_life_cost cost_unit="currency/m2"> 6.3 </end_of_life_cost>
<incomes>
<subsidies>
<construction cost_unit="%">2</construction>
<construction cost_unit="%">20</construction>
<hvac cost_unit="%">1.5</hvac>
<photovoltaic cost_unit="%">3.6</photovoltaic>
</subsidies>
<electricity_export cost_unit="currency/kWh">0</electricity_export>
<tax_reduction cost_unit="%">2</tax_reduction>
<electricity_export cost_unit="currency/kWh">0.05</electricity_export>
<tax_reduction cost_unit="%">0.05</tax_reduction>
</incomes>
</archetype>
</archetypes>

View File

@ -108,6 +108,18 @@
<dissipation_id>1</dissipation_id>
</equipments>
</system>
<system id = "16">
<name>Unitary air conditioner with baseboard heater electrical boiler</name>
<demands>
<demand>heating</demand>
<demand>domestic_hot_water</demand>
</demands>
<equipments>
<generation_id>2</generation_id>
<distribution_id>1</distribution_id>
<dissipation_id>1</dissipation_id>
</equipments>
</system>
<system id = "2">
<name>4 pipe fan coils with fuel fired boiler</name>
<demands>
@ -275,25 +287,25 @@
<system_cluster name="system 1 gas">
<systems>
<system_id>1</system_id>
<system_id>7</system_id>
<system_id>10</system_id>
</systems>
</system_cluster>
<system_cluster name="system 1 gas pv">
<systems>
<system_id>1</system_id>
<system_id>7</system_id>
<system_id>10</system_id>
<system_id>15</system_id>
</systems>
</system_cluster>
<system_cluster name="system 1 electricity">
<systems>
<system_id>1</system_id>
<system_id>16</system_id>
<system_id>10</system_id>
</systems>
</system_cluster>
<system_cluster name="system 1 electricity pv">
<systems>
<system_id>2</system_id>
<system_id>16</system_id>
<system_id>10</system_id>
<system_id>15</system_id>
</systems>

View File

@ -4,7 +4,9 @@ SPDX - License - Identifier: LGPL - 3.0 - or -later
Copyright © 2023 Concordia CERC group
Project Coder Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
"""
import logging
import copy
from pandas import DataFrame
@ -12,6 +14,10 @@ from hub.catalog_factories.energy_systems_catalog_factory import EnergySystemsCa
from hub.city_model_structure.energy_systems.generic_distribution_system import GenericDistributionSystem
from hub.city_model_structure.energy_systems.generic_energy_system import GenericEnergySystem
from hub.city_model_structure.energy_systems.generic_generation_system import GenericGenerationSystem
from hub.city_model_structure.energy_systems.energy_system import EnergySystem
from hub.city_model_structure.energy_systems.generation_system import GenerationSystem
from hub.city_model_structure.energy_systems.distribution_system import DistributionSystem
from hub.city_model_structure.energy_systems.emission_system import EmissionSystem
from hub.helpers.dictionaries import Dictionaries
@ -47,52 +53,15 @@ class MontrealCustomEnergySystemParameters:
archetype_name)
continue
building_systems = []
data = [archetype_name, building.name]
_energy_systems_connection_table.loc[len(_energy_systems_connection_table)] = data
for equipment in archetype.systems:
energy_system = GenericEnergySystem()
_hub_demand_types = []
for demand_type in equipment.demand_types:
_hub_demand_types.append(Dictionaries().montreal_demand_type_to_hub_energy_demand_type[demand_type])
energy_system.name = archetype_name
energy_system.demand_types = _hub_demand_types
_generation_system = GenericGenerationSystem()
archetype_generation_equipment = equipment.generation_system
_type = str(equipment.name).split('_', maxsplit=1)[0]
_generation_system.type = Dictionaries().montreal_system_to_hub_energy_generation_system[
_type]
_generation_system.fuel_type = archetype_generation_equipment.fuel_type
_generation_system.source_types = archetype_generation_equipment.source_types
_generation_system.heat_efficiency = archetype_generation_equipment.heat_efficiency
_generation_system.cooling_efficiency = archetype_generation_equipment.cooling_efficiency
_generation_system.electricity_efficiency = archetype_generation_equipment.electricity_efficiency
_generation_system.source_temperature = archetype_generation_equipment.source_temperature
_generation_system.source_mass_flow = archetype_generation_equipment.source_mass_flow
_generation_system.storage = archetype_generation_equipment.storage
_generation_system.auxiliary_equipment = None
energy_system.generation_system = _generation_system
_distribution_system = GenericDistributionSystem()
archetype_distribution_equipment = equipment.distribution_system
_distribution_system.type = archetype_distribution_equipment.type
_distribution_system.supply_temperature = archetype_distribution_equipment.supply_temperature
_distribution_system.distribution_consumption_fix_flow = \
archetype_distribution_equipment.distribution_consumption_fix_flow
_distribution_system.distribution_consumption_variable_flow = \
archetype_distribution_equipment.distribution_consumption_variable_flow
_distribution_system.heat_losses = archetype_distribution_equipment.heat_losses
energy_system.distribution_system = _distribution_system
building_systems.append(energy_system)
if archetype_name not in _generic_energy_systems:
_generic_energy_systems[archetype_name] = building_systems
_energy_systems_connection_table, _generic_energy_systems \
= self._create_generic_systems(archetype, building,
_energy_systems_connection_table, _generic_energy_systems)
city.energy_systems_connection_table = _energy_systems_connection_table
city.generic_energy_systems = _generic_energy_systems
self._associate_energy_systems(city)
@staticmethod
def _search_archetypes(catalog, name):
archetypes = catalog.entries('archetypes')
@ -100,3 +69,82 @@ class MontrealCustomEnergySystemParameters:
if str(name) == str(building_archetype.name):
return building_archetype
raise KeyError('archetype not found')
@staticmethod
def _create_generic_systems(archetype, building,
_energy_systems_connection_table, _generic_energy_systems):
building_systems = []
data = [archetype.name, building.name]
_energy_systems_connection_table.loc[len(_energy_systems_connection_table)] = data
for system in archetype.systems:
energy_system = GenericEnergySystem()
_hub_demand_types = []
for demand_type in system.demand_types:
_hub_demand_types.append(Dictionaries().montreal_demand_type_to_hub_energy_demand_type[demand_type])
energy_system.name = system.name
energy_system.demand_types = _hub_demand_types
_generation_system = GenericGenerationSystem()
archetype_generation_equipment = system.generation_system
_type = str(system.name).split('_', maxsplit=1)[0]
_generation_system.type = Dictionaries().montreal_system_to_hub_energy_generation_system[
_type]
_generation_system.fuel_type = archetype_generation_equipment.fuel_type
_generation_system.source_types = archetype_generation_equipment.source_types
_generation_system.heat_efficiency = archetype_generation_equipment.heat_efficiency
_generation_system.cooling_efficiency = archetype_generation_equipment.cooling_efficiency
_generation_system.electricity_efficiency = archetype_generation_equipment.electricity_efficiency
_generation_system.source_temperature = archetype_generation_equipment.source_temperature
_generation_system.source_mass_flow = archetype_generation_equipment.source_mass_flow
_generation_system.storage = archetype_generation_equipment.storage
_generation_system.auxiliary_equipment = None
energy_system.generation_system = _generation_system
_distribution_system = GenericDistributionSystem()
archetype_distribution_equipment = system.distribution_system
_distribution_system.type = archetype_distribution_equipment.type
_distribution_system.supply_temperature = archetype_distribution_equipment.supply_temperature
_distribution_system.distribution_consumption_fix_flow = \
archetype_distribution_equipment.distribution_consumption_fix_flow
_distribution_system.distribution_consumption_variable_flow = \
archetype_distribution_equipment.distribution_consumption_variable_flow
_distribution_system.heat_losses = archetype_distribution_equipment.heat_losses
energy_system.distribution_system = _distribution_system
building_systems.append(energy_system)
if archetype.name not in _generic_energy_systems:
_generic_energy_systems[archetype.name] = building_systems
return _energy_systems_connection_table, _generic_energy_systems
@staticmethod
def _associate_energy_systems(city):
energy_systems_connection = city.energy_systems_connection_table
for building in city.buildings:
_building_energy_systems = []
energy_systems = energy_systems_connection['Energy System Type'] \
.where(energy_systems_connection['Building'] == building.name)
for energy_system in energy_systems:
_generic_building_energy_systems = city.generic_energy_systems[energy_system]
for _generic_building_energy_system in _generic_building_energy_systems:
_building_energy_equipment = EnergySystem()
_building_energy_equipment.name = _generic_building_energy_system.name
_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_system)
_building_emission_system = EmissionSystem()
_building_emission_system.generic_emission_system = \
copy.deepcopy(_generic_building_energy_system.emission_system)
_building_generation_system = GenerationSystem()
_building_generation_system.generic_generation_system = \
copy.deepcopy(_generic_building_energy_system.generation_system)
_building_energy_equipment.generation_system = _building_generation_system
_building_energy_equipment.distribution_system = _building_distribution_system
_building_energy_equipment.emission_system = _building_emission_system
_building_energy_systems.append(_building_energy_equipment)
building.energy_systems = _building_energy_systems