costs_workflow/capital_cost.py
2023-01-28 18:25:57 -05:00

55 lines
3.2 KiB
Python

"""
CapitalCost calculates the Capital Cost of one building
SPDX - License - Identifier: LGPL - 3.0 - or -later
Copyright © 2022 Project Coder Atiya atiya.atiya@mail.concordia.ca
"""
class CapitalCost:
def calculate_capital_cost(building_area, municipality, building_volume, total_opaque_area, total_transparent_area, content, heating_load, cooling_load, floor_area):
for cost in content.costs:
if cost.municipality == municipality:
structural_cost = float(cost.capital_cost.structural_cost) * building_volume
sub_structural_cost = float(cost.capital_cost.sub_structural_cost) * building_area
envelop_cost = 0.0
for i in range(len(cost.capital_cost.envelop_cost)):
if cost.capital_cost.envelop_cost[i].type == 'opaque_cost':
opague_cost = float(cost.capital_cost.envelop_cost[i].reposition) * total_opaque_area + float(
cost.capital_cost.envelop_cost[i].initial_investment) * total_opaque_area
envelop_cost += opague_cost
if cost.capital_cost.envelop_cost[i].type == 'transparent_cost':
transparent_cost = float(cost.capital_cost.envelop_cost[i].reposition) * total_transparent_area + float(
cost.capital_cost.envelop_cost[i].initial_investment) * total_transparent_area
envelop_cost += transparent_cost
# print("envelop_cost ", envelop_cost)
hvac_cost = 0.0
for i in range(len(cost.capital_cost.system_cost.hvac_cost)):
if cost.capital_cost.system_cost.hvac_cost[i].type == 'heating_load_cost':
heating_load_cost = float(cost.capital_cost.system_cost.hvac_cost[i].reposition) * heating_load + float(
cost.capital_cost.system_cost.hvac_cost[i].initial_investment) * heating_load
hvac_cost += heating_load_cost
if cost.capital_cost.system_cost.hvac_cost[i].type == 'cooling_load_cost':
cooling_load_cost = float(cost.capital_cost.system_cost.hvac_cost[i].reposition) * cooling_load + float(
cost.capital_cost.system_cost.hvac_cost[i].initial_investment) * cooling_load
hvac_cost += cooling_load_cost
rest_cost = float(cost.capital_cost.system_cost.rest_cost.reposition) * floor_area
pv_cost = float(cost.capital_cost.system_cost.pv_cost.reposition) * floor_area
system_cost = hvac_cost + rest_cost + pv_cost
lighting_cost = float(cost.capital_cost.lighting_cost) * building_area
surface_finish_cost = float(cost.capital_cost.surface_finish_cost) * building_area
engineer_cost = (float(cost.capital_cost.engineer_cost) * (structural_cost + sub_structural_cost + envelop_cost + system_cost + lighting_cost + surface_finish_cost)) / 100
construction_subsidy = (float(cost.capital_cost.subsidy.construction_subsidy) * (structural_cost + sub_structural_cost + envelop_cost)) / 100
hvac_subsidy = (float(cost.capital_cost.subsidy.hvac_subsidy) * hvac_cost) / 100
pv_subsidy = (float(cost.capital_cost.subsidy.pv_subsidy) * pv_cost) / 100
subsidy = construction_subsidy + hvac_subsidy + pv_subsidy
capital_cost = structural_cost + sub_structural_cost + envelop_cost + system_cost + lighting_cost + surface_finish_cost + engineer_cost + subsidy
return capital_cost