Compare commits
6 Commits
main
...
summercour
Author | SHA1 | Date | |
---|---|---|---|
4c49d51a26 | |||
d48d811787 | |||
b74e0f21b5 | |||
95698d61ed | |||
44dff9b47e | |||
6c4559b3d6 |
249
input_files/eilat.geojson
Normal file
249
input_files/eilat.geojson
Normal file
@ -0,0 +1,249 @@
|
|||||||
|
{
|
||||||
|
"type": "FeatureCollection",
|
||||||
|
"features": [
|
||||||
|
{
|
||||||
|
"type": "Feature",
|
||||||
|
"id": 1,
|
||||||
|
"properties": {
|
||||||
|
"heightmax": 9,
|
||||||
|
"ANNEE_CONS": 1978,
|
||||||
|
"CODE_UTILI": "residential"
|
||||||
|
},
|
||||||
|
"geometry": {
|
||||||
|
"coordinates": [
|
||||||
|
[
|
||||||
|
[
|
||||||
|
34.95217088371581,
|
||||||
|
29.56694805860026
|
||||||
|
],
|
||||||
|
[
|
||||||
|
34.95262396587913,
|
||||||
|
29.566952667742285
|
||||||
|
],
|
||||||
|
[
|
||||||
|
34.95261999147337,
|
||||||
|
29.567024109421467
|
||||||
|
],
|
||||||
|
[
|
||||||
|
34.952169558914704,
|
||||||
|
29.567019500282157
|
||||||
|
],
|
||||||
|
[
|
||||||
|
34.95217088371581,
|
||||||
|
29.56694805860026
|
||||||
|
]
|
||||||
|
]
|
||||||
|
],
|
||||||
|
"type": "Polygon"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "Feature",
|
||||||
|
"id": 3,
|
||||||
|
"properties": {
|
||||||
|
"heightmax": 16,
|
||||||
|
"ANNEE_CONS": 2012,
|
||||||
|
"CODE_UTILI": "dormitory"
|
||||||
|
},
|
||||||
|
"geometry": {
|
||||||
|
"coordinates": [
|
||||||
|
[
|
||||||
|
[
|
||||||
|
34.95176644317411,
|
||||||
|
29.56827388702702
|
||||||
|
],
|
||||||
|
[
|
||||||
|
34.95176550020565,
|
||||||
|
29.568180388329026
|
||||||
|
],
|
||||||
|
[
|
||||||
|
34.95179850408434,
|
||||||
|
29.568180388329026
|
||||||
|
],
|
||||||
|
[
|
||||||
|
34.95179850408434,
|
||||||
|
29.5681303582886
|
||||||
|
],
|
||||||
|
[
|
||||||
|
34.95176644317411,
|
||||||
|
29.5681303582886
|
||||||
|
],
|
||||||
|
[
|
||||||
|
34.95176644317411,
|
||||||
|
29.568038499789708
|
||||||
|
],
|
||||||
|
[
|
||||||
|
34.951874884488376,
|
||||||
|
29.568038499789708
|
||||||
|
],
|
||||||
|
[
|
||||||
|
34.951874884488376,
|
||||||
|
29.568058183760357
|
||||||
|
],
|
||||||
|
[
|
||||||
|
34.95192391882168,
|
||||||
|
29.568058183760357
|
||||||
|
],
|
||||||
|
[
|
||||||
|
34.951922032885705,
|
||||||
|
29.56804178045124
|
||||||
|
],
|
||||||
|
[
|
||||||
|
34.95205216246262,
|
||||||
|
29.568042600617147
|
||||||
|
],
|
||||||
|
[
|
||||||
|
34.952051219494166,
|
||||||
|
29.568129538124154
|
||||||
|
],
|
||||||
|
[
|
||||||
|
34.95201821561636,
|
||||||
|
29.5681303582886
|
||||||
|
],
|
||||||
|
[
|
||||||
|
34.95201821561636,
|
||||||
|
29.568176287507143
|
||||||
|
],
|
||||||
|
[
|
||||||
|
34.95204839059062,
|
||||||
|
29.568176287507143
|
||||||
|
],
|
||||||
|
[
|
||||||
|
34.95205027652662,
|
||||||
|
29.56827552735433
|
||||||
|
],
|
||||||
|
[
|
||||||
|
34.95195503676348,
|
||||||
|
29.568274707190284
|
||||||
|
],
|
||||||
|
[
|
||||||
|
34.95195597973188,
|
||||||
|
29.56825830391628
|
||||||
|
],
|
||||||
|
[
|
||||||
|
34.951849424353696,
|
||||||
|
29.56825830391628
|
||||||
|
],
|
||||||
|
[
|
||||||
|
34.951849424353696,
|
||||||
|
29.568274707190284
|
||||||
|
],
|
||||||
|
[
|
||||||
|
34.95176644317411,
|
||||||
|
29.56827388702702
|
||||||
|
]
|
||||||
|
]
|
||||||
|
],
|
||||||
|
"type": "Polygon"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "Feature",
|
||||||
|
"id": 2,
|
||||||
|
"properties": {
|
||||||
|
"heightmax": 24,
|
||||||
|
"ANNEE_CONS": 2002,
|
||||||
|
"CODE_UTILI": "Hotel employ"
|
||||||
|
},
|
||||||
|
"geometry": {
|
||||||
|
"coordinates": [
|
||||||
|
[
|
||||||
|
[
|
||||||
|
34.94972280674813,
|
||||||
|
29.566224752287738
|
||||||
|
],
|
||||||
|
[
|
||||||
|
34.94974316291999,
|
||||||
|
29.56597561012454
|
||||||
|
],
|
||||||
|
[
|
||||||
|
34.94989147217407,
|
||||||
|
29.565980668855033
|
||||||
|
],
|
||||||
|
[
|
||||||
|
34.94987402402688,
|
||||||
|
29.566233605043536
|
||||||
|
],
|
||||||
|
[
|
||||||
|
34.94972280674813,
|
||||||
|
29.566224752287738
|
||||||
|
]
|
||||||
|
]
|
||||||
|
],
|
||||||
|
"type": "Polygon"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "Feature",
|
||||||
|
"id": 4,
|
||||||
|
"properties": {
|
||||||
|
"heightmax": 24,
|
||||||
|
"ANNEE_CONS": 2002,
|
||||||
|
"CODE_UTILI": "Hotel employ"
|
||||||
|
},
|
||||||
|
"geometry": {
|
||||||
|
"coordinates": [
|
||||||
|
[
|
||||||
|
[
|
||||||
|
34.9492572120038,
|
||||||
|
29.565899295950373
|
||||||
|
],
|
||||||
|
[
|
||||||
|
34.949411568175805,
|
||||||
|
29.565906093785898
|
||||||
|
],
|
||||||
|
[
|
||||||
|
34.94939398329561,
|
||||||
|
29.56615761339161
|
||||||
|
],
|
||||||
|
[
|
||||||
|
34.94924158099852,
|
||||||
|
29.566149116117728
|
||||||
|
],
|
||||||
|
[
|
||||||
|
34.9492572120038,
|
||||||
|
29.565899295950373
|
||||||
|
]
|
||||||
|
]
|
||||||
|
],
|
||||||
|
"type": "Polygon"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "Feature",
|
||||||
|
"id": 5,
|
||||||
|
"properties": {
|
||||||
|
"heightmax": 9,
|
||||||
|
"ANNEE_CONS": 1978,
|
||||||
|
"CODE_UTILI": "residential"
|
||||||
|
},
|
||||||
|
"geometry": {
|
||||||
|
"coordinates": [
|
||||||
|
[
|
||||||
|
[
|
||||||
|
34.95213398400861,
|
||||||
|
29.567197394967593
|
||||||
|
],
|
||||||
|
[
|
||||||
|
34.95258172690612,
|
||||||
|
29.56720586098278
|
||||||
|
],
|
||||||
|
[
|
||||||
|
34.95258172690612,
|
||||||
|
29.56727217807996
|
||||||
|
],
|
||||||
|
[
|
||||||
|
34.952132361751325,
|
||||||
|
29.56726935607685
|
||||||
|
],
|
||||||
|
[
|
||||||
|
34.95213398400861,
|
||||||
|
29.567197394967593
|
||||||
|
]
|
||||||
|
]
|
||||||
|
],
|
||||||
|
"type": "Polygon"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
27
main.py
27
main.py
@ -12,9 +12,10 @@ from sra_engine import SraEngine
|
|||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
file_path = (Path(__file__).parent / 'input_files' / 'output_buildings.geojson')
|
file_path = (Path(__file__).parent / 'input_files' / 'eilat.geojson')
|
||||||
construction_format = 'nrcan'
|
climate_reference_city = 'Montreal'
|
||||||
usage_format = 'nrcan'
|
construction_format = 'eilat'
|
||||||
|
usage_format = 'eilat'
|
||||||
energy_systems_format = 'montreal_custom'
|
energy_systems_format = 'montreal_custom'
|
||||||
|
|
||||||
out_path = (Path(__file__).parent / 'output_files')
|
out_path = (Path(__file__).parent / 'output_files')
|
||||||
@ -23,30 +24,26 @@ try:
|
|||||||
print('[simulation start]')
|
print('[simulation start]')
|
||||||
city = GeometryFactory('geojson',
|
city = GeometryFactory('geojson',
|
||||||
path=file_path,
|
path=file_path,
|
||||||
height_field='height',
|
height_field='heightmax',
|
||||||
year_of_construction_field='year_of_construction',
|
year_of_construction_field='ANNEE_CONS',
|
||||||
function_field='function',
|
function_field='CODE_UTILI',
|
||||||
function_to_hub=Dictionaries().montreal_function_to_hub_function).city
|
function_to_hub=Dictionaries().eilat_function_to_hub_function).city
|
||||||
|
|
||||||
print(f'city created from {file_path}')
|
print(f'city created from {file_path}')
|
||||||
ConstructionFactory(construction_format, city).enrich()
|
ConstructionFactory(construction_format, city).enrich()
|
||||||
print('enrich constructions... done')
|
print('enrich constructions... done')
|
||||||
UsageFactory(usage_format, city).enrich()
|
UsageFactory(usage_format, city).enrich()
|
||||||
print('enrich usage... done')
|
print('enrich usage... done')
|
||||||
i = 1
|
|
||||||
x = len(city.buildings)
|
|
||||||
for building in city.buildings:
|
for building in city.buildings:
|
||||||
if i < x:
|
building.energy_systems_archetype_name = 'system 1 gas pv'
|
||||||
building.energy_systems_archetype_name = 'system 1 gas'
|
|
||||||
else:
|
|
||||||
building.energy_systems_archetype_name = 'system 6 gas'
|
|
||||||
i = i + 1
|
|
||||||
EnergySystemsFactory(energy_systems_format, city).enrich()
|
EnergySystemsFactory(energy_systems_format, city).enrich()
|
||||||
print('enrich systems... done')
|
print('enrich systems... done')
|
||||||
|
|
||||||
print('exporting:')
|
print('exporting:')
|
||||||
SraEngine(city, tmp_folder)
|
sra_file = (tmp_folder / f'{city.name}_sra.xml').resolve()
|
||||||
|
SraEngine(city, sra_file, tmp_folder)
|
||||||
print(' sra processed...')
|
print(' sra processed...')
|
||||||
|
|
||||||
MonthlyEnergyBalanceEngine(city, tmp_folder)
|
MonthlyEnergyBalanceEngine(city, tmp_folder)
|
||||||
print(' insel processed...')
|
print(' insel processed...')
|
||||||
|
|
||||||
|
44
peak_load_class.py
Normal file
44
peak_load_class.py
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
from pathlib import Path
|
||||||
|
import pandas as pd
|
||||||
|
import hub.helpers.constants as cte
|
||||||
|
|
||||||
|
def Peak_load (building):
|
||||||
|
array = [None] * 12
|
||||||
|
heating = 0
|
||||||
|
cooling = 0
|
||||||
|
for system in building.energy_systems:
|
||||||
|
for demand_type in system.demand_types:
|
||||||
|
if demand_type == cte.HEATING:
|
||||||
|
heating = 1
|
||||||
|
if demand_type == cte.COOLING:
|
||||||
|
cooling = 1
|
||||||
|
if cte.MONTH in building.heating_peak_load.keys() and cte.MONTH in building.cooling_peak_load.keys():
|
||||||
|
peak_lighting = 0
|
||||||
|
peak_appliances = 0
|
||||||
|
for thermal_zone in building.internal_zones[0].thermal_zones:
|
||||||
|
lighting = thermal_zone.lighting
|
||||||
|
for schedule in lighting.schedules:
|
||||||
|
for value in schedule.values:
|
||||||
|
if value * lighting.density * thermal_zone.total_floor_area > peak_lighting:
|
||||||
|
peak_lighting = value * lighting.density * thermal_zone.total_floor_area
|
||||||
|
appliances = thermal_zone.appliances
|
||||||
|
for schedule in appliances.schedules:
|
||||||
|
for value in schedule.values:
|
||||||
|
if value * appliances.density * thermal_zone.total_floor_area > peak_appliances:
|
||||||
|
peak_appliances = value * appliances.density * thermal_zone.total_floor_area
|
||||||
|
|
||||||
|
monthly_electricity_peak = [0.9 * peak_lighting + 0.7 * peak_appliances] * 12
|
||||||
|
conditioning_peak = []
|
||||||
|
for i, value in enumerate(building.heating_peak_load[cte.MONTH]):
|
||||||
|
if cooling * building.cooling_peak_load[cte.MONTH][i] > heating * value:
|
||||||
|
conditioning_peak.append(cooling * building.cooling_peak_load[cte.MONTH][i])
|
||||||
|
else:
|
||||||
|
conditioning_peak.append(heating * value)
|
||||||
|
monthly_electricity_peak[i] += 0.8 * conditioning_peak[i]
|
||||||
|
|
||||||
|
electricity_peak_load_results = pd.DataFrame(monthly_electricity_peak
|
||||||
|
, columns=[f'{building.name} electricity peak load W'])
|
||||||
|
else:
|
||||||
|
electricity_peak_load_results = pd.DataFrame(array, columns=[f'{building.name} electricity peak load W'])
|
||||||
|
|
||||||
|
return electricity_peak_load_results
|
277
results.py
277
results.py
@ -9,50 +9,68 @@ class Results:
|
|||||||
self._path = path
|
self._path = path
|
||||||
|
|
||||||
def print(self):
|
def print(self):
|
||||||
|
print_results = None
|
||||||
file = 'city name: ' + self._city.name + '\n'
|
file = 'city name: ' + self._city.name + '\n'
|
||||||
|
array = [None] * 12
|
||||||
for building in self._city.buildings:
|
for building in self._city.buildings:
|
||||||
if cte.MONTH in building.heating_demand.keys():
|
if cte.MONTH in building.heating_demand.keys():
|
||||||
heating_results = building.heating_demand[cte.MONTH]
|
heating_results = building.heating_demand[cte.MONTH].rename(columns={cte.INSEL_MEB: f'{building.name} heating Wh'})
|
||||||
else:
|
else:
|
||||||
heating_results = [None] * 12
|
heating_results = pd.DataFrame(array, columns=[f'{building.name} heating demand Wh'])
|
||||||
if cte.MONTH in building.cooling_demand.keys():
|
if cte.MONTH in building.cooling_demand.keys():
|
||||||
cooling_results = building.cooling_demand[cte.MONTH]
|
cooling_results = building.cooling_demand[cte.MONTH].rename(columns={cte.INSEL_MEB: f'{building.name} cooling Wh'})
|
||||||
else:
|
else:
|
||||||
cooling_results = [None] * 12
|
cooling_results = pd.DataFrame(array, columns=[f'{building.name} cooling demand Wh'])
|
||||||
if cte.MONTH in building.lighting_electrical_demand.keys():
|
if cte.MONTH in building.lighting_electrical_demand.keys():
|
||||||
lighting_results = building.lighting_electrical_demand[cte.MONTH]
|
lighting_results = building.lighting_electrical_demand[cte.MONTH]\
|
||||||
|
.rename(columns={cte.INSEL_MEB: f'{building.name} lighting electrical demand Wh'})
|
||||||
else:
|
else:
|
||||||
lighting_results = [None] * 12
|
lighting_results = pd.DataFrame(array, columns=[f'{building.name} lighting electrical demand Wh'])
|
||||||
if cte.MONTH in building.appliances_electrical_demand.keys():
|
if cte.MONTH in building.appliances_electrical_demand.keys():
|
||||||
appliances_results = building.appliances_electrical_demand[cte.MONTH]
|
appliances_results = building.appliances_electrical_demand[cte.MONTH]\
|
||||||
|
.rename(columns={cte.INSEL_MEB: f'{building.name} appliances electrical demand Wh'})
|
||||||
else:
|
else:
|
||||||
appliances_results = [None] * 12
|
appliances_results = pd.DataFrame(array, columns=[f'{building.name} appliances electrical demand Wh'])
|
||||||
if cte.MONTH in building.domestic_hot_water_heat_demand.keys():
|
if cte.MONTH in building.domestic_hot_water_heat_demand.keys():
|
||||||
dhw_results = building.domestic_hot_water_heat_demand[cte.MONTH]
|
dhw_results = building.domestic_hot_water_heat_demand[cte.MONTH]\
|
||||||
|
.rename(columns={cte.INSEL_MEB: f'{building.name} domestic hot water demand Wh'})
|
||||||
else:
|
else:
|
||||||
dhw_results = [None] * 12
|
dhw_results = pd.DataFrame(array, columns=[f'{building.name} domestic hot water demand Wh'])
|
||||||
|
|
||||||
if cte.MONTH in building.heating_consumption.keys():
|
if cte.MONTH in building.heating_consumption.keys():
|
||||||
heating_consumption_results = building.heating_consumption[cte.MONTH]
|
heating_consumption_results = pd.DataFrame(building.heating_consumption[cte.MONTH],
|
||||||
|
columns=[f'{building.name} heating consumption Wh'])
|
||||||
else:
|
else:
|
||||||
heating_consumption_results = [None] * 12
|
heating_consumption_results = pd.DataFrame(array, columns=[f'{building.name} heating consumption Wh'])
|
||||||
if cte.MONTH in building.cooling_consumption.keys():
|
if cte.MONTH in building.cooling_consumption.keys():
|
||||||
cooling_consumption_results = building.cooling_consumption[cte.MONTH]
|
cooling_consumption_results = pd.DataFrame(building.cooling_consumption[cte.MONTH],
|
||||||
|
columns=[f'{building.name} cooling consumption Wh'])
|
||||||
else:
|
else:
|
||||||
cooling_consumption_results = [None] * 12
|
cooling_consumption_results = pd.DataFrame(array, columns=[f'{building.name} cooling consumption Wh'])
|
||||||
if cte.MONTH in building.domestic_hot_water_consumption.keys():
|
if cte.MONTH in building.domestic_hot_water_consumption.keys():
|
||||||
dhw_consumption_results = building.domestic_hot_water_consumption[cte.MONTH]
|
dhw_consumption_results = pd.DataFrame(building.domestic_hot_water_consumption[cte.MONTH],
|
||||||
|
columns=[f'{building.name} domestic hot water consumption Wh'])
|
||||||
else:
|
else:
|
||||||
dhw_consumption_results = [None] * 12
|
dhw_consumption_results = pd.DataFrame(array, columns=[f'{building.name} domestic hot water consumption Wh'])
|
||||||
|
|
||||||
if cte.MONTH in building.heating_peak_load.keys():
|
if cte.MONTH in building.heating_peak_load.keys():
|
||||||
heating_peak_load_results = building.heating_peak_load[cte.MONTH]
|
heating_peak_load_results = pd.DataFrame(building.heating_peak_load[cte.MONTH],
|
||||||
|
columns=[f'{building.name} heating peak load W'])
|
||||||
else:
|
else:
|
||||||
heating_peak_load_results = [None] * 12
|
heating_peak_load_results = pd.DataFrame(array, columns=[f'{building.name} heating peak load W'])
|
||||||
if cte.MONTH in building.cooling_peak_load.keys():
|
if cte.MONTH in building.cooling_peak_load.keys():
|
||||||
cooling_peak_load_results = building.cooling_peak_load[cte.MONTH]
|
cooling_peak_load_results = pd.DataFrame(building.cooling_peak_load[cte.MONTH],
|
||||||
|
columns=[f'{building.name} cooling peak load W'])
|
||||||
else:
|
else:
|
||||||
cooling_peak_load_results = [None] * 12
|
cooling_peak_load_results = pd.DataFrame(array, columns=[f'{building.name} cooling peak load W'])
|
||||||
|
|
||||||
|
if cte.MONTH in building.onsite_electrical_production.keys():
|
||||||
|
monthly_onsite_electrical_production = building.onsite_electrical_production[cte.MONTH]
|
||||||
|
onsite_electrical_production = pd.DataFrame(monthly_onsite_electrical_production,
|
||||||
|
columns=[f'{building.name} onsite electrical production Wh'])
|
||||||
|
else:
|
||||||
|
onsite_electrical_production = pd.DataFrame(array, columns=[f'{building.name} onsite electrical production Wh'])
|
||||||
|
|
||||||
heating = 0
|
heating = 0
|
||||||
cooling = 0
|
cooling = 0
|
||||||
for system in building.energy_systems:
|
for system in building.energy_systems:
|
||||||
@ -64,17 +82,17 @@ class Results:
|
|||||||
if cte.MONTH in building.heating_peak_load.keys() and cte.MONTH in building.cooling_peak_load.keys():
|
if cte.MONTH in building.heating_peak_load.keys() and cte.MONTH in building.cooling_peak_load.keys():
|
||||||
peak_lighting = 0
|
peak_lighting = 0
|
||||||
peak_appliances = 0
|
peak_appliances = 0
|
||||||
thermal_zone = building.thermal_zones_from_internal_zones[0]
|
for thermal_zone in building.internal_zones[0].thermal_zones:
|
||||||
lighting = thermal_zone.lighting
|
lighting = thermal_zone.lighting
|
||||||
for schedule in lighting.schedules:
|
for schedule in lighting.schedules:
|
||||||
for value in schedule.values:
|
for value in schedule.values:
|
||||||
if value * lighting.density * thermal_zone.total_floor_area > peak_lighting:
|
if value * lighting.density * thermal_zone.total_floor_area > peak_lighting:
|
||||||
peak_lighting = value * lighting.density * thermal_zone.total_floor_area
|
peak_lighting = value * lighting.density * thermal_zone.total_floor_area
|
||||||
appliances = thermal_zone.appliances
|
appliances = thermal_zone.appliances
|
||||||
for schedule in appliances.schedules:
|
for schedule in appliances.schedules:
|
||||||
for value in schedule.values:
|
for value in schedule.values:
|
||||||
if value * appliances.density * thermal_zone.total_floor_area > peak_appliances:
|
if value * appliances.density * thermal_zone.total_floor_area > peak_appliances:
|
||||||
peak_appliances = value * appliances.density * thermal_zone.total_floor_area
|
peak_appliances = value * appliances.density * thermal_zone.total_floor_area
|
||||||
|
|
||||||
monthly_electricity_peak = [0.9 * peak_lighting + 0.7 * peak_appliances] * 12
|
monthly_electricity_peak = [0.9 * peak_lighting + 0.7 * peak_appliances] * 12
|
||||||
conditioning_peak = []
|
conditioning_peak = []
|
||||||
@ -85,49 +103,37 @@ class Results:
|
|||||||
conditioning_peak.append(heating * value)
|
conditioning_peak.append(heating * value)
|
||||||
monthly_electricity_peak[i] += 0.8 * conditioning_peak[i]
|
monthly_electricity_peak[i] += 0.8 * conditioning_peak[i]
|
||||||
|
|
||||||
electricity_peak_load_results = monthly_electricity_peak
|
electricity_peak_load_results = pd.DataFrame(monthly_electricity_peak
|
||||||
|
, columns=[f'{building.name} electricity peak load W'])
|
||||||
else:
|
else:
|
||||||
electricity_peak_load_results = [None] * 12
|
electricity_peak_load_results = pd.DataFrame(array, columns=[f'{building.name} electricity peak load W'])
|
||||||
|
|
||||||
if cte.MONTH in building.onsite_electrical_production.keys():
|
|
||||||
monthly_onsite_electrical_production = building.onsite_electrical_production[cte.MONTH]
|
|
||||||
onsite_electrical_production = monthly_onsite_electrical_production
|
|
||||||
else:
|
|
||||||
onsite_electrical_production = [None] * 12
|
|
||||||
|
|
||||||
if cte.MONTH in building.distribution_systems_electrical_consumption.keys():
|
if cte.MONTH in building.distribution_systems_electrical_consumption.keys():
|
||||||
extra_electrical_consumption = building.distribution_systems_electrical_consumption[cte.MONTH]
|
extra_electrical_consumption = pd.DataFrame(building.distribution_systems_electrical_consumption[cte.MONTH],
|
||||||
|
columns=[
|
||||||
|
f'{building.name} electrical consumption for distribution Wh'])
|
||||||
else:
|
else:
|
||||||
extra_electrical_consumption = [None] * 12
|
extra_electrical_consumption = pd.DataFrame(array,
|
||||||
|
columns=[
|
||||||
|
f'{building.name} electrical consumption for distribution Wh'])
|
||||||
|
|
||||||
columns_names = [f'{building.name} heating demand J',
|
if print_results is None:
|
||||||
f'{building.name} cooling demand J',
|
print_results = heating_results
|
||||||
f'{building.name} lighting demand J',
|
else:
|
||||||
f'{building.name} appliances demand J',
|
print_results = pd.concat([print_results, heating_results], axis='columns')
|
||||||
f'{building.name} domestic hot water demand J',
|
print_results = pd.concat([print_results,
|
||||||
f'{building.name} heating consumption J',
|
cooling_results,
|
||||||
f'{building.name} cooling consumption J',
|
lighting_results,
|
||||||
f'{building.name} domestic hot water consumption J',
|
appliances_results,
|
||||||
f'{building.name} heating peak load W',
|
dhw_results,
|
||||||
f'{building.name} cooling peak load W',
|
heating_consumption_results,
|
||||||
f'{building.name} electricity peak load W',
|
cooling_consumption_results,
|
||||||
f'{building.name} onsite electrical production J',
|
dhw_consumption_results,
|
||||||
f'{building.name} extra electrical consumption J'
|
heating_peak_load_results,
|
||||||
]
|
cooling_peak_load_results,
|
||||||
print_results = pd.DataFrame([heating_results,
|
electricity_peak_load_results,
|
||||||
cooling_results,
|
onsite_electrical_production,
|
||||||
lighting_results,
|
extra_electrical_consumption], axis='columns')
|
||||||
appliances_results,
|
|
||||||
dhw_results,
|
|
||||||
heating_consumption_results,
|
|
||||||
cooling_consumption_results,
|
|
||||||
dhw_consumption_results,
|
|
||||||
heating_peak_load_results,
|
|
||||||
cooling_peak_load_results,
|
|
||||||
electricity_peak_load_results,
|
|
||||||
onsite_electrical_production,
|
|
||||||
extra_electrical_consumption]).T
|
|
||||||
print_results.columns = columns_names
|
|
||||||
file += '\n'
|
file += '\n'
|
||||||
file += f'name: {building.name}\n'
|
file += f'name: {building.name}\n'
|
||||||
file += f'year of construction: {building.year_of_construction}\n'
|
file += f'year of construction: {building.year_of_construction}\n'
|
||||||
@ -139,8 +145,137 @@ class Results:
|
|||||||
file += f'storeys: n/a\n'
|
file += f'storeys: n/a\n'
|
||||||
file += f'volume: {building.volume}\n'
|
file += f'volume: {building.volume}\n'
|
||||||
|
|
||||||
full_path_results = Path(self._path / f'demand_{building.name}.csv').resolve()
|
full_path_results = Path(self._path / 'demand.csv').resolve()
|
||||||
print_results.to_csv(full_path_results, na_rep='null')
|
print_results.to_csv(full_path_results, na_rep='null')
|
||||||
full_path_metadata = Path(self._path / 'metadata.csv').resolve()
|
full_path_metadata = Path(self._path / 'metadata.csv').resolve()
|
||||||
with open(full_path_metadata, 'w') as metadata_file:
|
with open(full_path_metadata, 'w') as metadata_file:
|
||||||
metadata_file.write(file)
|
metadata_file.write(file)
|
||||||
|
|
||||||
|
def outputsforgraph(self):
|
||||||
|
outputs_energy =pd.DataFrame()
|
||||||
|
array = [None] * 12
|
||||||
|
for building in self._city.buildings:
|
||||||
|
if cte.MONTH in building.heating_demand.keys():
|
||||||
|
heating_results = building.heating_demand[cte.MONTH].rename(
|
||||||
|
columns={cte.INSEL_MEB: f'{building.name} heating Wh'})
|
||||||
|
else:
|
||||||
|
heating_results = pd.DataFrame(array, columns=[f'{building.name} heating demand Wh'])
|
||||||
|
if cte.MONTH in building.cooling_demand.keys():
|
||||||
|
cooling_results = building.cooling_demand[cte.MONTH].rename(
|
||||||
|
columns={cte.INSEL_MEB: f'{building.name} cooling Wh'})
|
||||||
|
else:
|
||||||
|
cooling_results = pd.DataFrame(array, columns=[f'{building.name} cooling demand Wh'])
|
||||||
|
if cte.MONTH in building.lighting_electrical_demand.keys():
|
||||||
|
lighting_results = building.lighting_electrical_demand[cte.MONTH] \
|
||||||
|
.rename(columns={cte.INSEL_MEB: f'{building.name} lighting electrical demand Wh'})
|
||||||
|
else:
|
||||||
|
lighting_results = pd.DataFrame(array, columns=[f'{building.name} lighting electrical demand Wh'])
|
||||||
|
if cte.MONTH in building.appliances_electrical_demand.keys():
|
||||||
|
appliances_results = building.appliances_electrical_demand[cte.MONTH] \
|
||||||
|
.rename(columns={cte.INSEL_MEB: f'{building.name} appliances electrical demand Wh'})
|
||||||
|
else:
|
||||||
|
appliances_results = pd.DataFrame(array, columns=[f'{building.name} appliances electrical demand Wh'])
|
||||||
|
if cte.MONTH in building.domestic_hot_water_heat_demand.keys():
|
||||||
|
dhw_results = building.domestic_hot_water_heat_demand[cte.MONTH] \
|
||||||
|
.rename(columns={cte.INSEL_MEB: f'{building.name} domestic hot water demand Wh'})
|
||||||
|
else:
|
||||||
|
dhw_results = pd.DataFrame(array, columns=[f'{building.name} domestic hot water demand Wh'])
|
||||||
|
|
||||||
|
if cte.MONTH in building.heating_consumption.keys():
|
||||||
|
heating_consumption_results = pd.DataFrame(building.heating_consumption[cte.MONTH],
|
||||||
|
columns=[f'{building.name} heating consumption Wh'])
|
||||||
|
else:
|
||||||
|
heating_consumption_results = pd.DataFrame(array, columns=[f'{building.name} heating consumption Wh'])
|
||||||
|
if cte.MONTH in building.cooling_consumption.keys():
|
||||||
|
cooling_consumption_results = pd.DataFrame(building.cooling_consumption[cte.MONTH],
|
||||||
|
columns=[f'{building.name} cooling consumption Wh'])
|
||||||
|
else:
|
||||||
|
cooling_consumption_results = pd.DataFrame(array, columns=[f'{building.name} cooling consumption Wh'])
|
||||||
|
if cte.MONTH in building.domestic_hot_water_consumption.keys():
|
||||||
|
dhw_consumption_results = pd.DataFrame(building.domestic_hot_water_consumption[cte.MONTH],
|
||||||
|
columns=[f'{building.name} domestic hot water consumption Wh'])
|
||||||
|
else:
|
||||||
|
dhw_consumption_results = pd.DataFrame(array, columns=[f'{building.name} domestic hot water consumption Wh'])
|
||||||
|
|
||||||
|
if cte.MONTH in building.heating_peak_load.keys():
|
||||||
|
heating_peak_load_results = pd.DataFrame(building.heating_peak_load[cte.MONTH],
|
||||||
|
columns=[f'{building.name} heating peak load W'])
|
||||||
|
else:
|
||||||
|
heating_peak_load_results = pd.DataFrame(array, columns=[f'{building.name} heating peak load W'])
|
||||||
|
if cte.MONTH in building.cooling_peak_load.keys():
|
||||||
|
cooling_peak_load_results = pd.DataFrame(building.cooling_peak_load[cte.MONTH],
|
||||||
|
columns=[f'{building.name} cooling peak load W'])
|
||||||
|
else:
|
||||||
|
cooling_peak_load_results = pd.DataFrame(array, columns=[f'{building.name} cooling peak load W'])
|
||||||
|
|
||||||
|
if cte.MONTH in building.onsite_electrical_production.keys():
|
||||||
|
monthly_onsite_electrical_production = building.onsite_electrical_production[cte.MONTH]
|
||||||
|
onsite_electrical_production = pd.DataFrame(monthly_onsite_electrical_production,
|
||||||
|
columns=[f'{building.name} onsite electrical production Wh'])
|
||||||
|
else:
|
||||||
|
onsite_electrical_production = pd.DataFrame(array,
|
||||||
|
columns=[f'{building.name} onsite electrical production Wh'])
|
||||||
|
|
||||||
|
heating = 0
|
||||||
|
cooling = 0
|
||||||
|
for system in building.energy_systems:
|
||||||
|
for demand_type in system.demand_types:
|
||||||
|
if demand_type == cte.HEATING:
|
||||||
|
heating = 1
|
||||||
|
if demand_type == cte.COOLING:
|
||||||
|
cooling = 1
|
||||||
|
if cte.MONTH in building.heating_peak_load.keys() and cte.MONTH in building.cooling_peak_load.keys():
|
||||||
|
peak_lighting = 0
|
||||||
|
peak_appliances = 0
|
||||||
|
for thermal_zone in building.internal_zones[0].thermal_zones:
|
||||||
|
lighting = thermal_zone.lighting
|
||||||
|
for schedule in lighting.schedules:
|
||||||
|
for value in schedule.values:
|
||||||
|
if value * lighting.density * thermal_zone.total_floor_area > peak_lighting:
|
||||||
|
peak_lighting = value * lighting.density * thermal_zone.total_floor_area
|
||||||
|
appliances = thermal_zone.appliances
|
||||||
|
for schedule in appliances.schedules:
|
||||||
|
for value in schedule.values:
|
||||||
|
if value * appliances.density * thermal_zone.total_floor_area > peak_appliances:
|
||||||
|
peak_appliances = value * appliances.density * thermal_zone.total_floor_area
|
||||||
|
|
||||||
|
monthly_electricity_peak = [0.9 * peak_lighting + 0.7 * peak_appliances] * 12
|
||||||
|
conditioning_peak = []
|
||||||
|
for i, value in enumerate(building.heating_peak_load[cte.MONTH]):
|
||||||
|
if cooling * building.cooling_peak_load[cte.MONTH][i] > heating * value:
|
||||||
|
conditioning_peak.append(cooling * building.cooling_peak_load[cte.MONTH][i])
|
||||||
|
else:
|
||||||
|
conditioning_peak.append(heating * value)
|
||||||
|
monthly_electricity_peak[i] += 0.8 * conditioning_peak[i]
|
||||||
|
|
||||||
|
electricity_peak_load_results = pd.DataFrame(monthly_electricity_peak
|
||||||
|
, columns=[f'{building.name} electricity peak load W'])
|
||||||
|
else:
|
||||||
|
electricity_peak_load_results = pd.DataFrame(array, columns=[f'{building.name} electricity peak load W'])
|
||||||
|
|
||||||
|
if cte.MONTH in building.distribution_systems_electrical_consumption.keys():
|
||||||
|
extra_electrical_consumption = pd.DataFrame(building.distribution_systems_electrical_consumption[cte.MONTH],
|
||||||
|
columns=[
|
||||||
|
f'{building.name} electrical consumption for distribution Wh'])
|
||||||
|
else:
|
||||||
|
extra_electrical_consumption = pd.DataFrame(array,
|
||||||
|
columns=[
|
||||||
|
f'{building.name} electrical consumption for distribution Wh'])
|
||||||
|
|
||||||
|
listgraph = [lighting_results.values.sum(),
|
||||||
|
appliances_results.values.sum(),
|
||||||
|
heating_consumption_results.values.sum(),
|
||||||
|
cooling_consumption_results.values.sum(),
|
||||||
|
dhw_consumption_results.values.sum(),
|
||||||
|
extra_electrical_consumption.values.sum()
|
||||||
|
]
|
||||||
|
outputs_energy[f'building {building.name}'] = listgraph
|
||||||
|
outputs_energy.index = ['Lighting consumption', 'Appliances consumption', 'Heating consumption',
|
||||||
|
'Cooling consumption', 'DHW consumption', 'Extra electrical consumption']
|
||||||
|
total_final_energy = (lighting_results.values.sum() + appliances_results.values.sum() + \
|
||||||
|
heating_consumption_results.values.sum() + cooling_consumption_results.values.sum() + \
|
||||||
|
dhw_consumption_results.values.sum() + extra_electrical_consumption.values.sum())/1000
|
||||||
|
|
||||||
|
return outputs_energy, total_final_energy
|
||||||
|
|
||||||
|
|
||||||
|
@ -7,13 +7,14 @@ from hub.imports.results_factory import ResultFactory
|
|||||||
|
|
||||||
|
|
||||||
class SraEngine:
|
class SraEngine:
|
||||||
def __init__(self, city, output_file_path):
|
def __init__(self, city, file_path, output_file_path):
|
||||||
"""
|
"""
|
||||||
SRA class
|
SRA class
|
||||||
:param city: City
|
:param file_path: _sra.xml file path
|
||||||
:param output_file_path: path to output the sra calculation
|
:param output_file_path: path to output the sra calculation
|
||||||
"""
|
"""
|
||||||
self._city = city
|
self._city = city
|
||||||
|
self._file_path = file_path
|
||||||
self._output_file_path = output_file_path
|
self._output_file_path = output_file_path
|
||||||
if platform.system() == 'Linux':
|
if platform.system() == 'Linux':
|
||||||
self._executable = 'sra'
|
self._executable = 'sra'
|
||||||
@ -28,8 +29,6 @@ class SraEngine:
|
|||||||
Calls the software
|
Calls the software
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
subprocess.run([self._executable,
|
subprocess.run([self._executable, str(self._file_path)], stdout=subprocess.DEVNULL)
|
||||||
(self._output_file_path / f'{self._city.name}_sra.xml')],
|
|
||||||
stdout=subprocess.DEVNULL)
|
|
||||||
except (SubprocessError, TimeoutExpired, CalledProcessError) as error:
|
except (SubprocessError, TimeoutExpired, CalledProcessError) as error:
|
||||||
raise Exception(error)
|
raise Exception(error)
|
||||||
|
Loading…
Reference in New Issue
Block a user