Insert normal stress, get maximum and find which nodes have the max stress value

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

How can we insert a normal stress result, get the maximum value and find which nodes have the max stress value?

Tagged:

Answers

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

    One can make use of the PlotData property from the result plot to loop through the data table and find the nodes that have the maximum stress value. Below is a script example:

    # Create Normal Stress Plot
    model = ExtAPI.DataModel.Project.Model
    solution = model.Analyses[0].Solution
    new_stress = solution.AddNormalStress()
    new_stress.EvaluateAllResults()
    max_stress = new_stress.Maximum
    
    # Extract data from plot
    plot_data = new_stress.PlotData
    nodes = plot_data ['Node']
    result_value = plot_data ['Values']
    
    # Handle unit conversion
    import units
    currentLengthUnit=ExtAPI.DataModel.CurrentUnitFromQuantityName('Stress')
    scale_factor=units.ConvertUnit(1.,currentLengthUnit,result_value.Unit)
    
    for index in range(len(nodes)):
        if result_value[index] == max_stress.Value*scale_factor:
            print(nodes[index])