MDA

In this example, we will discover the different functions of the API 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 division, unicode_literals

from gemseo.api import (
    configure_logger,
    create_discipline,
    create_mda,
    get_available_mdas,
    get_mda_options_schema,
)

configure_logger()

Out:

<RootLogger root (INFO)>

Get available MDA

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

print(get_available_mdas())

Out:

['GSNewtonMDA', 'MDAChain', 'MDAGaussSeidel', 'MDAJacobi', 'MDANewtonRaphson', 'MDAQuasiNewton', 'MDARoot', 'MDASequential']

Get MDA options schema

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

print(get_mda_options_schema("MDAGaussSeidel"))

Out:

{'$schema': 'http://json-schema.org/schema#', 'type': 'object', 'properties': {'name': {'description': 'the name of the chain :type name: str', 'type': 'null'}, 'max_mda_iter': {'description': 'maximum number of iterations :type max_mda_iter: int', 'type': 'integer'}, 'grammar_type': {'description': 'the type of grammar to use for IO declaration either JSON_GRAMMAR_TYPE or SIMPLE_GRAMMAR_TYPE :type grammar_type: str', 'type': 'string'}, 'tolerance': {'description': 'tolerance of the iterative direct coupling solver, norm of the current residuals divided by initial residuals norm shall be lower than the tolerance to stop iterating :type tolerance: float', 'type': 'number'}, 'linear_solver_tolerance': {'description': 'Tolerance of the linear solver in the adjoint equation :type linear_solver_tolerance: float', 'type': 'number'}, 'warm_start': {'description': 'if True, the second iteration and ongoing start from the previous coupling solution :type warm_start: bool', 'type': 'boolean'}, 'use_lu_fact': {'description': 'if True, when using adjoint/forward differenciation, store a LU factorization of the matrix to solve faster multiple RHS problem :type use_lu_fact: bool', 'type': 'boolean'}, 'over_relax_factor': {'description': '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 over_relax_factor: float', 'type': 'number'}}, 'required': ['grammar_type', 'linear_solver_tolerance', 'max_mda_iter', 'over_relax_factor', 'tolerance', 'use_lu_fact', 'warm_start']}

Create an MDA

The API function create_mda() can be used to create a scenario:

disciplines = create_discipline(["Sellar1", "Sellar2"])
mda = create_mda("MDAGaussSeidel", disciplines)
output_data = mda.execute()
print(output_data)

Out:

{'x_local': array([0.+0.j]), 'x_shared': array([1.+0.j, 0.+0.j]), 'y_2': array([1.79999995+0.j]), 'y_1': array([0.79999995+0.j])}

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

Gallery generated by Sphinx-Gallery