From d7c1010ec7e756394fbaa4aab947f207d6f19ba6 Mon Sep 17 00:00:00 2001 From: imcovangent <I.vanGent@tudelft.nl> Date: Mon, 30 Jul 2018 16:36:03 +0200 Subject: [PATCH] Added adjustment to change the architecture role of coupled functions when they become post-coupling functions due to architecture imposition. Former-commit-id: 342d5bf1c1d1c85ff5a7aeeed69f556e48f4575d --- examples/scripts/ssbj_mdo.py | 3 ++- kadmos/graph/graph_data.py | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/examples/scripts/ssbj_mdo.py b/examples/scripts/ssbj_mdo.py index dd5e0bcc6..bdd7cc1d9 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 d4f10ff73..afe796ecf 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'): -- GitLab