Skip to content
Snippets Groups Projects
Commit 1af1697e authored by Jonas Brucksch's avatar Jonas Brucksch
Browse files

Merge branch 'main' of git-ce.rwth-aachen.de:ineed-dc/ineed-dc-framework

parents 71024fc6 13e82826
Branches
No related tags found
No related merge requests found
Showing
with 84 additions and 177 deletions
type,path,unit
demand_electric,generate,h
demand_heat,generate,h
irradiance,input_files/data/irradiance/Lindenberg2006BSRN_Irradiance_60sec.csv,min
temperature,input_files/data/temperature/temperature.csv,h
day_ahead_price,input_files/data/prices/day-ahead/hourly_price.csv,h
type,path,unit
demand_electric,generate,h
demand_heat,generate,h
irradiance,input_files/data/irradiance/Lindenberg2006BSRN_Irradiance_60sec.csv,min
temperature,input_files/data/temperature/temperature.csv,h
day_ahead_price,input_files/data/prices/day-ahead/hourly_price.csv,h
type,path,unit
demand_electric,generate,h
demand_heat,generate,h
irradiance,input_files/data/irradiance/Lindenberg2006BSRN_Irradiance_60sec.csv,min
temperature,input_files/data/temperature/temperature.csv,h
day_ahead_price,input_files/data/prices/day-ahead/hourly_price.csv,h
type,path,unit
demand_electric,generate,h
demand_heat,generate,h
irradiance,input_files/data/irradiance/Lindenberg2006BSRN_Irradiance_60sec.csv,min
temperature,input_files/data/temperature/temperature.csv,h
day_ahead_price,input_files/data/prices/day-ahead/hourly_price.csv,h
type,path,unit
demand_electric,generate,h
demand_heat,generate,h
irradiance,input_files/data/irradiance/Lindenberg2006BSRN_Irradiance_60sec.csv,min
temperature,input_files/data/temperature/temperature.csv,h
day_ahead_price,input_files/data/prices/day-ahead/hourly_price.csv,h
type,path,unit
demand_electric,generate,h
demand_heat,generate,h
irradiance,input_files/data/irradiance/Lindenberg2006BSRN_Irradiance_60sec.csv,min
temperature,input_files/data/temperature/temperature.csv,h
day_ahead_price,input_files/data/prices/day-ahead/hourly_price.csv,h
type,path,unit
demand_electric,generate,h
demand_heat,generate,h
irradiance,input_files/data/irradiance/Lindenberg2006BSRN_Irradiance_60sec.csv,min
temperature,input_files/data/temperature/temperature.csv,h
type,path,unit
demand_electric,generate,h
demand_heat,generate,h
irradiance,input_files/data/irradiance/Lindenberg2006BSRN_Irradiance_60sec.csv,min
temperature,input_files/data/temperature/temperature.csv,h
type,path,unit
demand_electric,generate,h
demand_heat,generate,h
irradiance,input_files/data/irradiance/Lindenberg2006BSRN_Irradiance_60sec.csv,min
temperature,input_files/data/temperature/temperature.csv,h
# runme.py is the central script to execute the optimization of the community.
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
from multiprocessing import Pool
from tqdm import tqdm
import os
from Model_Library.Prosumer.scripts.results_evaluation.results_evaluation import Plot_savings
import Model_Library.District.main_district as main_district
def process_each_prosumer(prosumer_name, prosumer_specification, input_profiles, t_start, t_horizon, t_step, prosumer_strategy):
prosumer = main.Main(prosumer_name, prosumer_specification, input_profiles, t_start, t_horizon, t_step)
def process_each_prosumer(prosumer_name, prosumer_specification, commentary, t_start, t_horizon, t_step, predictions, t_history, prosumer_strategy):
try:
# Start main programme
prosumer = main.Main(prosumer_name, prosumer_specification, t_start, t_horizon, t_step, predictions, t_history, commentary)
# Run optimization
prosumer.run_optimization(prosumer_strategy)
# Show results - Results are only plotted after last iteration of rolling horizon
prosumer.show_results()
return prosumer.prosumer
except ValueError:
print(prosumer_name+" could not be optimized!")
# # MAIN PROGRAM -------------------------------------------------------------------------------------------------------
if __name__ == "__main__":
# Initialization scenario path and global variables for the prosumer optimization
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
t_history = 0 # number of hours before actual simulation interval for the demand generator to be able to make required predictions
# Path to local data - this is only used when selecting local mode
# 'data_path': path to file specifying where input profiles are located
# 'topology_path': path to matrices that define the prosumer topology
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)
# 'topology_path': path to directory that contains the matrices that define the prosumer topology
# 'config_path': path to global configurations like prices, injection prices, emission costs, etc.
prosumer_dict = {'SCN2_CAT1_PV11_3000_6000':{'elec_demand': 3000,
'therm_demand': 6000,
'hot_water_demand': 1500,
'topology_path': 'input_files/models/prosumer_models/SCN2_CAT1_PV11',
prosumer_dict = {'SCN2_CAT1_PV11_3000_6000':{'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'},
'SCN0_CAT1_3000_6000': {'elec_demand': 3000,
'therm_demand': 6000,
'hot_water_demand': 1500,
'topology_path': 'input_files/models/prosumer_models/SCN0_CAT1',
'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': {'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'}}
ps_strategy = ['annuity']
# Prediction settings
predictions = {'demand_electric': 'ActualData',
'demand_heat': 'ActualData',
'day_ahead_price': 'ActualData',
'intraday_price': 'ActualData',
'solar_radiation': 'ActualData',
# currently the method generate_g_t_series takes the same t_start as the prediction -> no historical
# data for the prediction available: easy fix would be to set a minus time delta in the t_start
# argument of generate_g_t_series
'temperature': 'ActualData'}
reference_results = {}
commentary = False
'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'}}}
prosumer_strategy = ['annuity']
parallel_processing = False
# Start program
# Run multiple independent prosumers in parallel on multiple cores
final_prosumer_dict = dict.fromkeys(prosumer_dict.keys())
prosumers = 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, commentary = commentary, t_start = t_start, t_horizon = t_horizon, t_step = t_step, predictions = predictions, t_history = t_history, prosumer_strategy = ps_strategy)
parallel_func = partial(process_each_prosumer, input_profiles = input_profiles, t_start = t_start, t_horizon = t_horizon, t_step = t_step, prosumer_strategy = prosumer_strategy)
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], commentary, t_start, t_horizon, t_step, predictions, t_history, ps_strategy)
if reference_results:
for topology in prosumer_name:
Plot_savings(reference_results, topology)
'-----------------COMMUNITY-PART----------------------------------'
"------------------------Communnity Asset---------------------------"
"-------------------------------------------------------------------"
topology_path = 'input_files/models/district_models/example_CA'
config_path = topology_path + '/config.csv'
data_path = topology_path + '/data_path.csv'
ca_dict = {'ca_bat': {'elec_demand': 0,
'therm_demand': 0,
'hot_water_demand': 0,
'topology_path': topology_path,
'config_path': config_path,
'data_path': data_path}}
ca_strategy = 'sizing_max_operational_profit'
# initialize community component in the same way prosumers are.
# The difference is that they are not directly optimized
comm_assets = main.Main_CA(ca_dict, t_start, t_horizon, t_step, predictions, t_history, commentary)
"""---------------------------COMMUNITY-LEVEL----------------------"""
"""----------------------------------------------------------------"""
topology_path = 'input_files/models/district_models/example_community'
config_path = topology_path + '/config.csv'
data_path = topology_path + '/data_path.csv'
comm_dict = {'community': {'topology_path':topology_path,
'config_path': config_path,
'data_path': data_path}}
prosumers[prosumer_name] = process_each_prosumer(prosumer_name, prosumer_dict[prosumer_name], input_profiles, t_start, t_horizon, t_step, prosumer_strategy)
comm_strategy = ['max_operational_profit']
community_assets_dict = {'ca_bat': {'topology_path': 'input_files/models/district_models/example_CA',
'config_path': 'input_files/models/district_models/example_CA/config.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'}}}
community_main = main_district.MainDistrict(final_prosumer_dict,
comm_assets,
t_start,
t_horizon,
t_step,
comm_dict,
ca_strategy,
comm_strategy)
community_assets_strategy = 'sizing_max_operational_profit'
# ------------POST-PROCESS-----------------
community_assets = main.Main_CA(community_assets_dict, input_profiles, t_start, t_horizon, t_step)
community_dict = {'community': {'config_path': 'input_files/models/district_models/example_community/config.csv',
'profiles': {'elec_price': 'elec_price_1'}}}
community_strategy = ['max_operational_profit']
community_main = main_district.MainDistrict(community_dict, prosumers, community_assets, input_profiles, t_start, t_horizon, t_step, community_assets_strategy, community_strategy)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment