Code Duplication    Length = 25-25 lines in 2 locations

src/oemof/solph/components/_generic_storage.py 2 locations

@@ 1715-1739 (lines=25) @@
1712
            ) * m.timeincrement[t]
1713
            return expr == 0
1714
1715
        def _intra_storage_balance_rule(block, n, p, k, g):
1716
            """
1717
            Rule definition for the storage balance of every storage n and
1718
            every timestep.
1719
            """
1720
            t = m.get_timestep_from_tsam_timestep(p, k, g)
1721
            expr = 0
1722
            expr += block.intra_storage_delta[n, p, k, g + 1]
1723
            expr += (
1724
                -block.intra_storage_delta[n, p, k, g]
1725
                * (1 - n.loss_rate[t]) ** m.timeincrement[t]
1726
            )
1727
            expr += (
1728
                n.fixed_losses_relative[t]
1729
                * self.total[n, p]
1730
                * m.timeincrement[t]
1731
            )
1732
            expr += n.fixed_losses_absolute[t] * m.timeincrement[t]
1733
            expr += (
1734
                -m.flow[i[n], n, t] * n.inflow_conversion_factor[t]
1735
            ) * m.timeincrement[t]
1736
            expr += (
1737
                m.flow[n, o[n], t] / n.outflow_conversion_factor[t]
1738
            ) * m.timeincrement[t]
1739
            return expr == 0
1740
1741
        if not m.TSAM_MODE:
1742
            self.balance = Constraint(
@@ 633-657 (lines=25) @@
630
            ) * m.timeincrement[t]
631
            return expr == block.storage_content[n, t + 1]
632
633
        def _intra_storage_balance_rule(block, n, p, k, g):
634
            """
635
            Rule definition for the storage balance of every storage n and
636
            every timestep.
637
            """
638
            t = m.get_timestep_from_tsam_timestep(p, k, g)
639
            expr = 0
640
            expr += block.intra_storage_delta[n, p, k, g + 1]
641
            expr += (
642
                -block.intra_storage_delta[n, p, k, g]
643
                * (1 - n.loss_rate[t]) ** m.timeincrement[t]
644
            )
645
            expr += (
646
                n.fixed_losses_relative[t]
647
                * n.nominal_storage_capacity
648
                * m.timeincrement[t]
649
            )
650
            expr += n.fixed_losses_absolute[t] * m.timeincrement[t]
651
            expr += (
652
                -m.flow[i[n], n, t] * n.inflow_conversion_factor[t]
653
            ) * m.timeincrement[t]
654
            expr += (
655
                m.flow[n, o[n], t] / n.outflow_conversion_factor[t]
656
            ) * m.timeincrement[t]
657
            return expr == 0
658
659
        if not m.TSAM_MODE:
660
            self.balance = Constraint(