diff --git a/src/oemof/solph/flows/_simple_flow_block.py b/src/oemof/solph/flows/_simple_flow_block.py index 7b0e0a148..469ec1311 100644 --- a/src/oemof/solph/flows/_simple_flow_block.py +++ b/src/oemof/solph/flows/_simple_flow_block.py @@ -255,7 +255,7 @@ def _positive_gradient_flow_rule(model): """Rule definition for positive gradient constraint.""" for inp, out in self.POSITIVE_GRADIENT_FLOWS: for index in range(1, len(m.TIMESTEPS) + 1): - if m.TIMESTEPS.at(index)[1] > 0: + if m.TIMESTEPS.at(index) > 0: lhs = ( m.flow[ inp, @@ -269,7 +269,7 @@ def _positive_gradient_flow_rule(model): ] ) rhs = self.positive_gradient[ - inp, out, m.TIMESTEPS.at(index)[1] + inp, out, m.TIMESTEPS.at(index) ] self.positive_gradient_constr.add( (inp, out, m.TIMESTEPS.at(index)), diff --git a/tests/lp_files/source_with_gradient.lp b/tests/lp_files/source_with_gradient.lp index 75f93f31b..c65753b4c 100644 --- a/tests/lp_files/source_with_gradient.lp +++ b/tests/lp_files/source_with_gradient.lp @@ -2,60 +2,60 @@ min objective: -+23 flow(powerplant_electricityBus_0_0) -+23 flow(powerplant_electricityBus_0_1) -+23 flow(powerplant_electricityBus_0_2) ++23 flow(powerplant_electricityBus_0) ++23 flow(powerplant_electricityBus_1) ++23 flow(powerplant_electricityBus_2) s.t. -c_e_BusBlock_balance(electricityBus_0_0)_: -+1 flow(powerplant_electricityBus_0_0) +c_e_BusBlock_balance(electricityBus_0)_: ++1 flow(powerplant_electricityBus_0) = 0 -c_e_BusBlock_balance(electricityBus_0_1)_: -+1 flow(powerplant_electricityBus_0_1) +c_e_BusBlock_balance(electricityBus_1)_: ++1 flow(powerplant_electricityBus_1) = 0 -c_e_BusBlock_balance(electricityBus_0_2)_: -+1 flow(powerplant_electricityBus_0_2) +c_e_BusBlock_balance(electricityBus_2)_: ++1 flow(powerplant_electricityBus_2) = 0 -c_e_SimpleFlowBlock_positive_gradient_constr(powerplant_electricityBus_0_0)_: +c_e_SimpleFlowBlock_positive_gradient_constr(powerplant_electricityBus_0)_: +1 SimpleFlowBlock_positive_gradient(powerplant_electricityBus_0) = 0 -c_u_SimpleFlowBlock_positive_gradient_constr(powerplant_electricityBus_0_1)_: --1 flow(powerplant_electricityBus_0_0) -+1 flow(powerplant_electricityBus_0_1) +c_u_SimpleFlowBlock_positive_gradient_constr(powerplant_electricityBus_1)_: +-1 flow(powerplant_electricityBus_0) ++1 flow(powerplant_electricityBus_1) -1 SimpleFlowBlock_positive_gradient(powerplant_electricityBus_1) <= 0 -c_u_SimpleFlowBlock_positive_gradient_constr(powerplant_electricityBus_0_2)_: --1 flow(powerplant_electricityBus_0_1) -+1 flow(powerplant_electricityBus_0_2) +c_u_SimpleFlowBlock_positive_gradient_constr(powerplant_electricityBus_2)_: +-1 flow(powerplant_electricityBus_1) ++1 flow(powerplant_electricityBus_2) -1 SimpleFlowBlock_positive_gradient(powerplant_electricityBus_2) <= 0 -c_e_SimpleFlowBlock_negative_gradient_constr(powerplant_electricityBus_0_0)_: +c_e_SimpleFlowBlock_negative_gradient_constr(powerplant_electricityBus_0)_: +1 SimpleFlowBlock_negative_gradient(powerplant_electricityBus_0) = 0 -c_u_SimpleFlowBlock_negative_gradient_constr(powerplant_electricityBus_0_1)_: -+1 flow(powerplant_electricityBus_0_0) --1 flow(powerplant_electricityBus_0_1) +c_u_SimpleFlowBlock_negative_gradient_constr(powerplant_electricityBus_1)_: ++1 flow(powerplant_electricityBus_0) +-1 flow(powerplant_electricityBus_1) -1 SimpleFlowBlock_negative_gradient(powerplant_electricityBus_1) <= 0 -c_u_SimpleFlowBlock_negative_gradient_constr(powerplant_electricityBus_0_2)_: -+1 flow(powerplant_electricityBus_0_1) --1 flow(powerplant_electricityBus_0_2) +c_u_SimpleFlowBlock_negative_gradient_constr(powerplant_electricityBus_2)_: ++1 flow(powerplant_electricityBus_1) +-1 flow(powerplant_electricityBus_2) -1 SimpleFlowBlock_negative_gradient(powerplant_electricityBus_2) <= 0 bounds - 0 <= flow(powerplant_electricityBus_0_0) <= 999 - 0 <= flow(powerplant_electricityBus_0_1) <= 999 - 0 <= flow(powerplant_electricityBus_0_2) <= 999 + 0 <= flow(powerplant_electricityBus_0) <= 999 + 0 <= flow(powerplant_electricityBus_1) <= 999 + 0 <= flow(powerplant_electricityBus_2) <= 999 0 <= SimpleFlowBlock_positive_gradient(powerplant_electricityBus_0) <= 29.97 0 <= SimpleFlowBlock_positive_gradient(powerplant_electricityBus_1) <= 29.97 0 <= SimpleFlowBlock_positive_gradient(powerplant_electricityBus_2) <= 29.97