Generate a Sankey diagram from a Cantera Reactor Net simulation.

This script uses the generate_sankey_input_from_sim() function to generate a Sankey diagram from a Cantera Reactor Net simulation.

The plot_sankey_diagram() can also be used directly.

import plotly.graph_objects as go

from bloc.sankey import generate_sankey_input_from_sim
from bloc.test import default_simulation, defaults

# Generate a Reactor Net simulation
# ---------------------------------

config = defaults()
sim = default_simulation(**config)

sim.advance_to_steady_state()

# Generate Sankey data:
# ---------------------
links, nodes = generate_sankey_input_from_sim(sim, show_species=["H2", "CH4"])

# Plot :
# ------

fig = go.Figure(
    data=go.Sankey(
        # arrangement='snap',
        node={
            "label": nodes,
            "pad": 11,
            #'line': dict(color = "black", width = 0.5),
            "thickness": 20,
            "color": "grey",
        },
        link=links,
    )
)
fig.show()