MDA#

In this example, we will discover the different high-level functions related to MDAs, which are the GEMSEO' objects dedicated to the feasibility of the multidisciplinary coupling. All classes implementing MDAs inherit from BaseMDA which is an abstract class.

from __future__ import annotations

from gemseo import configure_logger
from gemseo import create_discipline
from gemseo import create_mda
from gemseo import get_available_mdas
from gemseo import get_mda_options_schema

configure_logger()
<RootLogger root (INFO)>

Get available MDA#

The get_available_mdas() function returns the list of MDAs available in GEMSEO or in external modules

get_available_mdas()
['MDAChain', 'MDAGSNewton', 'MDAGaussSeidel', 'MDAJacobi', 'MDANewtonRaphson', 'MDAQuasiNewton', 'MDASequential']

Get MDA options schema#

For a given MDA algorithm, e.g. "MDAGaussSeidel", we can get the options; e.g.

get_mda_options_schema("MDAGaussSeidel")
{'$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.'}, 'linear_solver_settings': {'type': 'object', 'description': 'The settings passed to the linear solver factory.'}, 'linear_solver_tolerance': {'type': 'number', 'description': 'The linear solver tolerance.  Linear solvers are used to compute the total derivatives.'}, '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.'}}}

Or import its settings model and pass it directly with the keyword "mda_settings_model".

from gemseo.settings.mda import MDAGaussSeidel_Settings  # noqa: E402

settings_model = MDAGaussSeidel_Settings()

See MDA Settings for more information on how to use settings models.

Create an MDA#

The high-level function create_mda() can be used to create a scenario:

disciplines = create_discipline(["Sellar1", "Sellar2"])
mda = create_mda("MDAGaussSeidel", disciplines)
output_data = mda.execute()
output_data
{'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])}

Total running time of the script: (0 minutes 0.012 seconds)

Gallery generated by Sphinx-Gallery