Skip to content
Snippets Groups Projects
Commit 06726b18 authored by Lukas Müller's avatar Lukas Müller
Browse files

Fixing another issue with reading equations from CMDOWS files and replaced...

Fixing another issue with reading equations from CMDOWS files and replaced ad-hoc additions to the CMDOWS by adding the information to the right location in the graph,
Trying to fix IDF scripting problem leading to undefined references


Former-commit-id: 0d66941d53777947013157af5ac2a420e7fea782
parent 356b341d
No related branches found
No related tags found
No related merge requests found
Pipeline #192709 canceled
Showing
with 14 additions and 27 deletions
......@@ -2,10 +2,8 @@
import logging
from collections import OrderedDict
from lxml import etree
from kadmos.graph import RepositoryConnectivityGraph, FundamentalProblemGraph
from kadmos.cmdows import CMDOWS
from kadmos.utilities.general import get_mdao_setup
......@@ -27,7 +25,7 @@ mdao_definitions = ['unconverged-MDA-J', # 0
# Settings for scripting
mdao_definitions_loop_all = True # Option for looping through all MDAO definitions
mdao_definition_id = 8 # Option for selecting a MDAO definitions (in case mdao_definitions_loop_all=False)
mdao_definition_id = 10 # Option for selecting a MDAO definitions (in case mdao_definitions_loop_all=False)
# Settings for saving
pdf_dir = 'sellar_problem/(X)DSM'
......@@ -200,6 +198,12 @@ for mdao_definition in mdao_definitions:
fpg.node['/data_schema/geometry/z1']['valid_ranges'] = {'limit_range': {'minimum': -10., 'maximum': 10.}}
fpg.node['/data_schema/geometry/z2']['problem_role'] = 'design variable'
fpg.node['/data_schema/geometry/z2']['valid_ranges'] = {'limit_range': {'minimum': 0., 'maximum': 10.}}
fpg.node['/data_schema/analyses/g2']['constraint_type'] = 'inequality'
fpg.node['/data_schema/analyses/g1']['constraint_type'] = 'inequality'
fpg.node['/data_schema/analyses/g2']['constraint_operator'] = '>='
fpg.node['/data_schema/analyses/g1']['constraint_operator'] = '>='
fpg.node['/data_schema/analyses/g2']['reference_value'] = 0.0
fpg.node['/data_schema/analyses/g1']['reference_value'] = 0.0
elif mdao_architecture in ['unconverged-MDA', 'converged-MDA']:
fpg.node['/data_schema/analyses/f']['problem_role'] = 'quantity of interest'
fpg.node['/data_schema/analyses/g1']['problem_role'] = 'quantity of interest'
......@@ -223,6 +227,8 @@ for mdao_definition in mdao_definitions:
if mdao_architecture == 'IDF':
fpg.node['/data_schema/analyses/y1']['valid_ranges'] = {'limit_range': {'minimum': -100., 'maximum': 100.}}
fpg.node['/data_schema/analyses/y2']['valid_ranges'] = {'limit_range': {'minimum': -100., 'maximum': 100.}}
#fpg.node['/data_schema/analyses/y1']['problem_role'] = 'design variable'
#fpg.node['/data_schema/analyses/y2']['problem_role'] = 'design variable'
# Search for problem roles
fpg.add_function_problem_roles()
......@@ -258,6 +264,11 @@ for mdao_definition in mdao_definitions:
mdg.edge['G1']['/data_schema/architectureNodes/finalOutputVariables/data_schemaCopy/analyses/g1']['equations'] = mdg.edge['G1']['/data_schema/analyses/g1']['equations']
mdg.edge['G2']['/data_schema/architectureNodes/finalOutputVariables/data_schemaCopy/analyses/g2']['equations'] = mdg.edge['G2']['/data_schema/analyses/g2']['equations']
# Add some more problem roles to avoid undefined uIDs in the CMDOWS file
#if mdao_architecture == 'IDF':
# mdg.node['/data_schema/architectureNodes/consistencyConstraintVariables/data_schemaCopy/analyses/gc_y1']['problem_role'] = 'constraint'
# mdg.node['/data_schema/architectureNodes/consistencyConstraintVariables/data_schemaCopy/analyses/gc_y2']['problem_role'] = 'constraint'
# Create a DSM visualization of the Mdao
mdg.create_dsm(file_name='Mdao_'+mdao_definition, include_system_vars=True, destination_folder=pdf_dir, mpg=mpg)
# Create a VISTOMS visualization of the Mdao (and add it to the existing directory)
......@@ -276,29 +287,5 @@ for mdao_definition in mdao_definitions:
test = mpg.get_nested_process_ordering()
# Add some more information to the CMDOWS files (which is not yet supported in KADMOS)
docs = ['FPG_' + mdao_definition + '.xml', 'Mdao_' + mdao_definition + '.xml']
for doc in docs:
xml = etree.parse(cmdows_dir + '/' + doc)
find_cnstrnts = xml.xpath('/cmdows/problemDefinition/problemRoles/parameters/constraintVariables')
if find_cnstrnts:
cnstrnts = find_cnstrnts[0]
for cnstrnt in cnstrnts:
cnstrntTypeElement = etree.Element("constraintType")
cnstrntTypeElement.text = r'inequality'
cnstrnt.append(cnstrntTypeElement)
cnstrntOperatorElement = etree.Element("constraintOperator")
cnstrntOperatorElement.text = r'>='
cnstrnt.append(cnstrntOperatorElement)
referenceValueElement = etree.Element("referenceValue")
referenceValueElement.text = '0.0'
cnstrnt.append(referenceValueElement)
xml.write(cmdows_dir + '/' + doc)
# Some checks
cmdows = CMDOWS(file_path=cmdows_dir + '/' + doc)
result = cmdows.check()
if not result:
logging.warning("The CMDOWS file " + doc + " has some flaws.")
print 'Done!'
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
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