""" Total maintenance costs module SPDX - License - Identifier: LGPL - 3.0 - or -later Copyright © 2023 Project Coder Guille Gutierrez guillermo.gutierrezmorote@concordia.ca Code contributor Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca Code contributor Oriol Gavalda Torrellas oriol.gavalda@concordia.ca """ import math import pandas as pd from hub.city_model_structure.building import Building import hub.helpers.constants as cte from costing_package.configuration import Configuration from costing_package.cost_base import CostBase class TotalMaintenanceCosts(CostBase): """ Total maintenance costs class """ def __init__(self, building: Building, configuration: Configuration): super().__init__(building, configuration) self._yearly_maintenance_costs = pd.DataFrame( index=self._rng, columns=[ 'Heating_maintenance', 'Cooling_maintenance', 'DHW_maintenance', 'PV_maintenance' ], dtype='float' ) def calculate(self) -> pd.DataFrame: """ Calculate total maintenance costs :return: pd.DataFrame """ building = self._building archetype = self._archetype # todo: change area pv when the variable exists roof_area = 0 surface_pv = 0 for roof in self._building.roofs: if roof.installed_solar_collector_area is not None: surface_pv += roof.installed_solar_collector_area else: surface_pv = roof_area * 0.5 energy_systems = building.energy_systems maintenance_heating_0 = 0 maintenance_cooling_0 = 0 maintenance_dhw_0 = 0 heating_equipments = {} cooling_equipments = {} dhw_equipments = {} for energy_system in energy_systems: if cte.COOLING in energy_system.demand_types: for generation_system in energy_system.generation_systems: if generation_system.fuel_type == cte.ELECTRICITY: if generation_system.system_type == cte.HEAT_PUMP and generation_system.source_medium == cte.AIR: cooling_equipments['air_source_heat_pump'] = generation_system.nominal_cooling_output / 1000 elif generation_system.system_type == cte.HEAT_PUMP and generation_system.source_medium == cte.GROUND: cooling_equipments['ground_source_heat_pump'] = generation_system.nominal_cooling_output / 1000 elif generation_system.system_type == cte.HEAT_PUMP and generation_system.source_medium == cte.WATER: cooling_equipments['water_source_heat_pump'] = generation_system.nominal_cooling_output / 1000 else: cooling_equipments['general_cooling_equipment'] = generation_system.nominal_cooling_output / 1000 if cte.HEATING in energy_system.demand_types: for generation_system in energy_system.generation_systems: if generation_system.system_type == cte.HEAT_PUMP and generation_system.source_medium == cte.AIR: heating_equipments['air_source_heat_pump'] = generation_system.nominal_heat_output / 1000 elif generation_system.system_type == cte.HEAT_PUMP and generation_system.source_medium == cte.GROUND: heating_equipments['ground_source_heat_pump'] = generation_system.nominal_heat_output / 1000 elif generation_system.system_type == cte.HEAT_PUMP and generation_system.source_medium == cte.WATER: heating_equipments['water_source_heat_pump'] = generation_system.nominal_heat_output / 1000 elif generation_system.system_type == cte.BOILER and generation_system.fuel_type == cte.GAS: heating_equipments['gas_boiler'] = generation_system.nominal_heat_output / 1000 elif generation_system.system_type == cte.BOILER and generation_system.fuel_type == cte.ELECTRICITY: heating_equipments['electric_boiler'] = generation_system.nominal_heat_output / 1000 else: heating_equipments['general_heating_equipment'] = generation_system.nominal_heat_output / 1000 if cte.DOMESTIC_HOT_WATER in energy_system.demand_types and cte.HEATING not in energy_system.demand_types: for generation_system in energy_system.generation_systems: if generation_system.system_type == cte.HEAT_PUMP and generation_system.source_medium == cte.AIR: dhw_equipments['air_source_heat_pump'] = generation_system.nominal_heat_output / 1000 elif generation_system.system_type == cte.HEAT_PUMP and generation_system.source_medium == cte.GROUND: dhw_equipments['ground_source_heat_pump'] = generation_system.nominal_heat_output / 1000 elif generation_system.system_type == cte.HEAT_PUMP and generation_system.source_medium == cte.WATER: dhw_equipments['water_source_heat_pump'] = generation_system.nominal_heat_output / 1000 elif generation_system.system_type == cte.BOILER and generation_system.fuel_type == cte.GAS: dhw_equipments['gas_boiler'] = generation_system.nominal_heat_output / 1000 elif generation_system.system_type == cte.BOILER and generation_system.fuel_type == cte.ELECTRICITY: dhw_equipments['electric_boiler'] = generation_system.nominal_heat_output / 1000 else: dhw_equipments['general_heating_equipment'] = generation_system.nominal_heat_output / 1000 for heating_equipment in heating_equipments: component = self.search_hvac_equipment(heating_equipment) maintenance_cost = component.maintenance[0] maintenance_heating_0 += (heating_equipments[heating_equipment] * maintenance_cost) for cooling_equipment in cooling_equipments: component = self.search_hvac_equipment(cooling_equipment) maintenance_cost = component.maintenance[0] maintenance_cooling_0 += (cooling_equipments[cooling_equipment] * maintenance_cost) for dhw_equipment in dhw_equipments: component = self.search_hvac_equipment(dhw_equipment) maintenance_cost = component.maintenance[0] maintenance_dhw_0 += (dhw_equipments[dhw_equipment] * maintenance_cost) maintenance_pv_0 = surface_pv * archetype.operational_cost.maintenance_pv for year in range(1, self._configuration.number_of_years + 1): costs_increase = math.pow(1 + self._configuration.consumer_price_index, year) self._yearly_maintenance_costs.loc[year, 'Heating_maintenance'] = ( maintenance_heating_0 * costs_increase ) self._yearly_maintenance_costs.loc[year, 'Cooling_maintenance'] = ( maintenance_cooling_0 * costs_increase ) self._yearly_maintenance_costs.loc[year, 'DHW_maintenance'] = ( maintenance_dhw_0 * costs_increase ) self._yearly_maintenance_costs.loc[year, 'PV_maintenance'] = ( maintenance_pv_0 * costs_increase ) self._yearly_maintenance_costs.fillna(0, inplace=True) return self._yearly_maintenance_costs def search_hvac_equipment(self, equipment_type): for component in self._archetype.operational_cost.maintenance_hvac: if component.type == equipment_type: return component