diff --git a/dhnx/optimization/oemof_heatpipe.py b/dhnx/optimization/oemof_heatpipe.py index dea9547d..d92d7cc6 100644 --- a/dhnx/optimization/oemof_heatpipe.py +++ b/dhnx/optimization/oemof_heatpipe.py @@ -34,10 +34,10 @@ def __str__(self): class HeatPipeline(Transformer): r"""A HeatPipeline represent a Pipeline in a district heating system. + This is done by a Transformer with a constant energy loss independent of - actual power, but dependent on the nominal power and the length parameter. - The HeatPipeline is a single-input-single-output transformer. Additionally, - conversion factors for in- and output flow can be applied. + actual power, but dependent on the nominal power. + The HeatPipeline is a single-input-single-output transformer. Parameters ---------- @@ -66,12 +66,23 @@ class HeatPipeline(Transformer): """ - def __init__(self, *args, **kwargs): - super().__init__(*args, **kwargs) - - self.heat_loss_factor = sequence(kwargs.get('heat_loss_factor', 0)) - self.heat_loss_factor_fix = sequence(kwargs.get( - 'heat_loss_factor_fix', 0)) + def __init__( + self, + inputs, + outputs, + label=None, + heat_loss_factor=0, + heat_loss_factor_fix=0, + ): + + self.heat_loss_factor = sequence(heat_loss_factor) + self.heat_loss_factor_fix = sequence(heat_loss_factor_fix) + + super().__init__( + inputs=inputs, + outputs=outputs, + label=label, + ) self._invest_group = False self._nonconvex_group = False @@ -178,10 +189,6 @@ class HeatPipelineBlock(ScalarBlock): # pylint: disable=too-many-ancestors loss of heat pipeline" ":math:`\dot{Q}_{nominal}`", ":py:obj:`flows[n, o].nominal_value`", " P", "Nominal capacity of heating pipeline" - ":math:`\eta_{out}`", ":py:obj:`conversion_factors[o][t]`", "P", " - Conversion factor of output flow (Heat Output)" - ":math:`\eta_{in}`", ":py:obj:`conversion_factors[i][t]`", "P", " - Conversion factor of input flow (Heat Input)" ":math:`f_{loss}(t)`", ":py:obj:`heat_loss_factor`", "P", "Specific heat loss factor for pipeline" ":math:`l`", ":py:obj:`length`", "P", "Length of heating pipeline" @@ -262,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 @@ -300,10 +313,6 @@ class HeatPipelineInvestBlock(ScalarBlock): # pylint: disable=too-many-ancestor loss of heat pipeline" ":math:`\dot{Q}_{nominal}`", ":py:obj:`flows[n, o].nominal_value`", " V", "Nominal capacity of heating pipeline" - ":math:`\eta_{out}`", ":py:obj:`conversion_factors[o][t]`", "P", " - Conversion factor of output flow (heat output)" - ":math:`\eta_{in}`", ":py:obj:`conversion_factors[i][t]`", "P", " - Conversion factor of input flow (heat input)" ":math:`f_{loss}(t)`", ":py:obj:`heat_loss_factor`", "P", "Specific heat loss factor for pipeline" ":math:`l`", ":py:obj:`length`", "P", "Length of heating pipeline" @@ -433,15 +442,13 @@ def _relation_rule_with_demand(block, n, t): expr = 0 try: # oemof.solph<=0.5.0 expr += - m.flow[n, o, t] - expr += m.flow[i, n, t] * n.conversion_factors[ - o][t] / n.conversion_factors[i][t] + expr += m.flow[i, n, t] expr += - block.heat_loss[n, t] expr += - m.flow[n, d, 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] * n.conversion_factors[ - o][t] / n.conversion_factors[i][t] + expr += m.flow[i, n, period, t] expr += - block.heat_loss[n, t] expr += - m.flow[n, d, period, t]