.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/api/plot_mda.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_examples_api_plot_mda.py: MDA === In this example, we will discover the different high-level functions related to MDAs, which are the |g|' objects dedicated to the feasibility of the multidisciplinary coupling. All classes implementing MDAs inherit from :class:`.BaseMDA` which is an abstract class. .. GENERATED FROM PYTHON SOURCE LINES 30-38 .. code-block:: Python from __future__ import annotations from gemseo import create_discipline from gemseo import create_mda from gemseo import get_available_mdas from gemseo import get_mda_options_schema .. GENERATED FROM PYTHON SOURCE LINES 39-44 Get available MDA ----------------- The :func:`.get_available_mdas` function returns the list of MDAs available in |g| or in external modules .. GENERATED FROM PYTHON SOURCE LINES 44-46 .. code-block:: Python get_available_mdas() .. rst-class:: sphx-glr-script-out .. code-block:: none ['MDAChain', 'MDAGSNewton', 'MDAGaussSeidel', 'MDAJacobi', 'MDANewtonRaphson', 'MDAQuasiNewton', 'MDASequential'] .. GENERATED FROM PYTHON SOURCE LINES 47-51 Get MDA options schema ---------------------- For a given MDA algorithm, e.g. ``"MDAGaussSeidel"``, we can get the options; e.g. .. GENERATED FROM PYTHON SOURCE LINES 51-53 .. code-block:: Python get_mda_options_schema("MDAGaussSeidel") .. rst-class:: sphx-glr-script-out .. code-block:: none {'$schema': 'http://json-schema.org/schema#', 'type': 'object', 'properties': {'coupling_structure': {'type': 'null', 'description': 'The coupling structure to be used by the MDA. If ``None``, the coupling structure is created from the disciplines.'}, 'linear_solver': {'type': 'string', 'description': 'The name of the linear solver. This field is ignored when ``linear_solver_settings`` is a Pydantic model.'}, 'linear_solver_settings': {'type': 'object', 'description': 'The settings of the linear solver.'}, 'linear_solver_tolerance': {'type': 'number', 'description': 'The linear solver tolerance.'}, 'log_convergence': {'type': 'boolean', 'description': 'Whether to log the MDA convergence. The log displays the normalized residual norm.'}, 'max_mda_iter': {'type': 'integer', 'description': 'The maximum number of iterations for the MDA algorithm. If 0, evaluate the coupling variables without trying to solve the coupling equations.'}, 'max_consecutive_unsuccessful_iterations': {'type': 'integer', 'description': 'The maximum number of consecutive unsuccessful iterations. Iterations are considered unsuccessful if the normalized residual norm increases.'}, 'name': {'type': 'string', 'description': 'The name to be given to the MDA. If empty, use the name of the class.'}, 'tolerance': {'type': 'number', 'description': 'The tolerance for the MDA algorithm residual. The available normalization strategies for the residual are described in :attr:`.BaseMDA.ResidualScaling`.'}, 'use_lu_fact': {'type': 'boolean', 'description': 'Whether to perform an LU factorization. The factorization is used to solve the linear systems arising in the computation of the total derivatives. Since there are possibly several right-hand side, if affordable, such a factorization may improve the solution time.'}, 'warm_start': {'type': 'boolean', 'description': 'Whether to warm start the execution of the MDA algorithm. The warm start strategy consists in using the last cached values for the coupling variables as an initial guess. This is expected to reduce the number of iteration of the MDA algorithm required to reach convergence.'}, 'acceleration_method': {'type': 'string', 'description': 'The acceleration method used within the fixed point iterations.'}, 'over_relaxation_factor': {'type': 'number', 'description': 'The over-relaxation factor.'}}} .. GENERATED FROM PYTHON SOURCE LINES 54-56 Or import its settings model and pass it directly with the keyword "mda_settings_model". .. GENERATED FROM PYTHON SOURCE LINES 56-60 .. code-block:: Python from gemseo.settings.mda import MDAGaussSeidel_Settings # noqa: E402 settings_model = MDAGaussSeidel_Settings() .. GENERATED FROM PYTHON SOURCE LINES 61-62 See :ref:`mda_settings` for more information on how to use settings models. .. GENERATED FROM PYTHON SOURCE LINES 64-68 Create an MDA ------------- The high-level function :func:`.create_mda` can be used to create an MDA: .. GENERATED FROM PYTHON SOURCE LINES 68-72 .. code-block:: Python disciplines = create_discipline(["Sellar1", "Sellar2"]) mda = create_mda("MDAGaussSeidel", disciplines) output_data = mda.execute() output_data .. rst-class:: sphx-glr-script-out .. code-block:: none {'x_1': array([0.]), 'x_shared': array([1., 0.]), 'y_2': array([1.80000001]), 'gamma': array([0.2]), 'x_2': array([0.]), 'y_1': array([0.80000001]), 'MDA residuals norm': array([4.79612702e-07])} .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.010 seconds) .. _sphx_glr_download_examples_api_plot_mda.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_mda.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_mda.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_mda.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_