.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/07_applications/plot_01_heat_exchanger_network.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code or to run this example in your browser via Binder. .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_07_applications_plot_01_heat_exchanger_network.py: 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. .. GENERATED FROM PYTHON SOURCE LINES 17-19 From the stream table to the network ------------------------------------ .. GENERATED FROM PYTHON SOURCE LINES 19-41 .. code-block:: Python 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") .. image-sg:: /auto_examples/07_applications/images/sphx_glr_plot_01_heat_exchanger_network_001.png :alt: SCC hierarchy of the HEN: one driver, three sensors :srcset: /auto_examples/07_applications/images/sphx_glr_plot_01_heat_exchanger_network_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none (22, 22) 56 edges; 10 exchanger cells unmatched nodes of a maximum matching: [] drivers: ['E9.h'] sensors: ['E1.h', 'C1', 'C2'] .. GENERATED FROM PYTHON SOURCE LINES 42-44 Sensor placement for a small relative order ------------------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 44-53 .. code-block:: Python 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() .. image-sg:: /auto_examples/07_applications/images/sphx_glr_plot_01_heat_exchanger_network_002.png :alt: minimal sensors: observation depth, GDFCMSA, bound 2: 7 sensors :srcset: /auto_examples/07_applications/images/sphx_glr_plot_01_heat_exchanger_network_002.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 54-59 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. .. GENERATED FROM PYTHON SOURCE LINES 59-67 .. code-block:: Python 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}") .. rst-class:: sphx-glr-script-out .. code-block:: none two cold streams drivers=1 sensors=3 max observation depth=6 five cold branches drivers=3 sensors=4 max observation depth=4 .. GENERATED FROM PYTHON SOURCE LINES 68-72 **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. .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.670 seconds) .. _sphx_glr_download_auto_examples_07_applications_plot_01_heat_exchanger_network.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: binder-badge .. image:: images/binder_badge_logo.svg :target: https://mybinder.org/v2/gh/ComplexSystemsIntelligence/nocad/main?urlpath=lab/tree/notebooks/auto_examples/07_applications/plot_01_heat_exchanger_network.ipynb :alt: Launch binder :width: 150 px .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_01_heat_exchanger_network.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_01_heat_exchanger_network.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_01_heat_exchanger_network.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_