Note
Go to the end to download the full example code
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 = dict.fromkeys(inputs, data)
outputs = dict.fromkeys(outputs, data)
discipline = MDODiscipline(discipline_name)
discipline.input_grammar.update_from_data(dict.fromkeys(inputs, data))
discipline.output_grammar.update_from_data(dict.fromkeys(outputs, data))
disciplines.append(discipline)
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.