from pathlib import Path from energy_system_modelling_package.energy_system_modelling_factories.energy_system_sizing_factory import \ EnergySystemsSizingFactory from energy_system_modelling_package.energy_system_modelling_factories.montreal_energy_system_archetype_modelling_factory import \ MontrealEnergySystemArchetypesSimulationFactory from hub.imports.energy_systems_factory import EnergySystemsFactory from hub.imports.geometry_factory import GeometryFactory from hub.helpers.dictionaries import Dictionaries from hub.imports.construction_factory import ConstructionFactory from hub.imports.usage_factory import UsageFactory from hub.imports.weather_factory import WeatherFactory import pandas as pd import hub.helpers.constants as cte from costing_package.constants import * from costing_package.cost import Cost # Specify the GeoJSON file path input_files_path = (Path(__file__).parent / 'input_files') input_files_path.mkdir(parents=True, exist_ok=True) geojson_file_path = input_files_path / 'rf_building.geojson' output_path = (Path(__file__).parent / 'out_files').resolve() output_path.mkdir(parents=True, exist_ok=True) simulation_results_path = (Path(__file__).parent / 'out_files' / 'simulation_results').resolve() simulation_results_path.mkdir(parents=True, exist_ok=True) cost_analysis_output_path = output_path / 'cost_analysis' cost_analysis_output_path.mkdir(parents=True, exist_ok=True) city = GeometryFactory(file_type='geojson', path=geojson_file_path, height_field='height', year_of_construction_field='year_of_construction', function_field='function', function_to_hub=Dictionaries().montreal_function_to_hub_function).city demands = pd.read_csv(input_files_path / 'cbt_data.csv') city.buildings[0].heating_demand[cte.HOUR] = [x * cte.WATTS_HOUR_TO_JULES * 1000 / 4 for x in demands['total'].to_list()] city.buildings[0].cooling_demand[cte.HOUR] = [0] * 8760 city.buildings[0].domestic_hot_water_heat_demand[cte.HOUR] = [0] * 8760 city.buildings[0].lighting_electrical_demand[cte.HOUR] = [0] * 8760 city.buildings[0].lighting_electrical_demand[cte.YEAR] = [0] city.buildings[0].appliances_electrical_demand[cte.YEAR] = [0] city.buildings[0].appliances_electrical_demand[cte.HOUR] = [0] * 8760 ConstructionFactory('nrcan', city).enrich() UsageFactory('nrcan', city).enrich() WeatherFactory('epw', city).enrich() for building in city.buildings: building.energy_systems_archetype_name = ('Central Hydronic Air and Electricity Source Heating System with Unitary ' 'Split and Air Source HP DHW') EnergySystemsFactory('montreal_future', city).enrich() EnergySystemsSizingFactory('peak_load_sizing', city).enrich() for building in city.buildings: MontrealEnergySystemArchetypesSimulationFactory(f'archetype_cluster_{building.energy_systems_archetype_cluster_id}', building, simulation_results_path).enrich() for building in city.buildings: cost_retrofit_scenario = SYSTEM_RETROFIT lcc_dataframe = Cost(building=building, retrofit_scenario=cost_retrofit_scenario, fuel_tariffs=['Electricity-D', 'Gas-Energir']).life_cycle lcc_dataframe.to_csv(cost_analysis_output_path / f'{building.name}_retrofitted_lcc.csv') print('test')