How to 'probe' principal stresses for a set of nodes?

Member, Moderator, Employee Posts: 108
25 Answers Second Anniversary 10 Comments 25 Likes
✭✭✭✭
edited June 2023 in Structures

Another customer request: how to probe for all principal stresses at once? This can't be done using regular probes.

Tagged:

Answers

  • Member, Moderator, Employee Posts: 108
    25 Answers Second Anniversary 10 Comments 25 Likes
    ✭✭✭✭
    Answer ✓

    Not really a probe, but I suggest the following which will display a message box with the values of the principal stresses. It uses DPF.

    1. import math
    2. import units
    3. import mech_dpf
    4. import Ans.DataProcessing as dpf
    5.  
    6. clr.AddReference("Ans.UI.Toolkit.Base")
    7. clr.AddReference("Ans.UI.Toolkit")
    8. from Ansys.UI.Toolkit import *
    9.  
    10. curSel=ExtAPI.SelectionManager.CurrentSelection
    11.  
    12. # Need to have two faces selected, otherwise pass
    13. if (curSel.Ids.Count==0):
    14. mess_line1 = 'Please select at least one node'
    15. MessageBox.Show(mess_line1)
    16. pass
    17.  
    18. meshData=ExtAPI.DataModel.Project.Model.Analyses[0].MeshData
    19.  
    20. scoping=dpf.data.Scoping()
    21. scoping.Ids = curSel.Ids
    22. scoping.Location=dpf.enums.location.nodal
    23.  
    24.  
    25. an1=ExtAPI.DataModel.AnalysisByName(ExtAPI.DataModel.AnalysisNames[0])
    26. rstFile=an1.WorkingDir+'file.rst'
    27.  
    28. dataSource = dpf.data.DataSources(rstFile)
    29.  
    30. stressOp1 = dpf.operators.result.stress_principal_1()
    31. stressOp2 = dpf.operators.result.stress_principal_2()
    32. stressOp3 = dpf.operators.result.stress_principal_3()
    33.  
    34. stressOp1.inputs.data_sources.Connect(dataSource)
    35. stressOp2.inputs.data_sources.Connect(dataSource)
    36. stressOp3.inputs.data_sources.Connect(dataSource)
    37.  
    38. stressOp1.inputs.mesh_scoping.Connect(scoping)
    39. stressOp2.inputs.mesh_scoping.Connect(scoping)
    40. stressOp3.inputs.mesh_scoping.Connect(scoping)
    41.  
    42. stressData1=stressOp1.outputs.fields_container.GetData()[0]
    43. stressData2=stressOp2.outputs.fields_container.GetData()[0]
    44. stressData3=stressOp3.outputs.fields_container.GetData()[0]
    45.  
    46. stressData=[]
    47.  
    48. for nid in curSel.Ids:
    49. stressData.append([nid,stressData1.GetEntityDataById(nid)[0],stressData2.GetEntityDataById(nid)[0],stressData3.GetEntityDataById(nid)[0]])
    50.  
    51. # Display result
    52. mess_line='Node\tS1\tS2\tS3\n'
    53. for sd in stressData:
    54. mess_line+=str(sd[0])+'\t'+str(round(sd[1],2))+'\t'+str(round(sd[2],2))+'\t'+str(round(sd[3],2))+'\n'
    55. MessageBox.Show(mess_line)

Welcome!

It looks like you're new here. Sign in or register to get started.