From 3abc40c800666614e34ef15b7a6e5cc921a30ee7 Mon Sep 17 00:00:00 2001 From: Johannes Roeder Date: Sat, 3 Feb 2024 00:24:07 +0100 Subject: [PATCH] Fix periods in existing heatpipelines (due to solph v0.5.1) --- dhnx/optimization/oemof_heatpipe.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/dhnx/optimization/oemof_heatpipe.py b/dhnx/optimization/oemof_heatpipe.py index d96f660e..d92d7cc6 100644 --- a/dhnx/optimization/oemof_heatpipe.py +++ b/dhnx/optimization/oemof_heatpipe.py @@ -269,8 +269,14 @@ def _relation_rule(block, n, t): o = list(n.outputs.keys())[0] expr = 0 - expr += - m.flow[n, o, t] - expr += m.flow[i, n, t] + try: # oemof.solph<=0.5.0 + expr += - m.flow[n, o, t] + expr += m.flow[i, n, t] + except KeyError: # oemof.solph>=0.5.1 + period = 0 # Periods are not (yet) supported in DHNx + expr += - m.flow[n, o, period, t] + expr += m.flow[i, n, period, t] + expr += - block.heat_loss[n, t] return expr == 0