added retrofitting_year_of_construction for two scenarios
This commit is contained in:
parent
512cd6b81e
commit
b2bbc7f7ee
|
@ -12,9 +12,11 @@ from datetime import date
|
||||||
|
|
||||||
import hub.helpers.constants as cte
|
import hub.helpers.constants as cte
|
||||||
|
|
||||||
|
|
||||||
class LifeCycleCosts:
|
class LifeCycleCosts:
|
||||||
def __init__(self, building, archetype, number_of_years, consumer_price_index, discount_rate,
|
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._building = building
|
||||||
self._number_of_years = number_of_years
|
self._number_of_years = number_of_years
|
||||||
self._consumer_price_index = consumer_price_index
|
self._consumer_price_index = consumer_price_index
|
||||||
|
@ -38,13 +40,13 @@ class LifeCycleCosts:
|
||||||
self._peak_lights = factor_peak_lights
|
self._peak_lights = factor_peak_lights
|
||||||
#todo: revise if it works
|
#todo: revise if it works
|
||||||
rng = range(40)
|
rng = range(40)
|
||||||
self._yearly_capital_costs = pd.DataFrame(index=rng , columns=['B2010_opaque_walls', 'B2020_transparent',
|
self._yearly_capital_costs = pd.DataFrame(index=rng, columns=['B2010_opaque_walls', 'B2020_transparent',
|
||||||
'B3010_opaque_roof','B10_superstructure',
|
'B3010_opaque_roof','B10_superstructure',
|
||||||
'D301010_photovoltaic_system','D3020_heat_generating_systems',
|
'D301010_photovoltaic_system','D3020_heat_generating_systems',
|
||||||
'D3030_cooling_generation_systems','D3040_distribution_systems',
|
'D3030_cooling_generation_systems','D3040_distribution_systems',
|
||||||
'D3080_other_hvac_ahu','D5020_lighting_and_branch_wiring',
|
'D3080_other_hvac_ahu','D5020_lighting_and_branch_wiring',
|
||||||
'D_services'], dtype='float')
|
'D_services'], dtype='float')
|
||||||
self._yearly_capital_costs.replace(np.nan,0)
|
self._yearly_capital_costs.replace(np.nan, 0)
|
||||||
|
|
||||||
def calculate_capital_costs(self):
|
def calculate_capital_costs(self):
|
||||||
building = self._building
|
building = self._building
|
||||||
|
@ -57,7 +59,6 @@ class LifeCycleCosts:
|
||||||
surface_ground = 0
|
surface_ground = 0
|
||||||
total_floor_area = self._total_floor_area
|
total_floor_area = self._total_floor_area
|
||||||
|
|
||||||
|
|
||||||
for internal_zone in building.internal_zones:
|
for internal_zone in building.internal_zones:
|
||||||
for thermal_zone in internal_zone.thermal_zones:
|
for thermal_zone in internal_zone.thermal_zones:
|
||||||
for thermal_boundary in thermal_zone.thermal_boundaries:
|
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)
|
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
|
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):
|
def calculate_end_of_life_costs(self):
|
||||||
archetype = self._archetype
|
archetype = self._archetype
|
||||||
|
|
166
main.py
166
main.py
|
@ -32,8 +32,8 @@ def _search_archetype(costs_catalog, building_function):
|
||||||
return building_archetype
|
return building_archetype
|
||||||
raise KeyError('archetype not found')
|
raise KeyError('archetype not found')
|
||||||
|
|
||||||
|
|
||||||
file_path = (Path(__file__).parent.parent/'costs_workflow'/'input_files'/'selected_building_2864.geojson')
|
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'
|
climate_reference_city = 'Montreal'
|
||||||
weather_file = 'CAN_PQ_Montreal.Intl.AP.716270_CWEC.epw'
|
weather_file = 'CAN_PQ_Montreal.Intl.AP.716270_CWEC.epw'
|
||||||
weather_format = 'epw'
|
weather_format = 'epw'
|
||||||
|
@ -44,6 +44,7 @@ basement_heated_case = 1
|
||||||
tmp_folder = (Path(__file__).parent.parent/'monthly_energy_balance_workflow'/'tmp')
|
tmp_folder = (Path(__file__).parent.parent/'monthly_energy_balance_workflow'/'tmp')
|
||||||
out_path = (Path(__file__).parent.parent / 'costs_workflow' / 'out_files')
|
out_path = (Path(__file__).parent.parent / 'costs_workflow' / 'out_files')
|
||||||
files = glob.glob(f'{out_path}/*')
|
files = glob.glob(f'{out_path}/*')
|
||||||
|
retrofitting_year_of_construction = 2015
|
||||||
|
|
||||||
for file in files:
|
for file in files:
|
||||||
if file != '.gitignore':
|
if file != '.gitignore':
|
||||||
|
@ -60,125 +61,78 @@ factor_peak_lights = 0.07
|
||||||
retrofitting_scenarios = [0, 1, 2, 3]
|
retrofitting_scenarios = [0, 1, 2, 3]
|
||||||
life_cycle_results = pd.DataFrame()
|
life_cycle_results = pd.DataFrame()
|
||||||
for retrofitting_scenario in retrofitting_scenarios:
|
for retrofitting_scenario in retrofitting_scenarios:
|
||||||
if retrofitting_scenario == 2 or retrofitting_scenario==3:
|
if retrofitting_scenario == 2 or retrofitting_scenario == 3:
|
||||||
heating_scop = 3
|
heating_scop = 3
|
||||||
cooling_seer = 4.5
|
cooling_seer = 4.5
|
||||||
else:
|
else:
|
||||||
heating_scop = 1
|
heating_scop = 1
|
||||||
cooling_seer = 2.8
|
cooling_seer = 2.8
|
||||||
|
|
||||||
|
print('[simulation start]')
|
||||||
|
city = GeometryFactory('geojson',
|
||||||
|
path=file_path,
|
||||||
|
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')
|
||||||
|
UsageFactory(usage_format, city).enrich()
|
||||||
|
print('enrich usage... done')
|
||||||
|
catalog = CostCatalogFactory('montreal_custom').catalog
|
||||||
|
print('costs catalog access... done')
|
||||||
|
|
||||||
if retrofitting_scenario == 0 or retrofitting_scenario == 2:
|
if retrofitting_scenario == 0 or retrofitting_scenario == 2:
|
||||||
print('[simulation start]')
|
|
||||||
city = GeometryFactory('geojson',
|
|
||||||
path=file_path,
|
|
||||||
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
|
|
||||||
|
|
||||||
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...')
|
|
||||||
|
|
||||||
for building in city.buildings:
|
for building in city.buildings:
|
||||||
building.attic_heated = attic_heated_case
|
building.year_of_construction = retrofitting_year_of_construction
|
||||||
building.basement_heated = basement_heated_case
|
|
||||||
|
|
||||||
MonthlyEnergyBalanceEngine(city, tmp_folder)
|
ConstructionFactory(construction_format, city).enrich()
|
||||||
|
print('enrich constructions... done')
|
||||||
|
|
||||||
for building in city.buildings:
|
# sra + monthly running
|
||||||
try:
|
|
||||||
function = Dictionaries().hub_function_to_montreal_custom_costs_function[building.function]
|
print('exporting:')
|
||||||
archetype = _search_archetype(catalog, function)
|
sra_file = (tmp_folder / f'{city.name}_sra.xml').resolve()
|
||||||
except KeyError:
|
SraEngine(city, sra_file, tmp_folder, weather_file)
|
||||||
logger.error(f'Building {building.name} has unknown costs archetype for building function: '
|
# Assign radiation to the city
|
||||||
|
print(' sra processed...')
|
||||||
|
|
||||||
|
for building in city.buildings:
|
||||||
|
building.attic_heated = attic_heated_case
|
||||||
|
building.basement_heated = basement_heated_case
|
||||||
|
|
||||||
|
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')
|
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
|
|
||||||
|
|
||||||
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...')
|
|
||||||
|
|
||||||
for building in city.buildings:
|
|
||||||
building.attic_heated = attic_heated_case
|
|
||||||
building.basement_heated = basement_heated_case
|
|
||||||
|
|
||||||
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
|
continue
|
||||||
lcc = LifeCycleCosts(building, archetype, number_of_years, consumer_price_index,
|
lcc = LifeCycleCosts(building, archetype, number_of_years, consumer_price_index,
|
||||||
discount_rate, retrofitting_scenario, heating_scop, cooling_seer,
|
discount_rate, retrofitting_scenario, heating_scop, cooling_seer,
|
||||||
peak_electricity_demand, factor_pv,factor_peak_lights)
|
peak_electricity_demand, factor_pv,factor_peak_lights)
|
||||||
|
|
||||||
total_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()
|
|
||||||
life_cycle_costs = total_capital_costs + end_of_life_costs + total_operational_costs + total_maintenance_costs
|
|
||||||
life_cycle_results[f'Scenario {retrofitting_scenario}'] = [total_capital_costs, end_of_life_costs,
|
|
||||||
total_operational_costs, total_maintenance_costs,
|
|
||||||
life_cycle_costs]
|
|
||||||
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)
|
|
||||||
|
|
||||||
|
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()
|
||||||
|
life_cycle_costs = total_capital_costs + end_of_life_costs + total_operational_costs + total_maintenance_costs
|
||||||
|
life_cycle_results[f'Scenario {retrofitting_scenario}'] = [total_capital_costs, end_of_life_costs,
|
||||||
|
total_operational_costs, total_maintenance_costs,
|
||||||
|
life_cycle_costs]
|
||||||
|
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)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user