Small changes to incorporate distribution and check mistakes

This commit is contained in:
Oriol Gavalda 2023-05-30 11:15:33 -04:00
parent dba0b3f77f
commit fff569b46f
2 changed files with 29 additions and 11 deletions

View File

@ -16,7 +16,7 @@ import hub.helpers.constants as cte
class LifeCycleCosts:
def __init__(self, building, archetype, number_of_years, consumer_price_index, electricity_peak_index,
electricity_price_index, gas_price_index, discount_rate,
retrofitting_scenario):
retrofitting_scenario,fuel_type):
self._building = building
self._number_of_years = number_of_years
self._consumer_price_index = consumer_price_index
@ -32,6 +32,7 @@ class LifeCycleCosts:
self._concepts = 0
self._retrofitting_scenario = retrofitting_scenario
self._total_floor_area = 0
self._fuel_type = fuel_type
for internal_zone in building.internal_zones:
for thermal_zone in internal_zone.thermal_zones:
self._total_floor_area += thermal_zone.total_floor_area
@ -178,24 +179,33 @@ class LifeCycleCosts:
building = self._building
archetype = self._archetype
total_floor_area = self._total_floor_area
factor_residential = total_floor_area / 80
#todo: split the heating between fuels
electricity_heating = building.heating_consumption[cte.YEAR][0] / (1000)
fixed_gas_cost_year_0 = 0
variable_gas_cost_year_0 = 0
electricity_heating = 0
domestic_hot_water_electricity = 0
if self._fuel_type == 1:
fixed_gas_cost_year_0 = archetype.operational_cost.fuels[1].fixed_monthly
variable_gas_cost_year_0 = (building.heating_consumption[cte.YEAR][0]+
building.domestic_hot_water_consumption[cte.YEAR][0]) / (1000) * \
archetype.operational_cost.fuels[1].variable[0]
if self._fuel_type == 0:
electricity_heating = building.heating_consumption[cte.YEAR][0] / (1000)
domestic_hot_water_electricity = building.domestic_hot_water_consumption[cte.YEAR][0] / 1000
electricity_cooling = building.cooling_consumption[cte.YEAR][0] / (1000)
electricity_lighting = building.lighting_electrical_demand[cte.YEAR]['insel meb']/1000
domestic_hot_water_demand = building.domestic_hot_water_consumption[cte.YEAR][0]/1000
electricity_plug_loads = building.appliances_electrical_demand[cte.YEAR]['insel meb']/1000
electricity_distribution = building.distribution_systems_electrical_consumption [cte.YEAR][0]/1000
electricity_distribution = 0 #building.distribution_systems_electrical_consumption[cte.YEAR][0]/1000
total_electricity_consumption = electricity_heating + electricity_cooling + electricity_lighting + \
domestic_hot_water_demand + electricity_plug_loads + electricity_distribution
domestic_hot_water_electricity + electricity_plug_loads + electricity_distribution
#todo: change when peak electricity demand is coded. Careful with factor residential
peak_electricity_demand = 100 #self._peak_electricity_demand
factor_residential= total_floor_area/80
variable_electricity_cost_year_0 = total_electricity_consumption * archetype.operational_cost.fuels[0].variable[0]
peak_electricity_cost_year_0 = peak_electricity_demand * archetype.operational_cost.fuels[0].fixed_power * 12
monthly_electricity_cost_year_0 = archetype.operational_cost.fuels[0].fixed_monthly * 12 * factor_residential
fixed_gas_cost_year_0 = archetype.operational_cost.fuels[1].fixed_monthly*12* factor_residential
variable_gas_cost_year_0 = total_electricity_consumption * archetype.operational_cost.fuels[1].variable[0]
price_increase_electricity = 0
price_increase_peak_electricity = 0
price_increase_gas = 0
@ -213,7 +223,7 @@ class LifeCycleCosts:
price_increase_electricity
self._yearly_operational_costs.at[year,'Fixed_costs_gas'] = fixed_gas_cost_year_0 * \
price_increase_gas
self._yearly_operational_costs.at[year,'Variable_costs_gas'] = variable_gas_cost_year_0* \
self._yearly_operational_costs.at[year,'Variable_costs_gas'] = variable_gas_cost_year_0* \
price_increase_peak_electricity
self._yearly_operational_costs.at[year,'Variable_costs_gas'] = variable_gas_cost_year_0 * \
price_increase_peak_electricity

10
main.py
View File

@ -126,8 +126,15 @@ for retrofitting_scenario in retrofitting_scenarios:
# f'{building.function}\n')
#continue
print('lcc for first building started')
if "gas" in building.energy_systems_archetype_name:
#0 to electricity, 1 to gas
fuel_type = 1
else:
fuel_type = 0
print(f'fuel type {fuel_type}')
lcc = LifeCycleCosts(building, archetype, number_of_years, consumer_price_index, electricity_peak_index,
electricity_price_index, gas_price_index, discount_rate, retrofitting_scenario)
electricity_price_index, gas_price_index, discount_rate, retrofitting_scenario,fuel_type)
global_capital_costs = lcc.calculate_capital_costs()
global_end_of_life_costs = lcc.calculate_end_of_life_costs()
global_operational_costs = lcc.calculate_total_operational_costs()
@ -179,6 +186,7 @@ for retrofitting_scenario in retrofitting_scenarios:
f'operational_incomes']
print(life_cycle_results)
print(f'Scenario {retrofitting_scenario} {life_cycle_costs}')
#todo: change if there is more than 1 building
life_cycle_results.to_excel(Path(__file__).parent/'out_files'/f'Results.xlsx', index=True)