diff --git a/energy_system_retrofit.py b/energy_system_retrofit.py index e757deb0..36c74439 100644 --- a/energy_system_retrofit.py +++ b/energy_system_retrofit.py @@ -92,9 +92,8 @@ for building in city.buildings: fuel_tariffs=['Electricity-D', 'Gas-Energir']).life_cycle lcc_dataframe.to_csv(cost_analysis_output_path / f'{building.name}_retrofitted_lcc.csv') retrofitted_life_cycle_cost[f'{building.name}'] = cost_data(building, lcc_dataframe, cost_retrofit_scenario) -for i in range(12): - dhw_consumption = 0 - for building in city.buildings: - dhw_consumption += building.domestic_hot_water_consumption[cte.MONTH][i] / 3.6e6 +EnergySystemRetrofitReport(city, output_path, 'PV Implementation and System Retrofit', + current_status_energy_consumption, retrofitted_energy_consumption, + current_status_life_cycle_cost, retrofitted_life_cycle_cost).create_report() diff --git a/input_files/test_geojson.geojson b/input_files/test_geojson.geojson deleted file mode 100644 index df9f0c4c..00000000 --- a/input_files/test_geojson.geojson +++ /dev/null @@ -1,55 +0,0 @@ -{ - "type": "FeatureCollection", - "features": [ - { - "type": "Feature", - "geometry": { - "type": "Polygon", - "coordinates": [ - [ - [ - -73.58000127109773, - 45.49613461675315 - ], - [ - -73.57962787855432, - 45.496524875557746 - ], - [ - -73.57996357265695, - 45.49668114195629 - ], - [ - -73.57996427397713, - 45.496680342403664 - ], - [ - -73.58034707390021, - 45.49625804233725 - ], - [ - -73.58034697395713, - 45.496257942524835 - ], - [ - -73.58000127109773, - 45.49613461675315 - ] - ] - ] - }, - "id": 179764, - "properties": { - "name": "01119274", - "address": "rue Guy (MTL) 2157", - "function": "Mixed use", - "mixed_type_1": "commercial", - "mixed_type_1_percentage": 50, - "mixed_type_2": "6000", - "mixed_type_2_percentage": 50, - "height": 62, - "year_of_construction": 1954 - } - } - ] -} \ No newline at end of file diff --git a/input_files/test_geojson1.geojson b/input_files/test_geojson1.geojson deleted file mode 100644 index 92307eae..00000000 --- a/input_files/test_geojson1.geojson +++ /dev/null @@ -1,52 +0,0 @@ -{ - "type": "FeatureCollection", - "features": [ - { - "type": "Feature", - "geometry": { - "type": "Polygon", - "coordinates": [ - [ - [ - -73.58000127109773, - 45.49613461675315 - ], - [ - -73.57962787855432, - 45.496524875557746 - ], - [ - -73.57996357265695, - 45.49668114195629 - ], - [ - -73.57996427397713, - 45.496680342403664 - ], - [ - -73.58034707390021, - 45.49625804233725 - ], - [ - -73.58034697395713, - 45.496257942524835 - ], - [ - -73.58000127109773, - 45.49613461675315 - ] - ] - ] - }, - "id": 179764, - "properties": { - "name": "01119274", - "address": "rue Guy (MTL) 2157", - "function": "Mixed use", - "usages": [{"usage": "commercial", "percentage": 50}, {"usage": "6000", "percentage": 50}], - "height": 62, - "year_of_construction": 1954 - } - } - ] -} \ No newline at end of file diff --git a/main.py b/main.py index 431f8e92..3baddf26 100644 --- a/main.py +++ b/main.py @@ -27,8 +27,8 @@ import numpy as np data = {} input_files_path = (Path(__file__).parent / 'input_files') input_files_path.mkdir(parents=True, exist_ok=True) -# geojson_file = process_geojson(x=-73.58001358793511, y=45.496445294438715, diff=0.0001) -geojson_file_path = input_files_path / 'test_geojson1.geojson' +geojson_file = process_geojson(x=-73.58001358793511, y=45.496445294438715, diff=0.0001) +geojson_file_path = input_files_path / 'output_buildings.geojson' output_path = (Path(__file__).parent / 'out_files').resolve() output_path.mkdir(parents=True, exist_ok=True) energy_plus_output_path = output_path / 'energy_plus_outputs' @@ -45,8 +45,8 @@ city = GeometryFactory(file_type='geojson', year_of_construction_field='year_of_construction', function_field='function', function_to_hub=Dictionaries().montreal_function_to_hub_function).city -# ConstructionFactory('nrcan', city).enrich() -# UsageFactory('nrcan', city).enrich() +ConstructionFactory('nrcan', city).enrich() +UsageFactory('nrcan', city).enrich() # WeatherFactory('epw', city).enrich() # energy_plus_workflow(city, energy_plus_output_path) # data[f'{city.buildings[0].function}'] = city.buildings[0].heating_demand[cte.YEAR][0] / 3.6e9 diff --git a/scripts/optimization/energy_system_sizing_optimization.py b/scripts/optimization/energy_system_sizing_optimization.py new file mode 100644 index 00000000..c5ef366a --- /dev/null +++ b/scripts/optimization/energy_system_sizing_optimization.py @@ -0,0 +1,26 @@ +import random +import numpy as np +import hub.helpers.constants as cte + +class EnergySystemOptimizer: + def __init__(self, building, objectives, population_size=20, number_of_generations=100, crossover_rate=0.8, + mutation_rate=0.1): + self.building = building + self.objectives = objectives + self.population_size = population_size + self.num_gen = number_of_generations + self.crossover_rate = crossover_rate + self.mutation_rate = mutation_rate + +# Initialize population + def initialize_population(self): + population = [] + for _ in range(self.population_size): + individual = [ + random.uniform(0.1, 10.0), # hp_size + random.uniform(0.1, 10.0), # boiler_size + random.uniform(0.1, 10.0), # tes_size + random.uniform(40, 60) # cutoff_temp + ] + population.append(individual) + return population \ No newline at end of file diff --git a/scripts/optimization/objectives.py b/scripts/optimization/objectives.py new file mode 100644 index 00000000..fce62a8d --- /dev/null +++ b/scripts/optimization/objectives.py @@ -0,0 +1,16 @@ +# Objective functions +MINIMUM_LCC = 1 +MINIMUM_EC = 2 +MINIMUM_EMISSIONS = 3 +MINIMUM_LCC_MINIMUM_EC = 4 +MINIMUM_LCC_MINIMUM_EMISSIONS = 5 +MINIMUM_EC_MINIMUM_EMISSIONS = 6 +MINIMUM_LCC_MINIMUM_EC_MINIMUM_EMISSIONS = 7 +OBJECTIVE_FUNCTIONS = [MINIMUM_LCC, + MINIMUM_EC, + MINIMUM_EMISSIONS, + MINIMUM_LCC_MINIMUM_EC, + MINIMUM_LCC_MINIMUM_EMISSIONS, + MINIMUM_EC_MINIMUM_EMISSIONS, + MINIMUM_LCC_MINIMUM_EC_MINIMUM_EMISSIONS] + diff --git a/scripts/random_assignation.py b/scripts/random_assignation.py index 950ca8c4..a478c35c 100644 --- a/scripts/random_assignation.py +++ b/scripts/random_assignation.py @@ -28,8 +28,8 @@ residential_systems_percentage = {'system 1 gas': 15, 'system 8 gas': 15, 'system 8 electricity': 35} -residential_new_systems_percentage = {'PV+ASHP+GasBoiler+TES': 100, - 'PV+4Pipe+DHW': 0, +residential_new_systems_percentage = {'PV+ASHP+GasBoiler+TES': 0, + 'PV+4Pipe+DHW': 100, 'PV+ASHP+ElectricBoiler+TES': 0, 'PV+GSHP+GasBoiler+TES': 0, 'PV+GSHP+ElectricBoiler+TES': 0, diff --git a/scripts/system_simulation_models/archetype1.py b/scripts/system_simulation_models/archetype1.py index 72d91b70..5c56ec66 100644 --- a/scripts/system_simulation_models/archetype1.py +++ b/scripts/system_simulation_models/archetype1.py @@ -16,7 +16,8 @@ class Archetype1: self._domestic_hot_water_peak_load = building.domestic_hot_water_peak_load[cte.YEAR][0] self._hourly_heating_demand = [0] + [demand / 3600 for demand in building.heating_demand[cte.HOUR]] self._hourly_cooling_demand = [demand / 3600 for demand in building.cooling_demand[cte.HOUR]] - self._hourly_dhw_demand = building.domestic_hot_water_heat_demand[cte.HOUR] + self._hourly_dhw_demand = [demand / cte.WATTS_HOUR_TO_JULES for demand in + building.domestic_hot_water_heat_demand[cte.HOUR]] self._output_path = output_path self._t_out = [0] + building.external_temperature[cte.HOUR] self.results = {} @@ -27,9 +28,9 @@ class Archetype1: heat_pump = self._hvac_system.generation_systems[0] boiler = self._hvac_system.generation_systems[1] thermal_storage = heat_pump.energy_storage_systems[0] - heat_pump.nominal_heat_output = round(0.5 * self._heating_peak_load / 3600) - heat_pump.nominal_cooling_output = round(self._cooling_peak_load / 3600) - boiler.nominal_heat_output = round(0.5 * self._heating_peak_load / 3600) + heat_pump.nominal_heat_output = round(0.5 * self._heating_peak_load) + heat_pump.nominal_cooling_output = round(self._cooling_peak_load) + boiler.nominal_heat_output = round(0.5 * self._heating_peak_load) thermal_storage.volume = round( (self._heating_peak_load * storage_factor * cte.WATTS_HOUR_TO_JULES) / (cte.WATER_HEAT_CAPACITY * cte.WATER_DENSITY * 25)) diff --git a/scripts/system_simulation_models/archetype13.py b/scripts/system_simulation_models/archetype13.py index 642bfca4..48ebee50 100644 --- a/scripts/system_simulation_models/archetype13.py +++ b/scripts/system_simulation_models/archetype13.py @@ -5,7 +5,7 @@ from hub.helpers.monthly_values import MonthlyValues class Archetype13: - def __init__(self, building, output_path): + def __init__(self, building, output_path, csv_output=True,): self._building = building self._name = building.name self._pv_system = building.energy_systems[0] @@ -25,6 +25,7 @@ class Archetype13: self._t_out = building.external_temperature[cte.HOUR] self.results = {} self.dt = 900 + self.csv_output = csv_output def hvac_sizing(self): storage_factor = 3 @@ -374,10 +375,11 @@ class Archetype13: MonthlyValues.get_total_month(self._building.domestic_hot_water_consumption[cte.HOUR])) self._building.domestic_hot_water_consumption[cte.YEAR] = [ sum(self._building.domestic_hot_water_consumption[cte.MONTH])] - file_name = f'energy_system_simulation_results_{self._name}.csv' - with open(self._output_path / file_name, 'w', newline='') as csvfile: - output_file = csv.writer(csvfile) - # Write header - output_file.writerow(self.results.keys()) - # Write data - output_file.writerows(zip(*self.results.values())) + if self.csv_output: + file_name = f'energy_system_simulation_results_{self._name}.csv' + with open(self._output_path / file_name, 'w', newline='') as csvfile: + output_file = csv.writer(csvfile) + # Write header + output_file.writerow(self.results.keys()) + # Write data + output_file.writerows(zip(*self.results.values()))