From 1116fbb1c87c9feaf3ecff7199d4444eaf786d74 Mon Sep 17 00:00:00 2001 From: tarao1006 Date: Sun, 7 Nov 2021 01:47:39 +0900 Subject: [PATCH] Add is_finished flag to exit outer loop --- src/pyheatintegration/grand_composite_curve.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/pyheatintegration/grand_composite_curve.py b/src/pyheatintegration/grand_composite_curve.py index bf51554..7abf8bb 100644 --- a/src/pyheatintegration/grand_composite_curve.py +++ b/src/pyheatintegration/grand_composite_curve.py @@ -134,6 +134,7 @@ def _update_external_streams_heat( or (stream.is_cold() and target_temperature > pinch_point_temp): continue + is_finished = False for i in range(len(heats)): if i == len(heats) - 1: # 与熱流体の場合は、流体温度がtemps[i]よりも大きい時、受熱流体の場合は、 @@ -141,6 +142,7 @@ def _update_external_streams_heat( if (stream.is_hot() and target_temperature >= temps[i]) \ or (stream.is_cold() and target_temperature <= temps[i]): stream.update_heat(not_heated) + is_finished = True break start_temp = temps[i] finish_temp = temps[i + 1] @@ -160,6 +162,8 @@ def _update_external_streams_heat( heated += heat not_heated -= heat break + if is_finished: + break return streams