diff --git a/examples/scripts/ssbj_mdo.py b/examples/scripts/ssbj_mdo.py index dd5e0bcc6c5dd3dba8491e7f596ffbcad38ad635..bdd7cc1d95287ca4991ed2db4c3feefc643d20a8 100644 --- a/examples/scripts/ssbj_mdo.py +++ b/examples/scripts/ssbj_mdo.py @@ -131,7 +131,6 @@ fpg.graph['description'] = 'Fundamental problem graph to solve the super-sonic b # Define settings of the problem formulation fpg.add_problem_formulation(mdao_definition_fpg, function_order) -fpg.graph['problem_formulation']['coupled_functions_groups'] = [['Structures'], ['Aerodynamics'], ['Propulsion']] # Assign design variables des_vars = [('/data_schema/aircraft/geometry/tc', 0.01, 0.05, 0.09), @@ -190,6 +189,8 @@ for mdao_definition in mdao_definitions: logging.info('Scripting {}...'.format(mdao_definition)) # Change the problem formulation of the FPG based on the MDAO definition + if mdao_definition in ['CO', 'BLISS-2000']: + fpg.graph['problem_formulation']['coupled_functions_groups'] = [['Structures'], ['Aerodynamics'], ['Propulsion']] fpg.add_problem_formulation(mdao_definition, function_order, doe_settings=None if mdao_definition is not 'BLISS-2000' else {'doe_method': 'Latin hypercube design', 'doe_seed': 5, 'doe_runs': 50}) diff --git a/kadmos/graph/graph_data.py b/kadmos/graph/graph_data.py index d4f10ff73cf2103fb977e9e2862ff6b68ab994bb..afe796ecfa684b9e5499c90d4befde75b22cf96f 100644 --- a/kadmos/graph/graph_data.py +++ b/kadmos/graph/graph_data.py @@ -6067,6 +6067,8 @@ class MdaoDataGraph(DataGraph, MdaoMixin): self.nodes[self.CONSCONS_STRING]['consistency_nodes'].append(consistency_node) else: self.nodes[self.CONSCONS_STRING]['consistency_nodes'] = [consistency_node] + # Change the role of the coupled function to post-coupled + self.nodes[coupling[1]]['architecture_role'] = self.ARCHITECTURE_ROLES_FUNS[8] # Remove coupling edge between coupling variable -> function self.remove_edge(coupling[2], coupling[1]) # If required, create final coupling variable node and let it come from the coupled function @@ -6082,6 +6084,15 @@ class MdaoDataGraph(DataGraph, MdaoMixin): if self.node_is_output(coupling[2]) and not keep_original_coupling_node: self.remove_node(coupling[2]) + # If there is no converger node or if the converger is an optimizer (IDF), then change the coupled functions + # to post-coupling functions + coupled_functions = copy.deepcopy(self.graph['mg_function_ordering'][self.FUNCTION_ROLES[1]]) + if converger is None or self.nodes[converger]['architecture_role'] == self.ARCHITECTURE_ROLES_FUNS[1]: + for coupled_function in coupled_functions: + self.nodes[coupled_function]['architecture_role'] = self.ARCHITECTURE_ROLES_FUNS[8] + self.graph['mg_function_ordering'][self.FUNCTION_ROLES[1]] = [] + self.graph['mg_function_ordering'][self.FUNCTION_ROLES[2]] = coupled_functions + self.graph['mg_function_ordering'][self.FUNCTION_ROLES[2]] + return def create_mpg(self, name='MPG'):