adjusting to changes in hub

This commit is contained in:
Pilar Monsalvete 2023-06-07 14:48:21 -04:00
parent 9f8642d0b5
commit 537809f3c8
3 changed files with 20 additions and 21 deletions

13
main.py
View File

@ -13,9 +13,8 @@ from sra_engine import SraEngine
try:
file_path = (Path(__file__).parent / 'data' / 'selected_building.geojson')
file_path = (Path(__file__).parent / 'input_files' / 'selected_building_warehouse.geojson')
climate_reference_city = 'Montreal'
weather_file = 'CAN_PQ_Montreal.Intl.AP.716270_CWEC.epw'
weather_format = 'epw'
construction_format = 'nrcan'
usage_format = 'nrcan'
@ -23,7 +22,7 @@ try:
attic_heated_case = 0
basement_heated_case = 1
out_path = (Path(__file__).parent / 'outputs')
out_path = (Path(__file__).parent / 'output_files')
tmp_folder = (Path(__file__).parent / 'tmp')
print('[simulation start]')
@ -36,7 +35,7 @@ try:
city.climate_reference_city = climate_reference_city
city.climate_file = (tmp_folder / f'{climate_reference_city}.cli').resolve()
print(f'city created from {file_path}')
WeatherFactory(weather_format, city, file_name=weather_file).enrich()
WeatherFactory(weather_format, city).enrich()
print('enrich weather... done')
ConstructionFactory(construction_format, city).enrich()
print('enrich constructions... done')
@ -49,7 +48,7 @@ try:
print('exporting:')
sra_file = (tmp_folder / f'{city.name}_sra.xml').resolve()
SraEngine(city, sra_file, tmp_folder, weather_file)
SraEngine(city, sra_file, tmp_folder)
print(' sra processed...')
MonthlyEnergyBalanceEngine(city, tmp_folder)
@ -58,9 +57,9 @@ try:
for building in city.buildings:
for energy_system in building.energy_systems:
if cte.HEATING in energy_system.demand_types:
energy_system.generation_system.heat_power = building.heating_peak_load[cte.YEAR][cte.HEATING_PEAK_LOAD][0]
energy_system.generation_system.heat_power = building.heating_peak_load[cte.YEAR][0]
if cte.COOLING in energy_system.demand_types:
energy_system.generation_system.cooling_power = building.cooling_peak_load[cte.YEAR][cte.COOLING_PEAK_LOAD][0]
energy_system.generation_system.cooling_power = building.cooling_peak_load[cte.YEAR][0]
print('importing results:')
results = Results(city, out_path)

View File

@ -13,12 +13,12 @@ class Results:
file = 'city name: ' + self._city.name + '\n'
array = [None] * 12
for building in self._city.buildings:
if cte.MONTH in building.heating.keys():
heating_results = building.heating[cte.MONTH].rename(columns={cte.INSEL_MEB: f'{building.name} heating Wh'})
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.keys():
cooling_results = building.cooling[cte.MONTH].rename(columns={cte.INSEL_MEB: f'{building.name} cooling 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():
@ -54,11 +54,13 @@ class Results:
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 = 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:
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 = 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:
cooling_peak_load_results = pd.DataFrame(array, columns=[f'{building.name} cooling peak load W'])
@ -92,12 +94,11 @@ class Results:
if value * appliances.density * thermal_zone.total_floor_area > peak_appliances:
peak_appliances = value * appliances.density * thermal_zone.total_floor_area
#todo:check with Pilar. Peak cannot be multiplied by 12. I deleted it. Is el. peak not saved in building?
monthly_electricity_peak = [0.9 * peak_lighting + 0.7 * peak_appliances]
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][cte.HEATING_PEAK_LOAD]):
if cooling * building.cooling_peak_load[cte.MONTH][cte.COOLING_PEAK_LOAD][i] > heating * value:
conditioning_peak.append(cooling * building.cooling_peak_load[cte.MONTH][cte.COOLING_PEAK_LOAD][i])
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]

View File

@ -7,7 +7,7 @@ from hub.imports.results_factory import ResultFactory
class SraEngine:
def __init__(self, city, file_path, output_file_path, weather_file):
def __init__(self, city, file_path, output_file_path):
"""
SRA class
:param file_path: _sra.xml file path
@ -16,12 +16,11 @@ class SraEngine:
self._city = city
self._file_path = file_path
self._output_file_path = output_file_path
self._weather_file = weather_file
if platform.system() == 'Linux':
self._executable = 'sra'
elif platform.system() == 'Windows':
self._executable = 'shortwave_integer'
ExportsFactory('sra', self._city, output_file_path, weather_file=self._weather_file, weather_format='epw').export()
ExportsFactory('sra', self._city, output_file_path).export()
self._run()
ResultFactory('sra', self._city, output_file_path).enrich()