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': {'name': {'description': 'The name to be given to the MDA. If empty, use the name of the class.', 'type': 'string'}, 'max_mda_iter': {'description': 'The maximum iterations number for the MDA algorithm. If 0, evaluate the coupling the coupling process without trying to solve the coupling equations.', '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'}, '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': 'object'}, '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_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.019 seconds)

Gallery generated by Sphinx-Gallery