Skip to content
Snippets Groups Projects
Commit 9f04aa95 authored by Yi Nie's avatar Yi Nie
Browse files

Merge branch 'dev_office_yni' into 'main'

Add use case 'office' and allow storage capacity result to be 0

See merge request ineed-dc/ineed-dc-framework!3
parents 4da262ab 93f18f96
No related branches found
No related tags found
No related merge requests found
injection_price,injection_price_variable,injection/pvpeak,gas_price,gas_price_variable,elec_price,elec_price_variable,heat_price,heat_price_variable,cooling_price,cooling_price_variable,injection_price_gas,injection_price_gas_variable,injection_price_heat,injection_price_heat_variable,injection_price_cooling,injection_price_cooling_variable,elec_emission,gas_emission,yearly_interest,planning_horizon,elec_price_cap_low,elec_price_cap_high
0.0793,0,0.7,0.0606,0,0.3046,0,0,0,0,0,0,0,0,0,0,0,0.401,0.21,0.03,20,15,107
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
comp_name,comp_type,model,min_size,max_size,current_size,pv_roof,inv_pv_bat,battery,heat_pump,grd,elec_cns
pv_roof,StandardPVGenerator,PV2,0,30,0,0,1,0,0,0,0
inv_pv_bat,Inverter,STP-7000TL-20,0,30,0,0,0,1,1,1,1
battery,LiionBattery,BAT1,0,1000,0,0,1,0,0,0,0
heat_pump,HeatPump,EHP1,2,50,0,0,0,0,0,0,0
grd,StandardACGrid,GRD1,1000,1000,0,0,1,0,1,0,1
elec_cns,StandardElectricalConsumption,CNS1,1000,1000,0,0,0,0,0,0,0
comp_name,comp_type,model,min_size,max_size,current_size,heat_pump,therm_cns,dhw_dmd,water_tes
heat_pump,HeatPump,EHP1,,,,0,0,0,1
therm_cns,HeatConsumption,HeatCNS1,1000,1000,0,0,0,0,0
dhw_dmd,HotWaterConsumption,HWCNS1,1000,1000,0,0,0,0,0
water_tes,HotWaterStorage,TES1,10,93,0,0,1,1,0
......@@ -30,11 +30,14 @@ import Model_Library.Prosumer.main as main
from multiprocessing import Pool
import os
from functools import partial
from Model_Library.Prosumer.scripts.results_evaluation.results_evaluation import Plot_savings
from Model_Library.Prosumer.scripts.results_evaluation.results_evaluation import \
Plot_savings
# from Tooling.results_evaluation.results_evaluation import Plot_savings
def process_each_prosumer(prosumer_name, prosumer_dict, data_source, commentary, no_process_bar_rh):
def process_each_prosumer(prosumer_name, prosumer_dict, data_source, commentary,
no_process_bar_rh):
"""
The method XYZ adds ...
:param
......@@ -100,13 +103,18 @@ def process_each_prosumer(prosumer_name, prosumer_dict, data_source, commentary,
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)
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'),
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):
# ToDo: replace first value with perfect value (can be done in runme)
# set end date for current loop
......@@ -115,23 +123,29 @@ def process_each_prosumer(prosumer_name, prosumer_dict, data_source, commentary,
# 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)
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
prosumer = main.Main(data_source, {prosumer_name: prosumer_dict[prosumer_name]}, t, t_end_loop, t_step,
prosumer = main.Main(data_source,
{prosumer_name: prosumer_dict[prosumer_name]},
t, t_end_loop, t_step,
predictions, t_current_value_length, t_end,
t_history, commentary, storage_states, t_rh_shift, aggregation=options.aggregate)
t_history, commentary, storage_states,
t_rh_shift, aggregation=options.aggregate)
# Run optimization
prosumer.run_optimization(prosumer.prosumer_name_list)
# 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(prosumer.prosumer_name_list, interim_results,
final_iteration)
# Get storage states from this iteration
storage_states = prosumer.charge_status
......@@ -164,16 +178,16 @@ if __name__ == "__main__":
# data_path = topology_path + '/data_path.csv'
# prosumer_name = 'office'
# prosumer_dict = {prosumer_name: {'topology_path': topology_path, 'config_path': config_path, 'data_path': data_path}}
topology_path = ['input_files/models/SCN0_CAT1']
prosumer_name = ['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
# topology_path = ['input_files/models/SCN0_CAT1']
# prosumer_name = ['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 = {}
# 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):
......@@ -186,14 +200,22 @@ if __name__ == "__main__":
'data_path': topology_path[i] + '/data_path.csv',
'rolling_horizon': rolling_horizon[i]}"""
prosumer_dict={#'SCN0_CAT1_2000_6000': {'elec_demand': 2000, 'therm_demand': 6000, 'hot_water_demand': 1500, 'topology_path': 'input_files/models/SCN0_CAT1', 'config_path': 'input_files/models/SCN0_CAT1/config.csv', 'data_path': 'input_files/models/SCN0_CAT1/data_path.csv', 'rolling_horizon': False},
prosumer_dict = {
# 'SCN0_CAT1_2000_6000': {'elec_demand': 2000, 'therm_demand': 6000, 'hot_water_demand': 1500, 'topology_path': 'input_files/models/SCN0_CAT1', 'config_path': 'input_files/models/SCN0_CAT1/config.csv', 'data_path': 'input_files/models/SCN0_CAT1/data_path.csv', 'rolling_horizon': False},
# 'SCN3_CAT1_3000_6000': {'elec_demand': 3000, 'therm_demand': 6000, 'hot_water_demand': 1500, 'topology_path': 'input_files/models/SCN3_CAT1', 'config_path': 'input_files/models/SCN3_CAT1/config.csv', 'data_path': 'input_files/models/SCN3_CAT1/data_path.csv', 'rolling_horizon': False},
# 'SCN1_CAT1_3000_6000': {'elec_demand': 3000, 'therm_demand': 6000, 'hot_water_demand': 1500, 'topology_path': 'input_files/models/SCN1_CAT1', 'config_path': 'input_files/models/SCN1_CAT1/config.csv', 'data_path': 'input_files/models/SCN1_CAT1/data_path.csv', 'rolling_horizon': False},
'SCN2_CAT1_PV14_HP_3000_6000': {'elec_demand': 3000, 'therm_demand': 6000,
'hot_water_demand': 1500,
'topology_path': 'input_files/models/prosumer_models/SCN2_CAT1_PV14_HP',
'config_path': 'input_files/models/prosumer_models/SCN2_CAT1_PV14_HP/config.csv',
'data_path': 'input_files/models/prosumer_models/SCN2_CAT1_PV14_HP/data_path.csv',
# 'SCN2_CAT1_PV14_HP_3000_6000': {'elec_demand': 3000, 'therm_demand': 6000,
# 'hot_water_demand': 1500,
# 'topology_path': 'input_files/models/prosumer_models/SCN2_CAT1_PV14_HP',
# 'config_path': 'input_files/models/prosumer_models/SCN2_CAT1_PV14_HP/config.csv',
# 'data_path': 'input_files/models/prosumer_models/SCN2_CAT1_PV14_HP/data_path.csv',
# 'rolling_horizon': False}
'office_pv_heatpump': {'elec_demand': 32905,
'therm_demand': 115154,
'hot_water_demand': 11882,
'topology_path': 'input_files/models/prosumer_models/office_pv_heatpump',
'config_path': 'input_files/models/prosumer_models/office_pv_heatpump/config.csv',
'data_path': 'input_files/models/prosumer_models/office_pv_heatpump/data_path.csv',
'rolling_horizon': False}
# 'SCN2_CAT1_PV12_BA_3000_6000': {'elec_demand': 9000, 'therm_demand': 20000, 'hot_water_demand': 1500, 'topology_path': 'input_files/models/SCN2_CAT1_PV12_BA', 'config_path': 'input_files/models/SCN2_CAT1_PV12_BA/config.csv', 'data_path': 'input_files/models/SCN3_CAT1_PV12_BA/data_path.csv', 'rolling_horizon': True}}
......@@ -214,14 +236,22 @@ if __name__ == "__main__":
if parallel_processing:
count_processes = len(prosumer_dict.keys())
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)
mapped_values = list(tqdm(pool.map(parallel_func, list(prosumer_dict.keys())), total=count_processes))
parallel_func = partial(process_each_prosumer,
prosumer_dict=prosumer_dict,
data_source=data_source,
commentary=commentary,
no_process_bar_rh=no_process_bar_rh)
mapped_values = list(
tqdm(pool.map(parallel_func, list(prosumer_dict.keys())),
total=count_processes))
# Normal processing, one core only
else:
for prosumer_name in list(prosumer_dict.keys()):
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)
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)
# Timer output
toc = time.time()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment