solved a bug in income.py and added creation of energy systems in buildings in importer
This commit is contained in:
parent
3cdad733b3
commit
22c4f362fe
|
@ -51,7 +51,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]:
|
||||
|
|
|
@ -605,6 +605,7 @@ class Building(CityObject):
|
|||
|
||||
def _calculate_working_hours(self):
|
||||
_working_hours = {}
|
||||
print('working hours')
|
||||
for internal_zone in self.internal_zones:
|
||||
for thermal_zone in internal_zone.thermal_zones:
|
||||
_working_hours_per_thermal_zone = {}
|
||||
|
@ -625,7 +626,8 @@ class Building(CityObject):
|
|||
_working_hours[key][i] = 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
|
||||
|
@ -641,6 +643,7 @@ class Building(CityObject):
|
|||
_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
|
||||
|
@ -652,29 +655,32 @@ class Building(CityObject):
|
|||
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 range(0, len(_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():
|
||||
print('works')
|
||||
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]
|
||||
print('cooling', _consumption)
|
||||
_demand = self.cooling[demand_key][cte.INSEL_MEB]
|
||||
for i in range(0, len(_consumption)):
|
||||
_consumption[i] += (parasitic_energy_consumption + consumption_variable_flow) * _demand[i]
|
||||
self._distribution_systems_electrical_consumption[demand_key] = _consumption
|
||||
print(_consumption)
|
||||
|
||||
for key in self._distribution_systems_electrical_consumption:
|
||||
for i in range(0, len(self._distribution_systems_electrical_consumption[key])):
|
||||
self._distribution_systems_electrical_consumption[key][i] += _peak_load * _consumption_fix_flow \
|
||||
* self._calculate_working_hours()
|
||||
* _working_hours
|
||||
return self._distribution_systems_electrical_consumption
|
||||
|
||||
def _calculate_consumption(self, consumption_type, demand):
|
||||
|
|
|
@ -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
|
||||
|
||||
|
||||
|
@ -46,6 +52,25 @@ class MontrealCustomEnergySystemParameters:
|
|||
logging.error(f'Building {building.name} has unknown energy system archetype for system name: {archetype_name}')
|
||||
continue
|
||||
|
||||
_energy_systems_connection_table, _generic_energy_systems \
|
||||
= self._create_generic_systems(archetype, building, archetype_name,
|
||||
_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')
|
||||
for building_archetype in archetypes:
|
||||
if str(name) == str(building_archetype.name):
|
||||
return building_archetype
|
||||
raise KeyError('archetype not found')
|
||||
|
||||
@staticmethod
|
||||
def _create_generic_systems(archetype, building, archetype_name,
|
||||
_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
|
||||
|
@ -89,13 +114,34 @@ class MontrealCustomEnergySystemParameters:
|
|||
if archetype_name not in _generic_energy_systems:
|
||||
_generic_energy_systems[archetype_name] = building_systems
|
||||
|
||||
city.energy_systems_connection_table = _energy_systems_connection_table
|
||||
city.generic_energy_systems = _generic_energy_systems
|
||||
return _energy_systems_connection_table, _generic_energy_systems
|
||||
|
||||
@staticmethod
|
||||
def _search_archetypes(catalog, name):
|
||||
archetypes = catalog.entries('archetypes')
|
||||
for building_archetype in archetypes:
|
||||
if str(name) == str(building_archetype.name):
|
||||
return building_archetype
|
||||
raise KeyError('archetype not found')
|
||||
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.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
|
||||
|
|
Loading…
Reference in New Issue
Block a user