.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/07_applications/plot_03_dynamical_benchmarks.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_03_dynamical_benchmarks.py: State matrices of real dynamical systems ======================================== Set III of the NOCAD study contains the zero patterns of the state matrices of engineering models from the benchmark collection of Chahlaoui and Van Dooren (beams, buildings, CD player, heat equation, circuits). Their diagonals are full and most of their edges symmetric, so applying the connection types changes nothing: the network of a real dynamical system already contains its self-influence and interactions. One input and one output per connected component usually suffice. .. GENERATED FROM PYTHON SOURCE LINES 14-16 Driver and sensor counts ------------------------ .. GENERATED FROM PYTHON SOURCE LINES 16-55 .. code-block:: Python import matplotlib.pyplot as plt import numpy as np import pandas as pd import nocad from nocad.datasets import list_networks, load_network from nocad.measures import percent_loop_sym rows = [] # [snippet:setiii] for name in list_networks("III"): net = load_network(name) if net.n_states > 1100: continue loops, sym = percent_loop_sym(net.adj) comps = nocad.condensation(net.adj) rows.append({"network": name, "N": net.n_states, "edges": net.n_edges, "loops %": round(loops), "symmetric %": round(sym), "SCCs": comps.n_components, "drivers": nocad.n_driver_nodes(net.adj, "minimum"), "drivers (g)": nocad.n_driver_nodes(nocad.apply_connection_type(net.adj, "g"), "minimum"), "sensors": nocad.sensor_nodes(net.adj, "minimum").size}) table = pd.DataFrame(rows) # [/snippet:setiii] pd.set_option("display.width", 140) print(table.to_string(index=False)) fig, ax = plt.subplots(figsize=(6.4, 3.4)) x = np.arange(len(table)) ax.bar(x - 0.2, table["drivers"] / table["N"], width=0.4, color=nocad.plotting.PALETTE[0], label="original") ax.bar(x + 0.2, table["drivers (g)"] / table["N"], width=0.4, color=nocad.plotting.PALETTE[2], label="with connection type g") ax.set_yscale("log") ax.set_xticks(x) ax.set_xticklabels(table.network, rotation=60, fontsize=7) ax.set_ylabel("share of driver nodes") ax.set_title("Set III: driver nodes do not change with the connection types", fontsize=10) ax.legend(frameon=False, fontsize=8) fig.tight_layout() .. image-sg:: /auto_examples/07_applications/images/sphx_glr_plot_03_dynamical_benchmarks_001.png :alt: Set III: driver nodes do not change with the connection types :srcset: /auto_examples/07_applications/images/sphx_glr_plot_03_dynamical_benchmarks_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none network N edges loops % symmetric % SCCs drivers drivers (g) sensors beam 348 60726 50 50 1 1 1 1 build 48 1176 50 52 1 1 1 1 cdplayer 120 240 100 100 60 60 60 60 eady 598 357406 100 100 1 1 1 1 fom 1006 1012 100 100 1003 1003 1003 1003 heatcont 200 598 100 100 1 1 1 1 heatdisc 200 598 100 100 1 1 1 1 iss 270 405 50 100 135 135 135 135 mna_1 578 1694 60 100 3 3 3 3 mna_4 980 2872 61 100 2 2 2 2 orrsom 100 10000 100 100 1 1 1 1 pde 84 382 100 100 1 1 1 1 peec 480 1346 63 100 1 1 1 1 random 200 2132 100 4 1 1 1 1 tline 256 256 100 0 256 256 256 256 .. GENERATED FROM PYTHON SOURCE LINES 56-59 **Take-away.** Where a network really is the state matrix of a physical system, its structure already encodes the balance equations, and the network-based design needs very few inputs and outputs. .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.421 seconds) .. _sphx_glr_download_auto_examples_07_applications_plot_03_dynamical_benchmarks.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_03_dynamical_benchmarks.ipynb :alt: Launch binder :width: 150 px .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_03_dynamical_benchmarks.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_03_dynamical_benchmarks.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_03_dynamical_benchmarks.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_