Skip to content

Commit

Permalink
Merge remote-tracking branch 'behnam2015/add_storage' into add_storage
Browse files Browse the repository at this point in the history
  • Loading branch information
behnam-zakeri committed May 1, 2019
2 parents 3e32c62 + 8faecab commit d1bb6f8
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 37 deletions.
33 changes: 28 additions & 5 deletions message_ix/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,38 @@
}


def init_storage(scen, *args, **kwargs):
# Initiating a set to specifiy storage level (no commodity balance needed)
scen.init_set('level_storage')

# Initiating a set to specifiy storage reservoir technology
scen.init_set('storage_tec')

# Initiating a set to map storage reservoir to its charger/discharger
scen.init_set('map_tec_storage', idx_sets=['technology', 'storage_tec'])

# Initiating a parameter to specify the order of sub-annual time steps
scen.init_par('time_seq', idx_sets=['time'])

# Initiating two parameters for specifying lower and upper bounds of
# storage reservoir as percentage of installed reservoir capacity
par_list_stor = ['bound_storage_lo', 'bound_storage_up']
for parname in par_list_stor:
scen.init_par(parname, idx_sets=['node', 'technology', 'commodity',
'level', 'year', 'time'])
# Initiating a parameter for specifying storage losses (percentage)
scen.init_par('storage_loss', idx_sets=['node', 'technology', 'commodity',
'level', 'year', 'time'])


def _init_scenario(s, commit=False):
"""Initialize a MESSAGEix Scenario object with default values"""
inits = (
# {
# 'test': False # some test,
# 'exec': [(pass, {'args': ()}), ],
# },
{
'test': 'level_storage' not in s.set_list(),
'exec': [(init_storage, {'args': (s,)}), ],
},
)

pass_idx = [i for i, init in enumerate(inits) if init['test']]
if len(pass_idx) == 0:
return # leave early, all init tests pass
Expand Down
32 changes: 0 additions & 32 deletions tests/test_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,34 +62,6 @@ def year_to_time(scen, parname, dict_par, filters=None):
scen.add_par(parname, new)


# A function for initiating sets/parameters required for storage equations
# NOTICE: this function can be deleted when storage parameters/sets are added
# to ixmp java backend
def init_storage(scen):

# Initiating a set to specifiy storage level (no commodity balance needed)
scen.init_set('level_storage')

# Initiating a set to specifiy storage reservoir technology
scen.init_set('storage_tec')

# Initiating a set to map storage reservoir to its charger/discharger
scen.init_set('map_tec_storage', idx_sets=['technology', 'storage_tec'])

# Initiating a parameter to specify the order of sub-annual time steps
scen.init_par('time_seq', idx_sets=['time'])

# Initiating two parameters for specifying lower and upper bounds of
# storage reservoir as percentage of installed reservoir capacity
par_list_stor = ['bound_storage_lo', 'bound_storage_up']
for parname in par_list_stor:
scen.init_par(parname, idx_sets=['node', 'technology', 'commodity',
'level', 'year', 'time'])
# Initiating a parameter for specifying storage losses (percentage)
scen.init_par('storage_loss', idx_sets=['node', 'technology', 'commodity',
'level', 'year', 'time'])


# A function for adding storage technologies and parameterization
def add_storage_data(scen, time_order):
# Adding level of storage
Expand Down Expand Up @@ -152,10 +124,6 @@ def test_storage(test_mp):
# First building a simple model
scen = Scenario(test_mp, 'no_storage', 'standard', version='new')
model_setup(scen, [2020])

# Initiating missing sets/parameters if not yet in ixmp backend
if not storage_in_java:
init_storage(scen)
scen.commit('initialized test model')
scen.solve(case='no_seasonality')

Expand Down

0 comments on commit d1bb6f8

Please sign in to comment.