Note
Go to the end to download the full example code or to run this example in your browser via Binder.
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.
Driver and sensor counts#
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()

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
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.
Total running time of the script: (0 minutes 0.421 seconds)