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 MDA 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': {'name': {'description': 'The name to be given to the MDA. If ``None``, use the name of the class.', 'type': 'null'}, 'max_mda_iter': {'description': 'The maximum iterations number for the MDA algorithm.', 'type': 'integer'}, 'grammar_type': {'description': 'The type of the input and output grammars.', 'type': 'string'}, 'tolerance': {'description': 'The tolerance of the iterative direct coupling solver; the norm of the current residuals divided by initial residuals norm shall be lower than the tolerance to stop iterating.', 'type': 'number'}, 'linear_solver_tolerance': {'description': 'The tolerance of the linear solver in the adjoint equation.', 'type': 'number'}, 'warm_start': {'description': 'Whether the second iteration and ongoing start from the previous coupling solution.', 'type': 'boolean'}, 'use_lu_fact': {'description': 'Whether to store a LU factorization of the matrix when using adjoint/forward differentiation. to solve faster multiple RHS problem.', 'type': 'boolean'}, 'over_relax_factor': {'description': 'Deprecated, please consider using :attr:`MDA.over_relaxation_factor` instead. The relaxation coefficient, used to make the method more robust, if ``0<over_relax_factor<1`` or faster if ``1<over_relax_factor<=2``. If ``over_relax_factor =1.``, it is deactivated.', 'type': 'null'}, 'coupling_structure': {'description': 'The coupling structure to be used by the MDA. If ``None``, it is created from `disciplines`.', 'type': 'null'}, 'log_convergence': {'description': 'Whether to log the MDA convergence, expressed in terms of normed residuals.', 'type': 'boolean'}, 'linear_solver': {'description': 'The name of the linear solver.', 'type': 'string'}, 'linear_solver_options': {'description': 'The options passed to the linear solver factory.', 'type': 'null'}, 'acceleration_method': {'description': 'The acceleration method to be used to improve the convergence rate of the fixed point iteration method.', 'type': 'string'}, 'over_relaxation_factor': {'description': 'The over-relaxation factor.', 'type': 'number'}}}

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_local': 0j, 'x_shared': array([1.+0.j, 0.+0.j]), 'y_2': (1.80000000566577+0j), 'y_1': (0.80000000566577+0j), 'MDA residuals norm': array([4.79612702e-07])}

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

Gallery generated by Sphinx-Gallery