Skip to content

Commit

Permalink
Merge pull request #1012 from oemof/fix/offset_converter_y-intercept
Browse files Browse the repository at this point in the history
Fix y intercept of OffsetConverter
  • Loading branch information
p-snft authored Nov 15, 2023
2 parents 7c7ba3b + 2781829 commit 72bfb3b
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 24 deletions.
8 changes: 2 additions & 6 deletions src/oemof/solph/components/_offset_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,9 +245,7 @@ def _relation_rule(block):
# `NonConvexFlow`.
try:
expr += (
m.InvestNonConvexFlowBlock.status_nominal[
n, o, t
]
m.InvestNonConvexFlowBlock.status[n, o, t]
* n.coefficients[0][t]
)
# `KeyError` occurs when more than one
Expand All @@ -262,9 +260,7 @@ def _relation_rule(block):
# (inside the `try` block) does not exist.
except (KeyError, AttributeError):
expr += (
m.NonConvexFlowBlock.status_nominal[
n, o, t
]
m.NonConvexFlowBlock.status[n, o, t]
* n.coefficients[0][t]
)
block.relation.add((n, i, o, p, t), (expr == 0))
Expand Down
12 changes: 6 additions & 6 deletions tests/lp_files/offsetconverter.lp
Original file line number Diff line number Diff line change
Expand Up @@ -47,32 +47,32 @@ c_e_NonConvexFlowBlock_status_nominal_constraint(gasBus_gasboiler_2)_:

c_u_NonConvexFlowBlock_min(gasBus_gasboiler_0_0)_:
-1 flow(gasBus_gasboiler_0_0)
+0.32 NonConvexFlowBlock_status_nominal(gasBus_gasboiler_0)
+0.32 NonConvexFlowBlock_status(gasBus_gasboiler_0)
<= 0

c_u_NonConvexFlowBlock_min(gasBus_gasboiler_0_1)_:
-1 flow(gasBus_gasboiler_0_1)
+0.32 NonConvexFlowBlock_status_nominal(gasBus_gasboiler_1)
+0.32 NonConvexFlowBlock_status(gasBus_gasboiler_1)
<= 0

c_u_NonConvexFlowBlock_min(gasBus_gasboiler_0_2)_:
-1 flow(gasBus_gasboiler_0_2)
+0.32 NonConvexFlowBlock_status_nominal(gasBus_gasboiler_2)
+0.32 NonConvexFlowBlock_status(gasBus_gasboiler_2)
<= 0

c_u_NonConvexFlowBlock_max(gasBus_gasboiler_0_0)_:
+1 flow(gasBus_gasboiler_0_0)
-1 NonConvexFlowBlock_status_nominal(gasBus_gasboiler_0)
-1 NonConvexFlowBlock_status(gasBus_gasboiler_0)
<= 0

c_u_NonConvexFlowBlock_max(gasBus_gasboiler_0_1)_:
+1 flow(gasBus_gasboiler_0_1)
-1 NonConvexFlowBlock_status_nominal(gasBus_gasboiler_1)
-1 NonConvexFlowBlock_status(gasBus_gasboiler_1)
<= 0

c_u_NonConvexFlowBlock_max(gasBus_gasboiler_0_2)_:
+1 flow(gasBus_gasboiler_0_2)
-1 NonConvexFlowBlock_status_nominal(gasBus_gasboiler_2)
-1 NonConvexFlowBlock_status(gasBus_gasboiler_2)
<= 0

c_e_OffsetConverterBlock_relation(gasboiler_0_0)_:
Expand Down
12 changes: 6 additions & 6 deletions tests/lp_files/offsetconverter_multi_period.lp
Original file line number Diff line number Diff line change
Expand Up @@ -147,37 +147,37 @@ c_u_NonConvexFlowBlock_max(gasboiler_thermalBus_2_5)_:
c_e_OffsetConverterBlock_relation(gasboiler_gasBus_thermalBus_0_0)_:
+0.9 flow(gasBus_gasboiler_0_0)
-1 flow(gasboiler_thermalBus_0_0)
-17 NonConvexFlowBlock_status_nominal(gasboiler_thermalBus_0)
-17 NonConvexFlowBlock_status(gasboiler_thermalBus_0)
= 0

c_e_OffsetConverterBlock_relation(gasboiler_gasBus_thermalBus_0_1)_:
+0.9 flow(gasBus_gasboiler_0_1)
-1 flow(gasboiler_thermalBus_0_1)
-17 NonConvexFlowBlock_status_nominal(gasboiler_thermalBus_1)
-17 NonConvexFlowBlock_status(gasboiler_thermalBus_1)
= 0

c_e_OffsetConverterBlock_relation(gasboiler_gasBus_thermalBus_1_2)_:
+0.9 flow(gasBus_gasboiler_1_2)
-1 flow(gasboiler_thermalBus_1_2)
-17 NonConvexFlowBlock_status_nominal(gasboiler_thermalBus_2)
-17 NonConvexFlowBlock_status(gasboiler_thermalBus_2)
= 0

c_e_OffsetConverterBlock_relation(gasboiler_gasBus_thermalBus_1_3)_:
+0.9 flow(gasBus_gasboiler_1_3)
-1 flow(gasboiler_thermalBus_1_3)
-17 NonConvexFlowBlock_status_nominal(gasboiler_thermalBus_3)
-17 NonConvexFlowBlock_status(gasboiler_thermalBus_3)
= 0

c_e_OffsetConverterBlock_relation(gasboiler_gasBus_thermalBus_2_4)_:
+0.9 flow(gasBus_gasboiler_2_4)
-1 flow(gasboiler_thermalBus_2_4)
-17 NonConvexFlowBlock_status_nominal(gasboiler_thermalBus_4)
-17 NonConvexFlowBlock_status(gasboiler_thermalBus_4)
= 0

c_e_OffsetConverterBlock_relation(gasboiler_gasBus_thermalBus_2_5)_:
+0.9 flow(gasBus_gasboiler_2_5)
-1 flow(gasboiler_thermalBus_2_5)
-17 NonConvexFlowBlock_status_nominal(gasboiler_thermalBus_5)
-17 NonConvexFlowBlock_status(gasboiler_thermalBus_5)
= 0

bounds
Expand Down
6 changes: 3 additions & 3 deletions tests/lp_files/offsetconverter_nonconvex.lp
Original file line number Diff line number Diff line change
Expand Up @@ -78,19 +78,19 @@ c_u_NonConvexFlowBlock_max(diesel_genset_bus_electricity_0_2)_:
c_e_OffsetConverterBlock_relation(diesel_genset_bus_diesel_bus_electricity_0_0)_:
+0.5 flow(bus_diesel_diesel_genset_0_0)
-1 flow(diesel_genset_bus_electricity_0_0)
+2.5 NonConvexFlowBlock_status_nominal(diesel_genset_bus_electricity_0)
+2.5 NonConvexFlowBlock_status(diesel_genset_bus_electricity_0)
= 0

c_e_OffsetConverterBlock_relation(diesel_genset_bus_diesel_bus_electricity_0_1)_:
+0.5 flow(bus_diesel_diesel_genset_0_1)
-1 flow(diesel_genset_bus_electricity_0_1)
+2.5 NonConvexFlowBlock_status_nominal(diesel_genset_bus_electricity_1)
+2.5 NonConvexFlowBlock_status(diesel_genset_bus_electricity_1)
= 0

c_e_OffsetConverterBlock_relation(diesel_genset_bus_diesel_bus_electricity_0_2)_:
+0.5 flow(bus_diesel_diesel_genset_0_2)
-1 flow(diesel_genset_bus_electricity_0_2)
+2.5 NonConvexFlowBlock_status_nominal(diesel_genset_bus_electricity_2)
+2.5 NonConvexFlowBlock_status(diesel_genset_bus_electricity_2)
= 0

bounds
Expand Down
6 changes: 3 additions & 3 deletions tests/lp_files/offsetconverter_nonconvex_investment.lp
Original file line number Diff line number Diff line change
Expand Up @@ -119,19 +119,19 @@ c_u_InvestNonConvexFlowBlock_invest_nc_three(diesel_genset_bus_electricity_0_2)_
c_e_OffsetConverterBlock_relation(diesel_genset_bus_diesel_bus_electricity_0_0)_:
+0.5 flow(bus_diesel_diesel_genset_0_0)
-1 flow(diesel_genset_bus_electricity_0_0)
+2.5 InvestNonConvexFlowBlock_status_nominal(diesel_genset_bus_electricity_0)
+2.5 InvestNonConvexFlowBlock_status(diesel_genset_bus_electricity_0)
= 0

c_e_OffsetConverterBlock_relation(diesel_genset_bus_diesel_bus_electricity_0_1)_:
+0.5 flow(bus_diesel_diesel_genset_0_1)
-1 flow(diesel_genset_bus_electricity_0_1)
+2.5 InvestNonConvexFlowBlock_status_nominal(diesel_genset_bus_electricity_1)
+2.5 InvestNonConvexFlowBlock_status(diesel_genset_bus_electricity_1)
= 0

c_e_OffsetConverterBlock_relation(diesel_genset_bus_diesel_bus_electricity_0_2)_:
+0.5 flow(bus_diesel_diesel_genset_0_2)
-1 flow(diesel_genset_bus_electricity_0_2)
+2.5 InvestNonConvexFlowBlock_status_nominal(diesel_genset_bus_electricity_2)
+2.5 InvestNonConvexFlowBlock_status(diesel_genset_bus_electricity_2)
= 0

bounds
Expand Down

0 comments on commit 72bfb3b

Please sign in to comment.