Multidisciplinary coupling graph

from __future__ import annotations

from numpy import ones

from gemseo import generate_n2_plot
from gemseo.core.discipline import MDODiscipline

Create the disciplines

descriptions = {
    "A": ([f"a{i}" for i in range(500)], ["b"]),
    "B": (["c"], [f"a{i}" for i in range(500)] + ["n"]),
    "C": (["b", "d"], ["c", "e"]),
    "D": (["f"], ["d", "g"]),
    "E": (["e"], ["f", "h", "o"]),
    "F": (["g", "j"], ["i"]),
    "G": (["i", "h"], ["k", "l"]),
    "H": (["k", "m"], ["j"]),
    "I": (["l"], ["m", "w"]),
    "J": (["n", "o"], ["p", "q"]),
    "K": (["y"], ["x"]),
    "L": (["w", "x"], ["y", "z"]),
    "M": (["p", "s"], ["r"]),
    "N": (["r"], ["t", "u"]),
    "O": (["q", "t"], ["s", "v"]),
    "P": (["u", "v", "z"], ["z"]),
disciplines = []
data = ones(1)
for discipline_name, (inputs, outputs) in descriptions.items():
    inputs = {name: data for name in inputs}
    outputs = {name: data for name in outputs}
    discipline = MDODiscipline(discipline_name)
    discipline.input_grammar.update_from_data({name: data for name in inputs})
    discipline.output_grammar.update_from_data({name: data for name in outputs})

Generate the N2 chart

We do not want to save the N2 chart as a PNG or a PDF file, but open a browser, display it and handle it.

generate_n2_plot(disciplines, save=False, show_html=True)

Click here to see the rendering.

Gallery generated by Sphinx-Gallery