gemseo / mda

# mda module¶

## Base class for all Multi-disciplinary Design Analysis¶

class gemseo.mda.mda.MDA(disciplines, max_mda_iter=10, name=None, grammar_type='JSON', tolerance=1e-06, linear_solver_tolerance=1e-12, warm_start=False, use_lu_fact=False, norm0=None)[source]

Perform an MDA analysis.

Base class.

Constructor.

Parameters
• disciplines – the disciplines list

• max_mda_iter – maximum iterations number for MDA

• tolerance – 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

• name – the name of the chain

• grammar_type – the type of grammar to use for IO declaration either JSON_GRAMMAR_TYPE or SIMPLE_GRAMMAR_TYPE

• warm_start – if True, the second iteration and ongoing start from the previous coupling solution

• linear_solver_tolerance – Tolerance of the linear solver in the adjoint equation

• use_lu_fact – if True, when using adjoint/forward differenciation, store a LU factorization of the matrix to solve faster multiple RHS problem

• norm0 (float) – reference value of the norm of the residual to compute the decrease stop criteria. Iterations stops when norm(residual)/norm0<tolerance

FINITE_DIFFERENCES = 'finite_differences'
N_CPUS = 2
check_jacobian(input_data=None, derr_approx='finite_differences', step=1e-07, threshold=1e-08, linearization_mode='auto', inputs=None, outputs=None, parallel=False, n_processes=2, use_threading=False, wait_time_between_fork=0)[source]

Check if the jacobian is correct.

This method checks the jacobian computed by the linearize() method.

Parameters
• input_data – input data dict (Default value = None)

• derr_approx – derivative approximation method: COMPLEX_STEP (Default value = COMPLEX_STEP)

• threshold – acceptance threshold for the jacobian error (Default value = 1e-8)

• linearization_mode – the mode of linearization: direct, adjoint or automated switch depending on dimensions of inputs and outputs (Default value = ‘auto’)

• inputs – list of inputs wrt which to differentiate (Default value = None)

• outputs – list of outputs to differentiate (Default value = None)

• step – the step for finite differences or complex step

• parallel – if True, executes in parallel

• n_processes – maximum number of processors on which to run

• use_threading – if True, use Threads instead of processes to parallelize the execution multiprocessing will copy (serialize) all the disciplines, while threading will share all the memory This is important to note if you want to execute the same discipline multiple times, you shall use multiprocessing

• wait_time_between_fork – time waited between two forks of the process /Thread

Returns

True if the check is accepted, False otherwise

get_expected_dataflow()[source]

Return the expected data exchange sequence.

This method is used for xdsm representation See MDOFormulation.get_expected_dataflow

get_expected_workflow()[source]

Return the expected execution sequence.

This method is used for xdsm representation See MDOFormulation.get_expected_workflow

plot_residual_history(show=False, save=True, n_iterations=None, logscale=None, filename=None, figsize=(50, 10))[source]

Generate a plot of the residual history.

All residuals are stored in the history ; only the final residual of the converged MDA is plotted at each optimization iteration

Parameters
• show – if True, displays the plot on screen (Default value = False)

• save – if True, saves the plot as a PDF file (Default value = True)

• n_iterations – if not None, fix the number of iterations in the x axis (Default value = None)

• logscale – if not None, fix the logscale in the y axis (Default value = None)

• filename – Default value = None)

reset_disciplines_statuses()[source]

Reset all the statuses of sub disciplines for run.

reset_statuses_for_run()[source]

Reset the statuses.