Skip to content
Snippets Groups Projects
Commit afe4cd18 authored by Christoph von Oy's avatar Christoph von Oy
Browse files

Implemented input profile processor

parent 0958ce80
No related branches found
No related tags found
No related merge requests found
Subproject commit 7fc1f3718bd483913c76c1f2922dcd1415cfbff0
Subproject commit 45ee9ad75756f37ecddd11dee4902c97bb590bbb
Subproject commit d97e5019054ed9dbb77750294a60553e5647e5d3
Subproject commit d7e201c3af6d28b04300dbf3c6fca4900852dc10
import time
import pandas as pd
import Tooling.input_profile_processor.input_profile_processor
import Model_Library.Prosumer.main as main
import Model_Library.District.main_district as main_district
from functools import partial
......@@ -7,9 +8,9 @@ from multiprocessing import Pool
from tqdm import tqdm
import os
def process_each_prosumer(prosumer_name, prosumer_specification, t_start, t_horizon, t_step, prosumer_strategy):
def process_each_prosumer(prosumer_name, prosumer_specification, t_start, t_horizon, t_step, prosumer_strategy, input_profiles):
before_setup = time.time()
prosumer = main.Main(prosumer_name, prosumer_specification, t_start, t_horizon, t_step)
prosumer = main.Main(prosumer_name, prosumer_specification, t_start, t_horizon, t_step, input_profiles)
after_setup = time.time()
print("process_each_prosumer:\tProsumer Construction [s]: \t" + str(after_setup - before_setup))
......@@ -26,6 +27,27 @@ t_start = pd.Timestamp("2019-05-10 00:00:00") # start time of simulation
t_horizon = 240 # number of time steps to be simulated
t_step = 1 # length of a time step in hours
input_profile_dict = {'irradiance_1': ['irradiance', 'input_files/data/irradiance/Lindenberg2006BSRN_Irradiance_60sec.csv'],
'temperature_1': ['air_temperature', 'input_files/data/temperature/temperature.csv'],
'demand_electric_1': ['elec_demand', 'generate', 3000],
'demand_heat_1': ['therm_demand', 'generate', 6000, 'temperature_1'],
'demand_hot_water_1': ['hot_water_demand', 'generate', 1500, 'temperature_1'],
'irradiance_2': ['irradiance', 'input_files/data/irradiance/Lindenberg2006BSRN_Irradiance_60sec.csv'],
'temperature_2': ['air_temperature', 'input_files/data/temperature/temperature.csv'],
'demand_electric_2': ['elec_demand', 'generate', 3000],
'demand_heat_2': ['therm_demand', 'generate', 6000, 'temperature_2'],
'demand_hot_water_2': ['hot_water_demand', 'generate', 1500, 'temperature_2'],
'irradiance_3': ['irradiance', 'input_files/data/irradiance/Lindenberg2006BSRN_Irradiance_60sec.csv'],
'temperature_3': ['air_temperature', 'input_files/data/temperature/temperature.csv'],
'demand_electric_3': ['elec_demand', 'generate', 0],
'demand_heat_3': ['therm_demand', 'generate', 0, 'temperature_3'],
'demand_hot_water_3': ['hot_water_demand', 'generate', 0, 'temperature_3'],
'elec_price_1': ['elec_price', 'input_files/data/prices/day-ahead/hourly_price.csv']}
input_profiles = Tooling.input_profile_processor.input_profile_processor.process_input_profiles(input_profile_dict, t_start, t_horizon, t_step)
after_input_processing = time.time()
print("runme:\t\t\tProfile Processing [s]: \t" + str(after_input_processing - start))
# 'data_path': path to file specifying where input profiles are located
# 'topology_path': path to matrices that define the prosumer topology
# 'config_path': path to global configurations like prices, injection prices, emission costs, etc.
......@@ -34,30 +56,40 @@ prosumer_dict = {'SCN2_CAT1_PV11_3000_6000':{'elec_demand': 3000,
'hot_water_demand': 1500,
'topology_path': 'input_files/models/prosumer_models/SCN2_CAT1_PV11',
'config_path': 'input_files/models/prosumer_models/SCN2_CAT1_PV11/config.csv',
'data_path': 'input_files/models/prosumer_models/SCN2_CAT1_PV11/data_path.csv'},
'data_path': 'input_files/models/prosumer_models/SCN2_CAT1_PV11/data_path.csv',
'profiles': {'irradiance': 'irradiance_1',
'air_temperature': 'temperature_1',
'elec_demand': 'demand_electric_1',
'therm_demand': 'demand_heat_1',
'hot_water_demand': 'demand_hot_water_1'}},
'SCN0_CAT1_3000_6000': {'elec_demand': 3000,
'therm_demand': 6000,
'hot_water_demand': 1500,
'topology_path': 'input_files/models/prosumer_models/SCN0_CAT1',
'config_path': 'input_files/models/prosumer_models/SCN0_CAT1/config.csv',
'data_path': 'input_files/models/prosumer_models/SCN0_CAT1/data_path.csv'}}
'data_path': 'input_files/models/prosumer_models/SCN0_CAT1/data_path.csv',
'profiles': {'irradiance': 'irradiance_2',
'air_temperature': 'temperature_2',
'elec_demand': 'demand_electric_2',
'therm_demand': 'demand_heat_2',
'hot_water_demand': 'demand_hot_water_2'}}}
ps_strategy = ['annuity']
parallel_processing = False
before_optimization = time.time()
print("runme:\t\t\tProsumer Setup [s]: \t\t" + str(before_optimization - start))
print("runme:\t\t\tProsumer Setup [s]: \t\t" + str(before_optimization - after_input_processing))
# Run multiple independent prosumers in parallel on multiple cores
final_prosumer_dict = dict.fromkeys(prosumer_dict.keys())
if parallel_processing:
count_processes = len(prosumer_dict.keys())
pool = Pool(os.cpu_count())
parallel_func = partial(process_each_prosumer, t_start = t_start, t_horizon = t_horizon, t_step = t_step, prosumer_strategy = ps_strategy)
parallel_func = partial(process_each_prosumer, t_start = t_start, t_horizon = t_horizon, t_step = t_step, prosumer_strategy = ps_strategy, input_profiles = input_profiles)
mapped_values = list(tqdm(pool.map(parallel_func, list(prosumer_dict.keys()), list(prosumer_dict.values())), total = count_processes))
# Normal processing, one core only
else:
for prosumer_name in list(prosumer_dict.keys()):
final_prosumer_dict[prosumer_name] = process_each_prosumer(prosumer_name, prosumer_dict[prosumer_name], t_start, t_horizon, t_step, ps_strategy)
final_prosumer_dict[prosumer_name] = process_each_prosumer(prosumer_name, prosumer_dict[prosumer_name], t_start, t_horizon, t_step, ps_strategy, input_profiles)
after_optimization = time.time()
print("runme:\t\t\tProsumer Optimization [s]: \t" + str(after_optimization - before_optimization))
......@@ -68,24 +100,30 @@ ca_dict = {'ca_bat': {'elec_demand': 0,
'hot_water_demand': 0,
'topology_path': 'input_files/models/district_models/example_CA',
'config_path': 'input_files/models/district_models/example_CA/config.csv',
'data_path': 'input_files/models/district_models/example_CA/data_path.csv'}}
'data_path': 'input_files/models/district_models/example_CA/data_path.csv',
'profiles': {'irradiance': 'irradiance_3',
'air_temperature': 'temperature_3',
'elec_demand': 'demand_electric_3',
'therm_demand': 'demand_heat_3',
'hot_water_demand': 'demand_hot_water_3'}}}
ca_strategy = 'sizing_max_operational_profit'
before_community_assets = time.time()
print("runme:\t\t\tCommunity Assets Setup [s]: \t" + str(before_community_assets - start_community))
comm_assets = main.Main_CA(ca_dict, t_start, t_horizon, t_step)
comm_assets = main.Main_CA(ca_dict, t_start, t_horizon, t_step, input_profiles)
after_community_assets = time.time()
print("runme:\t\t\tCommunity Assets Constr. [s]: \t" + str(after_community_assets - before_community_assets))
comm_dict = {'community': {'topology_path': 'input_files/models/district_models/example_community',
'config_path': 'input_files/models/district_models/example_community/config.csv',
'data_path': 'input_files/models/district_models/example_community/data_path.csv'}}
'data_path': 'input_files/models/district_models/example_community/data_path.csv',
'profiles': {'elec_price': 'elec_price_1'}}}
comm_strategy = ['max_operational_profit']
before_community_optimization = time.time()
print("runme:\t\t\tComm. Optimization Setup [s]: \t" + str(before_community_optimization - after_community_assets))
community_main = main_district.MainDistrict(final_prosumer_dict, comm_assets, t_start, t_horizon, t_step, comm_dict, ca_strategy, comm_strategy)
community_main = main_district.MainDistrict(final_prosumer_dict, comm_assets, t_start, t_horizon, t_step, comm_dict, ca_strategy, comm_strategy, input_profiles)
after_community_optimization = time.time()
print("runme:\t\t\tCommunity Optimization [s]: \t" + str(after_community_optimization - before_community_optimization))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment