Note
Go to the end to download the full example code or to run this example in your browser via Binder.
Heat exchanger networks#
Leitold, Vathy-Fogarassy and Abonyi analysed the controllability and observability of heat exchanger networks (HENs) on the network of their state variables. Every exchanger cell is a lumped unit with two states, the outlet temperatures of its hot and its cold side; both depend on themselves (self-loops) and on each other (heat transfer), and the outlet temperature of a unit is the inlet temperature of the next unit on the same stream. Every unit is therefore a strongly connected component, maximum matching finds no unmatched node at all, and path finding is needed. The network below has the composition of the Sensors 2018 case study: 6 hot and 2 cold streams, 10 exchanger cells and 2 coolers, 22 states and 56 edges.
From the stream table to the network#
import matplotlib.pyplot as plt
import nocad
from nocad.datasets import make_heat_exchanger_network
from nocad.placement import Placement
from nocad.plotting import default_layout
from nocad.viz import plot_depth_map, plot_scc_hierarchy
# [snippet:hen]
hot = [["E1", "E2"], ["E3", "C1"], ["E4", "E5"], ["E6", "E7", "C2"], ["E8"], ["E9", "E10"]]
cold = [["E10", "E8", "E5", "E2", "E1"], ["E9", "E7", "E6", "E4", "E3"]]
hen = make_heat_exchanger_network(hot, cold, coolers=["C1", "C2"])
print(hen.adj.shape, hen.adj.nnz, "edges;", hen.n_exchangers, "exchanger cells")
print("unmatched nodes of a maximum matching:", nocad.maximum_matching(hen.adj).unmatched)
design = nocad.InputOutputDesign("path_finding").fit(hen.adj)
print("drivers:", [hen.labels[v] for v in design.driver_nodes_], " sensors:",
[hen.labels[v] for v in design.sensor_nodes_])
# [/snippet:hen]
fig, ax = plt.subplots(figsize=(7.0, 6.0))
plot_scc_hierarchy(hen.adj, design.driver_nodes_, design.sensor_nodes_, ax=ax, labels=hen.labels, node_size=300,
title="SCC hierarchy of the HEN: one driver, three sensors")

(22, 22) 56 edges; 10 exchanger cells
unmatched nodes of a maximum matching: []
drivers: ['E9.h'] sensors: ['E1.h', 'C1', 'C2']
<Axes: title={'center': 'SCC hierarchy of the HEN: one driver, three sensors'}>
Sensor placement for a small relative order#
pos = default_layout(hen.adj)
fig, axes = plt.subplots(1, 2, figsize=(10.4, 4.0))
plot_depth_map(hen.adj, design.sensor_nodes_, "observation", pos=pos, ax=axes[0], labels=hen.labels,
node_size=230, title="minimal sensors: observation depth")
p = Placement(kind="sensors", method="gdfcmsa", r_max=2, n_iter=400, n_runs=5, random_state=0).fit(hen.adj)
plot_depth_map(hen.adj, p.nodes_, "observation", pos=pos, ax=axes[1], labels=hen.labels, node_size=230,
title=f"GDFCMSA, bound 2: {len(p.nodes_)} sensors")
fig.tight_layout()

Parameter study: how the stream structure changes the design#
The same exchangers in series on two cold streams (above) or with the cold streams split into five short branches: more, shorter streams mean more sink components and more sensors, but a smaller observation depth.
for name, cold_streams in (("two cold streams", cold),
("five cold branches", [["E10", "E8"], ["E5", "E2"], ["E1"], ["E9", "E7"],
["E6", "E4", "E3"]])):
h = make_heat_exchanger_network(hot, cold_streams, coolers=["C1", "C2"])
d = nocad.InputOutputDesign().fit(h.adj)
depth = nocad.observation_depth(h.adj, d.sensor_nodes_)
print(f"{name:18s} drivers={d.n_drivers_} sensors={d.n_sensors_} max observation depth={depth.max():.0f}")
two cold streams drivers=1 sensors=3 max observation depth=6
five cold branches drivers=3 sensors=4 max observation depth=4
Take-away. The state-variable network of a HEN consists of strongly connected units, so its inputs and outputs come from the source and sink components, not from unmatched nodes; a few additional sensors placed by GDFCMSA cut the observation depth by more than half.
Total running time of the script: (0 minutes 0.670 seconds)