diff --git a/src/oemof/solph/components/_generic_storage.py b/src/oemof/solph/components/_generic_storage.py index d1731ee1d..4f3b7165e 100644 --- a/src/oemof/solph/components/_generic_storage.py +++ b/src/oemof/solph/components/_generic_storage.py @@ -53,15 +53,15 @@ class GenericStorage(Node): :class:`oemof.solph.options.Investment` object Absolute nominal capacity of the storage, fixed value or object describing parameter of investment optimisations. - invest_relation_input_capacity : numeric or None, :math:`r_{cap,in}` + invest_relation_input_capacity : numeric (iterable or scalar) or None, :math:`r_{cap,in}` Ratio between the investment variable of the input Flow and the investment variable of the storage: :math:`\dot{E}_{in,invest} = E_{invest} \cdot r_{cap,in}` - invest_relation_output_capacity : numeric or None, :math:`r_{cap,out}` + invest_relation_output_capacity : numeric (iterable or scalar) or None, :math:`r_{cap,out}` Ratio between the investment variable of the output Flow and the investment variable of the storage: :math:`\dot{E}_{out,invest} = E_{invest} \cdot r_{cap,out}` - invest_relation_input_output : numeric or None, :math:`r_{in,out}` + invest_relation_input_output : numeric (iterable or scalar) or None, :math:`r_{in,out}` Ratio between the investment variable of the output Flow and the investment variable of the input flow. This ratio used to fix the flow investments to each other. @@ -237,9 +237,15 @@ def __init__( self.min_storage_level = solph_sequence(min_storage_level) self.fixed_costs = solph_sequence(fixed_costs) self.storage_costs = solph_sequence(storage_costs) - self.invest_relation_input_output = invest_relation_input_output - self.invest_relation_input_capacity = invest_relation_input_capacity - self.invest_relation_output_capacity = invest_relation_output_capacity + self.invest_relation_input_output = solph_sequence( + invest_relation_input_output + ) + self.invest_relation_input_capacity = solph_sequence( + invest_relation_input_capacity + ) + self.invest_relation_output_capacity = solph_sequence( + invest_relation_output_capacity + ) self.lifetime_inflow = lifetime_inflow self.lifetime_outflow = lifetime_outflow @@ -256,16 +262,14 @@ def _set_flows(self): coupled with storage capacity via invest relations """ for flow in self.inputs.values(): - if ( - self.invest_relation_input_capacity is not None - and not isinstance(flow.investment, Investment) - ): + if self.invest_relation_input_capacity[ + 0 + ] is not None and not isinstance(flow.investment, Investment): flow.investment = Investment(lifetime=self.lifetime_inflow) for flow in self.outputs.values(): - if ( - self.invest_relation_output_capacity is not None - and not isinstance(flow.investment, Investment) - ): + if self.invest_relation_output_capacity[ + 0 + ] is not None and not isinstance(flow.investment, Investment): flow.investment = Investment(lifetime=self.lifetime_outflow) def _check_invest_attributes(self): @@ -278,9 +282,9 @@ def _check_invest_attributes(self): ) raise AttributeError(e1) if ( - self.invest_relation_input_output is not None - and self.invest_relation_output_capacity is not None - and self.invest_relation_input_capacity is not None + self.invest_relation_input_output[0] is not None + and self.invest_relation_output_capacity[0] is not None + and self.invest_relation_input_capacity[0] is not None ): e2 = ( "Overdetermined. Three investment object will be coupled" @@ -483,7 +487,9 @@ def _create(self, group=None): self.STORAGES_WITH_INVEST_FLOW_REL = Set( initialize=[ - n for n in group if n.invest_relation_input_output is not None + n + for n in group + if n.invest_relation_input_output[0] is not None ] ) @@ -567,7 +573,7 @@ def _power_coupled(block): for p in m.PERIODS: expr = ( m.InvestmentFlowBlock.total[n, o[n], p] - ) * n.invest_relation_input_output == ( + ) * n.invest_relation_input_output[p] == ( m.InvestmentFlowBlock.total[i[n], n, p] ) self.power_coupled.add((n, p), expr) @@ -1161,7 +1167,7 @@ def _create(self, group=None): initialize=[ n for n in group - if n.invest_relation_input_capacity is not None + if n.invest_relation_input_capacity[0] is not None ] ) @@ -1169,13 +1175,15 @@ def _create(self, group=None): initialize=[ n for n in group - if n.invest_relation_output_capacity is not None + if n.invest_relation_output_capacity[0] is not None ] ) self.INVEST_REL_IN_OUT = Set( initialize=[ - n for n in group if n.invest_relation_input_output is not None + n + for n in group + if n.invest_relation_input_output[0] is not None ] ) @@ -1577,7 +1585,7 @@ def _power_coupled(block): for p in m.PERIODS: expr = ( m.InvestmentFlowBlock.total[n, o[n], p] - ) * n.invest_relation_input_output == ( + ) * n.invest_relation_input_output[p] == ( m.InvestmentFlowBlock.total[i[n], n, p] ) self.power_coupled.add((n, p), expr) @@ -1598,7 +1606,8 @@ def _storage_capacity_inflow_invest_rule(block): for p in m.PERIODS: expr = ( m.InvestmentFlowBlock.total[i[n], n, p] - == self.total[n, p] * n.invest_relation_input_capacity + == self.total[n, p] + * n.invest_relation_input_capacity[p] ) self.storage_capacity_inflow.add((n, p), expr) @@ -1620,7 +1629,8 @@ def _storage_capacity_outflow_invest_rule(block): for p in m.PERIODS: expr = ( m.InvestmentFlowBlock.total[n, o[n], p] - == self.total[n, p] * n.invest_relation_output_capacity + == self.total[n, p] + * n.invest_relation_output_capacity[p] ) self.storage_capacity_outflow.add((n, p), expr) diff --git a/tests/test_processing.py b/tests/test_processing.py index c7d9d5842..d10893dfe 100644 --- a/tests/test_processing.py +++ b/tests/test_processing.py @@ -164,8 +164,6 @@ def test_nodes_with_none_exclusion(self): { "balanced": True, "initial_storage_level": 0, - "invest_relation_input_capacity": 1 / 6, - "invest_relation_output_capacity": 1 / 6, "investment_age": 0, "investment_existing": 0, "investment_interest_rate": 0, @@ -180,6 +178,8 @@ def test_nodes_with_none_exclusion(self): "fixed_losses_absolute": 0, "fixed_losses_relative": 0, "inflow_conversion_factor": 1, + "invest_relation_input_capacity": 1 / 6, + "invest_relation_output_capacity": 1 / 6, "loss_rate": 0, "max_storage_level": 1, "min_storage_level": 0, @@ -204,8 +204,6 @@ def test_nodes_with_none_exclusion_old_name(self): { "balanced": True, "initial_storage_level": 0, - "invest_relation_input_capacity": 1 / 6, - "invest_relation_output_capacity": 1 / 6, "investment_age": 0, "investment_existing": 0, "investment_interest_rate": 0, @@ -220,6 +218,8 @@ def test_nodes_with_none_exclusion_old_name(self): "fixed_losses_absolute": 0, "fixed_losses_relative": 0, "inflow_conversion_factor": 1, + "invest_relation_input_capacity": 1 / 6, + "invest_relation_output_capacity": 1 / 6, "loss_rate": 0, "max_storage_level": 1, "min_storage_level": 0,