fix: bugs in costing solved

This commit is contained in:
Saeed Ranjbar 2024-05-17 09:52:42 -04:00
parent 1e8d064080
commit 28c642bacd
5 changed files with 28 additions and 25 deletions

View File

@ -172,8 +172,8 @@ class MontrealNewCatalog(Catalog):
lower_heating_value=lower_heating_value,
lower_heating_value_unit=lower_heating_value_unit)
fuels.append(fuel)
heating_equipment_maintenance = float(entry['maintenance']['heating_equipment']['#text']) / 1000
cooling_equipment_maintenance = float(entry['maintenance']['cooling_equipment']['#text']) / 1000
heating_equipment_maintenance = float(entry['maintenance']['heating_equipment']['#text'])
cooling_equipment_maintenance = float(entry['maintenance']['cooling_equipment']['#text'])
photovoltaic_system_maintenance = float(entry['maintenance']['photovoltaic_system']['#text'])
co2_emissions = float(entry['co2_cost']['#text'])
_operational_cost = OperationalCost(fuels,

View File

@ -25,8 +25,8 @@
<D_services>
<D20_onsite_generation>
<D2010_photovoltaic_system>
<investment_cost cost_unit="currency/m2"> 800 </investment_cost>
<reposition cost_unit="currency/m2"> 800 </reposition>
<investment_cost cost_unit="currency/m2"> 0 </investment_cost>
<reposition cost_unit="currency/m2"> 0 </reposition>
<lifetime_equipment lifetime="years"> 25 </lifetime_equipment>
</D2010_photovoltaic_system>
</D20_onsite_generation>
@ -63,7 +63,7 @@
<lifetime_equipment lifetime="years"> 15 </lifetime_equipment>
</D302070_natural_gas_boiler>
<D302080_electrical_boiler>
<investment_cost cost_unit="currency/kW"> 300 </investment_cost>
<investment_cost cost_unit="currency/kW"> 350 </investment_cost>
<reposition cost_unit="currency/kW"> 300 </reposition>
<lifetime_equipment lifetime="years"> 15 </lifetime_equipment>
</D302080_electrical_boiler>
@ -318,7 +318,7 @@
<maintenance>
<heating_equipment cost_unit="currency/kW">40</heating_equipment>
<cooling_equipment cost_unit="currency/kW">40</cooling_equipment>
<photovoltaic_system cost_unit="currency/m2">1</photovoltaic_system>
<photovoltaic_system cost_unit="currency/m2">0</photovoltaic_system>
</maintenance>
<co2_cost cost_unit="currency/kgCO2"> 30 </co2_cost>
</operational_cost>

28
main.py
View File

@ -15,11 +15,12 @@ from scripts.energy_system_sizing import SystemSizing
from scripts.energy_system_retrofit_results import system_results, new_system_results
from scripts.energy_system_sizing_and_simulation_factory import EnergySystemsSimulationFactory
from scripts.costs.cost import Cost
from scripts.costs.constants import SKIN_RETROFIT_AND_SYSTEM_RETROFIT_AND_PV
from scripts.costs.constants import SKIN_RETROFIT_AND_SYSTEM_RETROFIT_AND_PV, SYSTEM_RETROFIT_AND_PV
import hub.helpers.constants as cte
from hub.exports.exports_factory import ExportsFactory
# Specify the GeoJSON file path
geojson_file = process_geojson(x=-73.5681295982132, y=45.49218262677643, diff=0.0001)
file_path = (Path(__file__).parent.parent / 'input_files' / f'{geojson_file}')
# geojson_file = process_geojson(x=-73.5953602192335, y=45.492414530022515, diff=0.001)
file_path = (Path(__file__).parent / 'input_files' / 'output_buildings.geojson')
# Specify the output path for the PDF file
output_path = (Path(__file__).parent / 'out_files').resolve()
# Create city object from GeoJSON file
@ -34,12 +35,7 @@ ConstructionFactory('nrcan', city).enrich()
UsageFactory('nrcan', city).enrich()
WeatherFactory('epw', city).enrich()
ExportsFactory('sra', city, output_path).export()
sra_path = (output_path / f'{city.name}_sra.xml').resolve()
subprocess.run(['sra', str(sra_path)])
ResultFactory('sra', city, output_path).enrich()
energy_plus_workflow(city)
ExportsFactory('obj', city, output_path).export()
random_assignation.call_random(city.buildings, random_assignation.residential_systems_percentage)
EnergySystemsFactory('montreal_custom', city).enrich()
SystemSizing(city.buildings).montreal_custom()
@ -48,15 +44,21 @@ random_assignation.call_random(city.buildings, random_assignation.residential_ne
EnergySystemsFactory('montreal_future', city).enrich()
for building in city.buildings:
EnergySystemsSimulationFactory('archetype1', building=building, output_path=output_path).enrich()
new_system = system_results(city.buildings)
EnergySystemAnalysisReport(city, output_path).create_report(current_system, new_system)
print(building.energy_consumption_breakdown[cte.ELECTRICITY][cte.COOLING] +
building.energy_consumption_breakdown[cte.ELECTRICITY][cte.HEATING] +
building.energy_consumption_breakdown[cte.ELECTRICITY][cte.DOMESTIC_HOT_WATER])
new_system = new_system_results(city.buildings)
# EnergySystemAnalysisReport(city, output_path).create_report(current_system, new_system)
for building in city.buildings:
costs = Cost(building=building, retrofit_scenario=SKIN_RETROFIT_AND_SYSTEM_RETROFIT_AND_PV).life_cycle
costs = Cost(building=building, retrofit_scenario=SYSTEM_RETROFIT_AND_PV).life_cycle
costs.to_csv(output_path / f'{building.name}_lcc.csv')
(costs.loc['global_operational_costs', f'Scenario {SKIN_RETROFIT_AND_SYSTEM_RETROFIT_AND_PV}'].
(costs.loc['global_operational_costs', f'Scenario {SYSTEM_RETROFIT_AND_PV}'].
to_csv(output_path / f'{building.name}_op.csv'))
costs.loc['global_capital_costs', f'Scenario {SKIN_RETROFIT_AND_SYSTEM_RETROFIT_AND_PV}'].to_csv(
costs.loc['global_capital_costs', f'Scenario {SYSTEM_RETROFIT_AND_PV}'].to_csv(
output_path / f'{building.name}_cc.csv')
costs.loc['global_maintenance_costs', f'Scenario {SYSTEM_RETROFIT_AND_PV}'].to_csv(
output_path / f'{building.name}_m.csv')

View File

@ -52,17 +52,17 @@ class SystemSizing:
if cte.HEATING in demand_types:
if len(generation_systems) == 1:
for generation in generation_systems:
generation.nominal_heat_output = building.heating_peak_load[cte.YEAR][0] / 3.6e6
generation.nominal_heat_output = building.heating_peak_load[cte.YEAR][0] / 3600
else:
for generation in generation_systems:
generation.nominal_heat_output = building.heating_peak_load[cte.YEAR][0] / (len(generation_systems) * 3.6e6)
generation.nominal_heat_output = building.heating_peak_load[cte.YEAR][0] / (len(generation_systems) * 3600)
elif cte.COOLING in demand_types:
if len(generation_systems) == 1:
for generation in generation_systems:
generation.nominal_cooling_output = building.cooling_peak_load[cte.YEAR][0] / 3.6e6
generation.nominal_cooling_output = building.cooling_peak_load[cte.YEAR][0] / 3600
else:
for generation in generation_systems:
generation.nominal_heat_output = building.cooling_peak_load[cte.YEAR][0] / (len(generation_systems) * 3.6e6)
generation.nominal_heat_output = building.cooling_peak_load[cte.YEAR][0] / (len(generation_systems) * 3600)

View File

@ -86,7 +86,7 @@ class Archetype1:
cop_curve_coefficients[3] * t_out_fahrenheit +
cop_curve_coefficients[4] * t_out_fahrenheit ** 2 +
cop_curve_coefficients[5] * t_sup_hp_fahrenheit * t_out_fahrenheit)
hp_electricity[i + 1] = q_hp[i + 1] / hp_cop[i + 1]
hp_electricity[i + 1] = q_hp[i + 1] / hp_efficiency
else:
hp_cop[i + 1] = 0
hp_electricity[i + 1] = 0
@ -127,6 +127,7 @@ class Archetype1:
def cooling_system_simulation(self):
hp = self.hvac_sizing()[0]
eer_curve_coefficients = [float(coefficient) for coefficient in hp.cooling_efficiency_curve.coefficients]
cooling_efficiency = float(hp.cooling_efficiency)
demand = self._hourly_heating_demand
hp.source_temperature = self._t_out
variable_names = ["t_sup_hp", "t_ret", "m", "q_hp", "hp_electricity", "hp_eer"]
@ -159,7 +160,7 @@ class Archetype1:
eer_curve_coefficients[3] * t_out_fahrenheit +
eer_curve_coefficients[4] * t_out_fahrenheit ** 2 +
eer_curve_coefficients[5] * t_sup_hp_fahrenheit * t_out_fahrenheit))
hp_electricity[i] = q_hp[i] / hp_eer[i]
hp_electricity[i] = q_hp[i] / cooling_efficiency
else:
hp_eer[i] = 0
hp_electricity[i] = 0