From c9d345e1cba9fd8669684c9096c523fa414447e3 Mon Sep 17 00:00:00 2001 From: p_monsalvete Date: Fri, 7 Jul 2023 10:47:22 -0400 Subject: [PATCH] cleaned code. not found bug. not working --- costs/__init__.py | 1 - costs/__main__.py | 45 +++++++++++++++++++-------------------- costs/life_cycle_costs.py | 1 - costs/printing_results.py | 14 ++++++------ out_files/.gitignore | 4 ++++ 5 files changed, 32 insertions(+), 33 deletions(-) create mode 100644 out_files/.gitignore diff --git a/costs/__init__.py b/costs/__init__.py index 9425e48..be9b752 100644 --- a/costs/__init__.py +++ b/costs/__init__.py @@ -37,7 +37,6 @@ RETROFITTING_SCENARIOS = [ SKIN_RETROFIT_AND_SYSTEM_RETROFIT_AND_PV ] -EMISSION_FACTOR_GAS_QUEBEC = 0.25 EMISSION_FACTOR_ELECTRICITY_QUEBEC = 0.0015 #https://www.cer-rec.gc.ca/en/data-analysis/energy-markets/provincial-territorial-energy-profiles/provincial-territorial-energy-profiles-quebec.html#:~:text=GHG%20Emissions,-Quebec's%20GHG%20emissions&text=The%20largest%20emitting%20sectors%20in,2.3%20MT%20CO2e. EMISSION_FACTOR_GAS_QUEBEC = 0.183 #https://www.canada.ca/en/environment-climate-change/services/climate-change/pricing-pollution-how-it-will-work/output-based-pricing-system/federal-greenhouse-gas-offset-system/emission-factors-reference-values.html EMISSION_FACTOR_BIOMASS_QUEBEC = 0.035 #Data from Spain. https://www.miteco.gob.es/es/cambio-climatico/temas/mitigacion-politicas-y-medidas/factoresemision_tcm30-479095.pdf diff --git a/costs/__main__.py b/costs/__main__.py index 3c002fc..8463a8a 100644 --- a/costs/__main__.py +++ b/costs/__main__.py @@ -18,23 +18,20 @@ from hub.imports.usage_factory import UsageFactory from hub.imports.weather_factory import WeatherFactory from monthly_energy_balance_engine import MonthlyEnergyBalanceEngine from sra_engine import SraEngine -import numpy as np from printing_results import * from hub.helpers import constants as cte from life_cycle_costs import LifeCycleCosts -from costs import CLIMATE_REFERENCE_CITY, WEATHER_FILE, WEATHER_FORMAT, CONSTRUCTION_FORMAT, USAGE_FORMAT -from costs import ENERGY_SYSTEM_FORMAT, ATTIC_HEATED_CASE, BASEMENT_HEATED_CASE, RETROFITTING_SCENARIOS, NUMBER_OF_YEARS +from costs import CONSTRUCTION_FORMAT +from costs import ENERGY_SYSTEM_FORMAT, RETROFITTING_SCENARIOS, NUMBER_OF_YEARS from costs import CONSUMER_PRICE_INDEX, ELECTRICITY_PEAK_INDEX, ELECTRICITY_PRICE_INDEX, GAS_PRICE_INDEX, DISCOUNT_RATE from costs import SKIN_RETROFIT, SYSTEM_RETROFIT_AND_PV, SKIN_RETROFIT_AND_SYSTEM_RETROFIT_AND_PV from costs import RETROFITTING_YEAR_CONSTRUCTION -from costs import EMISSION_FACTOR_GAS_QUEBEC, EMISSION_FACTOR_ELECTRICITY_QUEBEC, EMISSION_FACTOR_GAS_QUEBEC,\ - EMISSION_FACTOR_BIOMASS_QUEBEC, EMISSION_FACTOR_FUEL_OIL_QUEBEC, EMISSION_FACTOR_DIESEL_QUEBEC - # import paths from results import Results + def _npv_from_list(npv_discount_rate, list_cashflow): lcc_value = npf.npv(npv_discount_rate, list_cashflow) return lcc_value @@ -147,27 +144,29 @@ for retrofitting_scenario in RETROFITTING_SCENARIOS: global_operational_incomes.to_excel(writer, sheet_name='global_operational_incomes') global_capital_incomes.to_excel(writer, sheet_name='global_capital_incomes') + investmentcosts = pd.DataFrame([]) + print('RETROFITTING SCENARIO', retrofitting_scenario) if retrofitting_scenario == 0: investmentcosts = [global_capital_costs['B2010_opaque_walls'][0], - global_capital_costs['B2020_transparent'][0], - global_capital_costs['B3010_opaque_roof'][0], - global_capital_costs['B10_superstructure'][0], - global_capital_costs['D3020_heat_generating_systems'][0], - global_capital_costs['D3080_other_hvac_ahu'][0], - global_capital_costs['D5020_lighting_and_branch_wiring'][0], - global_capital_costs['D301010_photovoltaic_system'][0]] + global_capital_costs['B2020_transparent'][0], + global_capital_costs['B3010_opaque_roof'][0], + global_capital_costs['B10_superstructure'][0], + global_capital_costs['D3020_heat_generating_systems'][0], + global_capital_costs['D3080_other_hvac_ahu'][0], + global_capital_costs['D5020_lighting_and_branch_wiring'][0], + global_capital_costs['D301010_photovoltaic_system'][0]] investmentcosts = pd.DataFrame(investmentcosts) - else: - investmentcosts[f'retrofitting_scenario {retrofitting_scenario}'] = [global_capital_costs['B2010_opaque_walls'][0], - global_capital_costs['B2020_transparent'][0], - global_capital_costs['B3010_opaque_roof'][0], - global_capital_costs['B10_superstructure'][0], - global_capital_costs['D3020_heat_generating_systems'][0], - global_capital_costs['D3080_other_hvac_ahu'][0], - global_capital_costs['D5020_lighting_and_branch_wiring'][0], - global_capital_costs['D301010_photovoltaic_system'][0]] + investmentcosts[f'retrofitting_scenario_{retrofitting_scenario}'] = \ + [global_capital_costs['B2010_opaque_walls'][0], + global_capital_costs['B2020_transparent'][0], + global_capital_costs['B3010_opaque_roof'][0], + global_capital_costs['B10_superstructure'][0], + global_capital_costs['D3020_heat_generating_systems'][0], + global_capital_costs['D3080_other_hvac_ahu'][0], + global_capital_costs['D5020_lighting_and_branch_wiring'][0], + global_capital_costs['D301010_photovoltaic_system'][0]] investmentcosts.index = ['Opaque walls', 'Transparent walls', 'Opaque roof', 'Superstructure', 'Heat generation systems', 'Other HVAC AHU', 'Lighting and branch wiring', 'PV systems'] @@ -242,7 +241,7 @@ for retrofitting_scenario in RETROFITTING_SCENARIOS: print(f'Scenario {retrofitting_scenario} {life_cycle_costs}') -printing_results(investmentcosts,life_cycle_results,total_floor_area) +# printing_results(investmentcosts, life_cycle_results, total_floor_area) diff --git a/costs/life_cycle_costs.py b/costs/life_cycle_costs.py index 240d690..470b242 100644 --- a/costs/life_cycle_costs.py +++ b/costs/life_cycle_costs.py @@ -102,7 +102,6 @@ class LifeCycleCosts: surface_transparent += thermal_boundary.opaque_area * thermal_boundary.window_ratio chapters = archetype.capital_cost - print('kk') peak_heating = building.heating_peak_load[cte.YEAR][0]/1000 peak_cooling = building.cooling_peak_load[cte.YEAR][0]/1000 # todo: change area pv when the variable exists diff --git a/costs/printing_results.py b/costs/printing_results.py index b735d07..e7e938e 100644 --- a/costs/printing_results.py +++ b/costs/printing_results.py @@ -1,16 +1,14 @@ -import numpy as np - import plotly.graph_objects as go -import plotly.offline as offline import matplotlib.pyplot as plt import plotly.express as px + def printing_results(investmentcosts, life_cycle_results,total_floor_area): labels = investmentcosts.index - values = investmentcosts['retrofitting_scenario 1'] - values2 = investmentcosts['retrofitting_scenario 2'] - values3 = investmentcosts['retrofitting_scenario 3'] + values = investmentcosts['retrofitting_scenario_1'] + values2 = investmentcosts['retrofitting_scenario_2'] + values3 = investmentcosts['retrofitting_scenario_3'] fig = go.Figure(data=[go.Pie(labels=labels, values=values)]) fig2 = go.Figure(data=[go.Pie(labels=labels, values=values2)]) @@ -21,11 +19,11 @@ def printing_results(investmentcosts, life_cycle_results,total_floor_area): showlegend=True ) fig2.update_layout( - title='Retrofitting scenario 1', + title='Retrofitting scenario 2', showlegend=True ) fig3.update_layout( - title='Retrofitting scenario 1', + title='Retrofitting scenario 3', showlegend=True ) diff --git a/out_files/.gitignore b/out_files/.gitignore new file mode 100644 index 0000000..9c3f9e4 --- /dev/null +++ b/out_files/.gitignore @@ -0,0 +1,4 @@ +# Ignore everything in this directory +.gitignore +# Except this file +!.gitignore \ No newline at end of file