Incorporated co2 in costs workflow. Constants initialised in init, and calculations done in __main__emissions.py

This commit is contained in:
Oriol Gavalda 2023-06-07 20:33:33 -04:00
parent dd0317c979
commit d3b524b677
4 changed files with 81 additions and 0 deletions

View File

@ -36,6 +36,15 @@ RETROFITTING_SCENARIOS = [
SYSTEM_RETROFIT_AND_PV, SYSTEM_RETROFIT_AND_PV,
SKIN_RETROFIT_AND_SYSTEM_RETROFIT_AND_PV 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
EMISSION_FACTOR_FUEL_OIL_QUEBEC = 0.274
EMISSION_FACTOR_DIESEL_QUEBEC = 0.240
tmp_folder = Path('./tmp').resolve() tmp_folder = Path('./tmp').resolve()
out_path = Path('./outputs').resolve() out_path = Path('./outputs').resolve()
files = glob.glob(f'{out_path}/*') files = glob.glob(f'{out_path}/*')

View File

@ -29,6 +29,9 @@ from costs import CONSUMER_PRICE_INDEX, ELECTRICITY_PEAK_INDEX, ELECTRICITY_PRIC
from costs import SKIN_RETROFIT, SYSTEM_RETROFIT_AND_PV, SKIN_RETROFIT_AND_SYSTEM_RETROFIT_AND_PV 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 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 # import paths
from costs import file_path, tmp_folder, out_path from costs import file_path, tmp_folder, out_path

View File

@ -0,0 +1,68 @@
"""
Costs Workflow
SPDX - License - Identifier: LGPL - 3.0 - or -later
Copyright © 2022 Project Author Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
Code contributor Oriol Gavalda Torrellas oriol.gavalda@concordia.ca
"""
from pathlib import Path
import pandas as pd
from hub.helpers.dictionaries import Dictionaries
from hub.catalog_factories.costs_catalog_factory import CostCatalogFactory
from costs import EMISSION_FACTOR_ELECTRICITY_QUEBEC, EMISSION_FACTOR_GAS_QUEBEC, EMISSION_FACTOR_BIOMASS_QUEBEC, \
EMISSION_FACTOR_FUEL_OIL_QUEBEC, EMISSION_FACTOR_DIESEL_QUEBEC, NUMBER_OF_YEARS
def _search_archetype(costs_catalog, building_function):
costs_archetypes = costs_catalog.entries('archetypes').archetypes
for building_archetype in costs_archetypes:
if str(building_function) == str(building_archetype.function):
return building_archetype
raise KeyError('archetype not found')
catalog = CostCatalogFactory('montreal_custom').catalog
for building in city.buildings:
building_heating_consumption = 1000
building_domestic_water_consumption = 1000
building_cooling_consumption = 1000
distribution_systems_electrical_consumption = 1000
lighting_electrical_demand = 1000
appliances_electrical_demand = 1000
rng = range(NUMBER_OF_YEARS)
function = Dictionaries().hub_function_to_montreal_custom_costs_function[building.function]
archetype = _search_archetype(catalog, function)
print('co2 for first building started')
if "gas" in building.energy_systems_archetype_name:
gas_consumption = building_heating_consumption + building_domestic_water_consumption
electricity_consumption = building_cooling_consumption + distribution_systems_electrical_consumption + \
lighting_electrical_demand + appliances_electrical_demand
biomass_consumption = 0
fuel_oil_consumption = 0
diesel_consumption = 0
else:
gas_consumption = 0
electricity_consumption = building_heating_consumption + building_domestic_water_consumption + \
building_cooling_consumption + distribution_systems_electrical_consumption + \
lighting_electrical_demand + appliances_electrical_demand
biomass_consumption = 0
fuel_oil_consumption = 0
diesel_consumption = 0
CO2_emissions = pd.DataFrame(index=rng, columns=['CO2 emissions gas', 'CO2 emissions electricity',
'CO2 Emissions biomass', 'CO2 emissions fueloil',
'CO2 emissions diesel'], dtype='float')
for year in range(1, NUMBER_OF_YEARS+1):
CO2_emissions.at[year,'CO2 emissions gas'] = gas_consumption * EMISSION_FACTOR_GAS_QUEBEC
CO2_emissions.at[year, 'CO2 emissions electricity'] = electricity_consumption * EMISSION_FACTOR_ELECTRICITY_QUEBEC
CO2_emissions.at[year, 'CO2 emissions biomass'] = biomass_consumption * EMISSION_FACTOR_BIOMASS_QUEBEC
CO2_emissions.at[year, 'CO2 emissions fueloil'] = fuel_oil_consumption * EMISSION_FACTOR_FUEL_OIL_QUEBEC
CO2_emissions.at[year, 'CO2 emissions diesel'] = diesel_consumption * EMISSION_FACTOR_DIESEL_QUEBEC
CO2_emissions_total = CO2_emissions.sum()

View File

@ -280,6 +280,7 @@ class LifeCycleCosts:
electricity_heating + electricity_cooling + electricity_lighting + domestic_hot_water_electricity + electricity_heating + electricity_cooling + electricity_lighting + domestic_hot_water_electricity +
electricity_plug_loads + electricity_distribution electricity_plug_loads + electricity_distribution
) )
print(f'electricity consumption {total_electricity_consumption}')
# todo: change when peak electricity demand is coded. Careful with factor residential # todo: change when peak electricity demand is coded. Careful with factor residential
peak_electricity_demand = 100 # self._peak_electricity_demand peak_electricity_demand = 100 # self._peak_electricity_demand