Skip to content

Commit

Permalink
Merge pull request #210 from BioSTEAMDevelopmentGroup/minor_hxn_update
Browse files Browse the repository at this point in the history
Allow sorting candidate heat utils by temperature in HeatExchangerNetwork
  • Loading branch information
yoelcortes authored Dec 9, 2024
2 parents e2bf79d + 46d41d3 commit 5c1a650
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
9 changes: 6 additions & 3 deletions biosteam/facilities/hxn/_heat_exchanger_network.py
Original file line number Diff line number Diff line change
@@ -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 <sarangb2@illinois.edu>, Yoel Cortes-Pena <yoelcortes@gmail.com>
# Copyright (C) 2020-, Sarang Bhagwat <sarangb2@illinois.edu>, Yoel Cortes-Pena <yoelcortes@gmail.com>
#
# This module is under the UIUC open-source license. See
# github.com/BioSTEAMDevelopmentGroup/biosteam/blob/master/LICENSE.txt
Expand Down Expand Up @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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
Expand Down
15 changes: 11 additions & 4 deletions biosteam/facilities/hxn/hxn_synthesis.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# HXN: The automated Heat Exchanger Network design package.
# Copyright (C) 2020-2023, Sarang Bhagwat <sarangb2@illinois.edu>
# Copyright (C) 2020-, Sarang Bhagwat <sarangb2@illinois.edu>
#
# This module is under the UIUC open-source license. See
# github.com/sarangbhagwat/hxn/blob/master/LICENSE.txt
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 5c1a650

Please sign in to comment.