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/output_buildings_expanded.geojson b/input_files/output_buildings_expanded.geojson new file mode 100644 index 00000000..43fd4d3f --- /dev/null +++ b/input_files/output_buildings_expanded.geojson @@ -0,0 +1,863 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [ + -73.56769087843276, + 45.49251875903776 + ], + [ + -73.56765050367694, + 45.492560280202284 + ], + [ + -73.5677794213865, + 45.49262188364245 + ], + [ + -73.56781916241786, + 45.49258006136105 + ], + [ + -73.56769087843276, + 45.49251875903776 + ] + ] + ] + }, + "id": 173347, + "properties": { + "name": "01044617", + "address": "rue Victor-Hugo (MTL) 1666", + "function": "1000", + "height": 9, + "year_of_construction": 1986 + } + }, + { + "type": "Feature", + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [ + -73.56765050367694, + 45.492560280202284 + ], + [ + -73.56761436875776, + 45.49259744179384 + ], + [ + -73.5676075694645, + 45.49260454199484 + ], + [ + -73.56773226889548, + 45.49266394156485 + ], + [ + -73.56773726906921, + 45.49266624130272 + ], + [ + -73.5677794213865, + 45.49262188364245 + ], + [ + -73.56765050367694, + 45.492560280202284 + ] + ] + ] + }, + "id": 173348, + "properties": { + "name": "01044619", + "address": "rue Victor-Hugo (MTL) 1670", + "function": "1000", + "height": 9, + "year_of_construction": 1986 + } + }, + { + "type": "Feature", + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [ + -73.56829026835214, + 45.492524742569145 + ], + [ + -73.56849646900322, + 45.49262354174874 + ], + [ + -73.56861067001111, + 45.492505541343576 + ], + [ + -73.56864076915663, + 45.492519941474434 + ], + [ + -73.56866246900178, + 45.49249754209202 + ], + [ + -73.56867696946317, + 45.49250454136644 + ], + [ + -73.56867726964143, + 45.49250414255471 + ], + [ + -73.56881486931461, + 45.492362042624144 + ], + [ + -73.56881686903772, + 45.492359941181455 + ], + [ + -73.5688004699483, + 45.49235084193039 + ], + [ + -73.56882097012145, + 45.4923320417195 + ], + [ + -73.56879846891101, + 45.49232034109352 + ], + [ + -73.56883736970825, + 45.492284841271946 + ], + [ + -73.56886806888434, + 45.492256240993704 + ], + [ + -73.56885337003277, + 45.49224914198001 + ], + [ + -73.56890226932418, + 45.49219894164121 + ], + [ + -73.56851866897392, + 45.49201434154299 + ], + [ + -73.56837326884313, + 45.492163841620254 + ], + [ + -73.56864696910176, + 45.49229554163243 + ], + [ + -73.5685268682051, + 45.49241904187041 + ], + [ + -73.56825396962694, + 45.49228824183907 + ], + [ + -73.56810906858335, + 45.49243794104013 + ], + [ + -73.56829026835214, + 45.492524742569145 + ] + ] + ] + }, + "id": 173403, + "properties": { + "name": "01044334", + "address": "rue Saint-Jacques (MTL) 1460", + "function": "1000", + "height": 15, + "year_of_construction": 1985 + } + }, + { + "type": "Feature", + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [ + -73.5683896684674, + 45.491800342137736 + ], + [ + -73.56838616878639, + 45.49180414157881 + ], + [ + -73.56850686988925, + 45.49185994152571 + ], + [ + -73.56851286844197, + 45.4918626410622 + ], + [ + -73.56855549071014, + 45.49181750806087 + ], + [ + -73.56842962331187, + 45.49175738300567 + ], + [ + -73.5683896684674, + 45.491800342137736 + ] + ] + ] + }, + "id": 174898, + "properties": { + "name": "01044590", + "address": "rue Victor-Hugo (MTL) 1600", + "function": "1000", + "height": 9, + "year_of_construction": 1986 + } + }, + { + "type": "Feature", + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [ + -73.5680637695714, + 45.49212884162544 + ], + [ + -73.56802228176146, + 45.49217205619571 + ], + [ + -73.56815668696326, + 45.49223626189717 + ], + [ + -73.56815766959974, + 45.49223524178655 + ], + [ + -73.56818746886172, + 45.49224944155107 + ], + [ + -73.56822816806918, + 45.49220694186927 + ], + [ + -73.5680637695714, + 45.49212884162544 + ] + ] + ] + }, + "id": 175785, + "properties": { + "name": "01044602", + "address": "rue Victor-Hugo (MTL) 1630", + "function": "1000", + "height": 12, + "year_of_construction": 1986 + } + }, + { + "type": "Feature", + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [ + -73.56850793693103, + 45.49167318076048 + ], + [ + -73.56846877951091, + 45.4917152818903 + ], + [ + -73.56859506290321, + 45.491775605518725 + ], + [ + -73.56863463503653, + 45.491733702062774 + ], + [ + -73.56850793693103, + 45.49167318076048 + ] + ] + ] + }, + "id": 175910, + "properties": { + "name": "01044586", + "address": "rue Victor-Hugo (MTL) 1590", + "function": "1000", + "height": 9, + "year_of_construction": 1986 + } + }, + { + "type": "Feature", + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [ + -73.56817543449134, + 45.49201384773851 + ], + [ + -73.56813497596143, + 45.49205532773507 + ], + [ + -73.56826745951075, + 45.492118613912375 + ], + [ + -73.56830763251781, + 45.49207699906335 + ], + [ + -73.56817543449134, + 45.49201384773851 + ] + ] + ] + }, + "id": 176056, + "properties": { + "name": "01044599", + "address": "rue Victor-Hugo (MTL) 1620", + "function": "1000", + "height": 8, + "year_of_construction": 1986 + } + }, + { + "type": "Feature", + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [ + -73.56772876855176, + 45.49247194194522 + ], + [ + -73.56773406949068, + 45.492474341387755 + ], + [ + -73.56773125185198, + 45.492477239659124 + ], + [ + -73.56785890467093, + 45.492538239964624 + ], + [ + -73.56789966910456, + 45.49249534173201 + ], + [ + -73.56776616865103, + 45.49243264153464 + ], + [ + -73.56772876855176, + 45.49247194194522 + ] + ] + ] + }, + "id": 176261, + "properties": { + "name": "01044613", + "address": "rue Victor-Hugo (MTL) 1656", + "function": "1000", + "height": 10, + "year_of_construction": 1986 + } + }, + { + "type": "Feature", + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [ + -73.56802228176146, + 45.49217205619571 + ], + [ + -73.56798225825526, + 45.492213743742184 + ], + [ + -73.56811660206223, + 45.49227791893211 + ], + [ + -73.56815668696326, + 45.49223626189717 + ], + [ + -73.56802228176146, + 45.49217205619571 + ] + ] + ] + }, + "id": 176293, + "properties": { + "name": "01044604", + "address": "rue Victor-Hugo (MTL) 1636", + "function": "1000", + "height": 12, + "year_of_construction": 1986 + } + }, + { + "type": "Feature", + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [ + -73.56790222258577, + 45.49229712328457 + ], + [ + -73.56785996900595, + 45.49234104192853 + ], + [ + -73.56799446861396, + 45.49240484193282 + ], + [ + -73.56803643080562, + 45.49236123475947 + ], + [ + -73.56790222258577, + 45.49229712328457 + ] + ] + ] + }, + "id": 176296, + "properties": { + "name": "01044611", + "address": "rue Victor-Hugo (MTL) 1650", + "function": "1000", + "height": 10, + "year_of_construction": 1986 + } + }, + { + "type": "Feature", + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [ + -73.56798225825526, + 45.492213743742184 + ], + [ + -73.56794223597048, + 45.4922554321734 + ], + [ + -73.56807651582375, + 45.49231957685336 + ], + [ + -73.56811660206223, + 45.49227791893211 + ], + [ + -73.56798225825526, + 45.492213743742184 + ] + ] + ] + }, + "id": 176298, + "properties": { + "name": "01044607", + "address": "rue Victor-Hugo (MTL) 1640", + "function": "1000", + "height": 12, + "year_of_construction": 1986 + } + }, + { + "type": "Feature", + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [ + -73.56742736898599, + 45.49184704208998 + ], + [ + -73.56761256873325, + 45.491896142437554 + ], + [ + -73.56766926915839, + 45.4917902412014 + ], + [ + -73.56766956853903, + 45.49179024192391 + ], + [ + -73.56792966911675, + 45.49183254222432 + ], + [ + -73.56793006788594, + 45.491831141828406 + ], + [ + -73.56794526884076, + 45.49174634219527 + ], + [ + -73.56794516904765, + 45.49174634225465 + ], + [ + -73.56753896905731, + 45.491638642248425 + ], + [ + -73.56742736898599, + 45.49184704208998 + ] + ] + ] + }, + "id": 176918, + "properties": { + "name": "01097185", + "address": "rue Victor-Hugo (MTL) 1591", + "function": "1000", + "height": 10, + "year_of_construction": 1987 + } + }, + { + "type": "Feature", + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [ + -73.56773125185198, + 45.492477239659124 + ], + [ + -73.56769087843276, + 45.49251875903776 + ], + [ + -73.56781916241786, + 45.49258006136105 + ], + [ + -73.56785890467093, + 45.492538239964624 + ], + [ + -73.56773125185198, + 45.492477239659124 + ] + ] + ] + }, + "id": 178164, + "properties": { + "name": "01044615", + "address": "rue Victor-Hugo (MTL) 1660", + "function": "1000", + "height": 9, + "year_of_construction": 1986 + } + }, + { + "type": "Feature", + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [ + -73.56846877951091, + 45.4917152818903 + ], + [ + -73.56842962331187, + 45.49175738300567 + ], + [ + -73.56855549071014, + 45.49181750806087 + ], + [ + -73.56859506290321, + 45.491775605518725 + ], + [ + -73.56846877951091, + 45.4917152818903 + ] + ] + ] + }, + "id": 179679, + "properties": { + "name": "01044588", + "address": "rue Victor-Hugo (MTL) 1596", + "function": "1000", + "height": 9, + "year_of_construction": 1986 + } + }, + { + "type": "Feature", + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [ + -73.56825635009473, + 45.49193088860213 + ], + [ + -73.56821589168355, + 45.491972368627906 + ], + [ + -73.5683477837006, + 45.4920353716151 + ], + [ + -73.56838787594006, + 45.49199371809223 + ], + [ + -73.56825635009473, + 45.49193088860213 + ] + ] + ] + }, + "id": 179789, + "properties": { + "name": "01044595", + "address": "rue Victor-Hugo (MTL) 1610", + "function": "1000", + "height": 8, + "year_of_construction": 1986 + } + }, + { + "type": "Feature", + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [ + -73.56821589168355, + 45.491972368627906 + ], + [ + -73.56817543449134, + 45.49201384773851 + ], + [ + -73.56830763251781, + 45.49207699906335 + ], + [ + -73.5683477837006, + 45.4920353716151 + ], + [ + -73.56821589168355, + 45.491972368627906 + ] + ] + ] + }, + "id": 181310, + "properties": { + "name": "01044597", + "address": "rue Victor-Hugo (MTL) 1616", + "function": "1000", + "height": 8, + "year_of_construction": 1986 + } + }, + { + "type": "Feature", + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [ + -73.56809506939487, + 45.49209624228538 + ], + [ + -73.56809246893268, + 45.4920988416879 + ], + [ + -73.56821287000538, + 45.49216124158406 + ], + [ + -73.56822186852654, + 45.49216584161625 + ], + [ + -73.56826745951075, + 45.492118613912375 + ], + [ + -73.56813497596143, + 45.49205532773507 + ], + [ + -73.56809506939487, + 45.49209624228538 + ] + ] + ] + }, + "id": 182393, + "properties": { + "name": "01044601", + "address": "rue Victor-Hugo (MTL) 1626", + "function": "1000", + "height": 8, + "year_of_construction": 1986 + } + }, + { + "type": "Feature", + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [ + -73.56790756893894, + 45.492291541967774 + ], + [ + -73.56790222258577, + 45.49229712328457 + ], + [ + -73.56803643080562, + 45.49236123475947 + ], + [ + -73.56807651582375, + 45.49231957685336 + ], + [ + -73.56794223597048, + 45.4922554321734 + ], + [ + -73.56790756893894, + 45.492291541967774 + ] + ] + ] + }, + "id": 182442, + "properties": { + "name": "01044609", + "address": "rue Victor-Hugo (MTL) 1646", + "function": "1000", + "height": 11, + "year_of_construction": 1986 + } + }, + { + "type": "Feature", + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [ + -73.56829706912258, + 45.49188914205178 + ], + [ + -73.56825635009473, + 45.49193088860213 + ], + [ + -73.56838787594006, + 45.49199371809223 + ], + [ + -73.56842846901456, + 45.49195154234486 + ], + [ + -73.56829706912258, + 45.49188914205178 + ] + ] + ] + }, + "id": 182546, + "properties": { + "name": "01044592", + "address": "rue Victor-Hugo (MTL) 1606", + "function": "1000", + "height": 8, + "year_of_construction": 1986 + } + } + ] +} \ 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/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()))