Insert contact tool, contact pressure, find max and find node numbers that have the max value

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

How can I insert a contact tool and contact pressure result, find the maximum value and the node numbers that have this max value?

Tagged:

Answers

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

    Adapt the following code:

    # Create contact tool and contact pressure
    model = ExtAPI.DataModel.Project.Model
    solution = model.Analyses[0].Solution
    contact_tool = solution.AddContactTool()
    contact_pressure = contact_tool.AddPressure()
    
    contact_pressure.EvaluateAllResults()
    contact_pressure_max = contact_pressure.Maximum
    
    
    # Extract data from plot
    plot_data = contact_pressure.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] == contact_pressure_max.Value*scale_factor:
        print(nodes[index])