.. 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 27-32 .. code-block:: default from numpy import ones from gemseo.api import generate_n2_plot from gemseo.core.discipline import MDODiscipline .. GENERATED FROM PYTHON SOURCE LINES 33-35 Create the disciplines ---------------------- .. GENERATED FROM PYTHON SOURCE LINES 35-65 .. code-block:: default descriptions = { "A": (["a{}".format(i) for i in range(500)], ["b"]), "B": (["c"], ["a{}".format(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"], []), } 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.initialize_from_base_dict({name: data for name in inputs}) discipline.output_grammar.initialize_from_base_dict( {name: data for name in outputs} ) disciplines.append(discipline) .. GENERATED FROM PYTHON SOURCE LINES 66-70 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 70-72 .. code-block:: default generate_n2_plot(disciplines, save=False, open_browser=True) .. GENERATED FROM PYTHON SOURCE LINES 73-74 `Click here <../../_static/n2.html>`_ to see the rendering. .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 0.000 seconds) .. _sphx_glr_download_examples_coupling_n2_chart.py: .. only :: html .. container:: sphx-glr-footer :class: 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 `_