added retrofitting_year_of_construction for two scenarios

This commit is contained in:
Pilar Monsalvete 2023-05-02 10:49:53 -04:00
parent 512cd6b81e
commit b2bbc7f7ee
2 changed files with 66 additions and 112 deletions

View File

@ -12,9 +12,11 @@ from datetime import date
import hub.helpers.constants as cte
class LifeCycleCosts:
def __init__(self, building, archetype, number_of_years, consumer_price_index, discount_rate,
retrofitting_scenario, heating_scop, cooling_seer, peak_electricity_demand, factor_pv,factor_peak_lights):
retrofitting_scenario, heating_scop, cooling_seer, peak_electricity_demand,
factor_pv, factor_peak_lights):
self._building = building
self._number_of_years = number_of_years
self._consumer_price_index = consumer_price_index
@ -57,7 +59,6 @@ class LifeCycleCosts:
surface_ground = 0
total_floor_area = self._total_floor_area
for internal_zone in building.internal_zones:
for thermal_zone in internal_zone.thermal_zones:
for thermal_boundary in thermal_zone.thermal_boundaries:
@ -153,9 +154,8 @@ class LifeCycleCosts:
reposition_cost_total = reposition_cost_subtotal * (1+chapters.design_allowance) * (1+chapters.overhead_and_profit)
life_cycle_cost_capital_total = capital_cost_total + reposition_cost_total
self._yearly_capital_costs.fillna(0,inplace=True)
return life_cycle_cost_capital_total
return life_cycle_cost_capital_total, self._yearly_capital_costs
def calculate_end_of_life_costs(self):
archetype = self._archetype

58
main.py
View File

@ -32,8 +32,8 @@ def _search_archetype(costs_catalog, building_function):
return building_archetype
raise KeyError('archetype not found')
file_path = (Path(__file__).parent.parent/'costs_workflow'/'input_files'/'selected_building_2864.geojson')
file_path2 = (Path(__file__).parent.parent/'costs_workflow'/'input_files'/'selected_building_2864_2.geojson')
climate_reference_city = 'Montreal'
weather_file = 'CAN_PQ_Montreal.Intl.AP.716270_CWEC.epw'
weather_format = 'epw'
@ -44,6 +44,7 @@ basement_heated_case = 1
tmp_folder = (Path(__file__).parent.parent/'monthly_energy_balance_workflow'/'tmp')
out_path = (Path(__file__).parent.parent / 'costs_workflow' / 'out_files')
files = glob.glob(f'{out_path}/*')
retrofitting_year_of_construction = 2015
for file in files:
if file != '.gitignore':
@ -67,7 +68,6 @@ for retrofitting_scenario in retrofitting_scenarios:
heating_scop = 1
cooling_seer = 2.8
if retrofitting_scenario == 0 or retrofitting_scenario == 2:
print('[simulation start]')
city = GeometryFactory('geojson',
path=file_path,
@ -84,63 +84,17 @@ for retrofitting_scenario in retrofitting_scenarios:
print(f'city created from {file_path}')
WeatherFactory(weather_format, city, file_name=weather_file).enrich()
print('enrich weather... done')
ConstructionFactory(construction_format, city).enrich()
print('enrich constructions... done')
UsageFactory(usage_format, city).enrich()
print('enrich usage... done')
catalog = CostCatalogFactory('montreal_custom').catalog
print('costs catalog access... done')
# sra + monthly running
print('exporting:')
sra_file = (tmp_folder / f'{city.name}_sra.xml').resolve()
SraEngine(city, sra_file, tmp_folder, weather_file)
# Assign radiation to the city
print(' sra processed...')
if retrofitting_scenario == 0 or retrofitting_scenario == 2:
for building in city.buildings:
building.attic_heated = attic_heated_case
building.basement_heated = basement_heated_case
building.year_of_construction = retrofitting_year_of_construction
MonthlyEnergyBalanceEngine(city, tmp_folder)
for building in city.buildings:
try:
function = Dictionaries().hub_function_to_montreal_custom_costs_function[building.function]
archetype = _search_archetype(catalog, function)
except KeyError:
logger.error(f'Building {building.name} has unknown costs archetype for building function: '
f'{building.function}\n')
sys.stderr.write(f'Building {building.name} has unknown costs archetype for building function: '
f'{building.function}\n')
continue
lcc = LifeCycleCosts(building, archetype, number_of_years, consumer_price_index,
discount_rate, retrofitting_scenario, heating_scop, cooling_seer,
peak_electricity_demand, factor_pv,factor_peak_lights)
else:
print('[simulation start]')
city = GeometryFactory('geojson',
path=file_path2,
height_field='heightmax',
name_field='OBJECTID_12',
year_of_construction_field='ANNEE_CONS',
function_field='CODE_UTILI',
function_to_hub=Dictionaries().montreal_function_to_hub_function).city
print(f'city created from {file_path}')
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()
print('enrich weather... done')
ConstructionFactory(construction_format, city).enrich()
print('enrich constructions... done')
UsageFactory(usage_format, city).enrich()
print('enrich usage... done')
catalog = CostCatalogFactory('montreal_custom').catalog
print('costs catalog access... done')
# sra + monthly running
@ -170,7 +124,8 @@ for retrofitting_scenario in retrofitting_scenarios:
discount_rate, retrofitting_scenario, heating_scop, cooling_seer,
peak_electricity_demand, factor_pv,factor_peak_lights)
total_capital_costs = lcc.calculate_capital_costs()
total_capital_costs, yearly_capital_costs = lcc.calculate_capital_costs()
end_of_life_costs = lcc.calculate_end_of_life_costs()
total_operational_costs = lcc.calculate_total_operational_costs()
total_maintenance_costs = lcc.calculate_total_maintenance_costs()
@ -181,4 +136,3 @@ for retrofitting_scenario in retrofitting_scenarios:
life_cycle_results.index = ['total_capital_costs', 'end_of_life_costs', 'total_operational_costs',
'total_maintenance_costs', 'life_cycle_costs']
life_cycle_results.to_excel(Path(__file__).parent/'out_files'/'Results.xlsx', index=True)