gemseo / core

coupling_structure module

Graph-based analysis of the weak and strong couplings between several disciplines.

Classes:

MDOCouplingStructure(disciplines)

Structure of the couplings between several disciplines.

class gemseo.core.coupling_structure.MDOCouplingStructure(disciplines)[source]

Bases: object

Structure of the couplings between several disciplines.

The methods of this class include the computation of weak, strong or all couplings.

disciplines

The disciplines.

Type

Sequence[MDODiscipline]

graph

The directed graph of the disciplines.

Type

DependencyGraph

sequence

The sequence of execution of the disciplines.

Type

List[List[Tuple[MDODiscipline]]]

Parameters

disciplines (Sequence[MDODiscipline]) – The disciplines that possibly exchange coupling variables.

Return type

None

Methods:

find_discipline(output)

Find which discipline produces a given output.

get_all_couplings()

Compute all the weak and strong coupling variables.

input_couplings(discipline)

Compute all the input coupling variables of a discipline.

is_self_coupled(discipline)

Test if the discipline is self-coupled.

output_couplings(discipline[, strong])

Compute the output coupling variables of a discipline, either strong or weak.

plot_n2_chart([file_path, show_data_names, ...])

Generate a N2 plot for the disciplines.

strong_couplings()

Determine the strong couplings.

strongly_coupled_disciplines([...])

Determines the strongly coupled disciplines, that is the disciplines that occur in (possibly different) MDAs.

weak_couplings()

Determine the weak couplings.

weakly_coupled_disciplines()

Determine the weakly coupled disciplines.

find_discipline(output)[source]

Find which discipline produces a given output.

Parameters

output (str) – The name of an output.

Returns

The discipline producing this output, if it exists.

Raises
  • TypeError – If the name of the output is not a string.

  • ValueError – If the output is not an output of the discipline.

Return type

gemseo.core.discipline.MDODiscipline

get_all_couplings()[source]

Compute all the weak and strong coupling variables.

Returns

The names of the coupling variables.

Return type

List[str]

input_couplings(discipline)[source]

Compute all the input coupling variables of a discipline.

Parameters

discipline (gemseo.core.discipline.MDODiscipline) – The discipline.

Returns

The names of the input coupling variables.

Return type

List[str]

static is_self_coupled(discipline)[source]

Test if the discipline is self-coupled.

Self-coupling means that one of its outputs is also an input.

Parameters

discipline (gemseo.core.discipline.MDODiscipline) – The discipline.

Returns

Whether the discipline is self-coupled.

Return type

bool

output_couplings(discipline, strong=True)[source]

Compute the output coupling variables of a discipline, either strong or weak.

Parameters
  • discipline (gemseo.core.discipline.MDODiscipline) – The discipline.

  • strong (bool) –

    If True, consider the strong couplings. Otherwise, the weak ones.

    By default it is set to True.

Returns

The names of the output coupling variables.

Return type

List[str]

plot_n2_chart(file_path='n2.pdf', show_data_names=True, save=True, show=False, figsize=(15, 10), open_browser=False)[source]

Generate a N2 plot for the disciplines.

Parameters
  • file_path (str) –

    The name of the file path of the figure.

    By default it is set to n2.pdf.

  • show_data_names (bool) –

    If True, show the names of the coupling data ; otherwise, circles are drawn, which size depend on the number of coupling names.

    By default it is set to True.

  • save (bool) –

    If True, save the figure to file_path.

    By default it is set to True.

  • show (bool) –

    If True, show the plot.

    By default it is set to False.

  • figsize (Tuple[int]) –

    The width and height of the figure.

    By default it is set to (15, 10).

  • open_browser (bool) –

    If True, open a browser and display an interactive N2 chart.

    By default it is set to False.

Raises

ValueError – If there is only 1 discipline.

Return type

None

strong_couplings()[source]

Determine the strong couplings.

These are the outputs of the strongly coupled disciplines that are also inputs of the strongly coupled disciplines.

Returns

The names of the strongly coupling variables.

Return type

List[str]

strongly_coupled_disciplines(add_self_coupled=True, by_group=False)[source]

Determines the strongly coupled disciplines, that is the disciplines that occur in (possibly different) MDAs.

Parameters
  • add_self_coupled (bool) –

    if True, adds the disciplines that are self-coupled to the list of strongly coupled disciplines

    By default it is set to True.

  • by_group (bool) –

    if True, returns a list of list of strongly coupled diciplines where the sublists contains the groups of disciplines that are strongly coupled together. if False, returns a single list

    By default it is set to False.

Returns

The coupled disciplines list or list of list

Return type

Union[List[gemseo.core.discipline.MDODiscipline], List[List[gemseo.core.discipline.MDODiscipline]]]

weak_couplings()[source]

Determine the weak couplings.

These are the outputs of the weakly coupled disciplines.

Returns

The names of the weakly coupling variables.

Return type

List[str]

weakly_coupled_disciplines()[source]

Determine the weakly coupled disciplines.

These are the disciplines that do not occur in MDAs.

Returns

The weakly coupled disciplines.

Return type

List[gemseo.core.discipline.MDODiscipline]