cost performance improvements

This commit is contained in:
Guille Gutierrez 2023-08-10 12:36:31 -04:00
parent d8c0644709
commit 62ae152ba7
3 changed files with 32 additions and 13 deletions

View File

@ -5,6 +5,8 @@ Copyright © 2023 Project Coder Guille Gutierrez guillermo.gutierrezmorote@conco
Code contributor Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
Code contributor Oriol Gavalda Torrellas oriol.gavalda@concordia.ca
"""
import datetime
import pandas as pd
import numpy_financial as npf
from hub.city_model_structure.building import Building
@ -72,12 +74,22 @@ class Cost:
:return: DataFrame
"""
results = pd.DataFrame()
start = datetime.datetime.now()
global_capital_costs, global_capital_incomes = CapitalCosts(self._building, self._configuration).calculate()
print(f'CapitalCosts: {datetime.datetime.now()-start}')
start = datetime.datetime.now()
global_end_of_life_costs = EndOfLifeCosts(self._building, self._configuration).calculate()
print(f'EndOfLifeCosts: {datetime.datetime.now() - start}')
start = datetime.datetime.now()
global_operational_costs = TotalOperationalCosts(self._building, self._configuration).calculate()
print(f'TotalOperationalCosts: {datetime.datetime.now() - start}')
start = datetime.datetime.now()
global_maintenance_costs = TotalMaintenanceCosts(self._building, self._configuration).calculate()
print(f'TotalMaintenanceCosts: {datetime.datetime.now() - start}')
start = datetime.datetime.now()
global_operational_incomes = TotalOperationalIncomes(self._building, self._configuration).calculate()
print(f'OperationalIncomes: {datetime.datetime.now() - start}')
start = datetime.datetime.now()
df_capital_costs_skin = (
global_capital_costs['B2010_opaque_walls'] +
global_capital_costs['B2020_transparent'] +
@ -151,5 +163,5 @@ class Cost:
'global_maintenance_costs',
'global_operational_incomes'
]
print(f'Dataframes: {datetime.datetime.now()-start}')
return results

View File

@ -28,22 +28,25 @@ class PeakLoad:
heating = 0
cooling = 0
for system in self._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.HEATING in system.demand_types:
heating = 1
if cte.COOLING in system.demand_types:
cooling = 1
if cte.MONTH in self._building.heating_peak_load.keys() and cte.MONTH in self._building.cooling_peak_load.keys():
peak_lighting = self._building.lighting_peak_load[cte.YEAR][0]
peak_appliances = self._building.appliances_peak_load[cte.YEAR][0]
monthly_electricity_peak = [0.9 * peak_lighting + 0.7 * peak_appliances] * 12
conditioning_peak = []
for i, value in enumerate(self._building.heating_peak_load[cte.MONTH]):
if cooling * self._building.cooling_peak_load[cte.MONTH][i] > heating * value:
conditioning_peak.append(cooling * self._building.cooling_peak_load[cte.MONTH][i])
conditioning_peak = max(self._building.heating_peak_load[cte.MONTH], self._building.cooling_peak_load[cte.MONTH])
for i in range(len(conditioning_peak)):
if cooling == 1 and heating == 1:
conditioning_peak[i] = conditioning_peak[i]
continue
elif cooling == 0:
conditioning_peak[i] = self._building.heating_peak_load[cte.MONTH][i] * heating
else:
conditioning_peak.append(heating * value)
conditioning_peak[i] = self._building.cooling_peak_load[cte.MONTH][i] * cooling
monthly_electricity_peak[i] += 0.8 * conditioning_peak[i]
electricity_peak_load_results = pd.DataFrame(
monthly_electricity_peak,
columns=[f'electricity peak load W']

View File

@ -42,14 +42,16 @@ class Initialize:
sra_file = str((output_path / f'{city.name}_sra.xml').resolve())
subprocess.run(['sra', sra_file], stdout=subprocess.DEVNULL)
ResultFactory('sra', city, output_path).enrich()
print(f'sra completed {datetime.datetime.now() - start}')
for building in city.buildings:
building.energy_systems_archetype_name = 'system 1 gas pv'
EnergySystemsFactory('montreal_custom', city).enrich()
print(f'energy systems completed {datetime.datetime.now() - start}')
EnergyBuildingsExportsFactory('insel_monthly_energy_balance', city, output_path).export()
_insel_files = glob.glob(f'{output_path}/*.insel')
for insel_file in _insel_files:
subprocess.run(['insel', str(insel_file)], stdout=subprocess.DEVNULL)
print(f'insel completed {datetime.datetime.now() - start}')
ResultFactory('insel_monthly_energy_balance', city, output_path).enrich()
self._city = city
print(f'init completed {datetime.datetime.now() - start}')
@ -61,7 +63,9 @@ class UnitTests(unittest.TestCase):
def test_current_status(self):
for building in self.init.city.buildings:
start = datetime.datetime.now()
result = Cost(building).life_cycle
print(f'Cost calculation for building {building.name}: {datetime.datetime.now()-start}')
self.assertIsNotNone(result)
self.assertEqual(0, result.values[0])