coupling_structure module¶
Graph-based analysis of the weak and strong couplings between several disciplines.
Classes:
|
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.
- Attributes
disciplines (Sequence[MDODiscipline]) – The disciplines.
graph (DependencyGraph) – The directed graph of the disciplines.
sequence (List[List[Tuple[MDODiscipline]]]) – The sequence of execution of the disciplines.
- 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.
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.
Determine the strong couplings.
Determines the strongly coupled disciplines, that is the disciplines that occur in (possibly different) MDAs.
Determine the weak couplings.
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
- 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.
- 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.
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.save (bool) – If True, save the figure to file_path.
show (bool) – If True, show the plot.
figsize (Tuple[int]) – The width and height of the figure.
open_browser (bool) – If True, open a browser and display an interactive N2 chart.
- 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_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
- 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]