Combine mode shapes using Mechanical automation API

Options
Pernelle Marone-Hitz
Pernelle Marone-Hitz Member, Moderator, Employee Posts: 813
First Comment First Anniversary Ansys Employee Solution Developer Community of Practice Member
edited June 2023 in Structures

I've run an eigenvalue buckling analysis and would like to:

  • add a mode shape result for all eigen modes
  • add a user-defined result that will plot a combined deformation of the mode shapes, with a scale factor
Tagged:

Best Answer

  • Pernelle Marone-Hitz
    Pernelle Marone-Hitz Member, Moderator, Employee Posts: 813
    First Comment First Anniversary Ansys Employee Solution Developer Community of Practice Member
    Answer ✓
    Options

    The following code can be adapted. A total deformation result is added for each eigen value, and an identifier is defined on the mode:

    Then scaling values are defined. In this example we use a scale value of 10 for the first mode, and 20 for all others.

    Finally, a user defined result is inserted with the combination of modes with the scaling values:


    The code is:

    eigenvalue_buckling_analysis = ExtAPI.DataModel.AnalysisByName('Eigenvalue Buckling')
    reader = eigenvalue_buckling_analysis.GetResultsData()
    result_sets = reader.ListTimeFreq
    solution = eigenvalue_buckling_analysis.Solution
    
    result_list = []
    for i in range(1, len(result_sets)+1):
        result = solution.AddTotalDeformation()
        result.Mode = i
        result.Identifier = "Mode" + str(i)
        result_list.append(result.Identifier)
    
    scale_value_1 = 10
    scale_value_2 = 20
    
    modified_result_list = [str(scale_value_1)+"*%s" % value if i == 0 else str(scale_value_2)+"*%s" % value for i,value in enumerate(result_list)]
    
    delimiter = "+"
    udr_expression =  delimiter.join(map(str, modified_result_list))
    udr = solution.AddUserDefinedResult()
    udr.Expression = udr_expression
    
    solution.EvaluateAllResults()
    

    The final plot of the combined result: