Skip to content
Snippets Groups Projects
Commit 71024fc6 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 fa9cf159 ff2c744b
No related branches found
No related tags found
No related merge requests found
Showing
with 84 additions and 263 deletions
Subproject commit aeafe454c86a7a7a486d442b29f1f26f2f37618b Subproject commit 4e49b79efb7880004cf752c3c4b9d5035280b8b2
comp_name,comp_type,model,min_size,max_size,current_size,pv_roof,inv_pv,battery,heat_pump,grd,elec_cns,inv_bat comp_name,comp_type,model,min_size,max_size,current_size,pv_roof,inv_pv,battery,heat_pump,grd,elec_cns,inv_bat
pv_roof,StandardPVGenerator,PV2,10,10,0,0,1,0,0,0,0,0 pv_roof,StandardPVGenerator,PV2,10,10,0,0,1,0,0,0,0,0
inv_pv,BasicInverter,INVPV,10,10,0,0,0,0,0,1,1,1 inv_pv,BasicInverter,INVPV,10,10,0,0,0,0,1,1,1,1
battery,LiionBattery,BAT1,10,10,0,0,0,0,0,0,0,1 battery,LiionBattery,BAT1,10,10,0,0,0,0,0,0,0,1
heat_pump,HeatPump,EHP1,10,10,0,0,0,0,0,0,0,0 heat_pump,HeatPump,EHP1,10,10,0,0,0,0,0,0,0,0
grd,StandardACGrid,GRD1,10000,10000,0,0,0,0,0,0,1,0 grd,StandardACGrid,GRD1,10000,10000,0,0,0,0,1,0,1,0
elec_cns,StandardElectricalConsumption,CNS1,10000,10000,0,0,0,0,1,0,0,0 elec_cns,StandardElectricalConsumption,CNS1,10000,10000,0,0,0,0,0,0,0,0
inv_bat,BasicInverter,INVBAT,10,10,0,0,0,1,0,1,1,0 inv_bat,BasicInverter,INVBAT,10,10,0,0,0,1,1,1,1,0
comp_name,comp_type,model,min_size,max_size,current_size,pv_roof,inv_pv,heat_pump,grd,elec_cns comp_name,comp_type,model,min_size,max_size,current_size,pv_roof,inv_pv,heat_pump,grd,elec_cns
pv_roof,StandardPVGenerator,PV2,10,10,0,0,1,0,0,0 pv_roof,StandardPVGenerator,PV2,10,10,0,0,1,0,0,0
inv_pv,BasicInverter,INVPV,10,10,0,0,0,0,1,1 inv_pv,BasicInverter,INVPV,10,10,0,0,0,1,1,1
heat_pump,HeatPump,EHP1,10,10,0,0,0,0,0,0 heat_pump,HeatPump,EHP1,10,10,0,0,0,0,0,0
grd,StandardACGrid,GRD1,10000,10000,0,0,0,0,0,1 grd,StandardACGrid,GRD1,10000,10000,0,0,0,1,0,1
elec_cns,StandardElectricalConsumption,CNS1,10000,10000,0,0,0,1,0,0 elec_cns,StandardElectricalConsumption,CNS1,10000,10000,0,0,0,0,0,0
comp_name,comp_type,model,min_size,max_size,current_size,pv_roof,inv_pv,battery,heat_pump,grd,elec_cns,inv_bat comp_name,comp_type,model,min_size,max_size,current_size,pv_roof,inv_pv,battery,heat_pump,grd,elec_cns,inv_bat
pv_roof,StandardPVGenerator,PV2,30,30,0,0,1,0,0,0,0,0 pv_roof,StandardPVGenerator,PV2,30,30,0,0,1,0,0,0,0,0
inv_pv,BasicInverter,INVPV,30,30,0,0,0,0,0,1,1,1 inv_pv,BasicInverter,INVPV,30,30,0,0,0,0,1,1,1,1
battery,LiionBattery,BAT1,10,10,0,0,0,0,0,0,0,1 battery,LiionBattery,BAT1,10,10,0,0,0,0,0,0,0,1
heat_pump,HeatPump,EHP1,10,10,0,0,0,0,0,0,0,0 heat_pump,HeatPump,EHP1,10,10,0,0,0,0,0,0,0,0
grd,StandardACGrid,GRD1,10000,10000,0,0,0,0,0,0,1,0 grd,StandardACGrid,GRD1,10000,10000,0,0,0,0,1,0,1,0
elec_cns,StandardElectricalConsumption,CNS1,10000,10000,0,0,0,0,1,0,0,0 elec_cns,StandardElectricalConsumption,CNS1,10000,10000,0,0,0,0,0,0,0,0
inv_bat,BasicInverter,INVBAT,10,10,0,0,0,1,0,1,1,0 inv_bat,BasicInverter,INVBAT,10,10,0,0,0,1,1,1,1,0
comp_name,comp_type,model,min_size,max_size,current_size,pv_roof,inv_pv,heat_pump,grd,elec_cns comp_name,comp_type,model,min_size,max_size,current_size,pv_roof,inv_pv,heat_pump,grd,elec_cns
pv_roof,StandardPVGenerator,PV2,30,30,0,0,1,0,0,0 pv_roof,StandardPVGenerator,PV2,30,30,0,0,1,0,0,0
inv_pv,BasicInverter,INVPV,30,30,0,0,0,0,1,1 inv_pv,BasicInverter,INVPV,30,30,0,0,0,1,1,1
heat_pump,HeatPump,EHP1,10,10,0,0,0,0,0,0 heat_pump,HeatPump,EHP1,10,10,0,0,0,0,0,0
grd,StandardACGrid,GRD1,10000,10000,0,0,0,0,0,1 grd,StandardACGrid,GRD1,10000,10000,0,0,0,1,0,1
elec_cns,StandardElectricalConsumption,CNS1,10000,10000,0,0,0,1,0,0 elec_cns,StandardElectricalConsumption,CNS1,10000,10000,0,0,0,0,0,0
comp_name,comp_type,model,min_size,max_size,current_size,pv_roof,inv_pv,battery,heat_pump,grd,elec_cns,inv_bat comp_name,comp_type,model,min_size,max_size,current_size,pv_roof,inv_pv,battery,heat_pump,grd,elec_cns,inv_bat
pv_roof,StandardPVGenerator,PV2,10,10,0,0,1,0,0,0,0,0 pv_roof,StandardPVGenerator,PV2,10,10,0,0,1,0,0,0,0,0
inv_pv,BasicInverter,INVPV,10,10,0,0,0,0,0,1,1,1 inv_pv,BasicInverter,INVPV,10,10,0,0,0,0,1,1,1,1
battery,LiionBattery,BAT1,10,10,0,0,0,0,0,0,0,1 battery,LiionBattery,BAT1,10,10,0,0,0,0,0,0,0,1
heat_pump,HeatPump,EHP1,10,10,0,0,0,0,0,0,0,0 heat_pump,HeatPump,EHP1,10,10,0,0,0,0,0,0,0,0
grd,StandardACGrid,GRD1,10000,10000,0,0,0,0,0,0,1,1 grd,StandardACGrid,GRD1,10000,10000,0,0,0,0,1,0,1,1
elec_cns,StandardElectricalConsumption,CNS1,10000,10000,0,0,0,0,1,0,0,0 elec_cns,StandardElectricalConsumption,CNS1,10000,10000,0,0,0,0,0,0,0,0
inv_bat,BasicInverter,INVBAT,10,10,0,0,0,1,0,1,1,0 inv_bat,BasicInverter,INVBAT,10,10,0,0,0,1,1,1,1,0
comp_name,comp_type,model,min_size,max_size,current_size,pv_roof,inv_pv,heat_pump,grd,elec_cns comp_name,comp_type,model,min_size,max_size,current_size,pv_roof,inv_pv,heat_pump,grd,elec_cns
pv_roof,StandardPVGenerator,PV2,10,10,0,0,1,0,0,0 pv_roof,StandardPVGenerator,PV2,10,10,0,0,1,0,0,0
inv_pv,BasicInverter,INVPV,10,10,0,0,0,0,1,1 inv_pv,BasicInverter,INVPV,10,10,0,0,0,1,1,1
heat_pump,HeatPump,EHP1,10,10,0,0,0,0,0,0 heat_pump,HeatPump,EHP1,10,10,0,0,0,0,0,0
grd,StandardACGrid,GRD1,10000,10000,0,0,0,0,0,1 grd,StandardACGrid,GRD1,10000,10000,0,0,0,1,0,1
elec_cns,StandardElectricalConsumption,CNS1,10000,10000,0,0,0,1,0,0 elec_cns,StandardElectricalConsumption,CNS1,10000,10000,0,0,0,0,0,0
comp_name,comp_type,model,min_size,max_size,current_size,pv_roof,inv_pv,battery,heat_pump,grd,elec_cns,inv_bat comp_name,comp_type,model,min_size,max_size,current_size,pv_roof,inv_pv,battery,heat_pump,grd,elec_cns,inv_bat
pv_roof,StandardPVGenerator,PV2,30,30,0,0,1,0,0,0,0,0 pv_roof,StandardPVGenerator,PV2,30,30,0,0,1,0,0,0,0,0
inv_pv,BasicInverter,INVPV,30,30,0,0,0,0,0,1,1,1 inv_pv,BasicInverter,INVPV,30,30,0,0,0,0,1,1,1,1
battery,LiionBattery,BAT1,10,10,0,0,0,0,0,0,0,1 battery,LiionBattery,BAT1,10,10,0,0,0,0,0,0,0,1
heat_pump,HeatPump,EHP1,10,10,0,0,0,0,0,0,0,0 heat_pump,HeatPump,EHP1,10,10,0,0,0,0,0,0,0,0
grd,StandardACGrid,GRD1,10000,10000,0,0,0,0,0,0,1,1 grd,StandardACGrid,GRD1,10000,10000,0,0,0,0,1,0,1,1
elec_cns,StandardElectricalConsumption,CNS1,10000,10000,0,0,0,0,1,0,0,0 elec_cns,StandardElectricalConsumption,CNS1,10000,10000,0,0,0,0,0,0,0,0
inv_bat,BasicInverter,INVBAT,10,10,0,0,0,1,0,1,1,0 inv_bat,BasicInverter,INVBAT,10,10,0,0,0,1,1,1,1,0
comp_name,comp_type,model,min_size,max_size,current_size,pv_roof,inv_pv,heat_pump,grd,elec_cns comp_name,comp_type,model,min_size,max_size,current_size,pv_roof,inv_pv,heat_pump,grd,elec_cns
pv_roof,StandardPVGenerator,PV2,30,30,0,0,1,0,0,0 pv_roof,StandardPVGenerator,PV2,30,30,0,0,1,0,0,0
inv_pv,BasicInverter,INVPV,30,30,0,0,0,0,1,1 inv_pv,BasicInverter,INVPV,30,30,0,0,0,1,1,1
heat_pump,HeatPump,EHP1,10,10,0,0,0,0,0,0 heat_pump,HeatPump,EHP1,10,10,0,0,0,0,0,0
grd,StandardACGrid,GRD1,10000,10000,0,0,0,0,0,1 grd,StandardACGrid,GRD1,10000,10000,0,0,0,1,0,1
elec_cns,StandardElectricalConsumption,CNS1,10000,10000,0,0,0,1,0,0 elec_cns,StandardElectricalConsumption,CNS1,10000,10000,0,0,0,0,0,0
component,type,model,min_size,max_size,lambda_1,lambda_st,phi,psi_f,beta,max_output,max_input,max_energy,min_energy,start_energy,start_cycles,pv,bat,invpv,grd,elec_cns,ehp,invbat component,type,model,min_size,max_size,lambda_1,lambda_st,phi,psi_f,beta,max_output,max_input,max_energy,min_energy,start_energy,start_cycles,pv,bat,invpv,grd,elec_cns,ehp,invbat
pv,StandardPVGenerator,Vitovolt300,9.76,9.76,14.122,15,52.21,0,30,,,,,,,0,0,1,0,0,0,0 pv,StandardPVGenerator,Vitovolt300,9.76,9.76,14.122,15,52.21,0,30,,,,,,,0,0,1,0,0,0,0
bat,LiionBattery,BAT1,10,10,,,,,,0.5,0.5,0.909,0,0,0,0,0,0,0,0,0,1 bat,LiionBattery,BAT1,10,10,,,,,,0.5,0.5,0.909,0,0,0,0,0,0,0,0,0,1
invpv,BasicInverter,INVPV,10,10,,,,,,,,,,,,0,0,0,1,1,0,1 invpv,BasicInverter,INVPV,10,10,,,,,,,,,,,,0,0,0,1,1,1,1
grd,StandardACGrid,GRD1,,,,,,,,,,,,,,0,0,0,0,1,0,0 grd,StandardACGrid,GRD1,,,,,,,,,,,,,,0,0,0,0,1,1,0
elec_cns,StandardElectricalConsumption,CNS1,,,,,,,,,,,,,,0,0,0,0,0,1,0 elec_cns,StandardElectricalConsumption,CNS1,,,,,,,,,,,,,,0,0,0,0,0,0,0
ehp,StandardElecHeatPump,EHP1,3,3,,,,,,,,,,,,0,0,0,0,0,0,0 ehp,StandardElecHeatPump,EHP1,3,3,,,,,,,,,,,,0,0,0,0,0,0,0
invbat,BasicInverter,INVBAT,5,5,,,,,,,,,,,,0,1,0,1,1,0,0 invbat,BasicInverter,INVBAT,5,5,,,,,,,,,,,,0,1,0,1,1,1,0
\ No newline at end of file \ No newline at end of file
# runme.py is the central script to execute the optimization of the community. # runme.py is the central script to execute the optimization of the community.
# Importing the necessary files
import numpy as np
import Model_Library.District.scripts as scripts
from datetime import timedelta
import math
import time import time
import pandas as pd import pandas as pd
import Model_Library.Prosumer.scripts as scripts
import Model_Library.Prosumer.main as main import Model_Library.Prosumer.main as main
import Model_Library.Prosumer.scripts.extract_inputs as extract_inputs
from functools import partial from functools import partial
from multiprocessing import Pool from multiprocessing import Pool
from tqdm import tqdm from tqdm import tqdm
import os import os
import argparse
from Model_Library.Prosumer.scripts.results_evaluation.results_evaluation import Plot_savings from Model_Library.Prosumer.scripts.results_evaluation.results_evaluation import Plot_savings
import Model_Library.District.main_district as main_district import Model_Library.District.main_district as main_district
def process_each_prosumer(prosumer_name, prosumer_specification, commentary, t_start, t_horizon, t_step, predictions, t_history, prosumer_strategy):
def process_each_prosumer(prosumer_name, prosumer_dict, data_source, commentary, no_process_bar_rh):
try: try:
# PLEASE CHANGE HERE
# Set the simulation time frame and optional rolling horizon configurations:
# 't_start': start date of simulations, Unit: JJJJ-MM-DD hh:mm:ss
# 't_end': end date of simulations, Unit: JJJJ-MM-DD hh:mm:ss
# 't_step': granularity of optimization model, Unit: hours
# Rolling horizon (RH) can be set by:
# 't_rh_horizon': width of rolling horizon intervals, Unit: hours, MINIMUM VALUE: 2 !!!
# 't_rh_shift': rolling horizon shift between intervals, Unit: hours
# 't_current_value_length': number of values at beginning of rolling horizon interval that are replaced by real values, Unit: hours
# 't_history': number of days before actual simulation interval for the demand generator to be able to make required predictions
if prosumer_dict[prosumer_name]['rolling_horizon']:
t_start = pd.Timestamp("2019-09-01 00:00:00")
t_end = pd.Timestamp("2019-09-01 5:00:00")
t_step = 1
t_rh_horizon = 3
t_rh_shift = 1
t_current_value_length = 2
t_history = 14 # days
# PLEASE CHANGE HERE
# Prediction settings
predictions = {'demand_electric': 'DayBefore',
'demand_heat': 'DayBefore',
'day_ahead_price': 'DayBefore',
'intraday_price': 'DayBefore',
'solar_radiation': 'DayBefore',
# 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': 'DayBefore'}
else:
t_start = pd.Timestamp("2019-07-01 00:00:00")
t_end = pd.Timestamp("2019-7-10 23:00:00") + pd.Timedelta(hours=1)
t_step = 1
t_rh_horizon = (t_end - t_start) / pd.Timedelta(hours=1)
t_rh_shift = t_rh_horizon - 1
t_current_value_length = t_rh_horizon
t_history = 0 # days
# PLEASE CHANGE HERE
# 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'}
# Fixed variables - DO NOT CHANGE
storage_states = {}
interim_results = {}
final_iteration = False
# Set aggregation options
parser = argparse.ArgumentParser(description='Start optimization from DB or local data')
parser.add_argument('-a', '--aggregate', action="store_true", dest="aggregate",
help="activating aggregation of input time series", default=False)
options = parser.parse_args()
# Calculate number of rolling horizon intervals and loop through them
for t in tqdm(pd.date_range(t_start, t_end - pd.Timedelta(hours=t_rh_shift + 1), freq=str(t_rh_shift) + 'H'), disable=no_process_bar_rh):
# set end date for current loop
t_end_loop = t + pd.Timedelta(hours=t_rh_horizon)
# exceptions that occur at global end of simulation horizon
if t_end_loop > t_end:
t_end_loop = t_end
if t_current_value_length > (t_end_loop - t) / pd.Timedelta(hours=1):
t_current_value_length = (t_end_loop - t) / pd.Timedelta(hours=1)
# Set flag for final iteration
if t == t_end - pd.Timedelta(hours=t_rh_shift + 1):
final_iteration = True
# Start main programme # Start main programme
prosumer = main.Main(data_source, {prosumer_name: prosumer_dict[prosumer_name]}, t, t_end_loop, t_step, prosumer = main.Main(prosumer_name, prosumer_specification, t_start, t_horizon, t_step, predictions, t_history, commentary)
predictions, t_current_value_length, t_end,
t_history, commentary, storage_states, t_rh_shift, aggregation=options.aggregate)
# Run optimization # Run optimization
prosumer.run_optimization(prosumer.prosumer_name_list) prosumer.run_optimization(prosumer_strategy)
# Show results - Results are only plotted after last iteration of rolling horizon # Show results - Results are only plotted after last iteration of rolling horizon
prosumer.show_results(prosumer.prosumer_name_list, interim_results, final_iteration) prosumer.show_results()
# Get storage states from this iteration
storage_states = prosumer.charge_status
# Get interim results of current rolling horizon interval return prosumer.prosumer
interim_results = prosumer.interim_results
return prosumer.prosumer[prosumer_name]
except ValueError: except ValueError:
print(prosumer_name+" could not be optimized!") print(prosumer_name+" could not be optimized!")
# # MAIN PROGRAM ------------------------------------------------------------------------------------------------------- # # MAIN PROGRAM -------------------------------------------------------------------------------------------------------
if __name__ == "__main__": if __name__ == "__main__":
# Initialization scenario path and global variables for the prosumer optimization # Initialization scenario path and global variables for the prosumer optimization
# Start timer t_start = pd.Timestamp("2019-05-10 00:00:00") # start time of simulation
start = time.time() 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
# PLEASE CHANGE HERE
# Path to local data - this is only used when selecting local mode # 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 # 'topology_path': path to matrices that define the prosumer topology
# 'config_path': path to global configurations like prices, injection prices, emission costs, etc. # 'config_path': path to global configurations like prices, injection prices, emission costs, etc.
#topology_path = 'input_files/models/Study_Base' prosumer_dict = {'SCN2_CAT1_PV11_3000_6000':{'elec_demand': 3000,
#config_path = topology_path + '/config.csv' 'therm_demand': 6000,
#data_path = topology_path + '/data_path.csv' 'hot_water_demand': 1500,
#prosumer_name = 'office'
#prosumer_dict = {prosumer_name: {'topology_path': topology_path, 'config_path': config_path, 'data_path': data_path}}
topology_path = ['input_files/models/prosumer_models/SCN0_CAT1']
prosumer_name = ['SCN0_CAT1', 'SCN0_CAT1']
rolling_horizon = [False]
elec_demand = [1500, 10000]
therm_demand = [5000, 20000]
hot_water_demand = 1500#[1500, 1500]
step_elec_demand = 500
step_therm_demand = 500
#step_hot_water_demand = 0
prosumer_dict = {}
""" for i in range(len(prosumer_name)):
for j in range(elec_demand[0], elec_demand[1], step_elec_demand):
for k in range(therm_demand[0], therm_demand[1], step_therm_demand):
#for l in range(hot_water_demand[0], hot_water_demand[1], step_hot_water_demand):
prosumer_dict[prosumer_name[i]+'_'+str(j)+'_'+str(k)] = {'elec_demand': j,
'therm_demand': k,
'hot_water_demand': hot_water_demand,
'topology_path': topology_path[i],
'config_path': topology_path[i] + '/config.csv',
'data_path': topology_path[i] + '/data_path.csv',
'rolling_horizon': rolling_horizon[i]}"""
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', 'topology_path': 'input_files/models/prosumer_models/SCN2_CAT1_PV11',
'config_path': 'input_files/models/prosumer_models/SCN2_CAT1_PV11/config.csv', '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'},
'rolling_horizon': False}, 'SCN0_CAT1_3000_6000': {'elec_demand': 3000,
'SCN2_CAT1_PV12_BA_6000_6000': {'elec_demand': 6000, 'therm_demand': 6000, 'hot_water_demand': 1500, 'therm_demand': 6000,
'topology_path': 'input_files/models/prosumer_models/SCN2_CAT1_PV12_BA', 'hot_water_demand': 1500,
'config_path': 'input_files/models/prosumer_models/SCN2_CAT1_PV12_BA/config.csv',
'data_path': 'input_files/models/prosumer_models/SCN2_CAT1_PV12_BA/data_path.csv',
'rolling_horizon': False},
'SCN0_CAT1_6000_6000': {'elec_demand': 6000, 'therm_demand': 6000, 'hot_water_demand': 1500,
'topology_path': 'input_files/models/prosumer_models/SCN0_CAT1', 'topology_path': 'input_files/models/prosumer_models/SCN0_CAT1',
'config_path': 'input_files/models/prosumer_models/SCN0_CAT1/config.csv', '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'}}
'rolling_horizon': False},
'SCN0_CAT1_3000_6000': {'elec_demand': 3000, 'therm_demand': 6000, 'hot_water_demand': 1500, ps_strategy = ['annuity']
'topology_path': 'input_files/models/prosumer_models/SCN0_CAT1',
'config_path': 'input_files/models/prosumer_models/SCN0_CAT1/config.csv', # Prediction settings
'data_path': 'input_files/models/prosumer_models/SCN0_CAT1/data_path.csv', predictions = {'demand_electric': 'ActualData',
'rolling_horizon': False}} 'demand_heat': 'ActualData',
# PLEASE CHANGE HERE 'day_ahead_price': 'ActualData',
# Select data source 'intraday_price': 'ActualData',
# Options: '1': import from database, '2': import from local folder 'solar_radiation': 'ActualData',
data_source = 2 # 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 = {} reference_results = {}
commentary = False commentary = False
no_process_bar_rh = True
parallel_processing = False parallel_processing = False
# Timer output
tic = time.time()
# Start program # Start program
# Run multiple independent prosumers in parallel on multiple cores # Run multiple independent prosumers in parallel on multiple cores
final_prosumer_dict = dict.fromkeys(prosumer_dict.keys()) final_prosumer_dict = dict.fromkeys(prosumer_dict.keys())
if parallel_processing: if parallel_processing:
count_processes = len(prosumer_dict.keys()) count_processes = len(prosumer_dict.keys())
pool = Pool(os.cpu_count()) pool = Pool(os.cpu_count())
parallel_func = partial(process_each_prosumer, prosumer_dict=prosumer_dict, data_source=data_source, commentary=commentary, no_process_bar_rh=no_process_bar_rh) 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)
mapped_values = list(tqdm(pool.map(parallel_func, list(prosumer_dict.keys())), total=count_processes)) mapped_values = list(tqdm(pool.map(parallel_func, list(prosumer_dict.keys()), list(prosumer_dict.values())), total = count_processes))
# Normal processing, one core only # Normal processing, one core only
else: else:
for prosumer_name in list(prosumer_dict.keys()): for prosumer_name in list(prosumer_dict.keys()):
final_prosumer_dict[prosumer_name] = process_each_prosumer(prosumer_name= prosumer_name, prosumer_dict=prosumer_dict, data_source=data_source, commentary=commentary, no_process_bar_rh=no_process_bar_rh) 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)
# Timer output
toc = time.time()
if reference_results: if reference_results:
for topology in prosumer_name: for topology in prosumer_name:
Plot_savings(reference_results, topology) Plot_savings(reference_results, topology)
# Timer output
end = time.time()
# Additional console output
if commentary:
print("============ Execution Times =============")
print("Pre-processing [s]: \t" + str(tic - start))
#print("(Interaction with database [s]:\t" + str(prosumer.connect_with_db) + ")")
print("Optimization [s]: \t" + str(toc - tic))
print("Post-processing [s]: \t" + str(end - toc))
print("----------------------------------------")
print("Total [s]: \t" + str((end - toc) + (toc - tic) + (tic - start)))
print("==========================================")
'-----------------COMMUNITY-PART----------------------------------' '-----------------COMMUNITY-PART----------------------------------'
start_total = time.time()
data_source = 2 # [1]: datasource from data bank; [2]: datasource from local
commentary = False
t_start = pd.Timestamp("2019-07-01 00:00:00")
t_end = pd.Timestamp("2019-07-10 23:00:00") + pd.Timedelta(hours=1)
t_step = 1
t_rh_horizon = (t_end - t_start) / pd.Timedelta(hours=1)
t_horizon = (pd.Timestamp(t_end) - pd.Timestamp(t_start)) / np.timedelta64(t_step, 'h')
"------------------------Communnity Asset---------------------------" "------------------------Communnity Asset---------------------------"
"-------------------------------------------------------------------" "-------------------------------------------------------------------"
...@@ -248,66 +100,35 @@ ca_dict = {'ca_bat': {'elec_demand': 0, ...@@ -248,66 +100,35 @@ ca_dict = {'ca_bat': {'elec_demand': 0,
'topology_path': topology_path, 'topology_path': topology_path,
'config_path': config_path, 'config_path': config_path,
'data_path': data_path}} 'data_path': data_path}}
#ca_dict = {}
# PLEASE CHANGE HERE
# Prediction settings
predictions = {'demand_electric': 'DayBefore',
'demand_heat': 'DayBefore',
'day_ahead_price': 'DayBefore',
'intraday_price': 'DayBefore',
'solar_radiation': 'DayBefore',
# 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': 'DayBefore'}
# Fixed variables - DO NOT CHANGE
storage_states = {}
interim_results = {}
final_iteration = False
ca_strategy = 'sizing_max_operational_profit' ca_strategy = 'sizing_max_operational_profit'
# create time steps list
time_steps = []
for t in pd.date_range(pd.Timestamp(t_start),
pd.Timestamp(t_start) + timedelta(hours=t_horizon) - timedelta(hours=t_step),
freq=str(t_step)+'H'):
time_steps.append(t)
t_start = pd.Timestamp(t_start)
t_end = pd.Timestamp(t_start) + timedelta(hours=t_horizon) - timedelta(hours=t_step)
t_rh_shift = 0
t_current_value_length = (t_end-t_start)/np.timedelta64(t_step, 'h')
t_history = t_horizon/24
# initialize community component in the same way prosumers are. # initialize community component in the same way prosumers are.
# The difference is that they are not directly optimized # The difference is that they are not directly optimized
comm_assets = main.Main_CA(data_source, ca_dict, t_start, t_end, t_step, predictions, t_current_value_length, t_end, comm_assets = main.Main_CA(ca_dict, t_start, t_horizon, t_step, predictions, t_history, commentary)
t_history, commentary, storage_states, t_rh_shift, aggregation=False)
"""---------------------------COMMUNITY-LEVEL----------------------""" """---------------------------COMMUNITY-LEVEL----------------------"""
"""----------------------------------------------------------------""" """----------------------------------------------------------------"""
topology_path = 'input_files/models/district_models/example_community' topology_path = 'input_files/models/district_models/example_community'
config_path = topology_path + '/config.csv' config_path = topology_path + '/config.csv'
data_path_comm = topology_path + '/data_path.csv' data_path = topology_path + '/data_path.csv'
comm_dict = {'community': {'topology_path': topology_path, 'config_path': config_path, 'data_path': data_path_comm}} comm_dict = {'community': {'topology_path':topology_path,
'config_path': config_path,
'data_path': data_path}}
comm_strategy = ['max_operational_profit'] comm_strategy = ['max_operational_profit']
community_main = main_district.MainDistrict(final_prosumer_dict, community_main = main_district.MainDistrict(final_prosumer_dict,
comm_assets, comm_assets,
time_steps, t_start,
t_horizon,
t_step, t_step,
comm_dict, comm_dict,
ca_strategy, ca_strategy,
comm_strategy, comm_strategy)
t_horizon)
# ------------POST-PROCESS----------------- # ------------POST-PROCESS-----------------
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment