.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/mda/plot_jacobi.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_mda_plot_jacobi.py: Jacobi MDA ================ A smart MDA that solves only strongly coupled disciplines and then executes the weakly coupled ones .. GENERATED FROM PYTHON SOURCE LINES 29-40 .. code-block:: default from __future__ import absolute_import, division, unicode_literals from os import name as os_name from gemseo.api import configure_logger, create_discipline, create_mda IS_NT = os_name == "nt" configure_logger() .. rst-class:: sphx-glr-script-out Out: .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 41-43 Define a way to display results ------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 43-76 .. code-block:: default def display_result(res, mda_name): """ Display coupling and output variables in logger @param res: result (dict) of MDA @param mda_name: name of the current MDA """ # names of the coupling variables coupling_names = [ "y_11", "y_12", "y_14", "y_21", "y_23", "y_24", "y_31", "y_32", "y_34", ] for coupling_var in coupling_names: print( "{}, coupling variable {}: {}".format( mda_name, coupling_var, res[coupling_var] ), ) # names of the output variables output_names = ["y_1", "y_2", "y_3", "y_4", "g_1", "g_2", "g_3"] for output_var in output_names: print( "{}, output variable {}: {}".format(mda_name, output_var, res[output_var]), ) .. GENERATED FROM PYTHON SOURCE LINES 77-82 Create, execute and post-process MDA ------------------------------------ We do not need to specify the inputs, the default inputs of the MDA will be used and computed from the Default inputs of the disciplines .. GENERATED FROM PYTHON SOURCE LINES 82-107 .. code-block:: default disciplines = create_discipline( [ "SobieskiStructure", "SobieskiPropulsion", "SobieskiAerodynamics", "SobieskiMission", ] ) use_threading = False if IS_NT: use_threading = True mda = create_mda( "MDAJacobi", disciplines, acceleration="m2d", warm_start=True, n_processes=4, use_threading=use_threading, ) res = mda.execute() display_result(res, mda.name) mda.plot_residual_history( n_iterations=10, logscale=[1e-8, 10.0], show=True, save=False, figsize=(10, 2) ) .. image:: /examples/mda/images/sphx_glr_plot_jacobi_001.png :alt: MDAJacobi: residual plot :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out Out: .. code-block:: none MDAJacobi, coupling variable y_11: [0.15591864] MDAJacobi, coupling variable y_12: [5.06070636e+04 9.50000000e-01] MDAJacobi, coupling variable y_14: [50607.06361137 7306.20262124] MDAJacobi, coupling variable y_21: [50607.06361137] MDAJacobi, coupling variable y_23: [12194.40917863] MDAJacobi, coupling variable y_24: [4.15002177] MDAJacobi, coupling variable y_31: [6354.40199354] MDAJacobi, coupling variable y_32: [0.50280211] MDAJacobi, coupling variable y_34: [1.10754577] MDAJacobi, output variable y_1: [5.06070636e+04 7.30620262e+03 9.50000000e-01] MDAJacobi, output variable y_2: [5.06070636e+04 1.21944092e+04 4.15002177e+00] MDAJacobi, output variable y_3: [1.10754577e+00 6.35440199e+03 5.02802105e-01] MDAJacobi, output variable y_4: [535.78213193] MDAJacobi, output variable g_1: [ 0.035 -0.00666667 -0.0275 -0.04 -0.04833333 -0.09 -0.15 ] MDAJacobi, output variable g_2: [-0.04] MDAJacobi, output variable g_3: [-0.99719789 -0.00280211 0.16206032 -0.02 ] .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 3.008 seconds) .. _sphx_glr_download_examples_mda_plot_jacobi.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: plot_jacobi.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_jacobi.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_