Volume and mass of elements above a result threshold

Using ACT scripting, how can I find the elements for which the average stress is above a specific value and sum the volume of these elements, and find the summed mass of these elements ?
Best Answer
-
The following code can be adapted. Please note that this simplified example considers that only one material is used in the model.
# Define threshold threshold = Quantity('100 [MPa]') # init summed_volume = 0 summed_mass = 0 # Insert result eqv_stress = ExtAPI.DataModel.Project.Model.Analyses[0].Solution.AddEquivalentStress() eqv_stress.DisplayOption = ResultAveragingType.ElementalMean eqv_stress.EvaluateAllResults() # Extract data from plot plot_data = eqv_stress.PlotData elements = plot_data ['Element'] result_value = plot_data ['Values'] # Mesh data mesh_data = ExtAPI.DataModel.Project.Model.Analyses[0].MeshData # Handle unit conversion import units result_unit = result_value.Unit mesh_unit = mesh_data.Unit scale_factor_stress = units.ConvertUnit(1.,result_unit,threshold.Unit) for index in range(len(elements)): if result_value[index]*scale_factor_stress > threshold.Value: summed_volume = summed_volume + mesh_data.ElementById(elements[index]).Volume summed_volume = Quantity(str(summed_volume) + '[' + mesh_unit + '^3]') print('Summed volume is: ' + str(summed_volume)) # Get material # WARNING this code demo only grabs the material of the first body in the tree and assumes all elements above use this material import materials mat = ExtAPI.DataModel.Project.Model.Materials.Children[0] # get engineering data material properties for this material matED = mat.GetEngineeringDataMaterial() density = materials.GetMaterialPropertyByName(matED,"Density")['Density'] # Get mass summed_mass = summed_volume.Value*density[1] print('Summed mass is: ' +str(summed_mass) + ' [kg]')
0
Answers
-
Hi Pernelle
You are using *.PlotData in above example to get the stresses. Can we also use dpf?
Regards
Lorenz
0 -
Hi @Lorenz , yes, DPF could also be used for that purpose. I think I had initially written that script before DPF was released.
0 -
I need to do this but more accurately than on an element by element basis. Give the nodal (or integration point stresses) can we determine the volume of that element that is above the threshold value?
0 -
@Jim Kosloski This should be doable but only through MAPDL / PyMAPDL I think
0