.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/coupling/n2_chart.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_examples_coupling_n2_chart.py: Multidisciplinary coupling graph ================================ .. GENERATED FROM PYTHON SOURCE LINES 25-31 .. code-block:: default from __future__ import annotations from gemseo.api import generate_n2_plot from gemseo.core.discipline import MDODiscipline from numpy import ones .. GENERATED FROM PYTHON SOURCE LINES 32-34 Create the disciplines ---------------------- .. GENERATED FROM PYTHON SOURCE LINES 34-62 .. code-block:: default 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}) disciplines.append(discipline) .. GENERATED FROM PYTHON SOURCE LINES 63-67 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. .. GENERATED FROM PYTHON SOURCE LINES 67-69 .. code-block:: default generate_n2_plot(disciplines, save=False, open_browser=True) .. GENERATED FROM PYTHON SOURCE LINES 70-71 `Click here <../../_static/n2.html>`_ to see the rendering. .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 0.181 seconds) .. _sphx_glr_download_examples_coupling_n2_chart.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: n2_chart.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: n2_chart.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_