Skip to content
Snippets Groups Projects
Commit 94fb1c0e authored by imcovangent's avatar imcovangent
Browse files

RCE scripting - update - debugged DOE strategy and tested on wing design case

Former-commit-id: 4f7cd82f9bd0aec428a0547c02bb5b3f8d465e8b
parent 8e6f6784
No related branches found
No related tags found
No related merge requests found
Showing
with 22405 additions and 9865 deletions
......@@ -263,25 +263,25 @@
<modes>wing_length_morph;wing_sweep_morph;wing_taper_morph;wing_root_chord_morph;wing_dihedral_morph</modes>
<wing_length_morph modes="wing_length_morph">
<wingUID>MainWing_wingID</wingUID>
<required_length unit="m">20.540000</required_length>
<required_length>20.540000</required_length>
</wing_length_morph>
<wing_sweep_morph modes="wing_sweep_morph">
<wingUID>MainWing_wingID</wingUID>
<required_sweep unit="deg">6.500000</required_sweep>
<required_sweep unit="deg">10.300000</required_sweep>
<required_sweep>6.500000</required_sweep>
<required_sweep>10.300000</required_sweep>
</wing_sweep_morph>
<wing_taper_morph modes="wing_taper_morph">
<wingUID>MainWing_wingID</wingUID>
<required_taper unit="-">0.950000</required_taper>
<required_taper unit="-">0.100000</required_taper>
<required_taper>0.950000</required_taper>
<required_taper>0.100000</required_taper>
</wing_taper_morph>
<wing_root_chord_morph modes="wing_root_chord_morph">
<wingUID>MainWing_wingID</wingUID>
<required_root_chord unit="m">9.500000</required_root_chord>
<required_root_chord>9.500000</required_root_chord>
</wing_root_chord_morph>
<wing_dihedral_morph modes="wing_dihedral_morph">
<wingUID>MainWing_wingID</wingUID>
<required_wing_dihedral unit="deg">18.000000</required_wing_dihedral>
<required_wing_dihedral>18.000000</required_wing_dihedral>
</wing_dihedral_morph>
</sCAM>
</toolspecific>
......
......@@ -29,27 +29,26 @@
<modes>wing_length_morph;wing_sweep_morph;wing_taper_morph;wing_root_chord_morph;wing_dihedral_morph</modes>
<wing_length_morph>
<wingUID>MainWing_wingID</wingUID>
<required_length unit="m">16.33982</required_length>
<required_length>16.33982</required_length>
</wing_length_morph>
<wing_sweep_morph>
<wingUID>MainWing_wingID</wingUID>
<required_sweep unit="deg">33.2273</required_sweep>
<required_sweep unit="deg">28.4037</required_sweep>
<required_sweep>33.2273</required_sweep>
<required_sweep>28.4037</required_sweep>
</wing_sweep_morph>
<wing_taper_morph>
<wingUID>MainWing_wingID</wingUID>
<required_taper unit="-">0.4251</required_taper>
<required_taper unit="-">0.1645182485</required_taper>
<required_taper>0.4251</required_taper>
<required_taper>0.1645182485</required_taper>
</wing_taper_morph>
<wing_root_chord_morph>
<wingUID>MainWing_wingID</wingUID>
<required_root_chord unit="m">6.3923</required_root_chord>
<required_root_chord>6.3923</required_root_chord>
</wing_root_chord_morph>
<wing_dihedral_morph>
<wingUID>MainWing_wingID</wingUID>
<required_wing_dihedral unit="deg">6.000</required_wing_dihedral>
<required_wing_dihedral>6.000</required_wing_dihedral>
</wing_dihedral_morph>
<SCAM_done>YES</SCAM_done>
</sCAM>
<sMFA>
<modelUID>agile_v13_modelID</modelUID>
......
......@@ -5249,22 +5249,51 @@ class FundamentalProblemGraph(KadmosGraph):
 
return check
 
def mark_as_design_variable(self, nodes):
def mark_as_design_variable(self, nodes, lower_bounds=None, nominal_values=None, upper_bounds=None, samples=None):
"""
Function to mark a list of nodes as design variable.
Function to mark a list of nodes as design variable and add metadata.
 
:param nodes: list of nodes present in the graph
:type nodes: list
:param lower_bounds: list of lower bound values
:type lower_bounds: list
:param nominal_values: list of nominal values
:type nominal_values: list
:param upper_bounds: list of upper bounds
:type upper_bounds: list
:param samples: nested list of sample values
:type samples: list
:return: enriched FPG
:rtype: FundamentalProblemGraph
"""
# Input assertions
assert isinstance(nodes, list), 'Input should be a list of nodes'
assert isinstance(nodes, list), 'Input should be a list of nodes.'
for node in nodes:
assert self.has_node(node), 'Node %s is not present in the graph.' % node
if lower_bounds:
assert isinstance(lower_bounds, list), 'lower_bounds input should be a list.'
assert len(nodes) == len(lower_bounds), 'Amound of lower_bounds does not match the amount of nodes.'
if nominal_values:
assert isinstance(nominal_values, list), 'nominal_values input should be a list.'
assert len(nodes) == len(nominal_values), 'Amound of nominal_values does not match the amount of nodes.'
if upper_bounds:
assert isinstance(upper_bounds, list), 'upper_bounds input should be a list.'
assert len(nodes) == len(upper_bounds), 'Amound of upper_bounds does not match the amount of nodes.'
if samples:
assert isinstance(samples, list), 'samples input should be a list.'
assert len(nodes) == len(samples), 'Amound of samples does not match the amount of nodes.'
# Mark nodes
for node in nodes:
for idx, node in enumerate(nodes):
self.node[node]['problem_role'] = self.PROBLEM_ROLES_VARS[0]
if lower_bounds:
self.node[node]['lower_bound'] = lower_bounds[idx]
if nominal_values:
self.node[node]['nominal_value'] = nominal_values[idx]
if upper_bounds:
self.node[node]['upper_bound'] = upper_bounds[idx]
if samples:
self.node[node]['samples'] = samples[idx]
 
def mark_as_objective(self, node):
"""
......@@ -6818,6 +6847,7 @@ class MdaoDataGraph(KadmosGraph):
for des_var in design_variable_nodes:
doe_table[idj].append(self.node[des_var]['samples'][idj])
self.graph['problem_formulation']['doe_settings']['doe_table'] = doe_table
self.graph['problem_formulation']['doe_settings']['doe_table_order'] = design_variable_nodes
 
# Manipulate the graph based on the architecture
# Connect design variables to the doe_block
......@@ -7204,7 +7234,10 @@ class MdaoDataGraph(KadmosGraph):
correct_coor_node = coor_out_id
rce_graph.node[correct_coor_node]['xpaths'].append(new_xpath)
else:
new_xpath = v
if 'related_to_schema_node' in rce_graph.node[v]:
new_xpath = rce_graph.node[v]['related_to_schema_node']
else:
new_xpath = v
correct_coor_node = coor_out_id
rce_graph.node[correct_coor_node]['xpaths'].append(new_xpath)
 
......@@ -7315,7 +7348,7 @@ class MdaoDataGraph(KadmosGraph):
'objective_variable': self.node[iter_node_name]['objective_variable'],
'constraint_variables': self.node[iter_node_name]['constraint_variables']}
elif iter_node['architecture_role'] == self.ARCHITECTURE_ROLES_FUNS[3]: # DOE
rce_role = self.RCE_ROLES_FUNS[9] # Optimizer
rce_role = self.RCE_ROLES_FUNS[9] # DOE
additional_attributes = {'design_variables': self.node[iter_node_name]['design_variables'],
'quantities_of_interest':
self.node[iter_node_name]['quantities_of_interest'],
......@@ -7918,8 +7951,9 @@ class MdaoDataGraph(KadmosGraph):
# Check and add XML mergers and assign rce_roles to coupled functions
 
# First for MDA analyses and independent output functions
nodes_of_interest = precoup_sorted + coups_sorted + opfs_sorted + iofs_sorted + [coor_lab + '-in'] + \
[iter_node_name + fourth_iter_name_app for iter_node_name in iterative_nodes]
nodes_of_interest = preiter_sorted + precoup_sorted + postiter_sorted + coups_sorted + opfs_sorted + \
iofs_sorted + [coor_lab + '-in'] + [iter_node_name + fourth_iter_name_app for
iter_node_name in iterative_nodes]
if self.DOE_STRING in iterative_nodes:
nodes_of_interest.remove(coor_lab + '-in')
for node_of_interest in nodes_of_interest:
......@@ -8428,7 +8462,7 @@ class RceGraph(KadmosGraph):
rce_role = node['rce_role']
if rce_role == self.RCE_ROLES_FUNS[0]: # Input Provider
# Add INI-out
abs_path_rce_work_dir = os.path.abspath(rce_working_dir)
abs_path_rce_work_dir = os.path.abspath(rce_working_dir)
if replace_dir is not None:
abs_path_rce_work_dir = abs_path_rce_work_dir.replace(replace_dir[0],replace_dir[1])\
.replace('/','\\') + '\\'
......@@ -8510,7 +8544,7 @@ class RceGraph(KadmosGraph):
for uxpath in node['xpaths']:
xpath = get_xpath_from_uxpath(tixi, uxpath)
rce_wf.add_dynamic_input(node_idx=pos,
name=self.get_var_name(uxpath),
name=self.get_var_name(uxpath).replace('_',''),
group="null",
datatype="Float",
metadata=OrdDict((
......@@ -8663,7 +8697,20 @@ class RceGraph(KadmosGraph):
else:
doe_seed = str(0)
if doe_method == 'Custom design table':
doe_table = str(node['settings']['doe_table'])
sorted_uxpaths = []
for idx, uxpath in enumerate(node['xpaths']):
sorted_uxpaths.append([self.get_var_name(uxpath).replace('_', ''), idx])
sorted_uxpaths.sort()
doe_table = list(node['settings']['doe_table'])
doe_table_order = list(node['settings']['doe_table_order'])
# Reorder the DOE table according to the xpaths in the node
new_table = [[None]*len(doe_table_order) for i in range(len(doe_table))]
for jdx, sample in enumerate(doe_table):
for idx, uxpath in enumerate(sorted_uxpaths):
table_idx = doe_table_order.index(node['xpaths'][uxpath[1]])
new_table[jdx][idx] = sample[table_idx]
doe_table = str(new_table)
doe_runs = str(len(node['settings']['doe_table']))
doe_end_sample = str(len(node['settings']['doe_table'])-1)
else:
......@@ -9150,7 +9197,7 @@ class RceGraph(KadmosGraph):
for k, entry in enumerate(rce_wf["nodes"][target_node['diagonal_position']][input_key]):
if entry["name"] == \
rce_wf["nodes"][source_node['diagonal_position']][output_key][j]["name"]:
inp_idx.append(k)
inp_idx.append(j)
input_id = [rce_wf["nodes"][target_node['diagonal_position']][input_key][i]["identifier"] for i in
inp_idx]
elif target_node['rce_role'] not in possible_rce_roles:
......
This diff is collapsed.
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment