Skip to content

Commit

Permalink
workgin on shifting
Browse files Browse the repository at this point in the history
  • Loading branch information
Sven Eggimann committed Jan 11, 2019
1 parent c09655f commit 0b64caa
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 17 deletions.
20 changes: 16 additions & 4 deletions energy_demand/enduse_func.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,16 @@ def load_shifting(
"""
# Get assumed load shift
if dm_improvement[enduse][curr_yr] == 0:

if curr_yr >= 2015:
print(fuel_yh.shape)
_sum_dayily = np.sum(fuel_yh, axis=0)
_peak_day = np.argmax(_sum_dayily)
print("aa " + str(_peak_day))
print(fuel_yh[int(_peak_day)])
__max_after = fuel_yh.argmax(fuel_yh[int(_peak_day)])
print("peak zero {}".format(__max_after))

pass # no load management
else:
# Calculate average for every day
Expand All @@ -420,8 +430,8 @@ def load_shifting(
param_lf_improved_cy,
loadfactor_yd_cy)

#import copy
#_a = copy.copy(fuel_yh)
import copy
_a = copy.copy(fuel_yh)

fuel_yh = lf.peak_shaving_max_min(
lf_improved_cy,
Expand All @@ -430,7 +440,8 @@ def load_shifting(
mode_constrained)


'''import matplotlib.pyplot as plt
#'''
import matplotlib.pyplot as plt
print(fuel_yh.shape)

plt.plot(fuel_yh[10], label="after")
Expand All @@ -444,7 +455,8 @@ def load_shifting(
_peak_day = np.argmax(_sum_dayily)
__max_after = fuel_yh.argmax(fuel_yh[_peak_day])
__max_before = fuel_yh.argmax(_a[_peak_day])
print("befire; {} after: {}".format(__max_before, __max_after))'''
print("befire; {} after: {}".format(__max_before, __max_after))
#'''

# -------------------------------------------------
# Convert all load profiles into flat load profiles
Expand Down
11 changes: 8 additions & 3 deletions energy_demand/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
move data config folder into data
Note
----
Always execute from root folder. (e.g. energy_demand/energy_demand/main.py
Always execute from root folder. e.g.:
energy_demand/energy_demand/main.py
"""
import os
import sys
Expand Down Expand Up @@ -115,8 +117,11 @@ def energy_demand_model(
#name_config_path = 'l_c'
#name_config_path = 'h_max'
#name_config_path = 'h_min'
name_config_path = 'h_min_zero'
#name_config_path = 'h_min_5dm'
#name_config_path = 'h_min_10dm'
#name_config_path = 'l_max'
name_config_path = 'l_min'
#name_config_path = 'l_min'

# Local path configurations
if config['CRITERIA']['cluster_calc']:
Expand All @@ -128,7 +133,7 @@ def energy_demand_model(
local_scenario = 'pop-b_econ-c_fuel-c' #high
elif name_config_path == 'h_c' or name_config_path == 'l_c':
local_scenario = 'pop-baseline16_econ-c16_fuel-c16' #middle
elif name_config_path == 'h_min' or name_config_path == 'l_min':
elif name_config_path == 'h_min' or name_config_path == 'l_min' or name_config_path in ['h_min_zero', 'h_min_5dm', 'h_min_10dm']:
local_scenario = 'pop-f_econ-c_fuel-c' #low

# --- Paths
Expand Down
6 changes: 3 additions & 3 deletions energy_demand/plotting/fig_3_plot_over_time.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@

colors = {
# High elec
'h_min': '#004529',
'h_c': '#238443',
'h_max': '#78c679',
#'h_min': '#004529',
#'h_c': '#238443',
#'h_max': '#78c679',

# Low elec
'l_min': '#800026',
Expand Down
4 changes: 2 additions & 2 deletions tests/profiles/test_load_factors.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def test_peak_shaving_max_min():
fuel_yh,
mode_constrained=False)

import matplotlib.pyplot as plt
'''import matplotlib.pyplot as plt
print(fuel_yh.shape)
print(fuel_yh[0][0])
print("--")
Expand All @@ -45,7 +45,7 @@ def test_peak_shaving_max_min():
plt.plot(result[0][0], label="after")
plt.legend()
plt.show()
print("----")
print("----")'''

# ---------
# expected
Expand Down
10 changes: 5 additions & 5 deletions tests/test_enduse_func.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,16 +196,16 @@ def test_calc_lf_improvement():

#all factors must be smaller than one
loadfactor_yd_cy = np.zeros((2, 2)) #to fueltypes, two days
loadfactor_yd_cy[0][0] = 2
loadfactor_yd_cy[0][1] = 4
loadfactor_yd_cy[1][0] = 1
loadfactor_yd_cy[1][1] = 3
loadfactor_yd_cy[0][0] = 0.2
loadfactor_yd_cy[0][1] = 0.4
loadfactor_yd_cy[1][0] = 0.1
loadfactor_yd_cy[1][1] = 0.3

result = enduse_func.calc_lf_improvement(
param_lf_improved_cy=param_lf_improved_cy,
loadfactor_yd_cy=loadfactor_yd_cy)

expected = loadfactor_yd_cy + 25
expected = loadfactor_yd_cy + param_lf_improved_cy

assert result[0][0] == expected[0][0]
assert result[0][1] == expected[0][1]
Expand Down

0 comments on commit 0b64caa

Please sign in to comment.