From bfb42c7886ea970f27b7f01716b4645c43b04104 Mon Sep 17 00:00:00 2001 From: sarangbhagwat Date: Thu, 31 Oct 2024 22:21:35 -0500 Subject: [PATCH 1/3] allow sorting hus by T --- biosteam/facilities/hxn/_heat_exchanger_network.py | 7 +++++-- biosteam/facilities/hxn/hxn_synthesis.py | 13 ++++++++++--- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/biosteam/facilities/hxn/_heat_exchanger_network.py b/biosteam/facilities/hxn/_heat_exchanger_network.py index f273c17a..fdc036cb 100644 --- a/biosteam/facilities/hxn/_heat_exchanger_network.py +++ b/biosteam/facilities/hxn/_heat_exchanger_network.py @@ -108,7 +108,8 @@ class HeatExchangerNetwork(bst.Facility): def __init__(self, ID='', T_min_app=5., units=None, ignored=None, Qmin=1e-3, force_ideal_thermo=False, cache_network=False, avoid_recycle=False, - acceptable_energy_balance_error=None, replace_unit_heat_utilities=False): + acceptable_energy_balance_error=None, replace_unit_heat_utilities=False, + sort_hus_by_T=False): bst.Facility.__init__(self, ID, None, None) self.T_min_app = T_min_app self.units = units @@ -118,6 +119,7 @@ def __init__(self, ID='', T_min_app=5., units=None, ignored=None, Qmin=1e-3, self.cache_network = cache_network self.avoid_recycle = avoid_recycle self.replace_unit_heat_utilities = replace_unit_heat_utilities + self.sort_hus_by_T = sort_hus_by_T if acceptable_energy_balance_error is not None: self.acceptable_energy_balance_error = acceptable_energy_balance_error @@ -189,7 +191,8 @@ def _cost(self): T_out_arr, pinch_T_arr, C_flow_vector, hx_heat_utils_rearranged, streams_inlet, stream_HXs_dict,\ hot_indices, cold_indices = \ synthesize_network(hx_utils, self.T_min_app, self.Qmin, - self.force_ideal_thermo, self.avoid_recycle) + self.force_ideal_thermo, self.avoid_recycle, + self.sort_hus_by_T) new_HXs = HXs_hot_side + HXs_cold_side self.cold_indices = cold_indices self.original_heat_exchangers = hxs diff --git a/biosteam/facilities/hxn/hxn_synthesis.py b/biosteam/facilities/hxn/hxn_synthesis.py index afe0b071..66e3f4e0 100644 --- a/biosteam/facilities/hxn/hxn_synthesis.py +++ b/biosteam/facilities/hxn/hxn_synthesis.py @@ -124,10 +124,16 @@ def get_sorted_life_cycle(self): return self.life_cycle -def temperature_interval_pinch_analysis(hus, T_min_app = 10, force_ideal_thermo=False): +def temperature_interval_pinch_analysis(hus, + T_min_app = 10, + force_ideal_thermo=False, + sort_hus_by_T=False): hx_utils = hus hus_heating = [hu for hu in hx_utils if hu.duty > 0] hus_cooling = [hu for hu in hx_utils if hu.duty < 0] + if sort_hus_by_T: + hus_heating.sort(key=lambda i: i.unit.ins[0].T, reverse=True) + hus_cooling.sort(key=lambda i: i.unit.ins[0].T) hx_utils_rearranged = hus_heating + hus_cooling hxs = [hu.unit for hu in hx_utils_rearranged] if force_ideal_thermo: @@ -249,10 +255,11 @@ def get_T_transient(pinch_T_arr, indices, T_in_arr): return T_transient def synthesize_network(hus, T_min_app=5., Qmin=1e-3, force_ideal_thermo=False, - avoid_recycle=False): + avoid_recycle=False, sort_hus_by_T=False): pinch_T_arr, hot_util_load, cold_util_load, T_in_arr, T_out_arr,\ hxs, hot_indices, cold_indices, indices, streams_inlet, hx_utils_rearranged, \ - streams_quenched = temperature_interval_pinch_analysis(hus, T_min_app, force_ideal_thermo) + streams_quenched = temperature_interval_pinch_analysis(hus, T_min_app, force_ideal_thermo, + sort_hus_by_T) H_out_arr = [i.H for i in streams_quenched] duties = np.array([abs(hx.Q) for hx in hxs]) dTs = np.abs(T_in_arr - T_out_arr) From 05aa667808538ea0aa075f75ad6b775673021d90 Mon Sep 17 00:00:00 2001 From: sarangbhagwat Date: Thu, 31 Oct 2024 22:23:15 -0500 Subject: [PATCH 2/3] remove unnecessary space --- biosteam/facilities/hxn/hxn_synthesis.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/biosteam/facilities/hxn/hxn_synthesis.py b/biosteam/facilities/hxn/hxn_synthesis.py index 66e3f4e0..a164d5f4 100644 --- a/biosteam/facilities/hxn/hxn_synthesis.py +++ b/biosteam/facilities/hxn/hxn_synthesis.py @@ -125,7 +125,7 @@ def get_sorted_life_cycle(self): def temperature_interval_pinch_analysis(hus, - T_min_app = 10, + T_min_app=10, force_ideal_thermo=False, sort_hus_by_T=False): hx_utils = hus From 46d41d320ec92a2b7b0c778dbaa0dd0ae281df69 Mon Sep 17 00:00:00 2001 From: sarangbhagwat Date: Thu, 31 Oct 2024 22:27:34 -0500 Subject: [PATCH 3/3] extend copyright --- biosteam/facilities/hxn/_heat_exchanger_network.py | 2 +- biosteam/facilities/hxn/hxn_synthesis.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/biosteam/facilities/hxn/_heat_exchanger_network.py b/biosteam/facilities/hxn/_heat_exchanger_network.py index fdc036cb..e5b5fd84 100644 --- a/biosteam/facilities/hxn/_heat_exchanger_network.py +++ b/biosteam/facilities/hxn/_heat_exchanger_network.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # This module will be moved to a new reporsitory called "HXN: The automated Heat Exchanger Network design package." -# Copyright (C) 2020-2023, Sarang Bhagwat , Yoel Cortes-Pena +# Copyright (C) 2020-, Sarang Bhagwat , Yoel Cortes-Pena # # This module is under the UIUC open-source license. See # github.com/BioSTEAMDevelopmentGroup/biosteam/blob/master/LICENSE.txt diff --git a/biosteam/facilities/hxn/hxn_synthesis.py b/biosteam/facilities/hxn/hxn_synthesis.py index a164d5f4..3299472b 100644 --- a/biosteam/facilities/hxn/hxn_synthesis.py +++ b/biosteam/facilities/hxn/hxn_synthesis.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # HXN: The automated Heat Exchanger Network design package. -# Copyright (C) 2020-2023, Sarang Bhagwat +# Copyright (C) 2020-, Sarang Bhagwat # # This module is under the UIUC open-source license. See # github.com/sarangbhagwat/hxn/blob/master/LICENSE.txt