From 68c678ce555813871a04ae6a9cc15e965c3fad87 Mon Sep 17 00:00:00 2001 From: Anne-Liza <a.m.r.m.bruggeman@student.tudelft.nl> Date: Wed, 4 Jul 2018 15:43:27 +0200 Subject: [PATCH] Fixed issue with equation labels of consistency constraint functions Former-commit-id: 2cab10991f8cd2a11fa555034ce6c2a46ccf620b --- kadmos/graph/graph_data.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/kadmos/graph/graph_data.py b/kadmos/graph/graph_data.py index b67e0227b..b58bb1914 100644 --- a/kadmos/graph/graph_data.py +++ b/kadmos/graph/graph_data.py @@ -4374,7 +4374,7 @@ class FundamentalProblemGraph(DataGraph, KeChainMixin): sub_func_orderings[partition]['coupled'] mdg.connect_converger(converger, conv_type_partition, nodes, True, label=converger_label, converger_is_optimizer=converger_is_optimizer) - # Connect remaining couplings to optimer as system converger + # Connect remaining couplings to optimizer as system converger mdg.connect_converger(sys_opt, graph.OPTIONS_ARCHITECTURES[2], coup_functions, True, system_converger=True, label=sys_opt_label, converger_is_optimizer=True) # Connect optimizer @@ -5993,7 +5993,6 @@ class MdaoDataGraph(DataGraph, MdaoMixin): couplings = self.get_direct_coupling_nodes(func_order, direction=direction, print_couplings=False) # Manipulate the coupling nodes accordingly - idx = 0 for coupling in couplings: if system_converger: assert 'coupled_functions_groups' in self.graph['problem_formulation'], 'Graph is not partitioned' @@ -6034,7 +6033,6 @@ class MdaoDataGraph(DataGraph, MdaoMixin): self.add_edge(coupling[2], converger) # If the converger node is an optimizer (IDF), then connect it accordingly elif self.nodes[converger]['architecture_role'] == self.ARCHITECTURE_ROLES_FUNS[1]: - idx += 1 # Connect initial guess as input to the optimizer self.add_edge(ini_guess_node, converger) # Create coupling copy variable (coming from converger/optimizer) and connect it accordingly @@ -6042,16 +6040,18 @@ class MdaoDataGraph(DataGraph, MdaoMixin): if not self.has_edge(converger, coupling_copy_node): self.add_edge(converger, coupling_copy_node) self.copy_edge((coupling[2], coupling[1]), (coupling_copy_node, coupling[1])) + # Create equation label + equation_label = coupling[2].split('/')[-1] # Connect original and copied coupling node to the consistency constraint function - self.add_edge(coupling[2], self.CONSCONS_STRING, equation_label='y{}'.format(idx)) - self.add_edge(coupling_copy_node, self.CONSCONS_STRING, equation_label='y{}c'.format(idx)) + self.add_edge(coupling[2], self.CONSCONS_STRING, equation_label=equation_label) + self.add_edge(coupling_copy_node, self.CONSCONS_STRING, equation_label=equation_label+'c') # Make original coupling node a design variable self.mark_as_design_variable(coupling[2]) # Create consistency constraint variables for each coupling and make them output of the function consistency_node = self.copy_node_as(coupling[2], self.ARCHITECTURE_ROLES_VARS[6]) self.mark_as_constraint(consistency_node, '==', 0.0) self.add_edge(self.CONSCONS_STRING, consistency_node) - self.add_equation((self.CONSCONS_STRING, consistency_node), 'y{}-y{}c'.format(idx, idx), 'Python') + self.add_equation((self.CONSCONS_STRING, consistency_node), '{0}-{0}c'.format(equation_label), 'Python') if 'consistency_nodes' in self.nodes[self.CONSCONS_STRING]: self.nodes[self.CONSCONS_STRING]['consistency_nodes'].append(consistency_node) else: -- GitLab