Skip to content

Commit

Permalink
Merge pull request oemof#561 from oemof/fix/bug_#559
Browse files Browse the repository at this point in the history
Fix bug oemof#559
  • Loading branch information
uvchik committed Jan 30, 2019
2 parents 513624a + 498c408 commit 73dd932
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 1 deletion.
2 changes: 1 addition & 1 deletion oemof/solph/components.py
Expand Up @@ -497,7 +497,7 @@ def _create(self, group=None):
def _storage_investvar_bound_rule(block, n):
"""Rule definition to bound the invested storage capacity `invest`.
"""
return 0, n.investment.maximum
return n.investment.minimum, n.investment.maximum
self.invest = Var(self.INVESTSTORAGES, within=NonNegativeReals,
bounds=_storage_investvar_bound_rule)

Expand Down
15 changes: 15 additions & 0 deletions tests/constraint_tests.py
Expand Up @@ -326,6 +326,21 @@ def test_storage_invest_6(self):
investment=solph.Investment(ep_costs=145, existing=10000))
self.compare_lp_files('storage_invest_6.lp')

def test_storage_minimum_invest(self):
"""All invest variables are coupled. The invest variables of the Flows
will be created during the initialisation of the storage e.g. battery
"""
bel = solph.Bus(label='electricityBus')

solph.components.GenericStorage(
label='storage1',
inputs={bel: solph.Flow()},
outputs={bel: solph.Flow()},
investment=solph.Investment(
ep_costs=145, minimum=100, maximum=200))

self.compare_lp_files('storage_invest_minimum.lp')

def test_transformer(self):
"""Constraint test of a LinearN1Transformer without Investment.
"""
Expand Down
74 changes: 74 additions & 0 deletions tests/lp_files/storage_invest_minimum.lp
@@ -0,0 +1,74 @@
\* Source Pyomo model name=Model *\

min
objective:
+145 GenericInvestmentStorageBlock_invest(storage1)

s.t.

c_e_Bus_balance(electricityBus_0)_:
-1 flow(electricityBus_storage1_0)
+1 flow(storage1_electricityBus_0)
= 0

c_e_Bus_balance(electricityBus_1)_:
-1 flow(electricityBus_storage1_1)
+1 flow(storage1_electricityBus_1)
= 0

c_e_Bus_balance(electricityBus_2)_:
-1 flow(electricityBus_storage1_2)
+1 flow(storage1_electricityBus_2)
= 0

c_e_GenericInvestmentStorageBlock_balance(storage1_0)_:
+1 GenericInvestmentStorageBlock_capacity(storage1_0)
-1 GenericInvestmentStorageBlock_capacity(storage1_2)
-1 flow(electricityBus_storage1_0)
+1 flow(storage1_electricityBus_0)
= 0

c_e_GenericInvestmentStorageBlock_balance(storage1_1)_:
-1 GenericInvestmentStorageBlock_capacity(storage1_0)
+1 GenericInvestmentStorageBlock_capacity(storage1_1)
-1 flow(electricityBus_storage1_1)
+1 flow(storage1_electricityBus_1)
= 0

c_e_GenericInvestmentStorageBlock_balance(storage1_2)_:
-1 GenericInvestmentStorageBlock_capacity(storage1_1)
+1 GenericInvestmentStorageBlock_capacity(storage1_2)
-1 flow(electricityBus_storage1_2)
+1 flow(storage1_electricityBus_2)
= 0

c_u_GenericInvestmentStorageBlock_max_capacity(storage1_0)_:
+1 GenericInvestmentStorageBlock_capacity(storage1_0)
-1 GenericInvestmentStorageBlock_invest(storage1)
<= 0

c_u_GenericInvestmentStorageBlock_max_capacity(storage1_1)_:
+1 GenericInvestmentStorageBlock_capacity(storage1_1)
-1 GenericInvestmentStorageBlock_invest(storage1)
<= 0

c_u_GenericInvestmentStorageBlock_max_capacity(storage1_2)_:
+1 GenericInvestmentStorageBlock_capacity(storage1_2)
-1 GenericInvestmentStorageBlock_invest(storage1)
<= 0

c_e_ONE_VAR_CONSTANT:
ONE_VAR_CONSTANT = 1.0

bounds
0 <= flow(electricityBus_storage1_0) <= +inf
0 <= flow(electricityBus_storage1_1) <= +inf
0 <= flow(electricityBus_storage1_2) <= +inf
0 <= flow(storage1_electricityBus_0) <= +inf
0 <= flow(storage1_electricityBus_1) <= +inf
0 <= flow(storage1_electricityBus_2) <= +inf
0 <= GenericInvestmentStorageBlock_capacity(storage1_0) <= +inf
0 <= GenericInvestmentStorageBlock_capacity(storage1_1) <= +inf
0 <= GenericInvestmentStorageBlock_capacity(storage1_2) <= +inf
100 <= GenericInvestmentStorageBlock_invest(storage1) <= 200
end

0 comments on commit 73dd932

Please sign in to comment.