diff --git a/src/oemof/solph/components/_generic_storage.py b/src/oemof/solph/components/_generic_storage.py index 1c34269ad..05a492216 100644 --- a/src/oemof/solph/components/_generic_storage.py +++ b/src/oemof/solph/components/_generic_storage.py @@ -1032,21 +1032,20 @@ def _create(self, group=None): # ########################## CHECKS ################################### if m.es.periods is not None: for n in group: - error = ( + error_fixed_absolute_losses = ( "For a multi-period investment model, fixed absolute" " losses are not supported. Please remove parameter." ) if n.fixed_losses_absolute.default != 0: - raise ValueError(error) - warning = ( + raise ValueError(error_fixed_absolute_losses) + error_initial_storage_level = ( "For a multi-period model, initial_storage_level is" - " not supported.\nIt is suggested to remove that" - " parameter since it has no effect.\nstorage_content" - " will be zero, until there is some usable storage " - " capacity installed." + " not supported.\nIt needs to be removed since it" + " has no effect.\nstorage_content will be zero," + " until there is some usable storage capacity installed." ) if n.initial_storage_level is not None: - warn(warning, debugging.SuspiciousUsageWarning) + raise ValueError(error_initial_storage_level) # ########################## SETS ##################################### @@ -1315,10 +1314,8 @@ def _old_storage_capacity_rule(block): def _initially_empty_rule(block): """Ensure storage to be empty initially""" for n in self.INVESTSTORAGES: - for t in m.TIMESTEPS: - if t == 0: - expr = self.storage_content[n, 0] == 0 - self.initially_empty.add((n, t), expr) + expr = self.storage_content[n, 0] == 0 + self.initially_empty.add((n, 0), expr) self.initially_empty = Constraint( self.INVESTSTORAGES, m.TIMESTEPS, noruleinit=True diff --git a/tests/multi_period_constraint_tests.py b/tests/multi_period_constraint_tests.py index ac776fc93..974e65e10 100644 --- a/tests/multi_period_constraint_tests.py +++ b/tests/multi_period_constraint_tests.py @@ -385,7 +385,6 @@ def test_storage_invest_2(self): investment=solph.Investment( ep_costs=145, lifetime=20, existing=20, age=19 ), - initial_storage_level=0.5, ) self.energysystem.add(bel, storage) self.compare_lp_files("storage_invest_2_multi_period.lp") @@ -612,7 +611,7 @@ def test_storage_invest_1_fixed_losses(self): self.get_om() def test_storage_invest_1_initial_storage_level(self): - """Test warning for initial storage level + """Test error for initial storage level with multi-period investments""" bel = solph.buses.Bus(label="electricityBus") storage = solph.components.GenericStorage( @@ -642,14 +641,12 @@ def test_storage_invest_1_initial_storage_level(self): self.energysystem.add(bel, storage) msg = ( "For a multi-period model, initial_storage_level is" - " not supported.\nIt is suggested to remove that" - " parameter since it has no effect.\nstorage_content" - " will be zero, until there is some usable storage " - " capacity installed." + " not supported.\nIt needs to be removed since it" + " has no effect.\nstorage_content will be zero," + " until there is some usable storage capacity installed." ) - with warnings.catch_warnings(record=True) as w: + with pytest.raises(ValueError, match=msg): self.get_om() - assert msg in str(w[1].message) def test_storage_invest_1_missing_lifetime(self): """Test error thrown if storage misses necessary lifetime"""