Exemplo n.º 1
0
    def test_2_stream_example(self):
        cold_stream = make_stream(-180, 20, 200)
        hot_stream = make_stream(180, 150, 50)
        analyzer = PinchAnalyzer(default_temp_shift=10)
        analyzer.add_streams(cold_stream, hot_stream)

        self.assertEqual(analyzer.cooling_demand, 180)
        self.assertEqual(analyzer.heating_demand, 180)
        self.assertEqual(analyzer.cold_utility_target, 70)
        self.assertEqual(analyzer.hot_utility_target, 70)
        self.assertEqual(analyzer.heat_recovery_target, 110)
        self.assertEqual(analyzer.pinch_temps, [140])
        self.assertEqual(analyzer.default_temp_shift, 10)

        self.assertEqual(analyzer.streams, [cold_stream, hot_stream])

        expected_cold_composite_curve = ([70, 250], [20, 200])
        self.assertEqual(analyzer.cold_composite_curve,
                         expected_cold_composite_curve)

        expected_hot_composite_curve = ([0, 180], [50, 150])
        self.assertEqual(analyzer.hot_composite_curve,
                         expected_hot_composite_curve)

        expected_shifted_cold_composite_curve = ([70, 250], [30, 210])
        self.assertEqual(analyzer.shifted_cold_composite_curve,
                         expected_shifted_cold_composite_curve)

        expected_shifted_hot_composite_curve = ([0, 180], [40, 140])
        self.assertEqual(analyzer.shifted_hot_composite_curve,
                         expected_shifted_hot_composite_curve)

        expected_grand_composite_curve = ([70, 80, 0, 70], [30, 40, 140, 210])
        self.assertEqual(analyzer.grand_composite_curve,
                         expected_grand_composite_curve)
Exemplo n.º 2
0
    def test_make_stream(self):
        from_init = Stream(make_segment(-320, 20, 100, 5))
        from_make = make_stream(-320, 20, 100, 5)
        self.assertEqual(from_init.segments, from_make.segments)

        from_init = Stream(make_segment(-400, 100, 100))
        from_make = make_stream(-400, 100, 100)
        self.assertEqual(from_init.segments, from_make.segments)
Exemplo n.º 3
0
    def test_extended_pinch(self):
        cold_stream = make_stream(-225, 20, 95)
        hot_stream = make_stream(267, 95, 6)
        analyzer = PinchAnalyzer(default_temp_shift=1)
        analyzer.add_streams(cold_stream, hot_stream)

        self.assertEqual(analyzer.cooling_demand, 267)
        self.assertEqual(analyzer.heating_demand, 225)
        self.assertEqual(analyzer.cold_utility_target, 48)
        self.assertEqual(analyzer.hot_utility_target, 6)
        self.assertEqual(analyzer.heat_recovery_target, 219)
        self.assertEqual(analyzer.pinch_temps, [21, 94])
        self.assertEqual(analyzer.default_temp_shift, 1)
Exemplo n.º 4
0
    def test_neutralizing_streams(self):
        cold_stream = make_stream(-40, 100, 100, 0)
        hot_stream = make_stream(40, 100, 100, 0)
        analyzer = PinchAnalyzer(default_temp_shift=5)
        analyzer.add_streams(cold_stream)
        analyzer.add_streams(hot_stream)

        self.assertEqual(analyzer.cooling_demand, 40)
        self.assertEqual(analyzer.heating_demand, 40)
        self.assertEqual(analyzer.cold_utility_target, 0)
        self.assertEqual(analyzer.hot_utility_target, 0)
        self.assertEqual(analyzer.heat_recovery_target, 40)
        self.assertEqual(analyzer.pinch_temps, [])
        self.assertEqual(analyzer.default_temp_shift, 5)
        self.assertEqual(analyzer.streams, [cold_stream, hot_stream])
Exemplo n.º 5
0
    def test_repr(self):
        exec("from pina.segments.latent_segment import LatentSegment")
        exec("from pina.segments.sensible_segment import SensibleSegment")

        single_seg_stream = make_stream(-320, 20, 100, 5)
        self.assertEqual(eval(repr(single_seg_stream)), single_seg_stream)

        multi_seg_stream = make_segmented_stream([-320, 20, 100, 5],
                                                 [-400, 100, 100])
        self.assertEqual(eval(repr(multi_seg_stream)), multi_seg_stream)
Exemplo n.º 6
0
    def test_cold_stream_only(self):
        cold_stream = make_stream(-40, 100, 100)
        analyzer = PinchAnalyzer(default_temp_shift=5)
        analyzer.add_streams(cold_stream)

        self.assertEqual(analyzer.cooling_demand, 0)
        self.assertEqual(analyzer.heating_demand, 40)
        self.assertEqual(analyzer.cold_utility_target, 0)
        self.assertEqual(analyzer.hot_utility_target, 40)
        self.assertEqual(analyzer.heat_recovery_target, 0)
        self.assertEqual(analyzer.pinch_temps, [105])
        self.assertEqual(analyzer.default_temp_shift, 5)
Exemplo n.º 7
0
    def test_hot_stream_only(self):
        hot_stream = make_stream(260, 150, 20)
        analyzer = PinchAnalyzer(default_temp_shift=5)
        analyzer.add_streams(hot_stream)

        self.assertEqual(analyzer.cooling_demand, 260)
        self.assertEqual(analyzer.heating_demand, 0)
        self.assertEqual(analyzer.cold_utility_target, 260)
        self.assertEqual(analyzer.hot_utility_target, 0)
        self.assertEqual(analyzer.heat_recovery_target, 0)
        self.assertEqual(analyzer.pinch_temps, [145])
        self.assertEqual(analyzer.default_temp_shift, 5)
Exemplo n.º 8
0
    def test_2_pinches(self):
        cold_stream = make_segmented_stream([-50, 50, 100], [-40, 100, 100],
                                            [-100, 100, 200])
        hot_stream = make_stream(260, 150, 20)
        analyzer = PinchAnalyzer(default_temp_shift=5)
        analyzer.add_streams(cold_stream, hot_stream)

        self.assertEqual(analyzer.cooling_demand, 260)
        self.assertEqual(analyzer.heating_demand, 190)
        self.assertEqual(analyzer.cold_utility_target, 130)
        self.assertEqual(analyzer.hot_utility_target, 60)
        self.assertEqual(analyzer.heat_recovery_target, 130)
        self.assertEqual(analyzer.pinch_temps, [105, 145])
        self.assertEqual(analyzer.default_temp_shift, 5)
Exemplo n.º 9
0
    def test_equality_comparison(self):
        single_seg_stream = make_stream(-320, 20, 100, 5)
        multi_seg_stream = make_segmented_stream([-320, 20, 100, 5],
                                                 [-400, 100, 100])

        self.assertEqual(single_seg_stream, make_stream(-320, 20, 100, 5))
        self.assertNotEqual(single_seg_stream, make_stream(-300, 20, 100, 5))
        self.assertNotEqual(single_seg_stream, make_stream(-320, 10, 100, 5))
        self.assertNotEqual(single_seg_stream, make_stream(-320, 20, 90, 5))
        self.assertNotEqual(single_seg_stream, make_stream(-320, 20, 100, 10))
        self.assertNotEqual(single_seg_stream,
                            make_stream(-320, 20, 100, None))

        self.assertEqual(
            multi_seg_stream,
            make_segmented_stream([-320, 20, 100, 5], [-400, 100, 100]),
        )
        self.assertNotEqual(single_seg_stream, multi_seg_stream)