costs_workflow/costs/__main__emissions.py

69 lines
3.2 KiB
Python
Raw Permalink Normal View History

"""
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()